From 97e7d30c660cee98a616bcfe20e29042b5513518 Mon Sep 17 00:00:00 2001 From: Shawn A Date: Fri, 7 Sep 2018 14:53:08 -0500 Subject: [PATCH] esp8266 2.3.0 compatability restored #576 asyncscannetworks not available in esp8266 2.3.0, adjusted server on to take cstr for backwards compatability --- WiFiManager.cpp | 28 ++++++++++++++++------------ WiFiManager.h | 6 ++++++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index ebd5c14d7..c7303e356 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -445,18 +445,18 @@ void WiFiManager::setupConfigPortal() { dnsServer->start(DNS_PORT, F("*"), WiFi.softAPIP()); /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */ - server->on((String)FPSTR(R_root), std::bind(&WiFiManager::handleRoot, this)); - server->on((String)FPSTR(R_wifi), std::bind(&WiFiManager::handleWifi, this, true)); - server->on((String)FPSTR(R_wifinoscan), std::bind(&WiFiManager::handleWifi, this, false)); - server->on((String)FPSTR(R_wifisave), std::bind(&WiFiManager::handleWifiSave, this)); - server->on((String)FPSTR(R_info), std::bind(&WiFiManager::handleInfo, this)); - server->on((String)FPSTR(R_param), std::bind(&WiFiManager::handleParam, this)); - server->on((String)FPSTR(R_paramsave), std::bind(&WiFiManager::handleParamSave, this)); - server->on((String)FPSTR(R_restart), std::bind(&WiFiManager::handleReset, this)); - server->on((String)FPSTR(R_exit), std::bind(&WiFiManager::handleExit, this)); - server->on((String)FPSTR(R_close), std::bind(&WiFiManager::handleClose, this)); - server->on((String)FPSTR(R_erase), std::bind(&WiFiManager::handleErase, this, false)); - server->on((String)FPSTR(R_status), std::bind(&WiFiManager::handleWiFiStatus, this)); + server->on(String(FPSTR(R_wifi)).c_str(), std::bind(&WiFiManager::handleWifi, this, true)); + server->on(String(FPSTR(R_root)).c_str(), std::bind(&WiFiManager::handleRoot, this)); + server->on(String(FPSTR(R_wifinoscan)).c_str(), std::bind(&WiFiManager::handleWifi, this, false)); + server->on(String(FPSTR(R_wifisave)).c_str(), std::bind(&WiFiManager::handleWifiSave, this)); + server->on(String(FPSTR(R_info)).c_str(), std::bind(&WiFiManager::handleInfo, this)); + server->on(String(FPSTR(R_param)).c_str(), std::bind(&WiFiManager::handleParam, this)); + server->on(String(FPSTR(R_paramsave)).c_str(), std::bind(&WiFiManager::handleParamSave, this)); + server->on(String(FPSTR(R_restart)).c_str(), std::bind(&WiFiManager::handleReset, this)); + server->on(String(FPSTR(R_exit)).c_str(), std::bind(&WiFiManager::handleExit, this)); + server->on(String(FPSTR(R_close)).c_str(), std::bind(&WiFiManager::handleClose, this)); + server->on(String(FPSTR(R_erase)).c_str(), std::bind(&WiFiManager::handleErase, this, false)); + server->on(String(FPSTR(R_status)).c_str(), std::bind(&WiFiManager::handleWiFiStatus, this)); server->onNotFound (std::bind(&WiFiManager::handleNotFound, this)); server->begin(); // Web server start @@ -1010,9 +1010,13 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){ if(async){ DEBUG_WM(DEBUG_VERBOSE,F("WiFi Scan ASYNC started")); #ifdef ESP8266 + #ifndef WM_NOASYNC // no async available < 2.4.0 using namespace std::placeholders; // for `_1` WiFi.scanNetworksAsync(std::bind(&WiFiManager::WiFi_scanComplete,this,_1)); #else + res = WiFi.scanNetworks(); + #endif + #else res = WiFi.scanNetworks(true); #endif return false; diff --git a/WiFiManager.h b/WiFiManager.h index 787c987f3..0619fa758 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -13,6 +13,7 @@ #ifndef WiFiManager_h #define WiFiManager_h +#include #include // #define WM_MDNS // also set MDNS with sethostname @@ -20,6 +21,11 @@ // #define WM_ERASE_NVS // esp32 erase(true) will erase NVS // #define WM_RTC // esp32 info page will include reset reasons +#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 +#warning "ARDUINO_ESP8266_RELEASE_2_3_0, some WM features disabled" +#define WM_NOASYNC // esp8266 no async scan wifi +#endif + // #include "soc/efuse_reg.h" // include to add efuse chip rev to info, getChipRevision() is almost always the same though, so not sure why it matters. // #define esp32autoreconnect // implement esp32 autoreconnect event listener kludge