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_IMAGE_SLOT_STATE notification callback: This 46 * callback function is used to allow applications or modules append custom fields to the image 47 * slot state response. 48 */ 49 struct img_mgmt_state_slot_encode { 50 bool *ok; 51 zcbor_state_t *zse; 52 const uint32_t slot; 53 const char *version; 54 const uint8_t *hash; 55 const int flags; 56 }; 57 58 /** 59 * Structure provided in the #MGMT_EVT_OP_IMG_MGMT_SLOT_INFO_IMAGE notification callback: This 60 * callback function is called once per image when the slot info command is used, it can be used 61 * to return additional information/fields in the response. 62 */ 63 struct img_mgmt_slot_info_image { 64 /** The image that is currently being enumerated. */ 65 const uint8_t image; 66 67 /** 68 * The zcbor encoder which is currently being used to output information, additional fields 69 * can be added using this. 70 */ 71 zcbor_state_t *zse; 72 }; 73 74 /** 75 * Structure provided in the #MGMT_EVT_OP_IMG_MGMT_SLOT_INFO_SLOT notification callback: This 76 * callback function is called once per slot per image when the slot info command is used, it can 77 * be used to return additional information/fields in the response. 78 */ 79 struct img_mgmt_slot_info_slot { 80 /** The image that is currently being enumerated. */ 81 const uint8_t image; 82 83 /** The slot that is currently being enumerated. */ 84 const uint8_t slot; 85 86 /** Flash area of the slot that is current being enumerated. */ 87 const struct flash_area *fa; 88 89 /** 90 * The zcbor encoder which is currently being used to output information, additional fields 91 * can be added using this. 92 */ 93 zcbor_state_t *zse; 94 }; 95 96 /** 97 * @} 98 */ 99 100 #ifdef __cplusplus 101 } 102 #endif 103 104 #endif 105