From b6e83fac62bbb21f032ec45122a43cb5f963bf24 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Mon, 22 May 2017 16:29:41 +0300 Subject: [PATCH] Initial WiFi auto reconnect implementation This needs proper testing! Fixes: https://github.com/espressif/arduino-esp32/issues/353 --- libraries/WiFi/src/WiFiSTA.cpp | 12 ++++++++++++ libraries/WiFi/src/WiFiSTA.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index 7657db21..db712028 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -84,6 +84,7 @@ static bool sta_config_equal(const wifi_config_t& lhs, const wifi_config_t& rhs) // ---------------------------------------------------- STA function ----------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------- +bool WiFiSTAClass::_autoReconnect = true; bool WiFiSTAClass::_useStaticIp = false; wl_status_t WiFiSTAClass::_status = WL_NO_SHIELD; /** @@ -302,6 +303,17 @@ bool WiFiSTAClass::getAutoConnect() return autoConnect; } +bool WiFiSTAClass::setAutoReconnect(bool autoReconnect) +{ + _autoReconnect = autoReconnect; + return true; +} + +bool WiFiSTAClass::getAutoReconnect() +{ + return _autoReconnect; +} + /** * Wait for WiFi connection to reach a result * returns the status reached or disconnect if STA is off diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h index ad02cef3..2e1a8fba 100644 --- a/libraries/WiFi/src/WiFiSTA.h +++ b/libraries/WiFi/src/WiFiSTA.h @@ -51,6 +51,7 @@ public: bool getAutoConnect(); bool setAutoReconnect(bool autoReconnect); + bool getAutoReconnect(); uint8_t waitForConnectResult(); @@ -84,6 +85,7 @@ public: protected: static wl_status_t _status; static bool _useStaticIp; + static bool _autoReconnect; public: bool beginSmartConfig();