Commit 0fe497e8 authored by Eric Duminil's avatar Eric Duminil
Browse files

Use namespace

parent cd8a4314
#include "web_config.h" #include "web_config.h"
namespace config { namespace config {
iotwebconf::TextTParameter<STRING_LEN> stringParam = iotwebconf::Builder<iotwebconf::TextTParameter< STRING_LEN>>( using namespace iotwebconf;
"stringParam").label("String param").build(); TextTParameter<STRING_LEN> stringParam =
Builder<TextTParameter<STRING_LEN>>("stringParam").label("String param").build();
} }
//TODO: Is there any conflict with SPIFFS/LittleFS? //TODO: Is there any conflict with SPIFFS/LittleFS?
...@@ -29,79 +30,77 @@ namespace web_config { ...@@ -29,79 +30,77 @@ namespace web_config {
/** /**
* Services * Services
*/ */
iotwebconf::CheckboxTParameter ampelWifiParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("WiFi").label( CheckboxTParameter ampelWifiParam = Builder<CheckboxTParameter>("WiFi").label("WiFi").defaultValue(true).build();
"WiFi").defaultValue(true).build();
//TODO: Distribute to corresponding classes, possibly with callbacks? //TODO: Distribute to corresponding classes, possibly with callbacks?
/** /**
* CO2 sensor * CO2 sensor
*/ */
iotwebconf::ParameterGroup co2Params = iotwebconf::ParameterGroup("co2", "CO2 Sensor"); //TODO: Conflict with labels? ParameterGroup co2Params = ParameterGroup("co2", "CO2 Sensor"); //TODO: Conflict with labels?
//TODO: UIntTParameter? //TODO: UIntTParameter?
iotwebconf::IntTParameter<uint16_t> timestepParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>( IntTParameter<uint16_t> timestepParam =
"timestep").label("Measurement timestep").defaultValue(MEASUREMENT_TIMESTEP).min(2).max(1800).step(1).placeholder( Builder<IntTParameter<uint16_t>>("timestep").label("Measurement timestep").defaultValue(MEASUREMENT_TIMESTEP).min(
"2..1800").build(); 2).max(1800).step(1).placeholder("2..1800").build();
iotwebconf::FloatTParameter temperatureOffsetParam = FloatTParameter temperatureOffsetParam =
iotwebconf::Builder<iotwebconf::FloatTParameter>("temp_offset").label("Temperature offset").defaultValue( Builder<FloatTParameter>("temp_offset").label("Temperature offset").defaultValue( TEMPERATURE_OFFSET).placeholder(
TEMPERATURE_OFFSET).placeholder("-3").step(0.1).build(); "-3").step(0.1).build();
iotwebconf::IntTParameter<uint16_t> altitudeParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>( IntTParameter<uint16_t> altitudeParam = Builder<IntTParameter<uint16_t>>("altitude").label("Altitude").defaultValue(
"altitude").label("Altitude").defaultValue(ALTITUDE_ABOVE_SEA_LEVEL).min(0).step(1).build(); ALTITUDE_ABOVE_SEA_LEVEL).min(0).step(1).build();
iotwebconf::IntTParameter<uint16_t> atmosphericCO2Param = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>( IntTParameter<uint16_t> atmosphericCO2Param = Builder<IntTParameter<uint16_t>>("atmospheric_co2").label(
"atmospheric_co2").label("Atmospheric CO2 concentration").defaultValue( "Atmospheric CO2 concentration").defaultValue(
ATMOSPHERIC_CO2_CONCENTRATION).min(400).max(2000).step(1).placeholder("400..2000").build(); ATMOSPHERIC_CO2_CONCENTRATION).min(400).max(2000).step(1).placeholder("400..2000").build();
iotwebconf::CheckboxTParameter autoCalibrateParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("asc").label( CheckboxTParameter autoCalibrateParam = Builder<CheckboxTParameter>("asc").label("Auto-calibration").defaultValue(
"Auto-calibration").defaultValue(true).build(); true).build();
/** /**
* CSV * CSV
*/ */
iotwebconf::OptionalParameterGroup csvParams = iotwebconf::OptionalParameterGroup("CSV", "CSV", true); OptionalParameterGroup csvParams = OptionalParameterGroup("CSV", "CSV", true);
iotwebconf::IntTParameter<uint16_t> csvTimestepParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>( IntTParameter<uint16_t> csvTimestepParam =
"csv_timestep").label("CSV timestep").defaultValue(CSV_INTERVAL).min(0).step(1).build(); Builder<IntTParameter<uint16_t>>("csv_timestep").label("CSV timestep").defaultValue(CSV_INTERVAL).min(0).step(1).build();
/** /**
* MQTT * MQTT
*/ */
iotwebconf::OptionalParameterGroup mqttParams = iotwebconf::OptionalParameterGroup("MQTT", "MQTT", true); OptionalParameterGroup mqttParams = OptionalParameterGroup("MQTT", "MQTT", true);
iotwebconf::IntTParameter<uint16_t> mqttTimestepParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>( IntTParameter<uint16_t> mqttTimestepParam =
"mqtt_timestep").label("MQTT timestep").defaultValue( Builder<IntTParameter<uint16_t>>("mqtt_timestep").label("MQTT timestep").defaultValue(
MQTT_SENDING_INTERVAL).min(0).step(1).defaultValue(300).build(); MQTT_SENDING_INTERVAL).min(0).step(1).defaultValue(300).build();
iotwebconf::CheckboxTParameter mqttCommandsParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>( CheckboxTParameter mqttCommandsParam =
"mqtt_commands").label("MQTT commands").defaultValue(false).build(); Builder<CheckboxTParameter>("mqtt_commands").label("MQTT commands").defaultValue(false).build();
iotwebconf::TextTParameter<STRING_LEN> mqttServerParam = iotwebconf::Builder<iotwebconf::TextTParameter<STRING_LEN>>( TextTParameter<STRING_LEN> mqttServerParam =
"mqtt_server").label("MQTT Server").defaultValue(MQTT_SERVER).build(); Builder<TextTParameter<STRING_LEN>>("mqtt_server").label("MQTT Server").defaultValue(MQTT_SERVER).build();
iotwebconf::IntTParameter<uint16_t> mqttPortParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>( IntTParameter<uint16_t> mqttPortParam = Builder<IntTParameter<uint16_t>>("mqtt_port").label("MQTT Port").defaultValue(
"mqtt_port").label("MQTT Port").defaultValue(MQTT_PORT).build(); MQTT_PORT).build();
iotwebconf::TextTParameter<STRING_LEN> mqttUserParam = iotwebconf::Builder<iotwebconf::TextTParameter<STRING_LEN>>( TextTParameter<STRING_LEN> mqttUserParam =
"mqtt_user").label("MQTT User").defaultValue(MQTT_USER).build(); Builder<TextTParameter<STRING_LEN>>("mqtt_user").label("MQTT User").defaultValue(MQTT_USER).build();
//TODO: Show the number of * for password? //TODO: Show the number of * for password?
iotwebconf::PasswordTParameter<STRING_LEN> mqttPasswordParam = iotwebconf::Builder< PasswordTParameter<STRING_LEN> mqttPasswordParam = Builder<PasswordTParameter< STRING_LEN>>("mqtt_password").label(
iotwebconf::PasswordTParameter< STRING_LEN>>("mqtt_password").label("MQTT password").defaultValue( "MQTT password").defaultValue(MQTT_PASSWORD).build();
MQTT_PASSWORD).build();
/** /**
* NTP Time * NTP Time
*/ */
iotwebconf::ParameterGroup timeParams = iotwebconf::ParameterGroup("NTP", "Time server"); ParameterGroup timeParams = ParameterGroup("NTP", "Time server");
iotwebconf::TextTParameter<STRING_LEN> ntpParam = iotwebconf::Builder<iotwebconf::TextTParameter< STRING_LEN>>( TextTParameter<STRING_LEN> ntpParam =
"ntp_server").label("NTP Server").defaultValue(NTP_SERVER).build(); Builder<TextTParameter< STRING_LEN>>("ntp_server").label("NTP Server").defaultValue(NTP_SERVER).build();
iotwebconf::IntTParameter<int16_t> timeOffsetParam = iotwebconf::Builder<iotwebconf::IntTParameter<int16_t>>( IntTParameter<int16_t> timeOffsetParam = Builder<IntTParameter<int16_t>>("timezone").label("Timezone").defaultValue(
"timezone").label("Timezone").defaultValue((UTC_OFFSET_IN_SECONDS) / 3600).min(-23).max(23).step(1).build(); (UTC_OFFSET_IN_SECONDS) / 3600).min(-23).max(23).step(1).build();
iotwebconf::CheckboxTParameter dstParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("dst").label( CheckboxTParameter dstParam =
"Daylight Saving Time").defaultValue(false).build(); Builder<CheckboxTParameter>("dst").label("Daylight Saving Time").defaultValue(false).build();
/** /**
* LED * LED
...@@ -110,12 +109,12 @@ namespace web_config { ...@@ -110,12 +109,12 @@ namespace web_config {
/** /**
* LoRa & Stuff * LoRa & Stuff
*/ */
iotwebconf::OptionalParameterGroup loraParams = iotwebconf::OptionalParameterGroup("LoRaWan", "LoRaWan", false); OptionalParameterGroup loraParams = OptionalParameterGroup("LoRaWan", "LoRaWan", false);
iotwebconf::IntTParameter<uint16_t> loraTimestepParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>( IntTParameter<uint16_t> loraTimestepParam =
"lora_timestep").label("LoRa timestep").defaultValue( Builder<IntTParameter<uint16_t>>("lora_timestep").label("LoRa timestep").defaultValue(
LORAWAN_SENDING_INTERVAL).min(0).step(1).defaultValue(300).build(); LORAWAN_SENDING_INTERVAL).min(0).step(1).defaultValue(300).build();
iotwebconf::OptionalGroupHtmlFormatProvider optionalGroupHtmlFormatProvider; OptionalGroupHtmlFormatProvider optionalGroupHtmlFormatProvider;
void update() { void update() {
iotWebConf->doLoop(); // Listen for HTTP requests from clients iotWebConf->doLoop(); // Listen for HTTP requests from clients
...@@ -126,7 +125,7 @@ namespace web_config { ...@@ -126,7 +125,7 @@ namespace web_config {
} }
void setWifiConnectionFailedCallback(void (*function)()) { void setWifiConnectionFailedCallback(void (*function)()) {
iotWebConf->setWifiConnectionFailedHandler([&function]() -> iotwebconf::WifiAuthInfo* { iotWebConf->setWifiConnectionFailedHandler([&function]() -> WifiAuthInfo* {
function(); function();
return NULL; return NULL;
}); });
......
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