Add VHF and UHF Packet channels to the Winlink radio client
This commit is contained in:
1 parent
bf8c3a5146
commit
0c0a716985
8 files changed
+84
-35
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import {readFile,writeFile,rename} from 'node:fs/promises';
|
||||
import {randomUUID} from 'node:crypto';
|
||||
export async function reservePacketSlot(client,controller,frequencyMHz,port){
|
||||
if(!controller)return;
|
||||
const request={id:randomUUID(),frequencyMHz,expiresAt:Date.now()+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){try{const state=JSON.parse(await readFile(controller.statusFile,'utf8'));if(state.manualRequestId===request.id&&state.phase==='vhf'&&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))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{}
|
||||
}
|
||||
Reference in new issue
Block a user