Commit f3e2e7dc authored by Jamie McCrae's avatar Jamie McCrae Committed by Benjamin Cabé
Browse files

mgmt: mcumgr: grp: img_mgmt: Add image number to confirmed callback



Adds the image number to the confirmed callback

Signed-off-by: default avatarJamie McCrae <jamie.mccrae@nordicsemi.no>
parent 8f647ef4
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -41,6 +41,16 @@ struct img_mgmt_upload_check {
	struct img_mgmt_upload_req *req;
};

/**
 * Structure provided in the #MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED notification callback: This
 * callback function is used to notify the application about an image confirmation being executed
 * successfully.
 */
struct img_mgmt_image_confirmed {
	/** Image number which has been confirmed */
	const uint8_t image;
};

/**
 * Structure provided in the #MGMT_EVT_OP_IMG_MGMT_IMAGE_SLOT_STATE notification callback: This
 * callback function is used to allow applications or modules append custom fields to the image
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ enum img_mgmt_group_events {
	/** Callback when a DFU operation has finished being transferred. */
	MGMT_EVT_OP_IMG_MGMT_DFU_PENDING		= MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_IMG, 3),

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

	/** Callback when an image write command has finished writing to flash. */
+11 −5
Original line number Diff line number Diff line
@@ -400,9 +400,12 @@ img_mgmt_state_confirm(void)
	if (!rc) {
		int32_t err_rc;
		uint16_t err_group;
		struct img_mgmt_image_confirmed confirmed_data = {
			.image = 0
		};

		(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, NULL, 0, &err_rc,
					   &err_group);
		(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, &confirmed_data,
					   sizeof(confirmed_data), &err_rc, &err_group);
	}
#endif

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

#if defined(CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS)
	if (rc == 0 && slot == active_slot && confirm) {
		/* Confirm event is only sent for active slot */
		int32_t err_rc;
		uint16_t err_group;
		struct img_mgmt_image_confirmed confirmed_data = {
			.image = img_mgmt_slot_to_image(slot)
		};

		/* Confirm event is only sent for active slot */
		(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, NULL, 0, &err_rc,
					   &err_group);
		(void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, &confirmed_data,
					   sizeof(confirmed_data), &err_rc, &err_group);
	}
#endif