Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
a350816c
Commit
a350816c
authored
May 09, 2021
by
Eric Duminil
Browse files
Rainbow wheel while waiting for client
parent
29ac1bbd
Changes
3
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/src/lib/WiFiManager/WiFiManager.cpp
View file @
a350816c
...
...
@@ -604,6 +604,10 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
// blocking loop waiting for config
while
(
1
){
if
(
_waiting_for_client_callback
!=
NULL
){
_waiting_for_client_callback
();
}
// if timed out or abort, break
if
(
configPortalHasTimeout
()
||
abort
){
DEBUG_WM
(
DEBUG_DEV
,
F
(
"configportal abort"
));
...
...
@@ -2198,6 +2202,11 @@ void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) {
_presavecallback
=
func
;
}
// CUSTOM for Ampel
void
WiFiManager
::
setWaitingForClientCallback
(
std
::
function
<
void
()
>
func
)
{
_waiting_for_client_callback
=
func
;
}
/**
* set custom head html
* custom element will be added to head, eg. new style tag etc.
...
...
ampel-firmware/src/lib/WiFiManager/WiFiManager.h
View file @
a350816c
...
...
@@ -216,6 +216,9 @@ class WiFiManager
//called when settings before have been changed and connection was successful
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.
//useful for devices that failed to connect at some point and got stuck in a webserver loop
...
...
@@ -600,6 +603,7 @@ class WiFiManager
std
::
function
<
void
()
>
_presavecallback
;
std
::
function
<
void
()
>
_saveparamscallback
;
std
::
function
<
void
()
>
_resetcallback
;
std
::
function
<
void
()
>
_waiting_for_client_callback
;
template
<
class
T
>
auto
optionalIPFromString
(
T
*
obj
,
const
char
*
s
)
->
decltype
(
obj
->
fromString
(
s
)
)
{
...
...
@@ -613,4 +617,4 @@ class WiFiManager
#endif
#endif
\ No newline at end of file
#endif
ampel-firmware/wifi_util.cpp
View file @
a350816c
...
...
@@ -50,22 +50,26 @@ namespace wifi {
wifiManager
.
resetSettings
();
},
F
(
"(Resets wifi config)"
));
wifiManager
.
setAPCallback
([](
WiFiManager
*
x
)
{
led_effects
::
showRainbowWheel
();
// wifiManager.setAPCallback([](WiFiManager *x) {
// led_effects::showRainbowWheel();
// });
//
wifiManager
.
setWaitingForClientCallback
([](){
led_effects
::
showRainbowWheel
(
50
);
// Shouldn't last too long, web server needs to be able to answer.
});
wifiManager
.
setWebServerCallback
([]()
{
led_effects
::
showKITTWheel
(
color
::
green
);
});
wifiManager
.
setSaveConfigCallback
([]()
{
led_effects
::
showKITTWheel
(
color
::
blue
);
});
wifiManager
.
setSaveConfigCallback
([]()
{
led_effects
::
showKITTWheel
(
color
::
magenta
);
});
//
//
wifiManager.setWebServerCallback([]() {
//
led_effects::showKITTWheel(color::green);
//
});
//
//
wifiManager.setSaveConfigCallback([]() {
//
led_effects::showKITTWheel(color::blue);
//
});
//
//
wifiManager.setSaveConfigCallback([]() {
//
led_effects::showKITTWheel(color::magenta);
//
});
//
wifiManager
.
autoConnect
(
hostname
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment