-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpi2-tmp.mjs
More file actions
11 lines (11 loc) · 837 Bytes
/
Copy pathpi2-tmp.mjs
File metadata and controls
11 lines (11 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
import WebSocket from 'ws';
const H='192.168.86.88:48004', CH=process.env.CH||'12B', sid='Q'+Date.now();
const w=new WebSocket(`ws://${H}/ws/user-spectrum?client=${sid}&user_session_id=${sid}`);
const t0=Date.now(); const s=()=>((Date.now()-t0)/1000).toFixed(1).padStart(5)+'s';
let n=0;
w.on('open',()=>setTimeout(()=>{console.log(s(),'-> dab on',CH); w.send(JSON.stringify({type:'dab',on:1,channel:CH}));},2500));
w.on('message',m=>{const t=m.toString(); if(t[0]!=='{'||!t.includes('"type":"dab"'))return;
let j; try{j=JSON.parse(t);}catch(e){return;} n++;
if(n<=6||n%20===0) console.log(`${s()} #${n} frames=${j.frames} locked=${j.locked} null=${j.nullDepthDb} prs=${j.prs} fib=${j.fibRate} samplesIn=${j.samplesIn} push=${j.pushOk}/${j.pushCalls}`);
});
setTimeout(()=>{console.log(`${s()} TOTAL ${n}`);process.exit(0);},45000);