Fixed OTA Ethernet bug
All checks were successful
Test compiling project / test (push) Successful in 2m28s
All checks were successful
Test compiling project / test (push) Successful in 2m28s
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#define water_level_min_key "water_level_min"
|
||||
#define water_level_max_key "water_level_max"
|
||||
#define water_volume_key "water_volume"
|
||||
#define current_software_version Version{0, 0, 17}
|
||||
#define current_software_version Version{0, 0, 18}
|
||||
#define REQUIRED_SPIFFS_VERSION Version{5, 0, 0}
|
||||
|
||||
#define RESISTOR_VALUE 4
|
||||
25
src/main.cpp
25
src/main.cpp
@@ -26,6 +26,7 @@
|
||||
#include <fetchOTA.h>
|
||||
#include <ESP32Ping.h>
|
||||
|
||||
|
||||
Preferences prefs;
|
||||
|
||||
extern WaterData water_data;
|
||||
@@ -209,9 +210,22 @@ void setup()
|
||||
digitalWrite(LED_RED, 0);
|
||||
|
||||
xTaskCreate(ethernet_task, "EthernetTask", 4096, NULL, 1, NULL);
|
||||
delay(1000);
|
||||
bool started = false;
|
||||
if (ETH.linkUp()){
|
||||
xTaskCreate(check_update_task, "CheckUpdateTask", 1024 * 8, NULL, 1, NULL);
|
||||
started = true;
|
||||
}
|
||||
xTaskCreate(wifi_task, "WiFiTask", 10000, NULL, 1, NULL);
|
||||
|
||||
delay(250);
|
||||
delay(2000);
|
||||
|
||||
if (!started) {
|
||||
xTaskCreate(check_update_task, "CheckUpdateTask", 1024 * 8, NULL, 1, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Log.verbose("Starting webserver");
|
||||
server.begin();
|
||||
@@ -235,15 +249,14 @@ void setup()
|
||||
} else {
|
||||
Log.verbose("No WiFi or Ethernet connection, retrying...");
|
||||
}
|
||||
delay(200); // Delay to prevent rapid retry
|
||||
delay(1000); // Delay to prevent rapid retry
|
||||
}
|
||||
xTaskCreate(check_update_task, "CheckUpdateTask", 1024 * 8, NULL, 1, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
ArduinoOTA.handle();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -81,6 +81,7 @@ void check_update_task(void* parameter) {
|
||||
OTA ota("https://iot.tobiasmaier.me/firmware/waterlevel", current_software_version, "INA233");
|
||||
#endif
|
||||
OTA spiffs_fs("https://iot.tobiasmaier.me/filesystem/waterlevel", REQUIRED_SPIFFS_VERSION, "generic");
|
||||
|
||||
|
||||
// Init SPIFFS update and check for update
|
||||
// If there is a SPIFSS update it will be ran automatically, as SPIFFS is necessary for the firmware to run
|
||||
@@ -139,11 +140,12 @@ void run_ota_update_task(void* parameter) {
|
||||
|
||||
void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type,
|
||||
void *arg, uint8_t *data, size_t len) {
|
||||
if (type == WS_EVT_CONNECT) {
|
||||
Serial.println("WebSocket client connected");
|
||||
} else if (type == WS_EVT_DISCONNECT) {
|
||||
Serial.println("WebSocket client disconnected");
|
||||
} else if (type == WS_EVT_DATA) {
|
||||
// Optionally process data received from the client
|
||||
}
|
||||
if (type == WS_EVT_CONNECT) {
|
||||
Serial.println("WebSocket client connected");
|
||||
} else if (type == WS_EVT_DISCONNECT) {
|
||||
Serial.println("WebSocket client disconnected");
|
||||
} else if (type == WS_EVT_DATA) {
|
||||
// Optionally process data received from the client
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user