Commit dea00172 authored by Eric Duminil's avatar Eric Duminil
Browse files

Trying to add more config

parent d1730e23
...@@ -17,19 +17,34 @@ namespace web_config { ...@@ -17,19 +17,34 @@ namespace web_config {
IotWebConf *iotWebConf; IotWebConf *iotWebConf;
// -- Configuration specific key. The value should be modified if config structure was changed. // -- Configuration specific key. The value should be modified if config structure was changed.
const char config_version[] = "ampel_test_v3"; const char config_version[] = "ampel_test_v4";
static const char chooserValues[][STRING_LEN] = { "red", "blue", "darkYellow" }; static const char chooserValues[][STRING_LEN] = { "red", "blue", "darkYellow" };
static const char chooserNames[][STRING_LEN] = { "Red", "Blue", "Dark yellow" }; static const char chooserNames[][STRING_LEN] = { "Red", "Blue", "Dark yellow" };
iotwebconf::ParameterGroup group1 = iotwebconf::ParameterGroup("group1", ""); iotwebconf::ParameterGroup serviceParams = iotwebconf::ParameterGroup("Services", "Services");
iotwebconf::IntTParameter<int16_t> intParam =
iotwebconf::Builder<iotwebconf::IntTParameter<int16_t>>("intParam").label("Int param").defaultValue(30).min(1).max( iotwebconf::CheckboxTParameter ampelWifiParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("WiFi").label(
100).step(1).placeholder("1..100").build(); "WiFi").defaultValue(true).build();
// -- We can add a legend to the separator iotwebconf::CheckboxTParameter ampelCSVParam =
iotwebconf::Builder<iotwebconf::CheckboxTParameter>("CSV").label("CSV").defaultValue(true).build();
iotwebconf::CheckboxTParameter ampelMQTTParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("MQTT").label(
"MQTT").defaultValue(true).build();
iotwebconf::CheckboxTParameter ampelLoRaWANParam =
iotwebconf::Builder<iotwebconf::CheckboxTParameter>("LoRaWAN").label("LoRaWAN").defaultValue(false).build();
iotwebconf::ParameterGroup co2Params = iotwebconf::ParameterGroup("co2", "CO2 Sensor");
//TODO: UIntTParameter?
iotwebconf::IntTParameter<uint16_t> timestepParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"timestep").label("Measurement timestep").defaultValue(MEASUREMENT_TIMESTEP).min(2).max(1800).step(1).placeholder(
"2..1800").build();
iotwebconf::FloatTParameter temperatureOffsetParam =
iotwebconf::Builder<iotwebconf::FloatTParameter>("temp_offset").label("Temperature offset").defaultValue(
TEMPERATURE_OFFSET).placeholder("-3").build();
iotwebconf::ParameterGroup group2 = iotwebconf::ParameterGroup("c_factor", "Calibration factor"); iotwebconf::ParameterGroup group2 = iotwebconf::ParameterGroup("c_factor", "Calibration factor");
iotwebconf::FloatTParameter floatParam = iotwebconf::Builder<iotwebconf::FloatTParameter>("floatParam").label(
"Float param").defaultValue(0.0).step(0.1).placeholder("e.g. 23.4").build();
iotwebconf::CheckboxTParameter checkboxParam = iotwebconf::CheckboxTParameter checkboxParam =
iotwebconf::Builder<iotwebconf::CheckboxTParameter>("checkParam").label("Check param").defaultValue(true).build(); iotwebconf::Builder<iotwebconf::CheckboxTParameter>("checkParam").label("Check param").defaultValue(true).build();
iotwebconf::SelectTParameter<STRING_LEN> chooserParam = iotwebconf::SelectTParameter<STRING_LEN> chooserParam =
...@@ -55,14 +70,16 @@ namespace web_config { ...@@ -55,14 +70,16 @@ namespace web_config {
void initialize() { void initialize() {
iotWebConf = new IotWebConf(ampel.sensorId, &dnsServer, &http, HTTP_PASSWORD, config_version); iotWebConf = new IotWebConf(ampel.sensorId, &dnsServer, &http, HTTP_PASSWORD, config_version);
group1.addItem(&intParam); serviceParams.addItem(&ampelWifiParam);
group2.addItem(&floatParam); serviceParams.addItem(&ampelMQTTParam);
group2.addItem(&checkboxParam); serviceParams.addItem(&ampelCSVParam);
group2.addItem(&chooserParam); serviceParams.addItem(&ampelLoRaWANParam);
co2Params.addItem(&timestepParam);
co2Params.addItem(&temperatureOffsetParam);
iotWebConf->addSystemParameter(&config::stringParam); iotWebConf->addParameterGroup(&serviceParams);
iotWebConf->addParameterGroup(&group1); iotWebConf->addParameterGroup(&co2Params);
iotWebConf->addParameterGroup(&group2);
sensor_console::defineCommand("reset_config", []() { sensor_console::defineCommand("reset_config", []() {
Serial.println(F("Resetting config...")); Serial.println(F("Resetting config..."));
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define STRING_LEN 64 #define STRING_LEN 64
//#include "config.h" #include "config.h"
#include <IotWebConf.h> #include <IotWebConf.h>
#include <IotWebConfTParameter.h> #include <IotWebConfTParameter.h>
......
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