Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
11b36705
Commit
11b36705
authored
Feb 12, 2022
by
Eric Duminil
Browse files
WiFi callbacks
parent
d0c32222
Pipeline
#5799
passed with stage
in 2 minutes and 37 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/ampel-firmware.ino
View file @
11b36705
...
...
@@ -56,11 +56,37 @@
* and define your credentials and parameters in 'config.h'.
*/
void
failedConnection
()
{
Serial
.
println
(
"Seriously. What???"
);
led_effects
::
showKITTWheel
(
color
::
red
);
//void failedConnection() {
// Serial.println("Seriously. What???");
// led_effects::showKITTWheel(color::red);
//}
//
void
wifiConnected
()
{
led_effects
::
showKITTWheel
(
color
::
green
);
Serial
.
println
();
Serial
.
print
(
F
(
"WiFi - Connected! IP address: "
));
IPAddress
address
=
WiFi
.
localIP
();
snprintf
(
wifi
::
local_ip
,
sizeof
(
wifi
::
local_ip
),
"%d.%d.%d.%d"
,
address
[
0
],
address
[
1
],
address
[
2
],
address
[
3
]);
Serial
.
println
(
wifi
::
local_ip
);
ntp
::
initialize
();
if
(
config
::
mqtt_active
())
{
mqtt
::
initialize
(
ampel
.
sensorId
);
}
//TODO: If http enabled
Serial
.
print
(
F
(
"You can access this sensor via http://"
));
Serial
.
print
(
ampel
.
sensorId
);
Serial
.
print
(
F
(
".local (might be unstable) or http://"
));
Serial
.
println
(
WiFi
.
localIP
());
}
void
wifiFailed
()
{
Serial
.
print
(
F
(
"WiFi - Could not connect to "
));
Serial
.
println
(
config
::
current_ssid
());
//TODO: Rename
led_effects
::
showKITTWheel
(
color
::
red
);
}
/*****************************************************************
* Setup *
*****************************************************************/
...
...
@@ -72,35 +98,9 @@ void setup() {
web_config
::
initialize
();
if
(
config
::
wifi_active
)
{
web_config
::
setWifiConnectionCallback
([]()
{
//TODO: Move somewhere else
led_effects
::
showKITTWheel
(
color
::
green
);
Serial
.
println
();
Serial
.
print
(
F
(
"WiFi - Connected! IP address: "
));
IPAddress
address
=
WiFi
.
localIP
();
snprintf
(
wifi
::
local_ip
,
sizeof
(
wifi
::
local_ip
),
"%d.%d.%d.%d"
,
address
[
0
],
address
[
1
],
address
[
2
],
address
[
3
]);
Serial
.
println
(
wifi
::
local_ip
);
ntp
::
initialize
();
if
(
config
::
mqtt_active
())
{
mqtt
::
initialize
(
ampel
.
sensorId
);
}
Serial
.
print
(
F
(
"You can access this sensor via http://"
));
Serial
.
print
(
ampel
.
sensorId
);
Serial
.
print
(
F
(
".local (might be unstable) or http://"
));
Serial
.
println
(
WiFi
.
localIP
());
});
web_config
::
setWifiConnectionCallback
(
wifiConnected
);
web_config
::
setWifiFailCallback
(
failedConnection
);
// web_config::setWifiConnectionFailedCallback([]() {
// led_effects::showKITTWheel(color::red);
// Serial.println(F("Connection to WiFi failed"));
// });
}
web_config
::
setWifiFailCallback
(
wifiFailed
);
pinMode
(
0
,
INPUT
);
// Flash button (used for forced calibration)
...
...
@@ -124,8 +124,6 @@ void setup() {
wifi
::
defineCommands
();
# if (AMPEL_HTTP==1)
web_server
::
definePages
();
//TODO: Rename. Not just web_server
// web_server::initialize();
# endif
}
...
...
ampel-firmware/web_config.cpp
View file @
11b36705
...
...
@@ -50,6 +50,7 @@ namespace web_config {
"[s]"
).
build
();
//TODO: Distribute to corresponding classes, possibly with callbacks?
//TODO: Chainedparameters?
/**
* CO2 sensor
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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