Commit 9edbc85a authored by Eric Duminil's avatar Eric Duminil
Browse files

Better

parent 87fa57ed
...@@ -63,8 +63,7 @@ namespace web_server { ...@@ -63,8 +63,7 @@ namespace web_server {
IotWebConf *iotWebConf; IotWebConf *iotWebConf;
void update() { void update() {
iotWebConf->doLoop(); iotWebConf->doLoop(); // Listen for HTTP requests from clients
// http.handleClient(); // Listen for HTTP requests from clients
} }
void initialize() { void initialize() {
...@@ -72,14 +71,19 @@ namespace web_server { ...@@ -72,14 +71,19 @@ namespace web_server {
Serial.print("HELLO : "); Serial.print("HELLO : ");
Serial.println(ampel.sensorId); 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(); iotWebConf->init();
sensor_console::defineCommand("reset_config", []() { sensor_console::defineCommand("reset_config", []() {
Serial.print("Resetting config..."); Serial.println(F("Resetting config..."));
iotWebConf->getSystemParameterGroup()->applyDefaultValue(); iotWebConf->getSystemParameterGroup()->applyDefaultValue();
iotWebConf->saveConfig(); iotWebConf->saveConfig();
Serial.println("Done!"); Serial.println(F("Done!"));
}, F("(resets the complete IotWeb config)")); }, F("(resets the complete IotWeb config)"));
header_template = header_template =
...@@ -103,6 +107,7 @@ namespace web_server { ...@@ -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-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" "<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" "<li class='pure-menu-item'><a href='#table' class='pure-menu-link'>Info</a></li>\n"
#ifdef AMPEL_CSV #ifdef AMPEL_CSV
"<li class='pure-menu-item'><a href='#graph' class='pure-menu-link'>Graph</a></li>\n" "<li class='pure-menu-item'><a href='#graph' class='pure-menu-link'>Graph</a></li>\n"
...@@ -233,8 +238,7 @@ namespace web_server { ...@@ -233,8 +238,7 @@ namespace web_server {
iotWebConf->handleNotFound(); iotWebConf->handleNotFound();
}); });
// http.begin(); //TODO: Only once wifi connected
Serial.print(F("You can access this sensor via http://")); Serial.print(F("You can access this sensor via http://"));
Serial.print(ampel.sensorId); Serial.print(ampel.sensorId);
Serial.print(F(".local (might be unstable) or http://")); Serial.print(F(".local (might be unstable) or http://"));
...@@ -248,9 +252,8 @@ namespace web_server { ...@@ -248,9 +252,8 @@ namespace web_server {
} }
void handleWebServerRoot() { void handleWebServerRoot() {
// -- Let IotWebConf test and handle captive portal requests.
if (iotWebConf->handleCaptivePortal()) { if (iotWebConf->handleCaptivePortal()) {
// -- Captive portal request were already served. // -- Captive portal requests were already served.
return; return;
} }
if (!shouldBeAllowed()) { if (!shouldBeAllowed()) {
......
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