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

Better

parent 87fa57ed
......@@ -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.println(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 requests were already served.
return;
}
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