Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ESPAsyncWiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ void AsyncWiFiManager::startConfigPortalModeless(char const *apName, char const
_modeless =true;
_apName = apName;
_apPassword = apPassword;
_shouldSaveConfig = false;

/*
AJS - do we want this?
Expand All @@ -371,6 +372,7 @@ void AsyncWiFiManager::startConfigPortalModeless(char const *apName, char const
DEBUG_WM(WiFi.localIP());
//connected
// call the callback!
_shouldSaveConfig = true;
if ( _savecallback != NULL) {
//todo: check if any custom parameters actually exist, and check if they really changed maybe
_savecallback();
Expand Down Expand Up @@ -428,6 +430,7 @@ void AsyncWiFiManager::criticalLoop(){
// alanswx - should we have a config to decide if we should shut down AP?
// WiFi.mode(WIFI_STA);
//notify that configuration has changed and any optional parameters should be saved
_shouldSaveConfig = true;
if ( _savecallback != NULL) {
//todo: check if any custom parameters actually exist, and check if they really changed maybe
_savecallback();
Expand All @@ -439,6 +442,7 @@ void AsyncWiFiManager::criticalLoop(){
if (_shouldBreakAfterConfig) {
//flag set to exit after config after trying to connect
//notify that configuration has changed and any optional parameters should be saved
_shouldSaveConfig = true;
if ( _savecallback != NULL) {
//todo: check if any custom parameters actually exist, and check if they really changed maybe
_savecallback();
Expand All @@ -462,6 +466,7 @@ boolean AsyncWiFiManager::startConfigPortal(char const *apName, char const *apP
WiFi.mode(WIFI_AP_STA);
DEBUG_WM("SET AP STA");

_shouldSaveConfig = false;
_apName = apName;
_apPassword = apPassword;

Expand Down Expand Up @@ -505,6 +510,7 @@ boolean AsyncWiFiManager::startConfigPortal(char const *apName, char const *apP
//connected
WiFi.mode(WIFI_STA);
//notify that configuration has changed and any optional parameters should be saved
_shouldSaveConfig = true;
if ( _savecallback != NULL) {
//todo: check if any custom parameters actually exist, and check if they really changed maybe
_savecallback();
Expand Down Expand Up @@ -533,6 +539,7 @@ boolean AsyncWiFiManager::startConfigPortal(char const *apName, char const *apP
}

if (_shouldBreakAfterConfig) {
_shouldSaveConfig = true;
//flag set to exit after config after trying to connect
//notify that configuration has changed and any optional parameters should be saved
if ( _savecallback != NULL) {
Expand Down
6 changes: 5 additions & 1 deletion ESPAsyncWiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class AsyncWiFiManager
//configuration portal (ESP as access point) is running [default true/on]
void setTryConnectDuringConfigPortal(boolean v);


void setDebugOutput(boolean debug);
//defaults to not showing anything under 8% signal quality if called
void setMinimumSignalQuality(int quality = 8);
Expand All @@ -157,6 +156,10 @@ class AsyncWiFiManager
void setAPCallback( void (*func)(AsyncWiFiManager*) );
//called when settings have been changed and connection was successful
void setSaveConfigCallback( void (*func)(void) );
//gets condition that signals if configuration should be saved
boolean shouldSaveConfig () {
return _shouldSaveConfig;
}
//adds a custom parameter
void addParameter(AsyncWiFiManagerParameter *p);
//if this is set, it will exit after config, even if connection is unsucessful.
Expand Down Expand Up @@ -260,6 +263,7 @@ class AsyncWiFiManager

void (*_apcallback)(AsyncWiFiManager*) = NULL;
void (*_savecallback)(void) = NULL;
boolean _shouldSaveConfig = false;

AsyncWiFiManagerParameter* _params[WIFI_MANAGER_MAX_PARAMS];

Expand Down