mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-13 14:51:21 +10:00
Merge branch 'master' of https://github.com/tzapu/WiFiManager
This commit is contained in:
+37
-33
@@ -226,7 +226,7 @@ WiFiManager::~WiFiManager() {
|
||||
_params = NULL;
|
||||
}
|
||||
|
||||
// @todo remove event
|
||||
// remove event
|
||||
// WiFi.onEvent(std::bind(&WiFiManager::WiFiEvent,this,_1,_2));
|
||||
#ifdef ESP32
|
||||
WiFi.removeEvent(wm_event_id);
|
||||
@@ -312,7 +312,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
DEBUG_WM(F("AutoConnect: ESP Already Connected"));
|
||||
#endif
|
||||
setSTAConfig();
|
||||
// @todo not sure if this check makes sense, causes dup setSTAConfig in connectwifi,
|
||||
// @todo not sure if this is safe, causes dup setSTAConfig in connectwifi,
|
||||
// and we have no idea WHAT we are connected to
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ bool WiFiManager::startAP(){
|
||||
|
||||
if(_debugLevel >= DEBUG_DEV) debugSoftAPConfig();
|
||||
|
||||
// @todo add softAP retry here
|
||||
// @todo add softAP retry here to dela with unknown failures
|
||||
|
||||
delay(500); // slight delay to make sure we get an AP IP
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -594,7 +594,7 @@ void WiFiManager::setupHTTPServer(){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("[CB] _webservercallback calling"));
|
||||
#endif
|
||||
_webservercallback();
|
||||
_webservercallback(); // @CALLBACK
|
||||
}
|
||||
// @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first
|
||||
|
||||
@@ -677,7 +677,6 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
if(!validApPassword()) return false;
|
||||
|
||||
// HANDLE issues with STA connections, shutdown sta if not connected, or else this will hang channel scanning and softap will not respond
|
||||
// @todo sometimes still cannot connect to AP for no known reason, no events in log either
|
||||
if(_disableSTA || (!WiFi.isConnected() && _disableSTAConn)){
|
||||
// this fixes most ap problems, however, simply doing mode(WIFI_AP) does not work if sta connection is hanging, must `wifi_station_disconnect`
|
||||
WiFi_Disconnect();
|
||||
@@ -687,7 +686,6 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
// @todo even if sta is connected, it is possible that softap connections will fail, IOS says "invalid password", windows says "cannot connect to this network" researching
|
||||
WiFi_enableSTA(true);
|
||||
}
|
||||
|
||||
@@ -756,6 +754,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
|
||||
// status change, break
|
||||
// @todo what is this for, should be moved inside the processor
|
||||
// I think.. this is to detect autoconnect by esp in background, there are also many open issues about autoreconnect not working
|
||||
if(state != WL_IDLE_STATUS){
|
||||
result = (state == WL_CONNECTED); // true if connected
|
||||
DEBUG_WM(DEBUG_DEV,F("configportal loop break"));
|
||||
@@ -784,12 +783,7 @@ boolean WiFiManager::process(){
|
||||
MDNS.update();
|
||||
#endif
|
||||
|
||||
if(configPortalActive && !_configPortalIsBlocking){
|
||||
if(configPortalHasTimeout()) shutdownConfigPortal();
|
||||
}
|
||||
|
||||
if(webPortalActive || (configPortalActive && !_configPortalIsBlocking)){
|
||||
|
||||
// if timed out or abort, break
|
||||
if(_allowExit && (configPortalHasTimeout() || abort)){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -847,7 +841,7 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("[CB] _savewificallback calling"));
|
||||
#endif
|
||||
_savewificallback();
|
||||
_savewificallback(); // @CALLBACK
|
||||
}
|
||||
if(!_connectonsave) return WL_IDLE_STATUS;
|
||||
if(_disableConfigPortal) shutdownConfigPortal();
|
||||
@@ -867,7 +861,7 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("[CB] WiFi/Param save callback"));
|
||||
#endif
|
||||
_savewificallback();
|
||||
_savewificallback(); // @CALLBACK
|
||||
}
|
||||
if(_disableConfigPortal) shutdownConfigPortal();
|
||||
return WL_CONNECT_FAILED; // CONNECT FAIL
|
||||
@@ -914,6 +908,7 @@ bool WiFiManager::shutdownConfigPortal(){
|
||||
server->handleClient();
|
||||
|
||||
// @todo what is the proper way to shutdown and free the server up
|
||||
// debug - many open issues aobut port not clearing for use with other servers
|
||||
server->stop();
|
||||
server.reset();
|
||||
|
||||
@@ -971,7 +966,7 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass, bool connect) {
|
||||
// make sure sta is on before `begin` so it does not call enablesta->mode while persistent is ON ( which would save WM AP state to eeprom !)
|
||||
// WiFi.setAutoReconnect(false);
|
||||
if(_cleanConnect) WiFi_Disconnect(); // disconnect before begin, in case anything is hung, this causes a 2 seconds delay for connect
|
||||
// @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status
|
||||
// @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status to avoid these
|
||||
|
||||
// if retry without delay (via begin()), the IDF is still busy even after returning status
|
||||
// E (5130) wifi:sta is connecting, return error
|
||||
@@ -1743,17 +1738,11 @@ void WiFiManager::handleWifiSave() {
|
||||
#endif
|
||||
handleRequest();
|
||||
|
||||
// @todo use new callback for before paramsaves
|
||||
if (!_paramsInWifi && _presavecallback != NULL) {
|
||||
_presavecallback();
|
||||
}
|
||||
|
||||
//SAVE/connect here
|
||||
_ssid = server->arg(F("s")).c_str();
|
||||
_pass = server->arg(F("p")).c_str();
|
||||
|
||||
if(_paramsInWifi) doParamSave();
|
||||
|
||||
// set static ips from server args
|
||||
if (server->arg(FPSTR(S_ip)) != "") {
|
||||
//_sta_static_ip.fromString(server->arg(FPSTR(S_ip));
|
||||
String ip = server->arg(FPSTR(S_ip));
|
||||
@@ -1784,6 +1773,12 @@ void WiFiManager::handleWifiSave() {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_presavewificallback != NULL) {
|
||||
_presavewificallback(); // @CALLBACK
|
||||
}
|
||||
|
||||
if(_paramsInWifi) doParamSave();
|
||||
|
||||
String page;
|
||||
|
||||
if(_ssid == ""){
|
||||
@@ -1831,8 +1826,8 @@ void WiFiManager::handleParamSave() {
|
||||
|
||||
void WiFiManager::doParamSave(){
|
||||
// @todo use new callback for before paramsaves, is this really needed?
|
||||
if ( _presavecallback != NULL) {
|
||||
_presavecallback();
|
||||
if ( _presaveparamscallback != NULL) {
|
||||
_presaveparamscallback(); // @CALLBACK
|
||||
}
|
||||
|
||||
//parameters
|
||||
@@ -1870,7 +1865,7 @@ void WiFiManager::doParamSave(){
|
||||
}
|
||||
|
||||
if ( _saveparamscallback != NULL) {
|
||||
_saveparamscallback();
|
||||
_saveparamscallback(); // @CALLBACK
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2516,7 +2511,7 @@ void WiFiManager::resetSettings() {
|
||||
WiFi_enableSTA(true,true); // must be sta to disconnect erase
|
||||
delay(500); // ensure sta is enabled
|
||||
if (_resetcallback != NULL){
|
||||
_resetcallback();
|
||||
_resetcallback(); // @CALLBACK
|
||||
}
|
||||
|
||||
#ifdef ESP32
|
||||
@@ -2699,6 +2694,15 @@ void WiFiManager::setSaveConfigCallback( std::function<void()> func ) {
|
||||
_savewificallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* setPreSaveConfigCallback, set a callback to fire before saving wifi or params
|
||||
* @access public
|
||||
* @param {[type]} void (*func)(void)
|
||||
*/
|
||||
void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) {
|
||||
_presavewificallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* setConfigResetCallback, set a callback to occur when a resetSettings() occurs
|
||||
* @access public
|
||||
@@ -2718,12 +2722,12 @@ void WiFiManager::setSaveParamsCallback( std::function<void()> func ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* setPreSaveConfigCallback, set a callback to fire before saving wifi or params
|
||||
* setPreSaveParamsCallback, set a pre save params callback on params save prior to anything else
|
||||
* @access public
|
||||
* @param {[type]} void (*func)(void)
|
||||
*/
|
||||
void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) {
|
||||
_presavecallback = func;
|
||||
void WiFiManager::setPreSaveParamsCallback( std::function<void()> func ) {
|
||||
_presaveparamscallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3343,7 +3347,7 @@ boolean WiFiManager::validApPassword(){
|
||||
DEBUG_WM(F("AccessPoint set password is INVALID or <8 chars"));
|
||||
#endif
|
||||
_apPassword = "";
|
||||
return false; // @todo FATAL or fallback to empty ?
|
||||
return false; // @todo FATAL or fallback to empty , currently fatal, fail secure.
|
||||
}
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("AccessPoint set password is VALID"));
|
||||
@@ -3423,7 +3427,7 @@ bool WiFiManager::WiFiSetCountry(){
|
||||
// ret = esp_wifi_set_bandwidth(WIFI_IF_AP,WIFI_BW_HT20); // WIFI_BW_HT40
|
||||
#ifdef ESP32
|
||||
esp_err_t err = ESP_OK;
|
||||
// @todo check if wifi is init, no idea how, doesnt seem to be exposed atm ( might be now! )
|
||||
// @todo check if wifi is init, no idea how, doesnt seem to be exposed atm ( check again it might be now! )
|
||||
if(WiFi.getMode() == WIFI_MODE_NULL){
|
||||
DEBUG_WM(DEBUG_ERROR,"[ERROR] cannot set country, wifi not init");
|
||||
} // exception if wifi not init!
|
||||
@@ -3473,7 +3477,7 @@ bool WiFiManager::WiFi_Mode(WiFiMode_t m,bool persistent) {
|
||||
return ret;
|
||||
#elif defined(ESP32)
|
||||
if(persistent && esp32persistent) WiFi.persistent(true);
|
||||
ret = WiFi.mode(m); // @todo persistent check persistant mode , NI
|
||||
ret = WiFi.mode(m); // @todo persistent check persistant mode, was eventually added to esp lib, but have to add version checking probably
|
||||
if(persistent && esp32persistent) WiFi.persistent(false);
|
||||
return ret;
|
||||
#endif
|
||||
@@ -3490,7 +3494,7 @@ bool WiFiManager::WiFi_Disconnect() {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_DEV,F("WiFi station disconnect"));
|
||||
#endif
|
||||
ETS_UART_INTR_DISABLE(); // @todo probably not needed
|
||||
ETS_UART_INTR_DISABLE(); // @todo possibly not needed
|
||||
ret = wifi_station_disconnect();
|
||||
ETS_UART_INTR_ENABLE();
|
||||
return ret;
|
||||
@@ -3752,7 +3756,7 @@ void WiFiManager::handleUpdating(){
|
||||
|
||||
// Use new callback for before OTA update
|
||||
if (_preotaupdatecallback != NULL) {
|
||||
_preotaupdatecallback();
|
||||
_preotaupdatecallback(); // @CALLBACK
|
||||
}
|
||||
#ifdef ESP8266
|
||||
WiFiUDP::stopAll();
|
||||
|
||||
Reference in New Issue
Block a user