Skip to content

Commit

Permalink
fw_update: when reporting IDLE during retry, use await retry reason
Browse files Browse the repository at this point in the history
Use the new GOLIOTH_OTA_REASON_AWAIT_RETRY reason when reporting IDLE state
during retry backoff period.

Signed-off-by: Mike Szczys <[email protected]>
  • Loading branch information
szczys committed Dec 10, 2024
1 parent 53d36c6 commit 051546f
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/fw_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,6 @@ static void fw_update_thread(void *arg)

while (1)
{
GLTH_LOGI(TAG, "State = Idle");
golioth_fw_update_report_state_sync(&_component_ctx,
GOLIOTH_OTA_STATE_IDLE,
GOLIOTH_OTA_REASON_READY,
true,
true,
true);

GLTH_LOGI(TAG, "Waiting to receive OTA manifest");

while (1)
Expand All @@ -386,6 +378,27 @@ static void fw_update_thread(void *arg)
? GOLIOTH_SYS_WAIT_FOREVER
: backoff_ms_before_expiration(&_component_ctx);

GLTH_LOGI(TAG, "State = Idle");

if (manifest_timeout == GOLIOTH_SYS_WAIT_FOREVER)
{
golioth_fw_update_report_state_sync(&_component_ctx,
GOLIOTH_OTA_STATE_IDLE,
GOLIOTH_OTA_REASON_READY,
true,
true,
false);
}
else
{
golioth_fw_update_report_state_sync(&_component_ctx,
GOLIOTH_OTA_STATE_IDLE,
GOLIOTH_OTA_REASON_AWAIT_RETRY,
true,
true,
true);
}

if (!golioth_sys_sem_take(_manifest_rcvd, manifest_timeout))
{
GLTH_LOGI(TAG,
Expand Down

0 comments on commit 051546f

Please sign in to comment.