This commit is contained in:
@@ -26,6 +26,7 @@ Firmware OTA::getLatestVersionOnServer() {
|
||||
}
|
||||
|
||||
String payload = http.getString();
|
||||
Log.verbose("Payload: %s", payload.c_str());
|
||||
DynamicJsonDocument doc(4096);
|
||||
DeserializationError error = deserializeJson(doc, payload);
|
||||
|
||||
@@ -39,8 +40,8 @@ Firmware OTA::getLatestVersionOnServer() {
|
||||
|
||||
std::vector<Configuration> configs;
|
||||
for (JsonObject config : doc["Configurations"].as<JsonArray>()) {
|
||||
if (config.containsKey("Version") && config.containsKey("URL") && config.containsKey("Configuration")) {
|
||||
String deviceConfig = config["Configuration"].as<String>();
|
||||
if (config.containsKey("Version") && config.containsKey("URL") && config.containsKey("Config")) {
|
||||
String deviceConfig = config["Config"].as<String>();
|
||||
if (deviceConfig == _current_device_configuration) {
|
||||
configs.push_back(Configuration{
|
||||
parseVersion(config["Version"]),
|
||||
@@ -48,6 +49,8 @@ Firmware OTA::getLatestVersionOnServer() {
|
||||
config["Board"],
|
||||
deviceConfig
|
||||
});
|
||||
} else {
|
||||
Log.verbose("Configuration %s does not match current device configuration %s", deviceConfig.c_str(), _current_device_configuration.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,7 +98,7 @@ void OTA::run_ota_update(String url, std::function<void()> callback_started, st
|
||||
WiFiClient client;
|
||||
ret = httpUpdate.update(client, url);
|
||||
} else {
|
||||
Log.error("URL is not valid");
|
||||
Log.error("URL is not valid: \n%s", url.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
#define water_level_min_key "water_level_min"
|
||||
#define water_level_max_key "water_level_max"
|
||||
#define water_volume_key "water_volume"
|
||||
#define current_software_version Version{0, 0, 6}
|
||||
#define current_software_version Version{0, 0, 7}
|
||||
|
||||
#define RESISTOR_VALUE 4
|
||||
@@ -59,6 +59,7 @@ void update_error(int err) {
|
||||
Firmware fw = ota.getLatestVersionOnServer();
|
||||
Log.verbose("we are done");
|
||||
Serial.printf("Firmware Info: Valid: %d, Version: %d.%d.%d, URL: %s\n", fw.valid, fw.version.major, fw.version.minor, fw.version.patch, fw.url.c_str());
|
||||
Log.verbose("Error message: %s", fw.error.c_str());
|
||||
ota.run_ota_update(fw.url, update_started, update_finished, update_progress, update_error);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user