Skip to content

Commit f50604d

Browse files
moduels: fota: fix state machine
Rename STATE_CANCELED to STATE_CANCELING. Add transition on FOTA_SUCCESS_REBOOT_NEEDED. Signed-off-by: Giacomo Dematteis <giacomo.dematteis@nordicsemi.no>
1 parent 19e5838 commit f50604d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/src/modules/fota/fota.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ enum fota_module_state {
6464
STATE_WAITING_FOR_IMAGE_APPLY,
6565
/* The FOTA module is waiting for a reboot */
6666
STATE_REBOOT_NEEDED,
67-
/* The FOTA module has been canceled, cleaning up */
68-
STATE_CANCELED,
67+
/* The FOTA module is canceling the job */
68+
STATE_CANCELING,
6969
};
7070

7171
/* User defined state object.
@@ -148,7 +148,7 @@ static const struct smf_state states[] = {
148148
NULL,
149149
&states[STATE_RUNNING],
150150
NULL),
151-
[STATE_CANCELED] =
151+
[STATE_CANCELING] =
152152
SMF_CREATE_STATE(state_canceling_entry,
153153
state_canceling_run,
154154
NULL,
@@ -266,7 +266,7 @@ static void state_running_run(void *o)
266266
const enum fota_msg_type msg_type = MSG_TO_FOTA_TYPE(state_object->msg_buf);
267267

268268
if (msg_type == FOTA_DOWNLOAD_CANCEL) {
269-
STATE_SET(fota_state, STATE_CANCELED);
269+
STATE_SET(fota_state, STATE_CANCELING);
270270
}
271271
}
272272
}
@@ -373,6 +373,9 @@ static void state_downloading_update_run(void *o)
373373
case FOTA_IMAGE_APPLY_NEEDED:
374374
STATE_SET(fota_state, STATE_WAITING_FOR_IMAGE_APPLY);
375375
break;
376+
case FOTA_SUCCESS_REBOOT_NEEDED:
377+
STATE_SET(fota_state, STATE_REBOOT_NEEDED);
378+
break;
376379
case FOTA_DOWNLOAD_CANCELED:
377380
__fallthrough;
378381
case FOTA_DOWNLOAD_TIMED_OUT:

0 commit comments

Comments
 (0)