Skip to content

Commit c625b55

Browse files
committed
disable OTA status updates
1 parent a06dbd9 commit c625b55

File tree

10 files changed

+27
-21
lines changed

10 files changed

+27
-21
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [0.3.1] - Work in Progress
5+
## [0.4.0] - Work in Progress
66

77
This minor upgrade might require one minor change as `MqttPubSub.h` and its class had been renamed to `MqttEndpoint.h`. However, it is strongly advised, that you change all existing WebSocketServer endpoints to the new event socket system.
88

@@ -40,6 +40,7 @@ The new Event Socket system is likely to change with coming updates.
4040
- Duplicate method in FeatureService [#18](https://github.com/theelims/ESP32-sveltekit/pull/18)
4141
- Duplicate lines in Systems Settings view.
4242
- Removes duplicate begin [#36](https://github.com/theelims/ESP32-sveltekit/pull/36)
43+
- Temporary disabled OTA progress update due to crash with PsychicHttp [#32](https://github.com/theelims/ESP32-sveltekit/issues/32) until a fix is found.
4344

4445
## [0.3.0] - 2023-02-05
4546

interface/src/routes/+layout.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
socket.on('errorToast', handleErrorToast);
4545
if ($page.data.features.analytics) socket.on('analytics', handleAnalytics);
4646
if ($page.data.features.battery) socket.on('battery', handleBattery);
47-
if ($page.data.features.download_firmware) socket.on('download_ota', handleOAT);
47+
if ($page.data.features.download_firmware) socket.on('otastatus', handleOAT);
4848
};
4949
5050
const removeEventListeners = () => {
@@ -57,7 +57,7 @@
5757
socket.off('warningToast', handleWarningToast);
5858
socket.off('errorToast', handleErrorToast);
5959
socket.off('battery', handleBattery);
60-
socket.off('download_ota', handleOAT);
60+
socket.off('otastatus', handleOAT);
6161
};
6262
6363
async function validateUser(userdata: userProfile) {

lib/framework/AnalyticsService.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <EventSocket.h>
2020

2121
#define MAX_ESP_ANALYTICS_SIZE 1024
22+
#define EVENT_ANALYTICS "analytics"
2223
#define ANALYTICS_INTERVAL 2000
2324

2425
class AnalyticsService
@@ -28,7 +29,7 @@ class AnalyticsService
2829

2930
void begin()
3031
{
31-
_socket->registerEvent("analytics");
32+
_socket->registerEvent(EVENT_ANALYTICS);
3233

3334
xTaskCreatePinnedToCore(
3435
this->_loopImpl, // Function that should be called
@@ -63,7 +64,7 @@ class AnalyticsService
6364
doc["core_temp"] = temperatureRead();
6465

6566
serializeJson(doc, message);
66-
_socket->emit("analytics", message);
67+
_socket->emit(EVENT_ANALYTICS, message);
6768

6869
vTaskDelayUntil(&xLastWakeTime, ANALYTICS_INTERVAL / portTICK_PERIOD_MS);
6970
}

lib/framework/BatteryService.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ BatteryService::BatteryService(EventSocket *socket) : _socket(socket)
1919

2020
void BatteryService::begin()
2121
{
22-
_socket->registerEvent("battery");
22+
_socket->registerEvent(EVENT_BATTERY);
2323
}
2424

2525
void BatteryService::batteryEvent()
@@ -29,5 +29,5 @@ void BatteryService::batteryEvent()
2929
doc["soc"] = _lastSOC;
3030
doc["charging"] = _isCharging;
3131
serializeJson(doc, message);
32-
_socket->emit("battery", message);
32+
_socket->emit(EVENT_BATTERY, message);
3333
}

lib/framework/BatteryService.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <EventSocket.h>
1717
#include <JsonUtils.h>
1818

19+
#define EVENT_BATTERY "battery"
20+
1921
class BatteryService
2022
{
2123
public:

lib/framework/DownloadFirmwareService.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void update_started()
2424
String output;
2525
doc["status"] = "preparing";
2626
serializeJson(doc, output);
27-
_socket->emit("download_ota", output.c_str());
27+
_socket->emit(EVENT_DOWNLOAD_OTA, output.c_str());
2828
}
2929

3030
void update_progress(int currentBytes, int totalBytes)
@@ -35,7 +35,7 @@ void update_progress(int currentBytes, int totalBytes)
3535
if (progress > previousProgress)
3636
{
3737
doc["progress"] = progress;
38-
_socket->emit("download_ota", output.c_str());
38+
_socket->emit(EVENT_DOWNLOAD_OTA, output.c_str());
3939
ESP_LOGV("Download OTA", "HTTP update process at %d of %d bytes... (%d %%)", currentBytes, totalBytes, progress);
4040
}
4141
previousProgress = progress;
@@ -46,7 +46,7 @@ void update_finished()
4646
String output;
4747
doc["status"] = "finished";
4848
serializeJson(doc, output);
49-
_socket->emit("download_ota", output.c_str());
49+
_socket->emit(EVENT_DOWNLOAD_OTA, output.c_str());
5050

5151
// delay to allow the event to be sent out
5252
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -63,9 +63,9 @@ void updateTask(void *param)
6363

6464
String url = *((String *)param);
6565
String output;
66-
httpUpdate.onStart(update_started);
67-
httpUpdate.onProgress(update_progress);
68-
httpUpdate.onEnd(update_finished);
66+
// httpUpdate.onStart(update_started);
67+
// httpUpdate.onProgress(update_progress);
68+
// httpUpdate.onEnd(update_finished);
6969

7070
t_httpUpdate_return ret = httpUpdate.update(client, url.c_str());
7171

@@ -76,7 +76,7 @@ void updateTask(void *param)
7676
doc["status"] = "error";
7777
doc["error"] = httpUpdate.getLastErrorString().c_str();
7878
serializeJson(doc, output);
79-
_socket->emit("download_ota", output.c_str());
79+
_socket->emit(EVENT_DOWNLOAD_OTA, output.c_str());
8080

8181
ESP_LOGE("Download OTA", "HTTP Update failed with error (%d): %s", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
8282
#ifdef SERIAL_INFO
@@ -88,7 +88,7 @@ void updateTask(void *param)
8888
doc["status"] = "error";
8989
doc["error"] = "Update failed, has same firmware version";
9090
serializeJson(doc, output);
91-
_socket->emit("download_ota", output.c_str());
91+
_socket->emit(EVENT_DOWNLOAD_OTA, output.c_str());
9292

9393
ESP_LOGE("Download OTA", "HTTP Update failed, has same firmware version");
9494
#ifdef SERIAL_INFO
@@ -115,7 +115,7 @@ DownloadFirmwareService::DownloadFirmwareService(PsychicHttpServer *server,
115115

116116
void DownloadFirmwareService::begin()
117117
{
118-
_socket->registerEvent("download_ota");
118+
_socket->registerEvent(EVENT_DOWNLOAD_OTA);
119119

120120
_server->on(GITHUB_FIRMWARE_PATH,
121121
HTTP_POST,
@@ -146,7 +146,7 @@ esp_err_t DownloadFirmwareService::downloadUpdate(PsychicRequest *request, JsonV
146146
String output;
147147
serializeJson(doc, output);
148148

149-
_socket->emit("download_ota", output.c_str());
149+
_socket->emit(EVENT_DOWNLOAD_OTA, output.c_str());
150150

151151
if (xTaskCreatePinnedToCore(
152152
&updateTask, // Function that should be called

lib/framework/DownloadFirmwareService.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
// #include <SSLCertBundle.h>
2828

2929
#define GITHUB_FIRMWARE_PATH "/rest/downloadUpdate"
30+
#define EVENT_DOWNLOAD_OTA "otastatus"
3031
#define OTA_TASK_STACK_SIZE 9216
3132

3233
class DownloadFirmwareService

lib/framework/WiFiSettingsService.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void WiFiSettingsService::initWiFi()
4949

5050
void WiFiSettingsService::begin()
5151
{
52-
_socket->registerEvent("rssi");
52+
_socket->registerEvent(EVENT_RSSI);
5353

5454
_httpEndpoint.begin();
5555
}
@@ -216,7 +216,7 @@ void WiFiSettingsService::updateRSSI()
216216
{
217217
char buffer[16];
218218
snprintf(buffer, sizeof(buffer), WiFi.isConnected() ? "%d" : "disconnected", WiFi.RSSI());
219-
_socket->emit("rssi", buffer);
219+
_socket->emit(EVENT_RSSI, buffer);
220220
}
221221

222222
void WiFiSettingsService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info)

lib/framework/WiFiSettingsService.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151

5252
#define WIFI_SETTINGS_BUFFER_SIZE 2048
5353

54+
#define EVENT_RSSI "rssi"
55+
5456
// Struct defining the wifi settings
5557
typedef struct
5658
{

platformio.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ build_flags =
2424
${features.build_flags}
2525
-D BUILD_TARGET=\"$PIOENV\"
2626
-D APP_NAME=\"ESP32-Sveltekit\" ; Must only contain characters from [a-zA-Z0-9-_] as this is converted into a filename
27-
-D APP_VERSION=\"0.3.1\" ; semver compatible version string
27+
-D APP_VERSION=\"0.4.0\" ; semver compatible version string
2828
; Uncomment to receive log messages from the ESP Arduino Core
2929
-D CORE_DEBUG_LEVEL=4
3030
; Move all networking stuff to the protocol core 0 and leave business logic on application core 1
@@ -95,4 +95,3 @@ build_flags =
9595
${env.build_flags}
9696
-D LED_BUILTIN=2
9797
-D KEY_BUILTIN=0
98-

0 commit comments

Comments
 (0)