[GH-ISSUE #21] Callback when in AP mode #18

Closed
opened 2026-02-28 01:22:53 +03:00 by kerem · 10 comments
Owner

Originally created by @alwynallan on GitHub (Dec 16, 2015).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/21

Others might have this need, so feel free to integrate my solution. My application has a display but no user input. It's useful to display that the device is in AP mode, waiting for configuration. I did it with a callback function: in WiFiManager.h, public:

void setAPCallback( void (*func)(void) );

and private:

void (*_apcallback)(void) = NULL;

Then in WiFiManger.cpp after WiFi.mode(WIFI_AP); I added

if( _apcallback != NULL) _apcallback();

and the obvious

void WiFiManager::setAPCallback( void (*func)(void) ) {
_apcallback = func;
}

Feel free to improve. Thanks for the handy library.

Originally created by @alwynallan on GitHub (Dec 16, 2015). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/21 Others might have this need, so feel free to integrate my solution. My application has a display but no user input. It's useful to display that the device is in AP mode, waiting for configuration. I did it with a callback function: in WiFiManager.h, public: `void setAPCallback( void (*func)(void) );` and private: `void (*_apcallback)(void) = NULL;` Then in WiFiManger.cpp after `WiFi.mode(WIFI_AP);` I added `if( _apcallback != NULL) _apcallback();` and the obvious `void WiFiManager::setAPCallback( void (*func)(void) ) {` `_apcallback = func;` `}` Feel free to improve. Thanks for the handy library.
kerem closed this issue 2026-02-28 01:22:54 +03:00
Author
Owner

@domonetic commented on GitHub (Dec 16, 2015):

+1

<!-- gh-comment-id:165214734 --> @domonetic commented on GitHub (Dec 16, 2015): +1
Author
Owner

@tzapu commented on GitHub (Dec 16, 2015):

Hi,

this is very nice, i will add it.

something like this i plan to also add for additional variables, thank you very much, you hva kickstarted me in the right direction.

cheers
alex

On 16 Dec 2015, at 19:52, Peter Allan notifications@github.com wrote:

Others might have this need, so feel free to integrate my solution My application has a display but no user input It's useful to display that the device is in AP mode, waiting for configuration I did it with a callback function: in WiFiManagerh, public:

void setAPCallback( void (*func)(void) );

and private:

void (*_apcallback)(void) = NULL;

Then in WiFiMangercpp after WiFimode(WIFI_AP); I added

if( _apcallback != NULL) _apcallback();

and the obvious

void WiFiManager::setAPCallback( void (*func)(void) ) {
_apcallback = func;
}

Feel free to improve Thanks for the handy library


Reply to this email directly or view it on GitHub https://github.com/tzapu/WiFiManager/issues/21.

<!-- gh-comment-id:165214970 --> @tzapu commented on GitHub (Dec 16, 2015): Hi, this is very nice, i will add it. something like this i plan to also add for additional variables, thank you very much, you hva kickstarted me in the right direction. cheers alex > On 16 Dec 2015, at 19:52, Peter Allan notifications@github.com wrote: > > Others might have this need, so feel free to integrate my solution My application has a display but no user input It's useful to display that the device is in AP mode, waiting for configuration I did it with a callback function: in WiFiManagerh, public: > > void setAPCallback( void (*func)(void) ); > > and private: > > void (*_apcallback)(void) = NULL; > > Then in WiFiMangercpp after WiFimode(WIFI_AP); I added > > if( _apcallback != NULL) _apcallback(); > > and the obvious > > void WiFiManager::setAPCallback( void (*func)(void) ) { > _apcallback = func; > } > > Feel free to improve Thanks for the handy library > > — > Reply to this email directly or view it on GitHub https://github.com/tzapu/WiFiManager/issues/21.
Author
Owner

@tzapu commented on GitHub (Dec 16, 2015):

I will also try to add a display/oled example for this, maybe i ll mange tomorrow
thank again

<!-- gh-comment-id:165220254 --> @tzapu commented on GitHub (Dec 16, 2015): I will also try to add a display/oled example for this, maybe i ll mange tomorrow thank again
Author
Owner

@tzapu commented on GitHub (Dec 16, 2015):

probably worth sending the ip of the AP in the call back as well

<!-- gh-comment-id:165220479 --> @tzapu commented on GitHub (Dec 16, 2015): probably worth sending the ip of the AP in the call back as well
Author
Owner

@domonetic commented on GitHub (Dec 16, 2015):

I think it would overload of unnecessary code, there are functions to find the ip.

<!-- gh-comment-id:165225139 --> @domonetic commented on GitHub (Dec 16, 2015): I think it would overload of unnecessary code, there are functions to find the ip.
Author
Owner

@tablatronix commented on GitHub (Dec 16, 2015):

Got a pull request or commit ? I was about to do this myself.

<!-- gh-comment-id:165243280 --> @tablatronix commented on GitHub (Dec 16, 2015): Got a pull request or commit ? I was about to do this myself.
Author
Owner

@tzapu commented on GitHub (Dec 17, 2015):

@domonetic you are right, makes sense
@tablatronix i plan on merging it today, as soon as i get a chance. will update here

<!-- gh-comment-id:165356803 --> @tzapu commented on GitHub (Dec 17, 2015): @domonetic you are right, makes sense @tablatronix i plan on merging it today, as soon as i get a chance. will update here
Author
Owner

@tzapu commented on GitHub (Dec 17, 2015):

guys, pushed an update, will update documentation as well later
thanks again

<!-- gh-comment-id:165367855 --> @tzapu commented on GitHub (Dec 17, 2015): guys, pushed an update, will update documentation as well later thanks again
Author
Owner

@tzapu commented on GitHub (Dec 28, 2015):

this is done and seems to work fine
thanks guys

<!-- gh-comment-id:167570768 --> @tzapu commented on GitHub (Dec 28, 2015): this is done and seems to work fine thanks guys
Author
Owner

@alwynallan commented on GitHub (Dec 28, 2015):

Thanks guys for including this. I have upgraded to your version and it all works. One day I'll learn git fork/merge and make my changes myself.

<!-- gh-comment-id:167583701 --> @alwynallan commented on GitHub (Dec 28, 2015): Thanks guys for including this. I have upgraded to your version and it all works. One day I'll learn git fork/merge and make my changes myself.
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#18
No description provided.