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

Adding more and more params

parent 7f4a849a
......@@ -19,9 +19,9 @@ namespace web_config {
// -- Configuration specific key. The value should be modified if config structure was changed.
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" };
/**
* Services
*/
iotwebconf::ParameterGroup serviceParams = iotwebconf::ParameterGroup("Services", "Services");
iotwebconf::CheckboxTParameter ampelWifiParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("WiFi").label(
......@@ -78,58 +78,30 @@ namespace web_config {
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>>(
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::TextTParameter<STRING_LEN> mqttUserParam = iotwebconf::Builder<iotwebconf::TextTParameter<STRING_LEN>>(
"mqtt_user").label("MQTT User").defaultValue(MQTT_USER).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?
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::PasswordTParameter<STRING_LEN> mqttPasswordParam = iotwebconf::Builder<
iotwebconf::PasswordTParameter< STRING_LEN>>("mqtt_password").label("MQTT password").defaultValue(
MQTT_PASSWORD).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();
/**
* NTP Time
*/
iotwebconf::CheckboxTParameter autoCalibrateParam = iotwebconf::Builder<iotwebconf::CheckboxTParameter>("asc").label(
"Auto-calibration").defaultValue(true).build();
/**
* LED
*/
iotwebconf::ParameterGroup group2 = iotwebconf::ParameterGroup("c_factor", "Calibration factor");
iotwebconf::CheckboxTParameter checkboxParam =
iotwebconf::Builder<iotwebconf::CheckboxTParameter>("checkParam").label("Check param").defaultValue(true).build();
iotwebconf::SelectTParameter<STRING_LEN> chooserParam =
iotwebconf::Builder<iotwebconf::SelectTParameter< STRING_LEN>>("chooseParam").label("Choose param").optionValues(
(const char*) chooserValues).optionNames((const char*) chooserNames).optionCount(
sizeof(chooserValues) / STRING_LEN).nameLength(STRING_LEN).build();
/**
* LoRa & Stuff
*/
void update() {
iotWebConf->doLoop(); // Listen for HTTP requests from clients
......@@ -160,8 +132,19 @@ namespace web_config {
co2Params.addItem(&atmosphericCO2Param);
co2Params.addItem(&autoCalibrateParam);
csvParams.addItem(&csvTimestepParam);
mqttParams.addItem(&mqttTimestepParam);
mqttParams.addItem(&mqttCommandsParam);
mqttParams.addItem(&mqttServerParam);
mqttParams.addItem(&mqttPortParam);
mqttParams.addItem(&mqttUserParam);
mqttParams.addItem(&mqttPasswordParam);
iotWebConf->addParameterGroup(&serviceParams);
iotWebConf->addParameterGroup(&co2Params);
iotWebConf->addParameterGroup(&csvParams);
iotWebConf->addParameterGroup(&mqttParams);
sensor_console::defineCommand("reset_config", []() {
Serial.println(F("Resetting config..."));
......
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