- 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
This commit is contained in:
ZanzyTHEbar 2022-07-30 17:50:21 +01:00
parent 19e0a66a46
commit 151b01251e
2 changed files with 6 additions and 19 deletions

View File

@ -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
}

View File

@ -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);
}