feat(routers): integrate Banana Pi Client API and onboard LibreSpeed measurements

Discover Ethernet routers under the board, map physical SIM slots, expose vendor controls and real telemetry, and provide packaged VPS speed tests with a live monochrome gauge. Enforce compact typography across Core and Node UI.
This commit is contained in:
DCCONSTRUCTIONS
2026-11-11 23:53:46 +03:00
parent 58ac9fe3d2
commit a49fb00b8e
208 changed files with 7007 additions and 881 deletions
+23
View File
@@ -0,0 +1,23 @@
import type {RouterDevice} from './contracts';
import {smoothTrafficSegment,type ChartPoint} from './overview';
export interface RadioSample {at:number;slot:number;rsrp:number|null;rsrq:number|null;sinr:number|null;band:string;cell:string}
export interface RadioHistory {key:string;day:number;samples:RadioSample[]}
export function collectRadio(previous:RadioHistory,key:string,device:RouterDevice,ready:boolean,now:number):RadioHistory {
const day=Math.floor(now/86400),samples=(previous.key===key&&previous.day===day?previous.samples:[]).filter(s=>s.at>=now-300&&s.at<=now+30);
if(ready&&device.observed_at>=now-40&&device.observed_at<=now+30)for(const m of device.modems){
const age=m.radio_age_seconds;if(device.client_api&&(age==null||age>40||age<0))continue;
const at=device.observed_at-(age??0),last=samples.filter(s=>s.slot===m.slot).at(-1);
if(at<now-300||last&&at<=last.at+1)continue;
samples.push({at,slot:m.slot,rsrp:m.rsrp,rsrq:m.rsrq,sinr:m.sinr,band:m.band,cell:m.cell_id});
}
return {key,day,samples:samples.slice(-270)};
}
export const radioMetrics={rsrp:{label:'Уровень · RSRP',unit:'dBm',min:-120,max:-60},rsrq:{label:'Качество · RSRQ',unit:'dB',min:-20,max:0},sinr:{label:'Сигнал / помехи · SINR',unit:'dB',min:-10,max:30}};
export function radioSegments(samples:RadioSample[],field:keyof typeof radioMetrics,end:number):ChartPoint[][] {
const metric=radioMetrics[field],segments:ChartPoint[][]=[];let part:ChartPoint[]=[],last:RadioSample|undefined;
for(const s of samples){const v=s[field];if(v==null||!Number.isFinite(v)||last&&(s.at-last.at>40||s.band!==last.band||s.cell!==last.cell)){if(part.length)segments.push(part);part=[];}
if(v!=null&&Number.isFinite(v)){part.push({x:2+316*Math.max(0,Math.min(1,(s.at-(end-300))/300)),y:78-72*Math.max(0,Math.min(1,(v-metric.min)/(metric.max-metric.min)))});}last=s;
}if(part.length)segments.push(part);return segments;
}
export function radioPath(samples:RadioSample[],field:keyof typeof radioMetrics,end:number){return radioSegments(samples,field,end).map(s=>smoothTrafficSegment(s)).join(' ');}
export function radioChanges(samples:RadioSample[]){return samples.flatMap((s,i)=>{const p=samples[i-1];if(!p||s.at-p.at>40)return [];const changes=[];if(p.band&&s.band&&p.band!==s.band)changes.push(`${p.band} → ${s.band}`);if(p.cell&&s.cell&&p.cell!==s.cell)changes.push(`Сота ${p.cell} → ${s.cell}`);return changes.length?[{at:s.at,text:changes.join(' · ')}]:[];}).slice(-6).reverse();}