Commit 81dc2d70 authored by Eric Duminil's avatar Eric Duminil
Browse files

Configurable name

parent 55b95e1e
Pipeline #5811 passed with stage
in 2 minutes and 43 seconds
...@@ -76,6 +76,8 @@ void setup() { ...@@ -76,6 +76,8 @@ void setup() {
Serial.println(); Serial.println();
Serial.print(F("Sensor ID: ")); Serial.print(F("Sensor ID: "));
Serial.println(ampel.sensorId); Serial.println(ampel.sensorId);
Serial.print(F("Name : "));
Serial.println(config::ampel_name());
Serial.print(F("MAC : ")); Serial.print(F("MAC : "));
Serial.println(ampel.macAddress); Serial.println(ampel.macAddress);
Serial.print(F("Board : ")); Serial.print(F("Board : "));
...@@ -87,7 +89,7 @@ void setup() { ...@@ -87,7 +89,7 @@ void setup() {
sensor::initialize(); sensor::initialize();
csv_writer::initialize(ampel.sensorId); csv_writer::initialize(config::ampel_name());
if (config::wifi_active) { if (config::wifi_active) {
wifi::defineCommands(); wifi::defineCommands();
...@@ -171,7 +173,7 @@ void wifiConnected() { ...@@ -171,7 +173,7 @@ void wifiConnected() {
} }
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(config::ampel_name());
Serial.print(F(".local (might be unstable) or http://")); Serial.print(F(".local (might be unstable) or http://"));
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
} }
......
...@@ -79,14 +79,14 @@ namespace csv_writer { ...@@ -79,14 +79,14 @@ namespace csv_writer {
} }
#endif #endif
char filename[15]; // "/ESPxxxxxx.csv\0" char filename[20]; // "/ESPxxxxxx.csv\0"
int getAvailableSpace() { int getAvailableSpace() {
return getTotalSpace() - getUsedSpace(); return getTotalSpace() - getUsedSpace();
} }
void initialize(const char *sensorId) { void initialize(const char *sensorId) {
snprintf(filename, sizeof(filename), "/%s.csv", sensorId); snprintf(filename, sizeof(filename), "/%.15s.csv", sensorId);
Serial.println(); Serial.println();
Serial.print(F("Initializing FS...")); Serial.print(F("Initializing FS..."));
......
...@@ -287,6 +287,10 @@ namespace web_config { ...@@ -287,6 +287,10 @@ namespace web_config {
*/ */
namespace config { namespace config {
char* ampel_name() {
return web_config::iotWebConf->getThingName();
}
char* selected_ssid() { char* selected_ssid() {
return web_config::iotWebConf->getWifiSsidParameter()->valueBuffer; return web_config::iotWebConf->getWifiSsidParameter()->valueBuffer;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
namespace config { namespace config {
void save(); // Save config to EEPROM void save(); // Save config to EEPROM
char* ampel_name();
// WiFi // WiFi
char* selected_ssid(); char* selected_ssid();
char* ap_password(); char* ap_password();
......
...@@ -191,7 +191,7 @@ namespace web_server { ...@@ -191,7 +191,7 @@ namespace web_server {
char content[2000]; // Update if needed char content[2000]; // Update if needed
// INFO - Header size : 1767 - Body size : 1991 - Script size : 1909 // INFO - Header size : 1767 - Body size : 1991 - Script size : 1909
snprintf_P(content, sizeof(content), header_template, sensor::co2, ampel.sensorId, wifi::local_ip, snprintf_P(content, sizeof(content), header_template, sensor::co2, config::ampel_name(), wifi::local_ip,
csv_writer::filename); csv_writer::filename);
Serial.print(F("INFO - Header size : ")); Serial.print(F("INFO - Header size : "));
...@@ -200,7 +200,7 @@ namespace web_server { ...@@ -200,7 +200,7 @@ namespace web_server {
web_config::http.send_P(200, PSTR("text/html"), content); web_config::http.send_P(200, PSTR("text/html"), content);
// Body // Body
snprintf_P(content, sizeof(content), body_template, ampel.sensorId, sensor::co2, sensor::temperature, snprintf_P(content, sizeof(content), body_template, config::ampel_name(), sensor::co2, sensor::temperature,
sensor::humidity, sensor::timestamp, config::measurement_timestep, csv_writer::last_successful_write, sensor::humidity, sensor::timestamp, config::measurement_timestep, csv_writer::last_successful_write,
config::csv_interval, csv_writer::getAvailableSpace() / 1024, mqtt::connected ? "Yes" : "No", config::csv_interval, csv_writer::getAvailableSpace() / 1024, mqtt::connected ? "Yes" : "No",
mqtt::last_successful_publish, config::mqtt_sending_interval, mqtt::last_successful_publish, config::mqtt_sending_interval,
...@@ -208,7 +208,7 @@ namespace web_server { ...@@ -208,7 +208,7 @@ namespace web_server {
lorawan::connected ? "Yes" : "No", config::lorawan_frequency_plan, lorawan::last_transmission, lorawan::connected ? "Yes" : "No", config::lorawan_frequency_plan, lorawan::last_transmission,
config::lorawan_sending_interval, config::lorawan_sending_interval,
#endif #endif
config::temperature_offset, config::auto_calibrate_sensor ? "Yes" : "No", ampel.sensorId, ampel.sensorId, config::temperature_offset, config::auto_calibrate_sensor ? "Yes" : "No", config::ampel_name(), config::ampel_name(),
wifi::local_ip, wifi::local_ip, ampel.macAddress, ESP.getFreeHeap(), esp_get_max_free_block_size(), wifi::local_ip, wifi::local_ip, ampel.macAddress, ESP.getFreeHeap(), esp_get_max_free_block_size(),
esp_get_heap_fragmentation(), ampel.max_loop_duration, ampel.board, ampel.version, dd, hh, mm, ss); esp_get_heap_fragmentation(), ampel.max_loop_duration, ampel.board, ampel.version, dd, hh, mm, ss);
...@@ -217,7 +217,7 @@ namespace web_server { ...@@ -217,7 +217,7 @@ namespace web_server {
web_config::http.sendContent(content); web_config::http.sendContent(content);
// Script // Script
snprintf_P(content, sizeof(content), script_template, csv_writer::filename, ampel.sensorId); snprintf_P(content, sizeof(content), script_template, csv_writer::filename, config::ampel_name());
Serial.print(F(" - Script size : ")); Serial.print(F(" - Script size : "));
Serial.println(strlen(content)); Serial.println(strlen(content));
......
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