1 /*
2  * Copyright (c) 2020 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFD_H__
8 #define ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFD_H__
9 
10 #include <zephyr/bluetooth/mesh.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * @defgroup bt_mesh_dfd Firmware Distribution models
18  * @ingroup bt_mesh
19  * @{
20  */
21 
22 /** Firmware distribution status. */
23 enum bt_mesh_dfd_status {
24 	/** The message was processed successfully. */
25 	BT_MESH_DFD_SUCCESS,
26 
27 	/** Insufficient resources on the node. */
28 	BT_MESH_DFD_ERR_INSUFFICIENT_RESOURCES,
29 
30 	/** The operation cannot be performed while the Server is in the current
31 	 *  phase.
32 	 */
33 	BT_MESH_DFD_ERR_WRONG_PHASE,
34 
35 	/** An internal error occurred on the node. */
36 	BT_MESH_DFD_ERR_INTERNAL,
37 
38 	/** The requested firmware image is not stored on the Distributor. */
39 	BT_MESH_DFD_ERR_FW_NOT_FOUND,
40 
41 	/** The AppKey identified by the AppKey Index is not known to the node.
42 	 */
43 	BT_MESH_DFD_ERR_INVALID_APPKEY_INDEX,
44 
45 	/** There are no Target nodes in the Distribution Receivers List
46 	 *  state.
47 	 */
48 	BT_MESH_DFD_ERR_RECEIVERS_LIST_EMPTY,
49 
50 	/** Another firmware image distribution is in progress. */
51 	BT_MESH_DFD_ERR_BUSY_WITH_DISTRIBUTION,
52 
53 	/** Another upload is in progress. */
54 	BT_MESH_DFD_ERR_BUSY_WITH_UPLOAD,
55 
56 	/** The URI scheme name indicated by the Update URI is not supported. */
57 	BT_MESH_DFD_ERR_URI_NOT_SUPPORTED,
58 
59 	/** The format of the Update URI is invalid. */
60 	BT_MESH_DFD_ERR_URI_MALFORMED,
61 
62 	/** The URI is currently unreachable. */
63 	BT_MESH_DFD_ERR_URI_UNREACHABLE,
64 
65 	/** The Check Firmware OOB procedure did not find any new firmware. */
66 	BT_MESH_DFD_ERR_NEW_FW_NOT_AVAILABLE,
67 
68 	/** The suspension of the Distribute Firmware procedure failed. */
69 	BT_MESH_DFD_ERR_SUSPEND_FAILED,
70 };
71 
72 /** Firmware distribution phases. */
73 enum bt_mesh_dfd_phase {
74 	/** No firmware distribution is in progress. */
75 	BT_MESH_DFD_PHASE_IDLE,
76 
77 	/** Firmware distribution is in progress. */
78 	BT_MESH_DFD_PHASE_TRANSFER_ACTIVE,
79 
80 	/** The Transfer BLOB procedure has completed successfully. */
81 	BT_MESH_DFD_PHASE_TRANSFER_SUCCESS,
82 
83 	/** The Apply Firmware on Target Nodes procedure is being executed. */
84 	BT_MESH_DFD_PHASE_APPLYING_UPDATE,
85 
86 	/** The Distribute Firmware procedure has completed successfully. */
87 	BT_MESH_DFD_PHASE_COMPLETED,
88 
89 	/** The Distribute Firmware procedure has failed. */
90 	BT_MESH_DFD_PHASE_FAILED,
91 
92 	/** The Cancel Firmware Update procedure is being executed. */
93 	BT_MESH_DFD_PHASE_CANCELING_UPDATE,
94 
95 	/** The Transfer BLOB procedure is suspended. */
96 	BT_MESH_DFD_PHASE_TRANSFER_SUSPENDED,
97 };
98 
99 /** Firmware upload phases. */
100 enum bt_mesh_dfd_upload_phase {
101 	/** No firmware upload is in progress. */
102 	BT_MESH_DFD_UPLOAD_PHASE_IDLE,
103 
104 	/** The Store Firmware procedure is being executed. */
105 	BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_ACTIVE,
106 
107 	/** The Store Firmware procedure or Store Firmware OOB procedure failed.
108 	 */
109 	BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_ERROR,
110 
111 	/** The Store Firmware procedure or the Store Firmware OOB procedure
112 	 *  completed successfully.
113 	 */
114 	BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_SUCCESS,
115 };
116 
117 /** @} */
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFD_H__ */
124