Commit a350816c authored by Eric Duminil's avatar Eric Duminil
Browse files

Rainbow wheel while waiting for client

parent 29ac1bbd
...@@ -604,6 +604,10 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo ...@@ -604,6 +604,10 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
// blocking loop waiting for config // blocking loop waiting for config
while(1){ while(1){
if ( _waiting_for_client_callback != NULL){
_waiting_for_client_callback();
}
// if timed out or abort, break // if timed out or abort, break
if(configPortalHasTimeout() || abort){ if(configPortalHasTimeout() || abort){
DEBUG_WM(DEBUG_DEV,F("configportal abort")); DEBUG_WM(DEBUG_DEV,F("configportal abort"));
...@@ -2198,6 +2202,11 @@ void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) { ...@@ -2198,6 +2202,11 @@ void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) {
_presavecallback = func; _presavecallback = func;
} }
// CUSTOM for Ampel
void WiFiManager::setWaitingForClientCallback( std::function<void()> func ) {
_waiting_for_client_callback = func;
}
/** /**
* set custom head html * set custom head html
* custom element will be added to head, eg. new style tag etc. * custom element will be added to head, eg. new style tag etc.
......
...@@ -216,6 +216,9 @@ class WiFiManager ...@@ -216,6 +216,9 @@ class WiFiManager
//called when settings before have been changed and connection was successful //called when settings before have been changed and connection was successful
void setPreSaveConfigCallback( std::function<void()> func ); void setPreSaveConfigCallback( std::function<void()> func );
//called while waiting for client to connect to config. Used for LEDs
void setWaitingForClientCallback( std::function<void()> func );
//sets timeout before AP,webserver loop ends and exits even if there has been no setup. //sets timeout before AP,webserver loop ends and exits even if there has been no setup.
//useful for devices that failed to connect at some point and got stuck in a webserver loop //useful for devices that failed to connect at some point and got stuck in a webserver loop
...@@ -600,6 +603,7 @@ class WiFiManager ...@@ -600,6 +603,7 @@ class WiFiManager
std::function<void()> _presavecallback; std::function<void()> _presavecallback;
std::function<void()> _saveparamscallback; std::function<void()> _saveparamscallback;
std::function<void()> _resetcallback; std::function<void()> _resetcallback;
std::function<void()> _waiting_for_client_callback;
template <class T> template <class T>
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) { auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
...@@ -613,4 +617,4 @@ class WiFiManager ...@@ -613,4 +617,4 @@ class WiFiManager
#endif #endif
#endif #endif
\ No newline at end of file
...@@ -50,22 +50,26 @@ namespace wifi { ...@@ -50,22 +50,26 @@ namespace wifi {
wifiManager.resetSettings(); wifiManager.resetSettings();
}, F("(Resets wifi config)")); }, F("(Resets wifi config)"));
wifiManager.setAPCallback([](WiFiManager *x) { // wifiManager.setAPCallback([](WiFiManager *x) {
led_effects::showRainbowWheel(); // led_effects::showRainbowWheel();
// });
//
wifiManager.setWaitingForClientCallback([](){
led_effects::showRainbowWheel(50); // Shouldn't last too long, web server needs to be able to answer.
}); });
//
wifiManager.setWebServerCallback([]() { // wifiManager.setWebServerCallback([]() {
led_effects::showKITTWheel(color::green); // led_effects::showKITTWheel(color::green);
}); // });
//
wifiManager.setSaveConfigCallback([]() { // wifiManager.setSaveConfigCallback([]() {
led_effects::showKITTWheel(color::blue); // led_effects::showKITTWheel(color::blue);
}); // });
//
wifiManager.setSaveConfigCallback([]() { // wifiManager.setSaveConfigCallback([]() {
led_effects::showKITTWheel(color::magenta); // led_effects::showKITTWheel(color::magenta);
}); // });
//
wifiManager.autoConnect(hostname); wifiManager.autoConnect(hostname);
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment