2023-03-01 19:28:02 +01:00
import { XmlRpcClient } from "@foxglove/xmlrpc" ;
2024-09-12 02:00:26 +02:00
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 ? ? '?' } ` ) ;
}
}
2023-03-01 19:28:02 +01:00
return {
pttDown : ( ) => {
2024-09-12 02:00:26 +02:00
setPtt ( 1 ) ;
2023-03-01 19:28:02 +01:00
} ,
pttUp : ( ) => {
2024-09-12 02:00:26 +02:00
setPtt ( 0 ) ;
2023-03-01 19:28:02 +01:00
}
} ;
} ;