diff --git a/Firmware/RTK_Surveyor/RTK_Surveyor.ino b/Firmware/RTK_Surveyor/RTK_Surveyor.ino index d246eaca9..44273ecb0 100644 --- a/Firmware/RTK_Surveyor/RTK_Surveyor.ino +++ b/Firmware/RTK_Surveyor/RTK_Surveyor.ino @@ -205,6 +205,14 @@ char logFileName[sizeof("SFE_Reference_Station_230101_120101.ubx_plusExtraSpace" #ifdef COMPILE_WIFI #include "ESP32OTAPull.h" //http://librarymanager/All#ESP-OTA-Pull Used for getting + +#define WIFI_STOP() \ +{ \ + if (settings.debugWifiState) \ + systemPrintf("wifiStop called by %s %d\r\n", __FILE__, __LINE__); \ + wifiStop(); \ +} + #endif // COMPILE_WIFI #define OTA_FIRMWARE_JSON_URL \ diff --git a/Firmware/RTK_Surveyor/States.ino b/Firmware/RTK_Surveyor/States.ino index 8a92da502..b82636542 100644 --- a/Firmware/RTK_Surveyor/States.ino +++ b/Firmware/RTK_Surveyor/States.ino @@ -120,7 +120,7 @@ void updateSystemState() setMuxport(settings.dataPortChannel); // Return mux to original channel - wifiStop(); // Stop WiFi, ntripClient will start as needed. + WIFI_STOP(); // Stop WiFi, ntripClient will start as needed. bluetoothStart(); // Turn on Bluetooth with 'Rover' name radioStart(); // Start internal radio if enabled, otherwise disable @@ -249,7 +249,7 @@ void updateSystemState() // Allow WiFi to continue running if NTRIP Client is needed for assisted survey in if (wifiIsNeeded() == false) - wifiStop(); + WIFI_STOP(); bluetoothStop(); bluetoothStart(); // Restart Bluetooth with 'Base' identifier diff --git a/Firmware/RTK_Surveyor/WiFi.ino b/Firmware/RTK_Surveyor/WiFi.ino index bc8e7b9de..79abb8b81 100644 --- a/Firmware/RTK_Surveyor/WiFi.ino +++ b/Firmware/RTK_Surveyor/WiFi.ino @@ -149,7 +149,7 @@ void menuWiFi() if (wifiIsConnected()) { log_d("Menu caused restarting of WiFi"); - wifiStop(); + WIFI_STOP(); wifiStart(); wifiConnectionAttempts = 0; // Reset the timeout } @@ -222,7 +222,7 @@ bool wifiStartAP(bool forceAP) if (settings.wifiConfigOverAP == true || forceAP) { // Stop any current WiFi activity - wifiStop(); + WIFI_STOP(); // Start in AP mode WiFi.mode(WIFI_AP); @@ -347,7 +347,7 @@ void wifiUpdate() { systemPrintln("WiFi connection failed. Giving up."); displayNoWiFi(2000); - wifiStop(); // Move back to WIFI_OFF + WIFI_STOP(); // Move back to WIFI_OFF } } } @@ -365,7 +365,7 @@ void wifiUpdate() // If WiFi is connected, and no services require WiFi, shut it off else if (wifiIsNeeded() == false) - wifiStop(); + WIFI_STOP(); break; } @@ -387,7 +387,7 @@ void wifiStart() { systemPrintln("Error: Please enter at least one SSID before using WiFi"); // paintNoWiFi(2000); //TODO - wifiStop(); + WIFI_STOP(); return; } @@ -441,7 +441,7 @@ void wifiShutdown() // esp_wifi_set_protocol requires WiFi to be started esp_err_t response = esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_LR); if (response != ESP_OK) - systemPrintf("wifiStop: Error setting ESP-Now lone protocol: %s\r\n", esp_err_to_name(response)); + systemPrintf("wifiShutdown: Error setting ESP-Now lone protocol: %s\r\n", esp_err_to_name(response)); else log_d("WiFi disabled, ESP-Now left in place"); } diff --git a/Firmware/RTK_Surveyor/menuFirmware.ino b/Firmware/RTK_Surveyor/menuFirmware.ino index f3d8f75c5..102ac68ab 100644 --- a/Firmware/RTK_Surveyor/menuFirmware.ino +++ b/Firmware/RTK_Surveyor/menuFirmware.ino @@ -120,7 +120,7 @@ void menuFirmware() systemPrintln("Firmware update failed to connect to WiFi."); if (previouslyConnected == false) - wifiStop(); + WIFI_STOP(); if(bluetoothOriginallyConnected == true) bluetoothStart(); // Restart BT according to settings @@ -141,7 +141,7 @@ void menuFirmware() // We get here if WiFi failed or the server was not available if (previouslyConnected == false) - wifiStop(); + WIFI_STOP(); } else if (incoming == 'e') @@ -315,7 +315,7 @@ void updateFromSD(const char *firmwareFileName) // Turn off any tasks so that we are not disrupted espnowStop(); - wifiStop(); + WIFI_STOP(); bluetoothStop(); // Delete tasks if running @@ -551,12 +551,12 @@ bool otaCheckVersion(char *versionAvailable, uint8_t versionAvailableLength) if (systemState != STATE_WIFI_CONFIG) { - // wifiStop() turns off the entire radio including the webserver. We need to turn off Station mode only. + // WIFI_STOP() turns off the entire radio including the webserver. We need to turn off Station mode only. // For now, unit exits AP mode via reset so if we are in AP config mode, leave WiFi Station running. // If WiFi was originally off, turn it off again if (previouslyConnected == false) - wifiStop(); + WIFI_STOP(); } if (gotVersion == true) @@ -619,7 +619,7 @@ void otaUpdate() // Update failed. If WiFi was originally off, turn it off again if (previouslyConnected == false) - wifiStop(); + WIFI_STOP(); #endif // COMPILE_WIFI } diff --git a/Firmware/RTK_Surveyor/menuPP.ino b/Firmware/RTK_Surveyor/menuPP.ino index 661fbd3e3..eccc7f754 100644 --- a/Firmware/RTK_Surveyor/menuPP.ino +++ b/Firmware/RTK_Surveyor/menuPP.ino @@ -1172,7 +1172,7 @@ void menuPointPerfect() } } - wifiStop(); + WIFI_STOP(); } else if (incoming == 4) {