refactor, added README
This commit is contained in:
@ -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);
|
||||
}
|
||||
};
|
||||
};
|
@ -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
12
providers/serial.js
Normal 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']);
|
||||
}
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user