Cleanup + Bugfix
All checks were successful
Test project compilation / test (push) Successful in 3m43s
All checks were successful
Test project compilation / test (push) Successful in 3m43s
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
#include <vector>
|
||||
#include <Elog.h>
|
||||
#include <HTTPUpdate.h>
|
||||
@@ -97,11 +98,11 @@ void run_ota_update(String url, std::function<void()> callback_started, std::fu
|
||||
httpUpdate.onError(callback_error);
|
||||
Logger.log(0, ELOG_LEVEL_DEBUG, "Defined callbacks, Starting update now");
|
||||
|
||||
t_httpUpdate_return ret;
|
||||
t_httpUpdate_return ret = HTTP_UPDATE_FAILED;
|
||||
|
||||
if (url.startsWith("https")) {
|
||||
Logger.log(0, ELOG_LEVEL_DEBUG, "HTTPS URL");
|
||||
WiFiClient client;
|
||||
WiFiClientSecure client;
|
||||
// client.setInsecure();
|
||||
ret = httpUpdate.update(client, url);
|
||||
} else if (url.startsWith("http")) {
|
||||
@@ -110,15 +111,20 @@ void run_ota_update(String url, std::function<void()> callback_started, std::fu
|
||||
ret = httpUpdate.update(client, url);
|
||||
} else {
|
||||
Logger.log(0, ELOG_LEVEL_ERROR, "URL is not valid: \n%s", url.c_str());
|
||||
if (callback_error) callback_error(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (ret) {
|
||||
case HTTP_UPDATE_FAILED:
|
||||
Logger.log(0, ELOG_LEVEL_ERROR, "HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
|
||||
// Don't restart ESP on HTTP errors, just return
|
||||
if (callback_error) callback_error(httpUpdate.getLastError());
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_NO_UPDATES:
|
||||
Logger.log(0, ELOG_LEVEL_ERROR, "HTTP_UPDATE_NO_UPDATES");
|
||||
if (callback_error) callback_error(-2);
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_OK:
|
||||
@@ -136,12 +142,12 @@ void run_ota_spiffs_update(String url, std::function<void()> callback_started,
|
||||
httpUpdate.onError(callback_error);
|
||||
Logger.log(0, ELOG_LEVEL_DEBUG, "Defined callbacks, Starting update now");
|
||||
|
||||
t_httpUpdate_return ret;
|
||||
t_httpUpdate_return ret = HTTP_UPDATE_FAILED;
|
||||
|
||||
if (url.startsWith("https")) {
|
||||
Logger.log(0, ELOG_LEVEL_DEBUG, "HTTPS URL");
|
||||
WiFiClient client;
|
||||
// client.setInsecure();
|
||||
WiFiClientSecure client;
|
||||
client.setInsecure();
|
||||
ret = httpUpdate.updateSpiffs(client, url);
|
||||
} else if (url.startsWith("http")) {
|
||||
Logger.log(0, ELOG_LEVEL_DEBUG, "HTTP URL");
|
||||
@@ -149,15 +155,20 @@ void run_ota_spiffs_update(String url, std::function<void()> callback_started,
|
||||
ret = httpUpdate.updateSpiffs(client, url);
|
||||
} else {
|
||||
Logger.log(0, ELOG_LEVEL_ERROR, "URL is not valid: \n%s", url.c_str());
|
||||
if (callback_error) callback_error(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (ret) {
|
||||
case HTTP_UPDATE_FAILED:
|
||||
Logger.log(0, ELOG_LEVEL_ERROR, "HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
|
||||
// Don't restart ESP on HTTP errors, just return
|
||||
if (callback_error) callback_error(httpUpdate.getLastError());
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_NO_UPDATES:
|
||||
Logger.log(0, ELOG_LEVEL_ERROR, "HTTP_UPDATE_NO_UPDATES");
|
||||
if (callback_error) callback_error(-2);
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_OK:
|
||||
|
||||
Reference in New Issue
Block a user