From 985e95600f08bc6c0f727396c428f44c84f222e7 Mon Sep 17 00:00:00 2001 From: Eric Duminil <eric.duminil@gmail.com> Date: Wed, 9 Feb 2022 12:59:25 +0100 Subject: [PATCH] Reordering params a bit --- ampel-firmware/web_config.cpp | 26 +++++++++++++++----------- ampel-firmware/web_config.h | 9 +++++---- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/ampel-firmware/web_config.cpp b/ampel-firmware/web_config.cpp index cc05a34..c81c494 100644 --- a/ampel-firmware/web_config.cpp +++ b/ampel-firmware/web_config.cpp @@ -30,13 +30,13 @@ namespace web_config { IotWebConf *iotWebConf; - const char config_version[IOTWEBCONF_CONFIG_VERSION_LENGTH] = "a07"; // -- Configuration specific key. The value should be modified if config structure was changed. + const char config_version[IOTWEBCONF_CONFIG_VERSION_LENGTH] = "a08"; // -- Configuration specific key. The value should be modified if config structure was changed. using namespace iotwebconf; /** * WiFi params */ - CheckboxTParameter ampelWifiParam = Builder<CheckboxTParameter>("WiFi").label("WiFi").defaultValue(true).build(); + CheckboxTParameter ampelWifiParam = Builder<CheckboxTParameter>("WiFi").label("WiFi?").defaultValue(true).build(); IntTParameter<uint16_t> wifiTimeoutParam = Builder<IntTParameter<uint16_t>>("wifi_timeout").label("WiFi timeout").defaultValue(WIFI_TIMEOUT).min(0).placeholder( "[s]").build(); @@ -63,7 +63,7 @@ namespace web_config { "Atmospheric CO2 concentration").defaultValue( ATMOSPHERIC_CO2_CONCENTRATION).min(400).max(2000).step(1).placeholder("ppm").build(); - CheckboxTParameter autoCalibrateParam = Builder<CheckboxTParameter>("asc").label("Auto-calibration").defaultValue( + CheckboxTParameter autoCalibrateParam = Builder<CheckboxTParameter>("asc").label("Auto-calibration?").defaultValue( AUTO_CALIBRATE_SENSOR).build(); /** @@ -105,8 +105,11 @@ namespace web_config { Builder<IntTParameter<uint16_t>>("mqtt_timestep").label("MQTT timestep").defaultValue( MQTT_SENDING_INTERVAL).min(0).step(1).defaultValue(300).placeholder("[s]").build(); + CheckboxTParameter mqttEncryptionParam = + Builder<CheckboxTParameter>("mqtt_encryption").label("Encrypt MQTT?").defaultValue(MQTT_ENCRYPTED).build(); + CheckboxTParameter mqttCommandsParam = - Builder<CheckboxTParameter>("mqtt_commands").label("MQTT commands").defaultValue(ALLOW_MQTT_COMMANDS).build(); + Builder<CheckboxTParameter>("mqtt_commands").label("Allow MQTT commands?").defaultValue(ALLOW_MQTT_COMMANDS).build(); TextTParameter<STRING_LEN> mqttServerParam = Builder<TextTParameter<STRING_LEN>>("mqtt_server").label("MQTT Server").defaultValue(MQTT_SERVER).build(); @@ -131,7 +134,7 @@ namespace web_config { IntTParameter<int16_t> timeOffsetParam = Builder<IntTParameter<int16_t>>("timezone").label("Timezone").defaultValue( (UTC_OFFSET_IN_SECONDS) / 3600).min(-23).max(23).step(1).placeholder("[h]").build(); CheckboxTParameter dstParam = - Builder<CheckboxTParameter>("dst").label("Daylight Saving Time").defaultValue(false).build(); + Builder<CheckboxTParameter>("dst").label("Daylight Saving Time?").defaultValue(false).build(); /** * LED @@ -183,8 +186,8 @@ namespace web_config { co2Params.addItem(&atmosphericCO2Param); co2Params.addItem(&autoCalibrateParam); - ledParams.addItem(&maxBrightnessParam); ledParams.addItem(&minBrightnessParam); + ledParams.addItem(&maxBrightnessParam); ledParams.addItem(&ledCountParam); timeParams.addItem(&ntpServerParam); @@ -194,11 +197,12 @@ namespace web_config { csvParams.addItem(&csvTimestepParam); mqttParams.addItem(&mqttTimestepParam); - mqttParams.addItem(&mqttCommandsParam); mqttParams.addItem(&mqttServerParam); mqttParams.addItem(&mqttPortParam); mqttParams.addItem(&mqttUserParam); mqttParams.addItem(&mqttPasswordParam); + mqttParams.addItem(&mqttEncryptionParam); + mqttParams.addItem(&mqttCommandsParam); //TODO: Only for ESP32 loraParams.addItem(&loraTimestepParam); @@ -270,9 +274,6 @@ namespace web_config { * Define all the corresponding config values as reference, so that they can be updated. */ namespace config { - // CSV - uint16_t &csv_interval = web_config::csvTimestepParam.value(); - // Sensor uint16_t &measurement_timestep = web_config::timestepParam.value(); // [s] Value between 2 and 1800 (range for SCD30 sensor). uint16_t &altitude_above_sea_level = web_config::altitudeParam.value(); // [m] @@ -290,12 +291,15 @@ namespace config { int16_t &time_zone = web_config::timeOffsetParam.value(); bool &daylight_saving_time = web_config::dstParam.value(); + // CSV + uint16_t &csv_interval = web_config::csvTimestepParam.value(); + // MQTT char *mqtt_server = web_config::mqttServerParam.value(); char *mqtt_user = web_config::mqttUserParam.value(); char *mqtt_password = web_config::mqttPasswordParam.value(); uint16_t &mqtt_port = web_config::mqttPortParam.value(); uint16_t &mqtt_sending_interval = web_config::mqttTimestepParam.value(); + bool &mqtt_encryption = web_config::mqttEncryptionParam.value(); bool &allow_mqtt_commands = web_config::mqttCommandsParam.value(); - } diff --git a/ampel-firmware/web_config.h b/ampel-firmware/web_config.h index ba4a4ea..3b6bf90 100644 --- a/ampel-firmware/web_config.h +++ b/ampel-firmware/web_config.h @@ -10,10 +10,6 @@ #endif namespace config { - //CSV - //TODO: Add use_csv - extern uint16_t &csv_interval; // [s] - // Sensor extern uint16_t &measurement_timestep; // [s] Value between 2 and 1800 (range for SCD30 sensor). extern uint16_t &altitude_above_sea_level; // [m] @@ -31,6 +27,10 @@ namespace config { extern int16_t &time_zone; // [h] extern bool &daylight_saving_time; // [true / false] + //CSV + //TODO: Add use_csv + extern uint16_t &csv_interval; // [s] + // MQTT //TODO: Add use_mqtt extern char *mqtt_server; @@ -38,6 +38,7 @@ namespace config { extern char *mqtt_password; extern uint16_t &mqtt_port; extern uint16_t &mqtt_sending_interval; // [s] + extern bool &mqtt_encryption; // [true / false] extern bool &allow_mqtt_commands; // [true / false] } -- GitLab