MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / runPtp

Function runPtp

web/scripts/ragnar_modern.js:1801–1833  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1799 }).catch(() => {});
1800}
1801
1802function wifiZbScan() {
1803 if (_wifiState.zbBusy) return;
1804 _wifiState.zbBusy = true;
1805 const st = document.getElementById('wifi-zb-status');
1806 if (st) st.textContent = 'Sniffing 802.15.4 (ch 11–26)…';
1807 fetch('/api/net/zigbee/scan?duration=8').then(r => r.json()).then(d => {
1808 _wifiState.zbBusy = false;
1809 if (d.error) { if (st) st.textContent = '⚠ ' + d.error; _wifiState.zb = null; if (_wifiState.data) _wifiDrawSpectrum(); return; }
1810 _wifiState.zb = d;
1811 if (_wifiState.zbSelected && !(d.devices || []).some(v => (v.addr || v.short_addr) === _wifiState.zbSelected))
1812 _wifiState.zbSelected = null;
1813 const i = d.interference || {};
1814 if (st) st.textContent = `${d.device_count} device(s) · ${i.channel_count || 0} ch` + (d.warning ? ' ⚠' : '');
1815 _wifiZbRender();
1816 _wifiFsRenderSide();
1817 if (_wifiState.data) _wifiDrawSpectrum();
1818 }).catch(() => { _wifiState.zbBusy = false; if (st) st.textContent = 'Zigbee scan failed'; });
1819}
1820
1821function _wifiZbRender() {
1822 const d = _wifiState.zb; if (!d) return;
1823 const i = d.interference || {};
1824 const sum = document.getElementById('wifi-zb-summary');
1825 if (sum) sum.textContent = `${i.device_count || 0} device(s) · ${i.channel_count || 0} channel(s) · ${i.strong_count || 0} close`;
1826 const note = document.getElementById('wifi-zb-note');
1827 if (note) note.textContent = (i.note || '') + ' ' + (d.companion_note || '');
1828 const pr = document.getElementById('wifi-zb-pressure');
1829 if (pr) pr.innerHTML = (i.wifi_channels || []).map(c => {
1830 const col = _BT_PRESSURE_COLOR[c.level] || '#64748b';
1831 return `<span class="px-1.5 py-0.5 rounded" style="background:${col}22;color:${col};border:1px solid ${col}55" title="Estimated Zigbee pressure on Wi-Fi ch ${c.wifi_channel}">ch${c.wifi_channel}: ${c.level}</span>`;
1832 }).join('');
1833 const tb = document.getElementById('wifi-zb-tbody');
1834 if (!tb) return;
1835 if (!d.devices.length) {
1836 tb.innerHTML = '<tr><td colspan="6" class="py-3 text-gray-500">No Zigbee / 802.15.4 devices heard this sweep.</td></tr>';

Callers

nothing calls this directly

Calls 5

_ndBusyFunction · 0.85
_ndMissingToolFunction · 0.85
pushMethod · 0.80
escapeHtmlFunction · 0.70
postAPIFunction · 0.70

Tested by

no test coverage detected