Verify packet PTT readiness and isolate manual VHF forwarding status
This commit is contained in:
1 parent
9bb62cf731
commit
abfc8be078
7 files changed
+16
-7
No files matched your search
@@ -2,7 +2,7 @@ import {readFile,writeFile,rename,mkdir,copyFile} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {reservePacketSlot,releasePacketSlot} from './radio-slot.mjs';
|
||||
import {WinlinkRadio,rawProfile,activeMailStreams} from './winlink-radio.mjs';
|
||||
import {safeScript} from './forwarding.mjs';
|
||||
import {safeScript,parseForwarding} from './forwarding.mjs';
|
||||
export function manualRoutes(config){
|
||||
const ids=new Set();return (config.manualForwardingRoutes||[]).map(route=>{
|
||||
if(!/^[A-Z0-9-]{1,32}$/.test(route.id)||route.id===route.peer||ids.has(route.id)||! /^[A-Z0-9]{1,6}$/.test(route.peer)||! /^[A-Z0-9]{3,7}(?:-\d{1,2})?$/.test(route.connectCall)||!Number.isFinite(route.frequencyMHz)||route.frequencyMHz<1||route.frequencyMHz>500||! /^(USB|LSB|FM|DATA-FM)$/.test(route.mode)||!config.ports.some(p=>p.id===route.port&&!/TELNET|AXIP/i.test(p.driver)))throw Error('Percorso manuale di forwarding non valido');
|
||||
@@ -17,6 +17,7 @@ export class ManualForwarding extends WinlinkRadio{
|
||||
profiles(native){return this.routes.flatMap(route=>{const p=native.find(p=>p.call===route.peer);if(!p)return [];const j=this.job?.channel?.id===route.id?this.job:null;const history=j?p.history.filter(s=>Date.parse(s.startedAt)>=Date.parse(j.startedAt)-1500&&(!j.endedAt||Date.parse(s.startedAt)<=Date.parse(j.endedAt))):[];return [{...p,call:route.id,label:route.label,peer:route.peer,manualOnly:true,enabled:false,interval:0,immediate:false,reverseInterval:0,times:[],configured:true,port:route.port,driver:this.config.ports.find(p=>p.id===route.port)?.driver||'',transport:'Radio',frequency:[String(route.frequencyMHz),route.mode],script:safeScript(route.script),history,last:history[0]||null,active:Boolean(j?.restoring),preparing:j?.state==='preparing',requestedAt:j?.startedAt||null,nextEstimated:null}];});}
|
||||
async prepare(route){await reservePacketSlot(this,route.controller,route.frequencyMHz,route.port);}
|
||||
async release(){await releasePacketSlot(this);}
|
||||
displayProfiles(native){const j=this.job;const base=native.map(p=>{if(!j||j.peer!==p.call)return p;const history=p.history.filter(s=>!(Date.parse(s.startedAt)>=Date.parse(j.startedAt)-1500&&(!j.endedAt||Date.parse(s.startedAt)<=Date.parse(j.endedAt))));const original=parseForwarding('BBSForwarding : { '+p.call+' : { '+Object.entries(j.original||{}).map(([k,v])=>k+' = "'+String(v).replaceAll('"','')+'";').join(' ')+' } }',this.config.ports)[0];return {...p,...(j.restoring?original:{}),history,last:history[0]||null,active:j.restoring?false:p.active,reservedBy:j.restoring?j.channel.id:null};});return [...base,...this.profiles(native)];}
|
||||
async startRoute(id){await this.init;return this.fwd.exclusive(async()=>{
|
||||
const route=this.routes.find(r=>r.id===id);if(!route)throw Error('Percorso manuale non configurato');
|
||||
if(this.job?.restoring||this.fwd.lockedPeers.has(route.peer))throw Error('Un inoltro per questo partner è già in corso');
|
||||
|
||||
Reference in new issue
Block a user