feat: AP always-on mode - hotspot stays until WiFi STA connects
Redesign provisioning from one-shot blocking to persistent background manager: - AP hotspot starts at boot regardless of eth0 status - Captive portal runs alongside AP for WiFi configuration - AP automatically shuts down only when WiFi STA connects - WiFi drops at runtime -> AP auto-restarts - WiFi connect fails -> AP auto-restarts for retry - client.js no longer blocks on network; connects WS when ready Made-with: Cursor
This commit is contained in:
@@ -173,8 +173,26 @@ function sleep(ms) {
|
||||
execSync(`sleep ${ms / 1000}`, { timeout: ms + 2000 });
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测 wlan0 是否以 STA 模式连接了 WiFi(排除自身热点)
|
||||
*/
|
||||
function isWifiStaConnected() {
|
||||
const iface = getWifiIface();
|
||||
try {
|
||||
const out = run('nmcli -t -f DEVICE,TYPE,STATE,CONNECTION device');
|
||||
for (const line of out.split('\n')) {
|
||||
const parts = line.split(':');
|
||||
if (parts[0] === iface && parts[1] === 'wifi' && parts[2] === 'connected') {
|
||||
return parts[3] !== CON_NAME;
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
hasInternet,
|
||||
isWifiStaConnected,
|
||||
getWifiIface,
|
||||
scanWifi,
|
||||
connectWifi,
|
||||
|
||||
Reference in New Issue
Block a user