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

Adding more and more params

parent dea00172
......@@ -17,7 +17,7 @@ namespace web_config {
IotWebConf *iotWebConf;
// -- Configuration specific key. The value should be modified if config structure was changed.
const char config_version[] = "ampel_test_v4";
const char config_version[] = "ampel_test_v6";
static const char chooserValues[][STRING_LEN] = { "red", "blue", "darkYellow" };
static const char chooserNames[][STRING_LEN] = { "Red", "Blue", "Dark yellow" };
......@@ -33,6 +33,75 @@ namespace web_config {
iotwebconf::CheckboxTParameter ampelLoRaWANParam =
iotwebconf::Builder<iotwebconf::CheckboxTParameter>("LoRaWAN").label("LoRaWAN").defaultValue(false).build();
//TODO: Distribute to corresponding classes, possibly with callbacks?
/**
* CO2 sensor
*/
iotwebconf::ParameterGroup co2Params = iotwebconf::ParameterGroup("co2", "CO2 Sensor"); //TODO: Conflict with labels?
//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").step(0.1).build();
iotwebconf::IntTParameter<uint16_t> altitudeParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"altitude").label("Altitude").defaultValue(ALTITUDE_ABOVE_SEA_LEVEL).min(0).step(1).build();
iotwebconf::IntTParameter<uint16_t> atmosphericCO2Param = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"atmospheric_co2").label("Atmospheric CO2 concentration").defaultValue(
ATMOSPHERIC_CO2_CONCENTRATION).min(400).max(2000).step(1).placeholder("400..2000").build();
iotwebconf::CheckboxTParameter autoCalibrateParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("asc").label(
"Auto-calibration").defaultValue(true).build();
/**
* CSV
*/
iotwebconf::ParameterGroup csvParams = iotwebconf::ParameterGroup("csvs", "CSV");
iotwebconf::IntTParameter<uint16_t> csvTimestepParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"csv_timestep").label("CSV timestep").defaultValue(CSV_INTERVAL).min(0).step(1).build();
/**
* MQTT
*/
iotwebconf::ParameterGroup mqttParams = iotwebconf::ParameterGroup("mqtts", "MQTT");
iotwebconf::IntTParameter<uint16_t> mqttTimestepParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"mqtt_timestep").label("MQTT timestep").defaultValue(
MQTT_SENDING_INTERVAL).min(0).step(1).defaultValue(300).build();
iotwebconf::CheckboxTParameter mqttCommandsParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>(
"mqtt_commands").label("MQTT commands").defaultValue(false).build();
# define MQTT_SERVER "test.mosquitto.org" // MQTT server URL or IP address
# define MQTT_PORT 8883
# define MQTT_USER ""
# define MQTT_PASSWORD ""
iotwebconf::TextTParameter<STRING_LEN> mqttServerParam = iotwebconf::Builder<iotwebconf::TextTParameter< STRING_LEN>>(
"mqtt_server").label("MQTT Server").defaultValue(MQTT_SERVER).build();
iotwebconf::IntTParameter<uint16_t> mqttPortParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"mqtt_port").label("MQTT Port").defaultValue(MQTT_PORT).build();
iotwebconf::FloatTParameter temperatureOffsetParam =
iotwebconf::Builder<iotwebconf::FloatTParameter>("temp_offset").label("Temperature offset").defaultValue(
TEMPERATURE_OFFSET).placeholder("-3").step(0.1).build();
iotwebconf::IntTParameter<uint16_t> altitudeParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"altitude").label("Altitude").defaultValue(ALTITUDE_ABOVE_SEA_LEVEL).min(0).step(1).build();
iotwebconf::IntTParameter<uint16_t> atmosphericCO2Param = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"atmospheric_co2").label("Atmospheric CO2 concentration").defaultValue(
ATMOSPHERIC_CO2_CONCENTRATION).min(400).max(2000).step(1).placeholder("400..2000").build();
iotwebconf::CheckboxTParameter autoCalibrateParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("asc").label(
"Auto-calibration").defaultValue(true).build();
iotwebconf::ParameterGroup co2Params = iotwebconf::ParameterGroup("co2", "CO2 Sensor");
//TODO: UIntTParameter?
......@@ -42,7 +111,17 @@ namespace web_config {
iotwebconf::FloatTParameter temperatureOffsetParam =
iotwebconf::Builder<iotwebconf::FloatTParameter>("temp_offset").label("Temperature offset").defaultValue(
TEMPERATURE_OFFSET).placeholder("-3").build();
TEMPERATURE_OFFSET).placeholder("-3").step(0.1).build();
iotwebconf::IntTParameter<uint16_t> altitudeParam = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"altitude").label("Altitude").defaultValue(ALTITUDE_ABOVE_SEA_LEVEL).min(0).step(1).build();
iotwebconf::IntTParameter<uint16_t> atmosphericCO2Param = iotwebconf::Builder<iotwebconf::IntTParameter<uint16_t>>(
"atmospheric_co2").label("Atmospheric CO2 concentration").defaultValue(
ATMOSPHERIC_CO2_CONCENTRATION).min(400).max(2000).step(1).placeholder("400..2000").build();
iotwebconf::CheckboxTParameter autoCalibrateParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("asc").label(
"Auto-calibration").defaultValue(true).build();
iotwebconf::ParameterGroup group2 = iotwebconf::ParameterGroup("c_factor", "Calibration factor");
iotwebconf::CheckboxTParameter checkboxParam =
......@@ -70,6 +149,13 @@ namespace web_config {
void initialize() {
iotWebConf = new IotWebConf(ampel.sensorId, &dnsServer, &http, HTTP_PASSWORD, config_version);
iotWebConf->setWifiConnectionHandler([](const char *ssid, const char *password) {
Serial.println("LETS TRY TO CONNECT NOW!");
WiFi.begin(ssid, password);
delay(10000);
Serial.println("WIFI DONE?");
});
serviceParams.addItem(&ampelWifiParam);
serviceParams.addItem(&ampelMQTTParam);
serviceParams.addItem(&ampelCSVParam);
......@@ -77,6 +163,9 @@ namespace web_config {
co2Params.addItem(&timestepParam);
co2Params.addItem(&temperatureOffsetParam);
co2Params.addItem(&altitudeParam);
co2Params.addItem(&atmosphericCO2Param);
co2Params.addItem(&autoCalibrateParam);
iotWebConf->addParameterGroup(&serviceParams);
iotWebConf->addParameterGroup(&co2Params);
......
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