Skip to content

Commit f3e2e7d

Browse files
nordicjmkartben
authored andcommitted
mgmt: mcumgr: grp: img_mgmt: Add image number to confirmed callback
Adds the image number to the confirmed callback Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
1 parent 8f647ef commit f3e2e7d

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

include/zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt_callbacks.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ struct img_mgmt_upload_check {
4141
struct img_mgmt_upload_req *req;
4242
};
4343

44+
/**
45+
* Structure provided in the #MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED notification callback: This
46+
* callback function is used to notify the application about an image confirmation being executed
47+
* successfully.
48+
*/
49+
struct img_mgmt_image_confirmed {
50+
/** Image number which has been confirmed */
51+
const uint8_t image;
52+
};
53+
4454
/**
4555
* Structure provided in the #MGMT_EVT_OP_IMG_MGMT_IMAGE_SLOT_STATE notification callback: This
4656
* callback function is used to allow applications or modules append custom fields to the image

include/zephyr/mgmt/mcumgr/mgmt/callbacks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ enum img_mgmt_group_events {
179179
/** Callback when a DFU operation has finished being transferred. */
180180
MGMT_EVT_OP_IMG_MGMT_DFU_PENDING = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_IMG, 3),
181181

182-
/** Callback when an image has been confirmed. */
182+
/** Callback when an image has been confirmed. data is img_mgmt_image_confirmed(). */
183183
MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_IMG, 4),
184184

185185
/** Callback when an image write command has finished writing to flash. */

subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,12 @@ img_mgmt_state_confirm(void)
400400
if (!rc) {
401401
int32_t err_rc;
402402
uint16_t err_group;
403+
struct img_mgmt_image_confirmed confirmed_data = {
404+
.image = 0
405+
};
403406

404-
(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, NULL, 0, &err_rc,
405-
&err_group);
407+
(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, &confirmed_data,
408+
sizeof(confirmed_data), &err_rc, &err_group);
406409
}
407410
#endif
408411

@@ -574,12 +577,15 @@ static int img_mgmt_set_next_boot_slot_common(int slot, int active_slot, bool co
574577

575578
#if defined(CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS)
576579
if (rc == 0 && slot == active_slot && confirm) {
580+
/* Confirm event is only sent for active slot */
577581
int32_t err_rc;
578582
uint16_t err_group;
583+
struct img_mgmt_image_confirmed confirmed_data = {
584+
.image = img_mgmt_slot_to_image(slot)
585+
};
579586

580-
/* Confirm event is only sent for active slot */
581-
(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, NULL, 0, &err_rc,
582-
&err_group);
587+
(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, &confirmed_data,
588+
sizeof(confirmed_data), &err_rc, &err_group);
583589
}
584590
#endif
585591

0 commit comments

Comments
 (0)