fix: memory leak on esp32 fixed

This commit is contained in:
Yurii
2024-04-06 20:28:05 +03:00
parent 86734ab622
commit ab1566bd45

View File

@@ -67,7 +67,7 @@ namespace Network {
return this; return this;
} }
Manager* setStaticConfig(IPAddress &ip, IPAddress &gateway, IPAddress &subnet, IPAddress &dns) { Manager* setStaticConfig(IPAddress& ip, IPAddress& gateway, IPAddress& subnet, IPAddress& dns) {
this->staticIp = ip; this->staticIp = ip;
this->staticGateway = gateway; this->staticGateway = gateway;
this->staticSubnet = subnet; this->staticSubnet = subnet;
@@ -181,7 +181,12 @@ namespace Network {
wifi_station_dhcpc_set_maxtry(5); wifi_station_dhcpc_set_maxtry(5);
#endif #endif
#ifdef ARDUINO_ARCH_ESP32
// Nothing. Because memory leaks when turn off WiFi on ESP32, bug?
return true;
#else
return WiFi.mode(WIFI_OFF); return WiFi.mode(WIFI_OFF);
#endif
} }
void reconnect() { void reconnect() {
@@ -328,12 +333,12 @@ namespace Network {
} else if (!this->isConnecting() && this->hasStaCredentials() && (!this->prevReconnectingTime || millis() - this->prevReconnectingTime > this->reconnectInterval)) { } else if (!this->isConnecting() && this->hasStaCredentials() && (!this->prevReconnectingTime || millis() - this->prevReconnectingTime > this->reconnectInterval)) {
Log.sinfoln(FPSTR(L_NETWORK), F("Try connect...")); Log.sinfoln(FPSTR(L_NETWORK), F("Try connect..."));
this->reconnectFlag = false; this->reconnectFlag = false;
Connection::reset(); Connection::reset();
if (!this->connect(true, this->connectionTimeout)) { if (!this->connect(true, this->connectionTimeout)) {
Log.straceln(FPSTR(L_NETWORK), F("Connection failed. Status: %d, reason: %d"), Connection::getStatus(), Connection::getDisconnectReason()); Log.straceln(FPSTR(L_NETWORK), F("Connection failed. Status: %d, reason: %d"), Connection::getStatus(), Connection::getDisconnectReason());
} }
this->prevReconnectingTime = millis(); this->prevReconnectingTime = millis();
} }
} }