Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/framework/DownloadFirmwareService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
extern const uint8_t rootca_crt_bundle_start[] asm("_binary_src_certs_x509_crt_bundle_bin_start");
extern const uint8_t rootca_crt_bundle_end[] asm("_binary_src_certs_x509_crt_bundle_bin_end");

static EventSocket *_socket = nullptr;
static EventSocket *_socket2 = nullptr;
static int previousProgress = 0;
JsonDocument doc;

Expand All @@ -25,7 +25,7 @@ void update_started()
String output;
doc["status"] = "preparing";
JsonObject jsonObject = doc.as<JsonObject>();
_socket->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);
_socket2->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);
}

void update_progress(int currentBytes, int totalBytes)
Expand All @@ -36,7 +36,7 @@ void update_progress(int currentBytes, int totalBytes)
{
doc["progress"] = progress;
JsonObject jsonObject = doc.as<JsonObject>();
_socket->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);
_socket2->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);
ESP_LOGV(SVK_TAG, "HTTP update process at %d of %d bytes... (%d %%)", currentBytes, totalBytes, progress);
}
previousProgress = progress;
Expand All @@ -46,7 +46,7 @@ void update_finished()
{
doc["status"] = "finished";
JsonObject jsonObject = doc.as<JsonObject>();
_socket->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);
_socket2->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);

// delay to allow the event to be sent out
vTaskDelay(100 / portTICK_PERIOD_MS);
Expand Down Expand Up @@ -83,7 +83,7 @@ void updateTask(void *param)
doc["status"] = "error";
doc["error"] = httpUpdate.getLastErrorString().c_str();
jsonObject = doc.as<JsonObject>();
_socket->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);
_socket2->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);

ESP_LOGE(SVK_TAG, "HTTP Update failed with error (%d): %s", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
#ifdef SERIAL_INFO
Expand All @@ -95,7 +95,7 @@ void updateTask(void *param)
doc["status"] = "error";
doc["error"] = "Update failed, has same firmware version";
jsonObject = doc.as<JsonObject>();
_socket->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);
_socket2->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);

ESP_LOGE(SVK_TAG, "HTTP Update failed, has same firmware version");
#ifdef SERIAL_INFO
Expand Down Expand Up @@ -154,6 +154,8 @@ esp_err_t DownloadFirmwareService::downloadUpdate(PsychicRequest *request, JsonV
JsonObject jsonObject = doc.as<JsonObject>();
_socket->emitEvent(EVENT_DOWNLOAD_OTA, jsonObject);

_socket2 = _socket;

if (xTaskCreatePinnedToCore(
&updateTask, // Function that should be called
"Update", // Name of the task (for debugging)
Expand Down