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
9edbc85a
Commit
9edbc85a
authored
May 14, 2021
by
Eric Duminil
Browse files
Better
parent
87fa57ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/web_server.cpp
View file @
9edbc85a
...
...
@@ -63,8 +63,7 @@ namespace web_server {
IotWebConf
*
iotWebConf
;
void
update
()
{
iotWebConf
->
doLoop
();
// http.handleClient(); // Listen for HTTP requests from clients
iotWebConf
->
doLoop
();
// Listen for HTTP requests from clients
}
void
initialize
()
{
...
...
@@ -72,14 +71,19 @@ namespace web_server {
Serial
.
print
(
"HELLO : "
);
Serial
.
println
(
ampel
.
sensorId
);
iotWebConf
=
new
IotWebConf
(
ampel
.
sensorId
,
&
dnsServer
,
&
http
,
HTTP_PASSWORD
);
iotWebConf
=
new
IotWebConf
(
ampel
.
sensorId
,
&
dnsServer
,
&
http
,
HTTP_PASSWORD
);
// So that sensorId is defined.
//TODO: Disable AP if WiFi connects
//TODO: Add callbacks
//TODO: Add LED effects
//TODO: Add other params
//TODO: Use HTTP_USER / HTTP_PASSWORD for config
iotWebConf
->
init
();
sensor_console
::
defineCommand
(
"reset_config"
,
[]()
{
Serial
.
print
(
"Resetting config..."
);
Serial
.
print
ln
(
F
(
"Resetting config..."
)
)
;
iotWebConf
->
getSystemParameterGroup
()
->
applyDefaultValue
();
iotWebConf
->
saveConfig
();
Serial
.
println
(
"Done!"
);
Serial
.
println
(
F
(
"Done!"
)
)
;
},
F
(
"(resets the complete IotWeb config)"
));
header_template
=
...
...
@@ -103,6 +107,7 @@ namespace web_server {
"<div class='pure-g'><div class='pure-u-1'><div class='pure-menu'><p class='pure-menu-heading'>HfT-Stuttgart CO<sub>2</sub> Ampel</p></div></div>
\n
"
"<div class='pure-u-1'><ul class='pure-menu pure-menu-horizontal pure-menu-list'>
\n
"
"<li class='pure-menu-item'><a href='/config' class='pure-menu-link'>Config</a></li>
\n
"
"<li class='pure-menu-item'><a href='#table' class='pure-menu-link'>Info</a></li>
\n
"
#ifdef AMPEL_CSV
"<li class='pure-menu-item'><a href='#graph' class='pure-menu-link'>Graph</a></li>
\n
"
...
...
@@ -233,8 +238,7 @@ namespace web_server {
iotWebConf
->
handleNotFound
();
});
// http.begin();
//TODO: Only once wifi connected
Serial
.
print
(
F
(
"You can access this sensor via http://"
));
Serial
.
print
(
ampel
.
sensorId
);
Serial
.
print
(
F
(
".local (might be unstable) or http://"
));
...
...
@@ -248,9 +252,8 @@ namespace web_server {
}
void
handleWebServerRoot
()
{
// -- Let IotWebConf test and handle captive portal requests.
if
(
iotWebConf
->
handleCaptivePortal
())
{
// -- Captive portal request were already served.
// -- Captive portal request
s
were already served.
return
;
}
if
(
!
shouldBeAllowed
())
{
...
...
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