Fixed stuff
All checks were successful
Test compiling project / test (push) Successful in 2m17s

This commit is contained in:
2025-02-15 18:05:25 +01:00
parent 97cd402aa4
commit 7c4dd280c2
3 changed files with 8 additions and 4 deletions

View File

@@ -26,6 +26,7 @@ Firmware OTA::getLatestVersionOnServer() {
} }
String payload = http.getString(); String payload = http.getString();
Log.verbose("Payload: %s", payload.c_str());
DynamicJsonDocument doc(4096); DynamicJsonDocument doc(4096);
DeserializationError error = deserializeJson(doc, payload); DeserializationError error = deserializeJson(doc, payload);
@@ -39,8 +40,8 @@ Firmware OTA::getLatestVersionOnServer() {
std::vector<Configuration> configs; std::vector<Configuration> configs;
for (JsonObject config : doc["Configurations"].as<JsonArray>()) { for (JsonObject config : doc["Configurations"].as<JsonArray>()) {
if (config.containsKey("Version") && config.containsKey("URL") && config.containsKey("Configuration")) { if (config.containsKey("Version") && config.containsKey("URL") && config.containsKey("Config")) {
String deviceConfig = config["Configuration"].as<String>(); String deviceConfig = config["Config"].as<String>();
if (deviceConfig == _current_device_configuration) { if (deviceConfig == _current_device_configuration) {
configs.push_back(Configuration{ configs.push_back(Configuration{
parseVersion(config["Version"]), parseVersion(config["Version"]),
@@ -48,6 +49,8 @@ Firmware OTA::getLatestVersionOnServer() {
config["Board"], config["Board"],
deviceConfig 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; WiFiClient client;
ret = httpUpdate.update(client, url); ret = httpUpdate.update(client, url);
} else { } else {
Log.error("URL is not valid"); Log.error("URL is not valid: \n%s", url.c_str());
} }

View File

@@ -7,6 +7,6 @@
#define water_level_min_key "water_level_min" #define water_level_min_key "water_level_min"
#define water_level_max_key "water_level_max" #define water_level_max_key "water_level_max"
#define water_volume_key "water_volume" #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 #define RESISTOR_VALUE 4

View File

@@ -59,6 +59,7 @@ void update_error(int err) {
Firmware fw = ota.getLatestVersionOnServer(); Firmware fw = ota.getLatestVersionOnServer();
Log.verbose("we are done"); 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()); 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); ota.run_ota_update(fw.url, update_started, update_finished, update_progress, update_error);
vTaskDelete(NULL); vTaskDelete(NULL);
} }