1 /* 2 * Copyright (c) 2022 Laird Connectivity 3 * Copyright (c) 2022 Nordic Semiconductor ASA 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #ifndef H_MCUMGR_IMG_MGMT_CALLBACKS_ 9 #define H_MCUMGR_IMG_MGMT_CALLBACKS_ 10 11 #include <stdbool.h> 12 #include <stdint.h> 13 #include <zcbor_common.h> 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 /* Dummy definitions, include zephyr/mgmt/mcumgr/grp/img_mgmt/img_mgmt.h for actual definitions */ 20 struct img_mgmt_upload_action; 21 struct img_mgmt_upload_req; 22 23 /** 24 * @brief MCUmgr img_mgmt callback API 25 * @defgroup mcumgr_callback_api_img_mgmt MCUmgr img_mgmt callback API 26 * @ingroup mcumgr_callback_api 27 * @{ 28 */ 29 30 /** 31 * Structure provided in the #MGMT_EVT_OP_IMG_MGMT_DFU_CHUNK notification callback: This callback 32 * function is used to notify the application about a pending firmware upload packet from a client 33 * and authorise or deny it. Upload will be allowed so long as all notification handlers return 34 * #MGMT_ERR_EOK, if one returns an error then the upload will be denied. 35 */ 36 struct img_mgmt_upload_check { 37 /** Action to take */ 38 struct img_mgmt_upload_action *action; 39 40 /** Upload request information */ 41 struct img_mgmt_upload_req *req; 42 }; 43 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 54 /** 55 * Structure provided in the #MGMT_EVT_OP_IMG_MGMT_IMAGE_SLOT_STATE notification callback: This 56 * callback function is used to allow applications or modules append custom fields to the image 57 * slot state response. 58 */ 59 struct img_mgmt_state_slot_encode { 60 bool *ok; 61 zcbor_state_t *zse; 62 const uint32_t slot; 63 const char *version; 64 const uint8_t *hash; 65 const int flags; 66 }; 67 68 /** 69 * Structure provided in the #MGMT_EVT_OP_IMG_MGMT_SLOT_INFO_IMAGE notification callback: This 70 * callback function is called once per image when the slot info command is used, it can be used 71 * to return additional information/fields in the response. 72 */ 73 struct img_mgmt_slot_info_image { 74 /** The image that is currently being enumerated. */ 75 const uint8_t image; 76 77 /** 78 * The zcbor encoder which is currently being used to output information, additional fields 79 * can be added using this. 80 */ 81 zcbor_state_t *zse; 82 }; 83 84 /** 85 * Structure provided in the #MGMT_EVT_OP_IMG_MGMT_SLOT_INFO_SLOT notification callback: This 86 * callback function is called once per slot per image when the slot info command is used, it can 87 * be used to return additional information/fields in the response. 88 */ 89 struct img_mgmt_slot_info_slot { 90 /** The image that is currently being enumerated. */ 91 const uint8_t image; 92 93 /** The slot that is currently being enumerated. */ 94 const uint8_t slot; 95 96 /** Flash area of the slot that is current being enumerated. */ 97 const struct flash_area *fa; 98 99 /** 100 * The zcbor encoder which is currently being used to output information, additional fields 101 * can be added using this. 102 */ 103 zcbor_state_t *zse; 104 }; 105 106 /** 107 * @} 108 */ 109 110 #ifdef __cplusplus 111 } 112 #endif 113 114 #endif 115