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");
});

View File

@@ -64,8 +64,8 @@ void wifi_task(void* parameter)
wifi_data.network_name = WiFi.SSID();
wifi_data.ip_address = WiFi.localIP().toString();
Log.verbose("RSSI: %F, IP Address, %p, SSID: %s", float(WiFi.RSSI()), WiFi.localIP(), prefs.getString(ssid_key, "NOSSID"));
Serial.println(WiFi.channel());
// Log.verbose("RSSI: %F, IP Address, %p, SSID: %s", float(WiFi.RSSI()), WiFi.localIP(), prefs.getString(ssid_key, "NOSSID"));
// Serial.println(WiFi.channel());
delay(5000);
} else {
Log.verbose("Connecting to %s using password %s", prefs.getString(ssid_key, ""), prefs.getString(wifi_password_key, ""));
@@ -87,7 +87,7 @@ void ethernet_task(void* parameter)
ethernet_data.link = ETH.linkUp();
ethernet_data.rssi = ETH.linkSpeed();
ethernet_data.ip_address = ETH.localIP().toString();
Log.verbose("Ethernet RSSI: %F, IP Address, %s, LINK: %s", float(ethernet_data.rssi), ethernet_data.ip_address, String(ethernet_data.link));
// Log.verbose("Ethernet RSSI: %F, IP Address, %s, LINK: %s", float(ethernet_data.rssi), ethernet_data.ip_address, String(ethernet_data.link));
delay(60 * 1000);
}
}

View File

@@ -1,14 +1,15 @@
#include "../global_data/defines.h"
#include <INA233.h>
#include <Preferences.h>
#include <ArduinoLog.h>
#include "Wire.h"
#include "../global_data/global_data.h"
#ifdef USE_INA226s
#ifdef USE_INA226
#include "INA226.h"
INA226 ina_sensor(0x40);
#else
#include <INA233.h>
INA233 ina_sensor(0x40);
#endif
@@ -60,8 +61,8 @@ void read_sensor_task(void* parameter)
float min_water_level_mA = 4 + min_water_level_mA_over_zero;
float max_water_level_mA = 4 + max_water_level_mA_over_zero;
Log.verbose("max_water_level_mA: %F", max_water_level_mA);
Log.verbose("min_water_level_mA_over_zero: %F", min_water_level_mA_over_zero);
// Log.verbose("max_water_level_mA: %F", max_water_level_mA);
// Log.verbose("min_water_level_mA_over_zero: %F", min_water_level_mA_over_zero);
// Current over the 0 level of the water
float shunt_current_over_zero = shunt_current - min_water_level_mA;
@@ -81,10 +82,10 @@ void read_sensor_task(void* parameter)
active_errors.current_high = shunt_current > 20.2;
active_errors.voltage_low = bus_voltage < 23;
active_errors.voltage_high = bus_voltage > 25;
Log.verbose("Shunt current: %F", shunt_current);
Log.verbose("Shunt voltage: %F", shunt_voltage);
Log.verbose("Bus voltage: %F", bus_voltage);
Log.verbose("cm_over_zero: %F", cm_over_zero);
// Log.verbose("Shunt current: %F", shunt_current);
// Log.verbose("Shunt voltage: %F", shunt_voltage);
// Log.verbose("Bus voltage: %F", bus_voltage);
// Log.verbose("cm_over_zero: %F", cm_over_zero);
shunt_data.bus_voltage = bus_voltage;
shunt_data.shunt_voltage = shunt_voltage;