Commit 168ea9b6 authored by Eric Duminil's avatar Eric Duminil
Browse files

Add save to save config

parent bf1050e5
Pipeline #5860 passed with stage
in 2 minutes and 32 seconds
...@@ -103,7 +103,7 @@ namespace sensor { ...@@ -103,7 +103,7 @@ namespace sensor {
Serial.println(F(" s during acclimatization.")); Serial.println(F(" s during acclimatization."));
scd30.setMeasurementInterval(config::measurement_timestep_bootup); // [s] scd30.setMeasurementInterval(config::measurement_timestep_bootup); // [s]
sensor_console::defineIntCommand("co2", setCO2forDebugging, F("1500 (Sets co2 level, for debugging purposes)")); sensor_console::defineIntCommand("co2", setCO2forDebugging, F("1500 (Sets co2 level, for debugging)"));
sensor_console::defineIntCommand("timer", setTimer, F("30 (Sets measurement interval, in s)")); sensor_console::defineIntCommand("timer", setTimer, F("30 (Sets measurement interval, in s)"));
sensor_console::defineCommand("calibrate", startCalibrationProcess, F("(Starts calibration process)")); sensor_console::defineCommand("calibrate", startCalibrationProcess, F("(Starts calibration process)"));
sensor_console::defineIntCommand("calibrate", calibrateSensorToSpecificPPM, sensor_console::defineIntCommand("calibrate", calibrateSensorToSpecificPPM,
...@@ -305,7 +305,6 @@ namespace sensor { ...@@ -305,7 +305,6 @@ namespace sensor {
Serial.println(F("s (change will only be applied after next measurement).")); Serial.println(F("s (change will only be applied after next measurement)."));
scd30.setMeasurementInterval(timestep); scd30.setMeasurementInterval(timestep);
config::measurement_timestep = timestep; config::measurement_timestep = timestep;
config::save();
led_effects::showKITTWheel(color::green, 1); led_effects::showKITTWheel(color::green, 1);
} }
} }
......
...@@ -176,7 +176,6 @@ namespace csv_writer { ...@@ -176,7 +176,6 @@ namespace csv_writer {
Serial.print(F("Setting CSV Interval to : ")); Serial.print(F("Setting CSV Interval to : "));
Serial.print(config::csv_interval); Serial.print(config::csv_interval);
Serial.println("s."); Serial.println("s.");
config::save();
led_effects::showKITTWheel(color::green, 1); led_effects::showKITTWheel(color::green, 1);
} }
......
...@@ -220,7 +220,6 @@ namespace lorawan { ...@@ -220,7 +220,6 @@ namespace lorawan {
Serial.print(F("Setting LoRa sending interval to : ")); Serial.print(F("Setting LoRa sending interval to : "));
Serial.print(config::lorawan_sending_interval); Serial.print(config::lorawan_sending_interval);
Serial.println("s."); Serial.println("s.");
config::save();
led_effects::showKITTWheel(color::green, 1); led_effects::showKITTWheel(color::green, 1);
} }
} }
......
...@@ -180,8 +180,7 @@ namespace mqtt { ...@@ -180,8 +180,7 @@ namespace mqtt {
config::mqtt_sending_interval = sending_interval; config::mqtt_sending_interval = sending_interval;
Serial.print(F("Setting MQTT sending interval to : ")); Serial.print(F("Setting MQTT sending interval to : "));
Serial.print(config::mqtt_sending_interval); Serial.print(config::mqtt_sending_interval);
Serial.println("s."); Serial.println(F("s."));
config::save();
led_effects::showKITTWheel(color::green, 1); led_effects::showKITTWheel(color::green, 1);
} }
......
#include "sensor_console.h" #include "sensor_console.h"
namespace sensor_console { namespace sensor_console {
const uint8_t MAX_COMMANDS = 22; const uint8_t MAX_COMMANDS = 25;
const uint8_t MAX_COMMAND_SIZE = 20; // Should be enough for "set_time 1618829570\n" const uint8_t MAX_COMMAND_SIZE = 20; // Should be enough for "set_time 1618829570\n"
uint8_t commands_count = 0; uint8_t commands_count = 0;
......
...@@ -223,20 +223,21 @@ namespace web_config { ...@@ -223,20 +223,21 @@ namespace web_config {
//TODO: Add "ap" command? //TODO: Add "ap" command?
//TODO: Add "wifi_ssid" command? //TODO: Add "wifi_ssid" command?
//TODO: Add "wifi_password" command? //TODO: Add "wifi_password" command?
//TODO: Add "save_config" command? sensor_console::defineCommand("save_config", config::save, F("(Saves the config to EEPROM)"));
sensor_console::defineCommand("reset_config", []() { sensor_console::defineCommand("reset_config", []() {
Serial.println(F("Resetting config...")); Serial.println(F("Resetting config..."));
iotWebConf->getRootParameterGroup()->applyDefaultValue(); iotWebConf->getRootParameterGroup()->applyDefaultValue();
iotWebConf->saveConfig(); iotWebConf->saveConfig();
Serial.println(F("Done!")); Serial.println(F("Done!"));
}, F("(resets the complete IotWeb config)")); }, F("(Resets the complete IotWeb config)"));
sensor_console::defineIntCommand("wifi", [](int32_t onOff) { sensor_console::defineIntCommand("wifi", [](int32_t onOff) {
config::is_wifi_on = onOff; config::is_wifi_on = onOff;
iotWebConf->saveConfig(); iotWebConf->saveConfig();
Serial.print(F("WiFi - ")); Serial.print(F("WiFi - "));
Serial.println(onOff ? F("On!") : F("Off!")); Serial.println(onOff ? F("On!") : F("Off!"));
}, F("0/1 (Turns Wifi on/off).")); }, F("0/1 (Turns Wifi on/off)"));
iotWebConf->loadConfig(); iotWebConf->loadConfig();
......
Supports Markdown
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