From 151b01251e034058ca508be0c007397edeb06c54 Mon Sep 17 00:00:00 2001 From: ZanzyTHEbar Date: Sat, 30 Jul 2022 17:50:21 +0100 Subject: [PATCH] update - Changed SerialManager to only set the config on newData - Changed serial manager to save to flash after all configs set - Changed main init config structs and load config --- .../src/io/SerialManager/serialmanager.cpp | 20 ++++--------------- ESP/src/main.cpp | 5 ++--- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/ESP/lib/src/io/SerialManager/serialmanager.cpp b/ESP/lib/src/io/SerialManager/serialmanager.cpp index 9ef75f8..d3e948e 100644 --- a/ESP/lib/src/io/SerialManager/serialmanager.cpp +++ b/ESP/lib/src/io/SerialManager/serialmanager.cpp @@ -104,18 +104,6 @@ void SerialManager::parseData() strtokIndx = strtok(NULL, ","); strcpy(wifi_config_password, strtokIndx); - - /* if (newData) - { - log_d("New data"); - newData = false; - char *token = strtok(tempBuffer, ","); - while (token != NULL) - { - log_d("Token: %s", token); - token = strtok(NULL, ","); - } - } */ } void SerialManager::handleSerial() @@ -125,10 +113,10 @@ void SerialManager::handleSerial() { strcpy(tempBuffer, serialBuffer); // this temporary copy is necessary to protect the original data because strtok() used in parseData() replaces the commas with \0 parseData(); // split the data into tokens and store them in the data structure + projectConfig.setDeviceConfig(device_config_name, device_config_OTAPassword, &device_config_OTAPort, true); // set the values in the project config + projectConfig.setCameraConfig(&camera_config_vflip, &camera_config_framesize, &camera_config_href, &camera_config_quality, true); // set the values in the project config + projectConfig.setWifiConfig(wifi_config_name, wifi_config_ssid, wifi_config_password, true); // set the values in the project config + projectConfig.save(); // save the config to the EEPROM newData = false; // reset new data } - - projectConfig.setDeviceConfig(device_config_name, device_config_OTAPassword, &device_config_OTAPort, true); // set the values in the project config - projectConfig.setCameraConfig(&camera_config_vflip, &camera_config_framesize, &camera_config_href, &camera_config_quality, true); // set the values in the project config - projectConfig.setWifiConfig(wifi_config_name, wifi_config_ssid, wifi_config_password, true); // set the values in the project config } diff --git a/ESP/src/main.cpp b/ESP/src/main.cpp index 3324f2c..5be5f95 100644 --- a/ESP/src/main.cpp +++ b/ESP/src/main.cpp @@ -24,6 +24,8 @@ void setup() Serial.begin(115200); Serial.setDebugOutput(true); ledManager.begin(); + projectConfig.initStructures(); + projectConfig.load(); cameraHandler.setupCamera(); WiFiHandler::setupWifi(&wifiStateManager, &projectConfig); @@ -33,9 +35,6 @@ void setup() apiServer.startAPIServer(); streamServer.startStreamServer(); } - - ledManager.onOff(true); - ota.SetupOTA(&projectConfig); }