Line data Source code
1 0 : /* 2 : * Copyright (c) 2020 Nordic Semiconductor ASA 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : #ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_H__ 8 : #define ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_H__ 9 : 10 : #include <sys/types.h> 11 : 12 : #include <zephyr/kernel.h> 13 : #include <zephyr/bluetooth/mesh/blob.h> 14 : 15 : #ifdef __cplusplus 16 : extern "C" { 17 : #endif 18 : 19 : /** 20 : * @defgroup bt_mesh_dfu Bluetooth Mesh Device Firmware Update 21 : * @ingroup bt_mesh 22 : * @{ 23 : */ 24 : 25 : #ifndef CONFIG_BT_MESH_DFU_FWID_MAXLEN 26 0 : #define CONFIG_BT_MESH_DFU_FWID_MAXLEN 0 27 : #endif 28 : 29 : #ifndef CONFIG_BT_MESH_DFU_METADATA_MAXLEN 30 0 : #define CONFIG_BT_MESH_DFU_METADATA_MAXLEN 0 31 : #endif 32 : 33 : #ifndef CONFIG_BT_MESH_DFU_URI_MAXLEN 34 0 : #define CONFIG_BT_MESH_DFU_URI_MAXLEN 0 35 : #endif 36 : 37 : #ifndef CONFIG_BT_MESH_DFU_SLOT_CNT 38 0 : #define CONFIG_BT_MESH_DFU_SLOT_CNT 0 39 : #endif 40 : 41 : /** DFU transfer phase. */ 42 1 : enum bt_mesh_dfu_phase { 43 : /** Ready to start a Receive Firmware procedure. */ 44 : BT_MESH_DFU_PHASE_IDLE, 45 : 46 : /** The Transfer BLOB procedure failed. */ 47 : BT_MESH_DFU_PHASE_TRANSFER_ERR, 48 : 49 : /** The Receive Firmware procedure is being executed. */ 50 : BT_MESH_DFU_PHASE_TRANSFER_ACTIVE, 51 : 52 : /** The Verify Firmware procedure is being executed. */ 53 : BT_MESH_DFU_PHASE_VERIFY, 54 : 55 : /** The Verify Firmware procedure completed successfully. */ 56 : BT_MESH_DFU_PHASE_VERIFY_OK, 57 : 58 : /** The Verify Firmware procedure failed. */ 59 : BT_MESH_DFU_PHASE_VERIFY_FAIL, 60 : 61 : /** The Apply New Firmware procedure is being executed. */ 62 : BT_MESH_DFU_PHASE_APPLYING, 63 : 64 : /** Firmware transfer has been canceled. */ 65 : BT_MESH_DFU_PHASE_TRANSFER_CANCELED, 66 : 67 : /** Firmware applying succeeded. */ 68 : BT_MESH_DFU_PHASE_APPLY_SUCCESS, 69 : 70 : /** Firmware applying failed. */ 71 : BT_MESH_DFU_PHASE_APPLY_FAIL, 72 : 73 : /** Phase of a node was not yet retrieved. */ 74 : BT_MESH_DFU_PHASE_UNKNOWN, 75 : }; 76 : 77 : 78 : /** DFU status. */ 79 1 : enum bt_mesh_dfu_status { 80 : /** The message was processed successfully. */ 81 : BT_MESH_DFU_SUCCESS, 82 : 83 : /** Insufficient resources on the node */ 84 : BT_MESH_DFU_ERR_RESOURCES, 85 : 86 : /** The operation cannot be performed while the Server is in the current 87 : * phase. 88 : */ 89 : BT_MESH_DFU_ERR_WRONG_PHASE, 90 : 91 : /** An internal error occurred on the node. */ 92 : BT_MESH_DFU_ERR_INTERNAL, 93 : 94 : /** The message contains a firmware index value that is not expected. */ 95 : BT_MESH_DFU_ERR_FW_IDX, 96 : 97 : /** The metadata check failed. */ 98 : BT_MESH_DFU_ERR_METADATA, 99 : 100 : /** The Server cannot start a firmware update. */ 101 : BT_MESH_DFU_ERR_TEMPORARILY_UNAVAILABLE, 102 : 103 : /** Another BLOB transfer is in progress. */ 104 : BT_MESH_DFU_ERR_BLOB_XFER_BUSY, 105 : }; 106 : 107 : /** Expected effect of a DFU transfer. */ 108 1 : enum bt_mesh_dfu_effect { 109 : /** No changes to node Composition Data. */ 110 : BT_MESH_DFU_EFFECT_NONE, 111 : 112 : /** Node Composition Data changed and the node does not support remote 113 : * provisioning. 114 : */ 115 : BT_MESH_DFU_EFFECT_COMP_CHANGE_NO_RPR, 116 : 117 : /** Node Composition Data changed, and remote provisioning is supported. 118 : * The node supports remote provisioning and Composition Data Page 119 : * 0x80. Page 0x80 contains different Composition Data than Page 0x0. 120 : */ 121 : BT_MESH_DFU_EFFECT_COMP_CHANGE, 122 : 123 : /** Node will be unprovisioned after the update. */ 124 : BT_MESH_DFU_EFFECT_UNPROV, 125 : }; 126 : 127 : /** Action for DFU iteration callbacks. */ 128 1 : enum bt_mesh_dfu_iter { 129 : /** Stop iterating. */ 130 : BT_MESH_DFU_ITER_STOP, 131 : 132 : /** Continue iterating. */ 133 : BT_MESH_DFU_ITER_CONTINUE, 134 : }; 135 : 136 : /** DFU image instance. 137 : * 138 : * Each DFU image represents a single updatable firmware image. 139 : */ 140 1 : struct bt_mesh_dfu_img { 141 : /** Firmware ID. */ 142 1 : const void *fwid; 143 : 144 : /** Length of the firmware ID. */ 145 1 : size_t fwid_len; 146 : 147 : /** Update URI, or NULL. */ 148 1 : const char *uri; 149 : }; 150 : 151 : /** DFU image slot for DFU distribution. */ 152 1 : struct bt_mesh_dfu_slot { 153 : /** Size of the firmware in bytes. */ 154 1 : size_t size; 155 : /** Length of the firmware ID. */ 156 1 : size_t fwid_len; 157 : /** Length of the metadata. */ 158 1 : size_t metadata_len; 159 : /** Firmware ID. */ 160 1 : uint8_t fwid[CONFIG_BT_MESH_DFU_FWID_MAXLEN]; 161 : /** Metadata. */ 162 1 : uint8_t metadata[CONFIG_BT_MESH_DFU_METADATA_MAXLEN]; 163 : }; 164 : 165 : /** @} */ 166 : 167 : #ifdef __cplusplus 168 : } 169 : #endif 170 : 171 : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_H__ */