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

+5 -1
View File
@@ -5,10 +5,14 @@ export async function reservePacketSlot(client,controller,frequencyMHz,port,{sig
const began=Date.now(),request={id:randomUUID(),frequencyMHz,expiresAt:began+90000};client.job.controller={...controller,id:request.id};await client.persist();
await writeFile(controller.requestFile+'.tmp',JSON.stringify(request));await rename(controller.requestFile+'.tmp',controller.requestFile);
const deadline=Date.now()+65000;
while(Date.now()<deadline){signal?.throwIfAborted();try{const state=JSON.parse(await readFile(controller.statusFile,'utf8'));if(state.manualRequestId===request.id&&state.phase==='vhf'&&state.pttReady===true&&Math.abs(Number(state.frequency)-frequencyMHz)<0.0001&&Date.now()-Date.parse(state.at)<5000){const html=await client.fwd.bpq('/Node/Port?'+port);if(/Connected to TNC/.test(html)&&/1200bd/.test(html)){client.job.controller.preparationMs=Date.now()-began;await client.persist();return;}}}catch{}await new Promise(resolve=>setTimeout(resolve,300));}
while(Date.now()<deadline){signal?.throwIfAborted();try{const state=JSON.parse(await readFile(controller.statusFile,'utf8'));if(state.manualRequestId===request.id&&state.phase==='vhf'&&state.pttReady===true&&Math.abs(Number(state.frequency)-frequencyMHz)<0.0001&&Date.now()-Date.parse(state.at)<5000){const ready=controller.independent?state.independent===true&&state.connections>0:await client.fwd.bpq('/Node/Port?'+port).then(html=>/Connected to TNC/.test(html)&&/1200bd/.test(html));if(ready){client.job.controller.preparationMs=Date.now()-began;await client.persist();return;}}}catch{}await new Promise(resolve=>setTimeout(resolve,300));}
throw Error('Modem packet non pronto: nessuna chiamata avviata');
}
export async function releasePacketSlot(client){
const c=client.job?.controller;if(!c||c.released)return;
try{const request=JSON.parse(await readFile(c.requestFile,'utf8'));if(request.id===c.id&&request.expiresAt){request.expiresAt=0;await writeFile(c.requestFile,JSON.stringify(request));}c.released=true;}catch{}
}
export async function renewPacketSlot(client){
const c=client.job?.controller;if(!c?.independent||c.released)return;
try{const request=JSON.parse(await readFile(c.requestFile,'utf8'));if(request.id===c.id&&request.expiresAt>Date.now()){request.expiresAt=Date.now()+90000;await writeFile(c.requestFile+'.tmp',JSON.stringify(request));await rename(c.requestFile+'.tmp',c.requestFile);}}catch{}
}