From 07ebc4668fbd9d1ab6b972cae165a3fce59a9e7e Mon Sep 17 00:00:00 2001 From: Eric Duminil <eric.duminil@gmail.com> Date: Thu, 10 Feb 2022 09:21:52 +0100 Subject: [PATCH] Expect services to be set to true/false in config --- ampel-firmware/config.public.h | 12 ++++++------ ampel-firmware/web_config.cpp | 13 +++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/ampel-firmware/config.public.h b/ampel-firmware/config.public.h index cf0325f..b91b236 100644 --- a/ampel-firmware/config.public.h +++ b/ampel-firmware/config.public.h @@ -7,12 +7,12 @@ * SERVICES */ -// Comment or remove those lines if you want to disable the corresponding services -# define AMPEL_WIFI // Should ESP connect to WiFi? It allows the Ampel to get time from an NTP server. -# define AMPEL_HTTP // Should HTTP web server be started? (AMPEL_WIFI should be enabled too) -# define AMPEL_MQTT // Should data be sent over MQTT? (AMPEL_WIFI should be enabled too) -# define AMPEL_CSV // Should data be logged as CSV, on the ESP flash memory? -// # define AMPEL_LORAWAN // Should data be sent over LoRaWAN? (Requires ESP32 + LoRa modem, and "MCCI LoRaWAN LMIC library") +// Define the default for corresponding services. They can be enabled/disabled later in the web-config. +# define AMPEL_WIFI true // Should ESP connect to WiFi? It allows the Ampel to get time from an NTP server. +# define AMPEL_HTTP true // Should HTTP web server be started? (AMPEL_WIFI should be enabled too) +# define AMPEL_MQTT true // Should data be sent over MQTT? (AMPEL_WIFI should be enabled too) +# define AMPEL_CSV true // Should data be logged as CSV, on the ESP flash memory? +# define AMPEL_LORAWAN false // Should data be sent over LoRaWAN? (Requires ESP32 + LoRa modem, and "MCCI LoRaWAN LMIC library") /** * WIFI diff --git a/ampel-firmware/web_config.cpp b/ampel-firmware/web_config.cpp index e3018e6..9a02186 100644 --- a/ampel-firmware/web_config.cpp +++ b/ampel-firmware/web_config.cpp @@ -34,7 +34,8 @@ namespace web_config { /** * WiFi params */ - CheckboxTParameter ampelWifiParam = Builder<CheckboxTParameter>("WiFi").label("WiFi?").defaultValue(true).build(); + CheckboxTParameter ampelWifiParam = + Builder<CheckboxTParameter>("WiFi").label("WiFi?").defaultValue(AMPEL_WIFI).build(); IntTParameter<uint16_t> wifiTimeoutParam = Builder<IntTParameter<uint16_t>>("wifi_timeout").label("WiFi timeout").defaultValue(WIFI_TIMEOUT).min(0).placeholder( "[s]").build(); @@ -87,7 +88,7 @@ namespace web_config { /** * CSV */ - OptionalParameterGroup csvParams = OptionalParameterGroup("CSV", "CSV", true); + OptionalParameterGroup csvParams = OptionalParameterGroup("CSV", "CSV", AMPEL_CSV); IntTParameter<uint16_t> csvTimestepParam = Builder<IntTParameter<uint16_t>>("csv_timestep").label("CSV timestep").defaultValue(CSV_INTERVAL).min(0).step(1).placeholder( @@ -96,16 +97,12 @@ namespace web_config { /** * MQTT */ - OptionalParameterGroup mqttParams = OptionalParameterGroup("MQTT", "MQTT", true); + OptionalParameterGroup mqttParams = OptionalParameterGroup("MQTT", "MQTT", AMPEL_MQTT); IntTParameter<uint16_t> mqttTimestepParam = Builder<IntTParameter<uint16_t>>("mqtt_timestep").label("MQTT timestep").defaultValue( MQTT_SENDING_INTERVAL).min(0).step(1).defaultValue(300).placeholder("[s]").build(); -#if !defined(MQTT_ENCRYPTED) -# define MQTT_ENCRYPTED true // Old config files might not define it, and encryption was on by default. -#endif - CheckboxTParameter mqttEncryptionParam = Builder<CheckboxTParameter>("mqtt_encryption").label("Encrypt MQTT?").defaultValue(MQTT_ENCRYPTED).build(); @@ -144,7 +141,7 @@ namespace web_config { /** * LoRa & Stuff */ - OptionalParameterGroup loraParams = OptionalParameterGroup("LoRaWan", "LoRaWan", false); + OptionalParameterGroup loraParams = OptionalParameterGroup("LoRaWan", "LoRaWan", AMPEL_LORAWAN); IntTParameter<uint16_t> loraTimestepParam = Builder<IntTParameter<uint16_t>>("lora_timestep").label("LoRa timestep").defaultValue( LORAWAN_SENDING_INTERVAL).min(0).step(1).defaultValue(300).placeholder("[s]").build(); -- GitLab