Skip to content

Commit

Permalink
fix(OTA): close HTTP connection before sending update status
Browse files Browse the repository at this point in the history
  • Loading branch information
becem-gharbi committed Jun 22, 2024
1 parent 757eeac commit 00a56ed
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions src/OTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ namespace ESPAdmin

if (err == ESP_OK)
{
Store::updateRunning = false;
_aborted = false;
Update::onChange(UPDATE_FAILED);
break;
Store::updateRunning = false;
continue;
}
}

Expand All @@ -89,33 +90,16 @@ namespace ESPAdmin

if (err == ESP_OK)
{
Store::updateRunning = false;

bool success = esp_https_ota_is_complete_data_received(_otaHandle);

if (success)
{
Update::onChange(UPDATE_SUCCEDED);
}
else
{
Update::onChange(UPDATE_FAILED);
}
esp_err_t err = esp_https_ota_finish(_otaHandle);
Update::onChange(err == ESP_OK ? UPDATE_SUCCEDED : UPDATE_FAILED);
}
else
{
Store::updateRunning = false;
esp_https_ota_finish(_otaHandle);
Update::onChange(UPDATE_FAILED);
}
}

if (_aborted == false)
{
esp_https_ota_finish(_otaHandle);
}
else
{
_aborted = false;
Store::updateRunning = false;
}

vTaskDelete(nullptr);
Expand Down

0 comments on commit 00a56ed

Please sign in to comment.