refactor, added README

This commit is contained in:
2024-09-12 02:00:26 +02:00
parent 352174cd83
commit 221b739774
11 changed files with 105 additions and 43 deletions

View File

@ -1,14 +1,22 @@
import { XmlRpcClient } from "@foxglove/xmlrpc";
export default function flrig() {
const client = new XmlRpcClient(`http://127.0.0.1:12345`);
export default function flrig(opts) {
const client = new XmlRpcClient(opts.flrig.url);
const setPtt = async (state) => {
try {
await client.methodCall('rig.set_ptt', [state]);
} catch (ex) {
console.error(`Cannot send rig.set_ptt(${state}) to flrig (${opts.flrig.url}) -- perhaps it's not running? ${ex.code ?? 'unknown'} at ${ex.erroredSysCall ?? '?'}`);
}
}
return {
pttDown: () => {
client.methodCall('rig.set_ptt', [1]);
setPtt(1);
},
pttUp: () => {
client.methodCall('rig.set_ptt', [0]);
setPtt(0);
}
};
};

View File

@ -1,12 +0,0 @@
import { spawn } from 'child_process';
export default function() {
return {
pttDown: () => {
spawn('/home/omega/Documents/ts3_remote/ptt_daemon', ['/dev/mhuxd/fsk1', '1']);
},
pttUp: () => {
spawn('/home/omega/Documents/ts3_remote/ptt_daemon', ['/dev/mhuxd/fsk1', '0']);
}
};
};

12
providers/serial.js Normal file
View File

@ -0,0 +1,12 @@
import { spawn } from 'child_process';
export default function serial(opts) {
return {
pttDown: () => {
spawn('./ptt_daemon', [opts.serial.port, '1']);
},
pttUp: () => {
spawn('./ptt_daemon', [opts.serial.port, '0']);
}
};
};