Make BPQ console station-independent with modem detection and Windows installer

This commit is contained in:
alberto committed 2026-10-14 19:43:01 +02:00
1 parent 5a50f0cfdf
commit 3bf26cec13
22 files changed
+285 -133

No files matched your search

+1 -1
View File
@@ -9,6 +9,6 @@ export function parseVaraRate(text){
return {bps,direction,level:Number(line.match(/\((\d+)\)/)?.[1])||null};
}
export class VaraRate {
constructor(){this.lastPacket=0;this.lastRate=null;this.tx=null;this.rx=null;this.error=null;this.listening=false;this.socket=dgram.createSocket('udp4');this.socket.on('listening',()=>{this.listening=true});this.socket.on('error',()=>{this.error='Logging VARA non disponibile';this.listening=false});this.socket.on('message',(packet,remote)=>{if(remote.address!=='127.0.0.1')return;this.lastPacket=Date.now();const text=packet.toString('utf8');const rate=parseVaraRate(text);if(rate){const sample={...rate,at:this.lastPacket};this.lastRate=sample;if(rate.direction==='TX')this.tx=sample;if(rate.direction==='RX')this.rx=sample;}else if(/\bDISCONNECTED\b|\bDisconnected\b/.test(text)){this.lastRate=null;this.tx=null;this.rx=null;}});this.socket.bind(18514,'127.0.0.1');this.socket.unref();}
constructor(port=18514){this.lastPacket=0;this.lastRate=null;this.tx=null;this.rx=null;this.error=null;this.listening=false;this.socket=dgram.createSocket('udp4');this.socket.on('listening',()=>{this.listening=true});this.socket.on('error',()=>{this.error='Logging VARA non disponibile';this.listening=false});this.socket.on('message',(packet,remote)=>{if(remote.address!=='127.0.0.1')return;this.lastPacket=Date.now();const text=packet.toString('utf8');const rate=parseVaraRate(text);if(rate){const sample={...rate,at:this.lastPacket};this.lastRate=sample;if(rate.direction==='TX')this.tx=sample;if(rate.direction==='RX')this.rx=sample;}else if(/\bDISCONNECTED\b|\bDisconnected\b/.test(text)){this.lastRate=null;this.tx=null;this.rx=null;}});this.socket.bind(port,'127.0.0.1');this.socket.unref();}
snapshot(active){return {listening:this.listening,lastPacket:this.lastPacket||null,error:this.error,at:active?this.lastRate?.at||null:null,bps:active?this.lastRate?.bps??null:null,direction:active?this.lastRate?.direction||null:null,level:active?this.lastRate?.level??null:null,tx:active?this.tx?.bps??null:null,rx:active?this.rx?.bps??null:null};}
}