generated from Grigo/AndroidTemplate
added more fields
This commit is contained in:
@@ -379,7 +379,7 @@ def health():
|
||||
return {
|
||||
"ok": status["db_ok"],
|
||||
"ts": time.time(),
|
||||
"api_build": "2026-06-16f",
|
||||
"api_build": "2026-06-16g",
|
||||
**status,
|
||||
**elevation_status(),
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@
|
||||
{ position: 'topright', collapsed: true }
|
||||
).addTo(map);
|
||||
|
||||
const API_BUILD = '2026-06-16f';
|
||||
const API_BUILD = '2026-06-16g';
|
||||
|
||||
const markers = {};
|
||||
let selectedId = null;
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
const KNOWN_LABELS = new Set([
|
||||
'send', 'receive', 'frequency', 'power', 'rssi', 'snr',
|
||||
'spreading factor', 'bandwidth', 'packet', 'packet number', 'payload',
|
||||
'on air', 'tx speed', 'rx speed', 'per', 'rx quality'
|
||||
'packet receive', 'packet total', 'packet error', 'crc error',
|
||||
'preamble detected', 'header valid',
|
||||
'on air', 'tx speed', 'rx speed', 'per', 'rx quality',
|
||||
'code rate', 'preamble length', 'low data rate', 'crc', 'payload length', 'tx timeout'
|
||||
]);
|
||||
|
||||
function roleLabel(role) {
|
||||
@@ -22,6 +25,15 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
function fmtCrc(enabled) {
|
||||
if (enabled == null) return '—';
|
||||
return enabled ? 'On' : 'Off';
|
||||
}
|
||||
|
||||
function fmtBw(khz) {
|
||||
return khz != null ? `${Number(khz).toFixed(2)} kHz` : '—';
|
||||
}
|
||||
|
||||
function parseRadioSnapshot(meta, roleFallback, rssiFallback) {
|
||||
const snap = {
|
||||
role: roleFallback || null,
|
||||
@@ -39,6 +51,18 @@
|
||||
rxPktPerS: null,
|
||||
perPercent: null,
|
||||
rxQualityPercent: null,
|
||||
codeRate: null,
|
||||
preambleLength: null,
|
||||
lowDataRateOpt: null,
|
||||
crcEnabled: null,
|
||||
payloadLengthBytes: null,
|
||||
txTimeoutMs: null,
|
||||
packetReceive: null,
|
||||
packetTotal: null,
|
||||
packetError: null,
|
||||
crcError: null,
|
||||
preambleDetected: null,
|
||||
headerValid: null,
|
||||
extraFields: {}
|
||||
};
|
||||
if (!meta) return snap;
|
||||
@@ -62,6 +86,18 @@
|
||||
if (o.per_percent != null) snap.perPercent = Number(o.per_percent);
|
||||
if (o.rx_quality_percent != null) snap.rxQualityPercent = Number(o.rx_quality_percent);
|
||||
if (o.stats_at != null) snap.statsAt = Number(o.stats_at);
|
||||
if (o.code_rate != null) snap.codeRate = String(o.code_rate);
|
||||
if (o.preamble_length != null) snap.preambleLength = Number(o.preamble_length);
|
||||
if (o.low_data_rate_opt != null) snap.lowDataRateOpt = String(o.low_data_rate_opt);
|
||||
if (o.crc_enabled != null) snap.crcEnabled = Boolean(o.crc_enabled);
|
||||
if (o.payload_length_bytes != null) snap.payloadLengthBytes = Number(o.payload_length_bytes);
|
||||
if (o.tx_timeout_ms != null) snap.txTimeoutMs = Number(o.tx_timeout_ms);
|
||||
if (o.packet_receive != null) snap.packetReceive = Number(o.packet_receive);
|
||||
if (o.packet_total != null) snap.packetTotal = Number(o.packet_total);
|
||||
if (o.packet_error != null) snap.packetError = Number(o.packet_error);
|
||||
if (o.crc_error != null) snap.crcError = Number(o.crc_error);
|
||||
if (o.preamble_detected != null) snap.preambleDetected = Number(o.preamble_detected);
|
||||
if (o.header_valid != null) snap.headerValid = Number(o.header_valid);
|
||||
if (o.fields && typeof o.fields === 'object') {
|
||||
for (const [k, v] of Object.entries(o.fields)) {
|
||||
if (!isKnownLabel(k)) snap.extraFields[k] = String(v);
|
||||
@@ -79,11 +115,16 @@
|
||||
const changed = new Set();
|
||||
if (!a || !b) return changed;
|
||||
const keys = ['gps', 'packetTime', 'role', 'rssiDbm', 'snrDb', 'rxQualityPercent', 'packet', 'payload', 'perPercent',
|
||||
'txPktPerS', 'rxPktPerS', 'frequencyMhz', 'sf', 'bwKhz', 'powerDbm'];
|
||||
const map = { gps: 'gps', packetTime: 'packetTime', role: 'role', rssiDbm: 'rssi', snrDb: 'snr', rxQualityPercent: 'rxQuality',
|
||||
packet: 'packet',
|
||||
payload: 'payload', perPercent: 'per', txPktPerS: 'txSpeed', rxPktPerS: 'rxSpeed',
|
||||
frequencyMhz: 'frequency', sf: 'sf', bwKhz: 'bw', powerDbm: 'power' };
|
||||
'packetReceive', 'packetTotal', 'packetError', 'crcError', 'preambleDetected', 'headerValid',
|
||||
'txPktPerS', 'rxPktPerS', 'frequencyMhz', 'sf', 'bwKhz', 'powerDbm', 'codeRate', 'crcEnabled'];
|
||||
const map = {
|
||||
gps: 'gps', packetTime: 'packetTime', role: 'role', rssiDbm: 'rssi', snrDb: 'snr',
|
||||
rxQualityPercent: 'rxQuality', packet: 'packet', payload: 'payload', perPercent: 'per',
|
||||
packetReceive: 'packetReceive', packetTotal: 'packetTotal', packetError: 'packetError',
|
||||
crcError: 'crcError', preambleDetected: 'preambleDetected', headerValid: 'headerValid',
|
||||
txPktPerS: 'txSpeed', rxPktPerS: 'rxSpeed',
|
||||
frequencyMhz: 'frequency', sf: 'sf', bwKhz: 'bw', powerDbm: 'power', codeRate: 'codeRate', crcEnabled: 'crc'
|
||||
};
|
||||
for (const k of keys) {
|
||||
if (a[k] !== b[k] && !(a[k] == null && b[k] == null)) changed.add(map[k]);
|
||||
}
|
||||
@@ -99,6 +140,12 @@
|
||||
{ key: 'packet', label: 'Пакет', fmt: s => s.packet != null ? String(s.packet) : '—' },
|
||||
{ key: 'payload', label: 'Payload', fmt: s => s.payload || '—' },
|
||||
{ key: 'per', label: 'PER', fmt: s => s.perPercent != null ? `${s.perPercent} %` : '—' },
|
||||
{ key: 'packetReceive', label: 'Принято', fmt: s => s.packetReceive != null ? String(s.packetReceive) : '—' },
|
||||
{ key: 'packetTotal', label: 'Всего', fmt: s => s.packetTotal != null ? String(s.packetTotal) : '—' },
|
||||
{ key: 'packetError', label: 'Ошибки', fmt: s => s.packetError != null ? String(s.packetError) : '—' },
|
||||
{ key: 'crcError', label: 'CRC err', fmt: s => s.crcError != null ? String(s.crcError) : '—' },
|
||||
{ key: 'preambleDetected', label: 'Preamble', fmt: s => s.preambleDetected != null ? String(s.preambleDetected) : '—' },
|
||||
{ key: 'headerValid', label: 'Header OK', fmt: s => s.headerValid != null ? String(s.headerValid) : '—' },
|
||||
{ key: 'txSpeed', label: 'TX Speed', fmt: s => s.txPktPerS != null ? `${s.txPktPerS} pkt/s` : '—' },
|
||||
{ key: 'rxSpeed', label: 'RX Speed', fmt: s => s.rxPktPerS != null ? `${s.rxPktPerS} pkt/s` : '—' }
|
||||
];
|
||||
@@ -107,8 +154,14 @@
|
||||
{ key: 'role', label: 'Роль', fmt: s => roleLabel(s.role) },
|
||||
{ key: 'frequency', label: 'Частота', fmt: s => s.frequencyMhz != null ? `${s.frequencyMhz.toFixed(3)} MHz` : '—' },
|
||||
{ key: 'sf', label: 'SF', fmt: s => s.sf != null ? String(s.sf) : '—' },
|
||||
{ key: 'bw', label: 'BW', fmt: s => s.bwKhz != null ? `${s.bwKhz} kHz` : '—' },
|
||||
{ key: 'bw', label: 'BW', fmt: s => fmtBw(s.bwKhz) },
|
||||
{ key: 'power', label: 'Мощность', fmt: s => s.powerDbm != null ? `${s.powerDbm} dBm` : '—' },
|
||||
{ key: 'codeRate', label: 'Code Rate', fmt: s => s.codeRate || '—' },
|
||||
{ key: 'preambleLength', label: 'Preamble', fmt: s => s.preambleLength != null ? String(s.preambleLength) : '—' },
|
||||
{ key: 'lowDataRateOpt', label: 'LDR', fmt: s => s.lowDataRateOpt || '—' },
|
||||
{ key: 'crc', label: 'CRC', fmt: s => fmtCrc(s.crcEnabled) },
|
||||
{ key: 'payloadLength', label: 'Payl.len', fmt: s => s.payloadLengthBytes != null ? `${s.payloadLengthBytes} B` : '—' },
|
||||
{ key: 'txTimeout', label: 'TX Timeout', fmt: s => s.txTimeoutMs != null ? `${s.txTimeoutMs} ms` : '—' },
|
||||
{ key: 'onAir', label: 'On Air', fmt: s => s.onAirMs != null ? `${s.onAirMs} ms` : '—' }
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user