mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
Merge pull request #734 from irwanayeah/development
add callback before save config wifi or params
This commit is contained in:
@@ -1278,6 +1278,11 @@ void WiFiManager::handleWifiSave() {
|
||||
DEBUG_WM(DEBUG_DEV,F("Method:"),server->method() == HTTP_GET ? (String)FPSTR(S_GET) : (String)FPSTR(S_POST));
|
||||
handleRequest();
|
||||
|
||||
// @todo use new callback for before paramsaves
|
||||
if ( _presavecallback != NULL) {
|
||||
_presavecallback();
|
||||
}
|
||||
|
||||
//SAVE/connect here
|
||||
_ssid = server->arg(F("s")).c_str();
|
||||
_pass = server->arg(F("p")).c_str();
|
||||
@@ -1324,6 +1329,12 @@ void WiFiManager::handleParamSave() {
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("<- HTTP WiFi save "));
|
||||
DEBUG_WM(DEBUG_DEV,F("Method:"),server->method() == HTTP_GET ? (String)FPSTR(S_GET) : (String)FPSTR(S_POST));
|
||||
handleRequest();
|
||||
|
||||
// @todo use new callback for before paramsaves
|
||||
if ( _presavecallback != NULL) {
|
||||
_presavecallback();
|
||||
}
|
||||
|
||||
doParamSave();
|
||||
|
||||
// @todo use new callback for paramsaves
|
||||
@@ -2009,6 +2020,16 @@ void WiFiManager::setSaveConfigCallback( std::function<void()> func ) {
|
||||
_savecallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* setPreSaveConfigCallback, set a pre save config callback after closing configportal
|
||||
* @todo only calls if configportal stopped
|
||||
* @access public
|
||||
* @param {[type]} void (*func)(void) [description]
|
||||
*/
|
||||
void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) {
|
||||
_presavecallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* set custom head html
|
||||
* custom element will be added to head, eg. new style tag etc.
|
||||
|
||||
@@ -198,6 +198,8 @@ class WiFiManager
|
||||
void setAPCallback( std::function<void(WiFiManager*)> func );
|
||||
//called when settings have been changed and connection was successful
|
||||
void setSaveConfigCallback( std::function<void()> func );
|
||||
//called when settings before have been changed and connection was successful
|
||||
void setPreSaveConfigCallback( std::function<void()> func );
|
||||
//adds a custom parameter, returns false on failure
|
||||
bool addParameter(WiFiManagerParameter *p);
|
||||
//returns the list of Parameters
|
||||
@@ -470,6 +472,7 @@ class WiFiManager
|
||||
// callbacks
|
||||
std::function<void(WiFiManager*)> _apcallback;
|
||||
std::function<void()> _savecallback;
|
||||
std::function<void()> _presavecallback;
|
||||
|
||||
template <class T>
|
||||
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
|
||||
|
||||
Reference in New Issue
Block a user