From 877dc824a9979ab81dd5b76bbe506a9f7531b2c9 Mon Sep 17 00:00:00 2001 From: Jm Date: Tue, 22 Dec 2020 22:26:08 -0800 Subject: [PATCH] #407 - Fix for wifi does not come back up after power down --- platformio.ini | 2 +- src/meshwifi/meshwifi.cpp | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/platformio.ini b/platformio.ini index 015aa105..327c5d6c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -103,7 +103,7 @@ lib_deps = # board_build.ldscript = linker/esp32.extram.bss.ld lib_ignore = segger_rtt platform_packages = - framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#2814f110aa618429bdd9a0a2d6a93c55f29f87a6 + framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#c29e0bcde1b1b4a939dd7339dea0302d2d589ae7 ; customize the partition table ; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables diff --git a/src/meshwifi/meshwifi.cpp b/src/meshwifi/meshwifi.cpp index 16ae6185..54358077 100644 --- a/src/meshwifi/meshwifi.cpp +++ b/src/meshwifi/meshwifi.cpp @@ -40,12 +40,14 @@ bool isWifiAvailable() const char *wifiName = radioConfig.preferences.wifi_ssid; const char *wifiPsw = radioConfig.preferences.wifi_password; - // strcpy(radioConfig.preferences.wifi_ssid, ""); - // strcpy(radioConfig.preferences.wifi_password, ""); + // strcpy(radioConfig.preferences.wifi_ssid, "meshtastic"); + // strcpy(radioConfig.preferences.wifi_password, "meshtastic!"); // strcpy(radioConfig.preferences.wifi_ssid, "meshtasticAdmin"); // strcpy(radioConfig.preferences.wifi_password, "12345678"); + // radioConfig.preferences.wifi_ap_mode = true; + // radioConfig.preferences.wifi_ap_mode = false; if (*wifiName && *wifiPsw) { return 1; @@ -221,9 +223,16 @@ static void WiFiEvent(WiFiEvent_t event) DEBUG_MSG("Obtained IP address: \n"); Serial.println(WiFi.localIP()); - // Start web server - initWebServer(); - initApiServer(); + if (!APStartupComplete) { + // Start web server + DEBUG_MSG("... Starting network services\n"); + initWebServer(); + initApiServer(); + + APStartupComplete = true; + } else { + DEBUG_MSG("... Not starting network services (They're already running)\n"); + } break; case SYSTEM_EVENT_STA_LOST_IP: @@ -253,7 +262,7 @@ static void WiFiEvent(WiFiEvent_t event) APStartupComplete = true; } else { - DEBUG_MSG("... Not starting network services\n"); + DEBUG_MSG("... Not starting network services (They're already running)\n"); } break;