fix: single boot refresh with QR code, async WiFi scan, skip light sleep in AP mode
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -46,13 +46,24 @@
|
||||
async function scanNetworks() {
|
||||
try {
|
||||
const res = await fetch('/api/wifi/scan');
|
||||
const networks = await res.json();
|
||||
const data = await res.json();
|
||||
if (data.scanning) {
|
||||
// Scan in progress — retry after 2s
|
||||
setTimeout(scanNetworks, 2000);
|
||||
return;
|
||||
}
|
||||
const select = document.getElementById('wifiSsid');
|
||||
select.innerHTML = networks.map(n =>
|
||||
if (data.length === 0) {
|
||||
select.innerHTML = '<option value="">No networks found</option>';
|
||||
setTimeout(scanNetworks, 3000);
|
||||
return;
|
||||
}
|
||||
select.innerHTML = data.map(n =>
|
||||
`<option value="${n.ssid}">${n.ssid} (${n.rssi}dBm)</option>`
|
||||
).join('');
|
||||
} catch (e) {
|
||||
console.error('Scan failed:', e);
|
||||
setTimeout(scanNetworks, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user