[GH-ISSUE #1810] Add additional callback options #1526

Open
opened 2026-02-28 01:30:24 +03:00 by kerem · 0 comments
Owner

Originally created by @frogen1 on GitHub (Mar 18, 2025).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1810

I downloaded source and modified for my application to add a new callback for the handleErase() function.

My project has a touch screen and I needed to give users the ability to erase wifi config without reseting the ESP. This gives them the option to either use the touchscreen or Config/Web portal to set and clear wifi configs.

So I added:

std::function<void()> _erasewificallback;

void WiFiManager::eraseConfigCallback( std::function<void()> func ) {
_erasewificallback = func;
}

And changed the following at the end of:

void WiFiManager::handleErase() {
.......

if (_erasewificallback != NULL) {
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(WM_DEBUG_VERBOSE,F("[CB] _erasewificallback calling"));
#endif
_erasewificallback(); // @CALLBACK
}
else if(ret){ //if callback set do not reset. Let callback decide.
delay(2000);
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(F("RESETTING ESP"));
#endif
reboot();
}

Originally created by @frogen1 on GitHub (Mar 18, 2025). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1810 I downloaded source and modified for my application to add a new callback for the handleErase() function. My project has a touch screen and I needed to give users the ability to erase wifi config without reseting the ESP. This gives them the option to either use the touchscreen or Config/Web portal to set and clear wifi configs. So I added: std::function<void()> _erasewificallback; void WiFiManager::eraseConfigCallback( std::function<void()> func ) { _erasewificallback = func; } And changed the following at the end of: void WiFiManager::handleErase() { ....... if (_erasewificallback != NULL) { #ifdef WM_DEBUG_LEVEL DEBUG_WM(WM_DEBUG_VERBOSE,F("[CB] _erasewificallback calling")); #endif _erasewificallback(); // @CALLBACK } else if(ret){ //if callback set do not reset. Let callback decide. delay(2000); #ifdef WM_DEBUG_LEVEL DEBUG_WM(F("RESETTING ESP")); #endif reboot(); }
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1526
No description provided.