Skip to content

Commit

Permalink
esp8266 2.3.0 compatability restored #576
Browse files Browse the repository at this point in the history
asyncscannetworks not available in esp8266 2.3.0, adjusted server on to take cstr for backwards compatability
  • Loading branch information
tablatronix committed Sep 7, 2018
1 parent 04552e4 commit 97e7d30
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
28 changes: 16 additions & 12 deletions WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions WiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@
#ifndef WiFiManager_h
#define WiFiManager_h

#include <core_version.h>
#include <vector>

// #define WM_MDNS // also set MDNS with sethostname
// #define WM_FIXERASECONFIG // use erase flash fix
// #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
Expand Down

3 comments on commit 97e7d30

@LuchtwachtersDelft
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you consider turning this into a hotfix for 0.14 for backwards compatibility?

@tablatronix
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats wrong with .14 ?

@tablatronix
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah we cna just add cstr to it to support new esp lib if its not working

Please sign in to comment.