New method to deinit the wifi stack.

1.2-legacy
Jm Casler 2020-09-14 20:27:49 -07:00
rodzic b2a6a4000b
commit 066d9d48a4
3 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -5,6 +5,12 @@
#include "NodeDB.h"
#include "meshwifi/meshhttp.h"
void deinitWifi()
{
WiFi.mode(WIFI_MODE_NULL);
DEBUG_MSG("WiFi Turned Off\n");
}
void initWifi()
{
strcpy(radioConfig.preferences.wifi_ssid, WiFi_SSID_NAME);
@ -68,6 +74,7 @@ void WiFiEvent(WiFiEvent_t event)
// Start web server
initWebServer();
break;
case SYSTEM_EVENT_STA_LOST_IP:
DEBUG_MSG("Lost IP address and IP address is reset to 0");

Wyświetl plik

@ -8,5 +8,7 @@ void reconnectWiFi();
void initWifi();
void deinitWifi();
void WiFiEvent(WiFiEvent_t event);

Wyświetl plik

@ -518,6 +518,8 @@ void setBluetoothEnable(bool on)
// ESP_ERROR_CHECK( heap_trace_start(HEAP_TRACE_LEAKS) );
reinitBluetooth();
// Don't try to reconnect wifi before bluetooth is configured.
// WiFi is initialized from main.cpp in setup() .
if (firstTime) {
firstTime = 0;
} else {
@ -526,7 +528,8 @@ void setBluetoothEnable(bool on)
} else {
// We have to totally teardown our bluetooth objects to prevent leaks
deinitBLE();
//WiFi.mode(WIFI_MODE_NULL); // shutdown wifi
WiFi.mode(WIFI_MODE_NULL); // shutdown wifi
Serial.printf("Shutdown BT: %u heap size\n", ESP.getFreeHeap());
// ESP_ERROR_CHECK( heap_trace_stop() );
// heap_trace_dump();