A ton of things
Some checks failed
Test compiling project / test (push) Failing after 1m38s

This commit is contained in:
2025-02-14 21:27:04 +01:00
parent 04b2aba6ca
commit 5738eb4451
9 changed files with 333 additions and 41 deletions

View File

@@ -12,9 +12,6 @@
#include <ArduinoOTA.h>
#include "INA226.h"
#include "INA233.h"
#include "global_data/defines.h"
#include "networking/networking.h"
@@ -26,6 +23,7 @@
#include <Preferences.h>
#include "networking/json_builder.h"
#include "networking/responses.h"
#include <fetchOTA.h>
Preferences prefs;
@@ -57,33 +55,38 @@ void update_started() {
}
void run_ota(void* parameter) {
Serial.println("RUNNING OTA");
// WiFiClient client;
httpUpdate.onStart(update_started);
httpUpdate.onEnd(update_finished);
httpUpdate.onProgress(update_progress);
httpUpdate.onError(update_error);
Serial.println("RUNNING OTA");
OTA ota("https://iot.tobiasmaier.me/firmware/waterlevel", "1.1.1", "INA233");
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());
// Serial.println("RUNNING OTA");
// // WiFiClient client;
// httpUpdate.onStart(update_started);
// httpUpdate.onEnd(update_finished);
// httpUpdate.onProgress(update_progress);
// httpUpdate.onError(update_error);
// Serial.println("RUNNING OTA");
WiFiClientSecure client;
client.setInsecure();
// WiFiClientSecure client;
// client.setInsecure();
t_httpUpdate_return ret = httpUpdate.update(client, "https://iot.tobiasmaier.me/firmware/waterlevel/INA233/1_1_1.bin");
// t_httpUpdate_return ret = httpUpdate.update(client, "https://iot.tobiasmaier.me", 443, "/firmware/waterlevel/INA233/1_0_1.bin");
// t_httpUpdate_return ret = httpUpdate.update(client, "https://iot.tobiasmaier.me/firmware/waterlevel/INA233/1_1_1.bin");
// // t_httpUpdate_return ret = httpUpdate.update(client, "https://iot.tobiasmaier.me", 443, "/firmware/waterlevel/INA233/1_0_1.bin");
switch (ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;
// switch (ret) {
// case HTTP_UPDATE_FAILED:
// Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
// break;
case HTTP_UPDATE_NO_UPDATES:
Serial.println("HTTP_UPDATE_NO_UPDATES");
break;
// case HTTP_UPDATE_NO_UPDATES:
// Serial.println("HTTP_UPDATE_NO_UPDATES");
// break;
case HTTP_UPDATE_OK:
Serial.println("HTTP_UPDATE_OK");
break;
}
// case HTTP_UPDATE_OK:
// Serial.println("HTTP_UPDATE_OK");
// break;
// }
vTaskDelete(NULL);
}
void setup()
@@ -199,8 +202,7 @@ void setup()
server.on("/ota", HTTP_GET, [](AsyncWebServerRequest* request) {
Serial.println("OTA Task start");
xTaskCreate(run_ota, "RunOTATask", 1024 * 8, NULL, 1, NULL);
xTaskCreate(run_ota, "OTATask", 1024 * 8, NULL, 1, NULL);
request->send(200, "text/plain", "OTA done");
});