fix ota upload
All checks were successful
Compilie project and upload binaries / test (push) Successful in 3m59s

This commit is contained in:
2025-11-05 22:08:42 +01:00
parent 53920dbb77
commit 3dc339c449
8 changed files with 84 additions and 31 deletions

View File

@@ -90,6 +90,7 @@ Firmware OTA::createErrorResponse(const String& errorMsg) {
void run_ota_update(String url, std::function<void()> callback_started, std::function<void()> callback_finished, std::function<void(int, int)> callback_progress, std::function<void(int)> callback_error) {
Logger.log(0, ELOG_LEVEL_DEBUG, "Starting OTA upgrade");
Logger.log(0, ELOG_LEVEL_DEBUG, "URL: %s", url);
HTTPUpdate httpUpdate;
httpUpdate.onStart(callback_started);
httpUpdate.onEnd(callback_finished);
@@ -101,13 +102,14 @@ void run_ota_update(String url, std::function<void()> callback_started, std::fu
if (url.startsWith("https")) {
Logger.log(0, ELOG_LEVEL_DEBUG, "HTTPS URL");
WiFiClient client;
// client.setInsecure();
ret = httpUpdate.update(client, url);
HTTPClient http_client;
http_client.begin(url);
ret = httpUpdate.update(http_client, url);
} else if (url.startsWith("http")) {
Logger.log(0, ELOG_LEVEL_DEBUG, "HTTP URL");
WiFiClient client;
ret = httpUpdate.update(client, url);
HTTPClient http_client;
http_client.begin(url);
ret = httpUpdate.update(http_client, url);
} else {
Logger.log(0, ELOG_LEVEL_ERROR, "URL is not valid: \n%s", url.c_str());
}
@@ -140,13 +142,15 @@ void run_ota_spiffs_update(String url, std::function<void()> callback_started,
if (url.startsWith("https")) {
Logger.log(0, ELOG_LEVEL_DEBUG, "HTTPS URL");
WiFiClient client;
HTTPClient http_client;
http_client.begin(url);
// client.setInsecure();
ret = httpUpdate.updateSpiffs(client, url);
ret = httpUpdate.updateSpiffs(http_client, url);
} else if (url.startsWith("http")) {
Logger.log(0, ELOG_LEVEL_DEBUG, "HTTP URL");
WiFiClient client;
ret = httpUpdate.updateSpiffs(client, url);
HTTPClient http_client;
http_client.begin(url);
ret = httpUpdate.updateSpiffs(http_client, url);
} else {
Logger.log(0, ELOG_LEVEL_ERROR, "URL is not valid: \n%s", url.c_str());
}