Add multi-port radio controls and APRS activity dashboard

This commit is contained in:
alberto committed 2026-10-17 21:29:53 +02:00
1 parent 018c0f574e
commit c980ba10de
30 files changed
+1147 -20

No files matched your search

+4 -3
View File
@@ -7,14 +7,15 @@ 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');
if(route.controller&&(!path.isAbsolute(route.controller.requestFile||'')||!path.isAbsolute(route.controller.statusFile||'')))throw Error('Percorsi del controllo radio non validi');
ids.add(route.id);return {...route,label:String(route.label||route.id).slice(0,80),script:`ATTACH ${route.port}|RADIO ${route.frequencyMHz.toFixed(6)} ${route.mode}|PAUSE 2|C ${route.connectCall}`};
const nativeKiss=route.nativeKiss===true&&route.controller?.independent===true&&/KISS/i.test(config.ports.find(p=>p.id===route.port)?.driver||'');
ids.add(route.id);return {...route,label:String(route.label||route.id).slice(0,80),script:nativeKiss?`C ${route.port} !${route.connectCall}`:`ATTACH ${route.port}|RADIO ${route.frequencyMHz.toFixed(6)} ${route.mode}|PAUSE 2|C ${route.connectCall}`};
});
}
export class ManualForwarding extends WinlinkRadio{
constructor(config,dir,forwarding){super(config,dir,forwarding,null,{stateFile:'manual-forwarding.session.json'});this.routes=manualRoutes(config);}
snapshot(){const state=super.snapshot();if(state?.error)state.error=state.error.replaceAll('profilo RMS','profilo del partner');return state;}
async restore(){const state=await super.restore();await this.release();return state;}
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}];});}
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,independentRadio:route.controller?.independent===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,signal){await reservePacketSlot(this,route.controller,route.frequencyMHz,route.port,{signal});}
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)];}
@@ -22,7 +23,7 @@ export class ManualForwarding extends WinlinkRadio{
signal?.throwIfAborted();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');
if(!(await this.fwd.profiles()).some(p=>p.call===route.peer&&p.configured))throw Error('Partner BBS non configurato');
const radio=this.fwd.radio();if(!radio?.available||radio.active||radio.connecting||Date.now()-radio.at>20000)throw Error('Radio non disponibile o impegnata');
const radio=this.fwd.radio();if(radio?.txSuspended||radio?.portsPaused?.[route.port])throw Error('Trasmissioni radio sospese');if(!route.controller?.independent&&(!radio?.available||radio.active||radio.connecting||Date.now()-radio.at>20000))throw Error('Radio non disponibile o impegnata');
if(activeMailStreams(await this.fwd.bpq('/Mail/Status')).length)throw Error('Attendi la fine delle sessioni BBS');
const file=path.join(this.config.root,'BPQMailChat','BPQMail.cfg'),original=rawProfile(await readFile(file,'utf8'),route.peer);
const backup=path.join(this.config.root,'BPQMailChat','Backup-manual-forwarding-'+new Date().toISOString().replace(/[:.]/g,'-'));await mkdir(backup);await copyFile(file,path.join(backup,'BPQMail.cfg'));