fix(tpager): enable Wi-Fi without reboot

This commit is contained in:
Pixel Perfect
2026-08-05 17:56:11 -07:00
parent 3f222ceecd
commit 0175cebcd8
5 changed files with 270 additions and 113 deletions
+24 -1
View File
@@ -725,7 +725,7 @@ bool MyMesh::handleMeshcomodCommand(const char* text, int text_len) {
} else if (wifiConfigPagerWifiBlocksBle()) {
pushMeshcomodReply("OK\nble: pending (Wi-Fi handoff)");
} else if (wifiConfigGetBleEnabled()) {
pushMeshcomodReply("ble: pending (restart required)");
pushMeshcomodReply("ble: pending (retry from Settings)");
#endif
} else {
pushMeshcomodReply("error: Bluetooth could not start");
@@ -932,14 +932,35 @@ bool MyMesh::handleMeshcomodCommand(const char* text, int text_len) {
pushMeshcomodReply("error: wifi radio off — send wifi on first");
return true;
}
if (wifiScanIsActive()) {
pushMeshcomodReply("wifi: scan already in progress");
return true;
}
// Ensure STA is fully up before scan; disconnected STA needs a bit more settle time.
wifi_mode_t mode = WiFi.getMode();
#if defined(TLORA_PAGER)
// Never cold-initialize Wi-Fi from a command handler while NimBLE is
// resident. The main loop performs the ordered live handoff; a subsequent
// command can scan once that short transition has completed.
if ((mode & WIFI_MODE_STA) == 0) {
wifiConfigRequestApply();
pushMeshcomodReply("wifi: starting; retry scan shortly");
return true;
}
if (wifiConfigPagerWifiBlocksBle()) {
pushMeshcomodReply("wifi: association in progress; retry scan shortly");
return true;
}
delay(40);
#else
if ((mode & WIFI_MODE_STA) == 0) {
WiFi.mode(WIFI_STA);
delay(180);
} else {
delay(40);
}
#endif
wifiScanSetActive(true);
s_meshcomod_scan_count = 0;
// Watchdog-safe: one bounded, yielding async pass (see wifiScanWatchdogSafe).
// This handler runs on the main/loop task, so the old twin synchronous scans
@@ -948,6 +969,7 @@ bool MyMesh::handleMeshcomodCommand(const char* text, int text_len) {
if (found <= 0) {
pushMeshcomodReply("scan: no networks (2.4GHz only)");
WiFi.scanDelete();
wifiScanSetActive(false);
return true;
}
String scanMsg = "scan results:";
@@ -992,6 +1014,7 @@ bool MyMesh::handleMeshcomodCommand(const char* text, int text_len) {
pushMeshcomodReply(scanMsg.c_str());
}
WiFi.scanDelete();
wifiScanSetActive(false);
return true;
}
if (strncasecmp(p, "use", 3) == 0 && (p[3] == '\0' || p[3] == ' ' || p[3] == '\t')) {