1 /*
2  * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef _ESP_BLE_MESH_DEFS_H_
8 #define _ESP_BLE_MESH_DEFS_H_
9 
10 #include <stdint.h>
11 
12 #include "mesh_config.h"
13 #include "mesh_common.h"
14 #include "proxy_server.h"
15 #include "provisioner_main.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /*!< The maximum length of a BLE Mesh message, including Opcode, Payload and TransMIC */
22 #define ESP_BLE_MESH_SDU_MAX_LEN            384
23 
24 /*!< Length of a short Mesh MIC. */
25 #define ESP_BLE_MESH_MIC_SHORT              4
26 
27 /*!< Length of a long Mesh MIC. */
28 #define ESP_BLE_MESH_MIC_LONG               8
29 
30 /*!< The maximum length of a BLE Mesh provisioned node name */
31 #define ESP_BLE_MESH_NODE_NAME_MAX_LEN      31
32 
33 /*!< The maximum length of a BLE Mesh unprovisioned device name */
34 #define ESP_BLE_MESH_DEVICE_NAME_MAX_LEN    DEVICE_NAME_SIZE
35 
36 /*!< The maximum length of settings user id */
37 #define ESP_BLE_MESH_SETTINGS_UID_SIZE      20
38 
39 /*!< Invalid settings index */
40 #define ESP_BLE_MESH_INVALID_SETTINGS_IDX   0xFF
41 
42 /*!< Define the BLE Mesh octet 16 bytes size */
43 #define ESP_BLE_MESH_OCTET16_LEN    16
44 typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN];
45 
46 /*!< Define the BLE Mesh octet 8 bytes size */
47 #define ESP_BLE_MESH_OCTET8_LEN     8
48 typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
49 
50 /*!< Invalid Company ID */
51 #define ESP_BLE_MESH_CID_NVAL                     0xFFFF
52 
53 /*!< Special TTL value to request using configured default TTL */
54 #define ESP_BLE_MESH_TTL_DEFAULT                  0xFF
55 
56 /*!< Maximum allowed TTL value */
57 #define ESP_BLE_MESH_TTL_MAX                      0x7F
58 
59 #define ESP_BLE_MESH_ADDR_UNASSIGNED              0x0000
60 #define ESP_BLE_MESH_ADDR_ALL_NODES               0xFFFF
61 #define ESP_BLE_MESH_ADDR_PROXIES                 0xFFFC
62 #define ESP_BLE_MESH_ADDR_FRIENDS                 0xFFFD
63 #define ESP_BLE_MESH_ADDR_RELAYS                  0xFFFE
64 
65 #define ESP_BLE_MESH_KEY_UNUSED                   0xFFFF
66 #define ESP_BLE_MESH_KEY_DEV                      0xFFFE
67 
68 #define ESP_BLE_MESH_KEY_PRIMARY                  0x0000
69 #define ESP_BLE_MESH_KEY_ANY                      0xFFFF
70 
71 /*!< Internal macros used to initialize array members */
72 #define ESP_BLE_MESH_KEY_UNUSED_ELT_(IDX, _) ESP_BLE_MESH_KEY_UNUSED
73 #define ESP_BLE_MESH_ADDR_UNASSIGNED_ELT_(IDX, _) ESP_BLE_MESH_ADDR_UNASSIGNED
74 #define ESP_BLE_MESH_MODEL_KEYS_UNUSED            \
75     { LISTIFY(CONFIG_BLE_MESH_MODEL_KEY_COUNT, ESP_BLE_MESH_KEY_UNUSED_ELT_, (,)) }
76 #define ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED      \
77     { LISTIFY(CONFIG_BLE_MESH_MODEL_GROUP_COUNT, ESP_BLE_MESH_ADDR_UNASSIGNED_ELT_, (,)) }
78 
79 /*!< Primary Network Key index */
80 #define ESP_BLE_MESH_NET_PRIMARY                  0x000
81 
82 /*!< Relay state value */
83 #define ESP_BLE_MESH_RELAY_DISABLED               0x00
84 #define ESP_BLE_MESH_RELAY_ENABLED                0x01
85 #define ESP_BLE_MESH_RELAY_NOT_SUPPORTED          0x02
86 
87 /*!< Beacon state value */
88 #define ESP_BLE_MESH_BEACON_DISABLED              0x00
89 #define ESP_BLE_MESH_BEACON_ENABLED               0x01
90 
91 /*!< GATT Proxy state value */
92 #define ESP_BLE_MESH_GATT_PROXY_DISABLED          0x00
93 #define ESP_BLE_MESH_GATT_PROXY_ENABLED           0x01
94 #define ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED     0x02
95 
96 /*!< Friend state value */
97 #define ESP_BLE_MESH_FRIEND_DISABLED              0x00
98 #define ESP_BLE_MESH_FRIEND_ENABLED               0x01
99 #define ESP_BLE_MESH_FRIEND_NOT_SUPPORTED         0x02
100 
101 /*!< Node identity state value */
102 #define ESP_BLE_MESH_NODE_IDENTITY_STOPPED        0x00
103 #define ESP_BLE_MESH_NODE_IDENTITY_RUNNING        0x01
104 #define ESP_BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED  0x02
105 
106 /*!< Supported features */
107 #define ESP_BLE_MESH_FEATURE_RELAY                BIT(0)
108 #define ESP_BLE_MESH_FEATURE_PROXY                BIT(1)
109 #define ESP_BLE_MESH_FEATURE_FRIEND               BIT(2)
110 #define ESP_BLE_MESH_FEATURE_LOW_POWER            BIT(3)
111 #define ESP_BLE_MESH_FEATURE_ALL_SUPPORTED        (ESP_BLE_MESH_FEATURE_RELAY |     \
112                                                    ESP_BLE_MESH_FEATURE_PROXY |     \
113                                                    ESP_BLE_MESH_FEATURE_FRIEND |    \
114                                                    ESP_BLE_MESH_FEATURE_LOW_POWER)
115 
116 #define ESP_BLE_MESH_ADDR_IS_UNICAST(addr)        ((addr) && (addr) < 0x8000)
117 #define ESP_BLE_MESH_ADDR_IS_GROUP(addr)          ((addr) >= 0xC000 && (addr) <= 0xFF00)
118 #define ESP_BLE_MESH_ADDR_IS_VIRTUAL(addr)        ((addr) >= 0x8000 && (addr) < 0xC000)
119 #define ESP_BLE_MESH_ADDR_IS_RFU(addr)            ((addr) >= 0xFF00 && (addr) <= 0xFFFB)
120 
121 #define ESP_BLE_MESH_INVALID_NODE_INDEX           0xFFFF
122 
123 /** @def    ESP_BLE_MESH_TRANSMIT
124  *
125  *  @brief  Encode transmission count & interval steps.
126  *
127  *  @note   For example, ESP_BLE_MESH_TRANSMIT(2, 20) means that the message
128  *          will be sent about 90ms(count is 3, step is 1, interval is 30 ms
129  *          which includes 10ms of advertising interval random delay).
130  *
131  *  @param  count   Number of retransmissions (first transmission is excluded).
132  *  @param  int_ms  Interval steps in milliseconds. Must be greater than 0
133  *                  and a multiple of 10.
134  *
135  *  @return BLE Mesh transmit value that can be used e.g. for the default
136  *          values of the Configuration Model data.
137  */
138 #define ESP_BLE_MESH_TRANSMIT(count, int_ms)    ((count) | (((int_ms / 10) - 1) << 3))
139 
140 /** @def ESP_BLE_MESH_GET_TRANSMIT_COUNT
141  *
142  *  @brief Decode transmit count from a transmit value.
143  *
144  *  @param transmit Encoded transmit count & interval value.
145  *
146  *  @return Transmission count (actual transmissions equal to N + 1).
147  */
148 #define ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit)   (((transmit) & (uint8_t)BIT_MASK(3)))
149 
150 /** @def ESP_BLE_MESH_GET_TRANSMIT_INTERVAL
151  *
152  *  @brief Decode transmit interval from a transmit value.
153  *
154  *  @param transmit Encoded transmit count & interval value.
155  *
156  *  @return Transmission interval in milliseconds.
157  */
158 #define ESP_BLE_MESH_GET_TRANSMIT_INTERVAL(transmit)    ((((transmit) >> 3) + 1) * 10)
159 
160 /** @def ESP_BLE_MESH_PUBLISH_TRANSMIT
161  *
162  *  @brief Encode Publish Retransmit count & interval steps.
163  *
164  *  @param count   Number of retransmissions (first transmission is excluded).
165  *  @param int_ms  Interval steps in milliseconds. Must be greater than 0
166  *                 and a multiple of 50.
167  *
168  *  @return BLE Mesh transmit value that can be used e.g. for the default
169  *          values of the Configuration Model data.
170  */
171 #define ESP_BLE_MESH_PUBLISH_TRANSMIT(count, int_ms)    ESP_BLE_MESH_TRANSMIT(count, (int_ms) / 5)
172 
173 /** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT
174  *
175  *  @brief Decode Publish Retransmit count from a given value.
176  *
177  *  @param transmit Encoded Publish Retransmit count & interval value.
178  *
179  *  @return Retransmission count (actual transmissions equal to N + 1).
180  */
181 #define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT(transmit)   ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit)
182 
183 /** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL
184  *
185  *  @brief Decode Publish Retransmit interval from a given value.
186  *
187  *  @param transmit Encoded Publish Retransmit count & interval value.
188  *
189  *  @return Transmission interval in milliseconds.
190  */
191 #define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL(transmit)    ((((transmit) >> 3) + 1) * 50)
192 
193 /*!< Callbacks which are not needed to be initialized by users (set with 0 and will be initialized internally) */
194 typedef uint32_t esp_ble_mesh_cb_t;
195 
196 typedef enum {
197     ESP_BLE_MESH_TYPE_PROV_CB,
198     ESP_BLE_MESH_TYPE_OUTPUT_NUM_CB,
199     ESP_BLE_MESH_TYPE_OUTPUT_STR_CB,
200     ESP_BLE_MESH_TYPE_INTPUT_CB,
201     ESP_BLE_MESH_TYPE_LINK_OPEN_CB,
202     ESP_BLE_MESH_TYPE_LINK_CLOSE_CB,
203     ESP_BLE_MESH_TYPE_COMPLETE_CB,
204     ESP_BLE_MESH_TYPE_RESET_CB,
205 } esp_ble_mesh_cb_type_t;
206 
207 /*!< This enum value is provisioning authentication oob method */
208 typedef enum {
209     ESP_BLE_MESH_NO_OOB,
210     ESP_BLE_MESH_STATIC_OOB,
211     ESP_BLE_MESH_OUTPUT_OOB,
212     ESP_BLE_MESH_INPUT_OOB,
213 } esp_ble_mesh_oob_method_t;
214 
215 /*!< This enum value is associated with bt_mesh_output_action_t in mesh_main.h */
216 typedef enum {
217     ESP_BLE_MESH_NO_OUTPUT       = 0,
218     ESP_BLE_MESH_BLINK           = BIT(0),
219     ESP_BLE_MESH_BEEP            = BIT(1),
220     ESP_BLE_MESH_VIBRATE         = BIT(2),
221     ESP_BLE_MESH_DISPLAY_NUMBER  = BIT(3),
222     ESP_BLE_MESH_DISPLAY_STRING  = BIT(4),
223 } esp_ble_mesh_output_action_t;
224 
225 /*!< This enum value is associated with bt_mesh_input_action_t in mesh_main.h */
226 typedef enum {
227     ESP_BLE_MESH_NO_INPUT      = 0,
228     ESP_BLE_MESH_PUSH          = BIT(0),
229     ESP_BLE_MESH_TWIST         = BIT(1),
230     ESP_BLE_MESH_ENTER_NUMBER  = BIT(2),
231     ESP_BLE_MESH_ENTER_STRING  = BIT(3),
232 } esp_ble_mesh_input_action_t;
233 
234 /*!< This enum value is associated with bt_mesh_prov_bearer_t in mesh_main.h */
235 typedef enum {
236     ESP_BLE_MESH_PROV_ADV   = BIT(0),
237     ESP_BLE_MESH_PROV_GATT  = BIT(1),
238 } esp_ble_mesh_prov_bearer_t;
239 
240 /*!< This enum value is associated with bt_mesh_prov_oob_info_t in mesh_main.h */
241 typedef enum {
242     ESP_BLE_MESH_PROV_OOB_OTHER     = BIT(0),
243     ESP_BLE_MESH_PROV_OOB_URI       = BIT(1),
244     ESP_BLE_MESH_PROV_OOB_2D_CODE   = BIT(2),
245     ESP_BLE_MESH_PROV_OOB_BAR_CODE  = BIT(3),
246     ESP_BLE_MESH_PROV_OOB_NFC       = BIT(4),
247     ESP_BLE_MESH_PROV_OOB_NUMBER    = BIT(5),
248     ESP_BLE_MESH_PROV_OOB_STRING    = BIT(6),
249     /* 7 - 10 are reserved */
250     ESP_BLE_MESH_PROV_OOB_ON_BOX    = BIT(11),
251     ESP_BLE_MESH_PROV_OOB_IN_BOX    = BIT(12),
252     ESP_BLE_MESH_PROV_OOB_ON_PAPER  = BIT(13),
253     ESP_BLE_MESH_PROV_OOB_IN_MANUAL = BIT(14),
254     ESP_BLE_MESH_PROV_OOB_ON_DEV    = BIT(15),
255 } esp_ble_mesh_prov_oob_info_t;
256 
257 /*!< Maximum length of value used by Static OOB authentication */
258 #define ESP_BLE_MESH_PROV_STATIC_OOB_MAX_LEN    16
259 
260 /*!< Maximum length of string used by Output OOB authentication */
261 #define ESP_BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN    8
262 
263 /*!< Maximum length of string used by Output OOB authentication */
264 #define ESP_BLE_MESH_PROV_INPUT_OOB_MAX_LEN     8
265 
266 /*!< Macros used to define message opcode */
267 #define ESP_BLE_MESH_MODEL_OP_1(b0)         (b0)
268 #define ESP_BLE_MESH_MODEL_OP_2(b0, b1)     (((b0) << 8) | (b1))
269 #define ESP_BLE_MESH_MODEL_OP_3(b0, cid)    ((((b0) << 16) | 0xC00000) | (cid))
270 
271 /*!< This macro is associated with BLE_MESH_MODEL_CB in mesh_access.h */
272 #define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data)          \
273 {                                                                   \
274     .model_id = (_id),                                              \
275     .pub = _pub,                                                    \
276     .keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED,                         \
277     .groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED,                 \
278     .op = _op,                                                      \
279     .user_data = _user_data,                                        \
280 }
281 
282 /*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
283 #define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
284 {                                                                       \
285     .vnd = {                                                            \
286         .company_id = (_company),                                       \
287         .model_id = (_id),                                              \
288     },                                                                  \
289     .pub = _pub,                                                        \
290     .keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED,                             \
291     .groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED,                     \
292     .op = _op,                                                          \
293     .user_data = _user_data,                                            \
294 }
295 
296 /** @brief Helper to define a BLE Mesh element within an array.
297  *
298  *  In case the element has no SIG or Vendor models, the helper
299  *  macro ESP_BLE_MESH_MODEL_NONE can be given instead.
300  *
301  *  @note This macro is associated with BLE_MESH_ELEM in mesh_access.h
302  *
303  *  @param _loc       Location Descriptor.
304  *  @param _mods      Array of SIG models.
305  *  @param _vnd_mods  Array of vendor models.
306  */
307 #define ESP_BLE_MESH_ELEMENT(_loc, _mods, _vnd_mods)    \
308 {                                                       \
309     .location         = (_loc),                         \
310     .sig_model_count  = ARRAY_SIZE(_mods),              \
311     .vnd_model_count  = ARRAY_SIZE(_vnd_mods),          \
312     .sig_models       = (_mods),                        \
313     .vnd_models       = (_vnd_mods),                    \
314 }
315 
316 #define ESP_BLE_MESH_PROV(uuid, sta_val, sta_val_len, out_size, out_act, in_size, in_act) { \
317     .uuid           = uuid,         \
318     .static_val     = sta_val,      \
319     .static_val_len = sta_val_len,  \
320     .output_size    = out_size,     \
321     .output_action  = out_act,      \
322     .input_size     = in_size,      \
323     .input_action   = in_act,       \
324 }
325 
326 typedef uint8_t UINT8;
327 typedef uint16_t UINT16;
328 typedef uint32_t UINT32;
329 typedef uint64_t UINT64;
330 
331 #define BT_OCTET32_LEN    32
332 typedef UINT8 BT_OCTET32[BT_OCTET32_LEN];   /* octet array: size 32 */
333 
334 
335 #ifndef BD_ADDR_LEN
336 #define BD_ADDR_LEN     6
337 typedef uint8_t BD_ADDR[BD_ADDR_LEN];
338 #endif
339 
340 typedef uint8_t esp_ble_mesh_bd_addr_t[BD_ADDR_LEN];
341 
342 #define ESP_BLE_MESH_ADDR_TYPE_PUBLIC       0x00
343 #define ESP_BLE_MESH_ADDR_TYPE_RANDOM       0x01
344 #define ESP_BLE_MESH_ADDR_TYPE_RPA_PUBLIC   0x02
345 #define ESP_BLE_MESH_ADDR_TYPE_RPA_RANDOM   0x03
346 /// BLE device address type
347 typedef uint8_t esp_ble_mesh_addr_type_t;
348 
349 /** BLE Mesh deinit parameters */
350 typedef struct {
351     bool erase_flash;   /*!< Indicate if erasing flash when deinit mesh stack */
352 } esp_ble_mesh_deinit_param_t;
353 
354 typedef struct esp_ble_mesh_model esp_ble_mesh_model_t;
355 
356 /** Abstraction that describes a BLE Mesh Element.
357  *  This structure is associated with struct bt_mesh_elem in mesh_access.h
358  */
359 typedef struct {
360     /** Element Address, assigned during provisioning. */
361     uint16_t element_addr;
362 
363     /** Location Descriptor (GATT Bluetooth Namespace Descriptors) */
364     const uint16_t location;
365 
366     const uint8_t sig_model_count;      /*!< SIG Model count */
367     const uint8_t vnd_model_count;      /*!< Vendor Model count */
368 
369     esp_ble_mesh_model_t *sig_models;   /*!< SIG Models */
370     esp_ble_mesh_model_t *vnd_models;   /*!< Vendor Models */
371 } esp_ble_mesh_elem_t;
372 
373 /** Abstraction that describes a model publication context.
374  *  This structure is associated with struct bt_mesh_model_pub in mesh_access.h
375  */
376 typedef struct {
377     /** Pointer to the model to which the context belongs. Initialized by the stack. */
378     esp_ble_mesh_model_t *model;
379 
380     uint16_t publish_addr;  /*!< Publish Address. */
381     uint16_t app_idx:12,    /*!< Publish AppKey Index. */
382              cred:1,        /*!< Friendship Credentials Flag. */
383              send_rel:1;    /*!< Force reliable sending (segment acks) */
384 
385     uint8_t  ttl;           /*!< Publish Time to Live. */
386     uint8_t  retransmit;    /*!< Retransmit Count & Interval Steps. */
387 
388     uint8_t  period;        /*!< Publish Period. */
389     uint8_t  period_div:4,  /*!< Divisor for the Period. */
390              fast_period:1, /*!< Use FastPeriodDivisor */
391              count:3;       /*!< Retransmissions left. */
392 
393     uint32_t period_start; /*!< Start of the current period. */
394 
395     /** @brief Publication buffer, containing the publication message.
396      *
397      *  This will get correctly created when the publication context
398      *  has been defined using the ESP_BLE_MESH_MODEL_PUB_DEFINE macro.
399      *
400      *  ESP_BLE_MESH_MODEL_PUB_DEFINE(name, size);
401      */
402     struct net_buf_simple *msg;
403 
404     /** Callback used to update publish message. Initialized by the stack. */
405     esp_ble_mesh_cb_t update;
406 
407     /** Publish Period Timer. Initialized by the stack. */
408     struct k_delayed_work timer;
409 
410     /** Role of the device that is going to publish messages */
411     uint8_t dev_role;
412 } esp_ble_mesh_model_pub_t;
413 
414 /** @def ESP_BLE_MESH_MODEL_PUB_DEFINE
415  *
416  *  Define a model publication context.
417  *
418  *  @param _name    Variable name given to the context.
419  *  @param _msg_len Length of the publication message.
420  *  @param _role    Role of the device which contains the model.
421  */
422 #define ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, _msg_len, _role) \
423     NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
424     static esp_ble_mesh_model_pub_t _name = { \
425         .msg = &bt_mesh_pub_msg_##_name, \
426         .update = (uint32_t)NULL, \
427         .dev_role = _role, \
428     }
429 
430 /** @def ESP_BLE_MESH_MODEL_OP
431  *
432  *  Define a model operation context.
433  *
434  *  @param _opcode  Message opcode.
435  *  @param _min_len Message minimum length.
436  */
437 #define ESP_BLE_MESH_MODEL_OP(_opcode, _min_len) \
438 { \
439     .opcode = _opcode, \
440     .min_len = _min_len, \
441     .param_cb = (uint32_t)NULL, \
442 }
443 
444 /** Abstraction that describes a model operation context.
445  *  This structure is associated with struct bt_mesh_model_op in mesh_access.h
446  */
447 typedef struct {
448     const uint32_t    opcode;   /*!< Message opcode */
449     const size_t      min_len;  /*!< Message minimum length */
450     esp_ble_mesh_cb_t param_cb; /*!< Callback used to handle message. Initialized by the stack. */
451 } esp_ble_mesh_model_op_t;
452 
453 /** Define the terminator for the model operation table.
454  *  Each model operation struct array must use this terminator as
455  *  the end tag of the operation unit.
456  */
457 #define ESP_BLE_MESH_MODEL_OP_END {0, 0, 0}
458 
459 /** Abstraction that describes a model callback structure.
460  *  This structure is associated with struct bt_mesh_model_cb in mesh_access.h.
461  */
462 typedef struct {
463     /** Callback used during model initialization. Initialized by the stack. */
464     esp_ble_mesh_cb_t init_cb;
465 
466 #if CONFIG_BLE_MESH_DEINIT
467     /** Callback used during model deinitialization. Initialized by the stack. */
468     esp_ble_mesh_cb_t deinit_cb;
469 #endif /* CONFIG_BLE_MESH_DEINIT */
470 } esp_ble_mesh_model_cbs_t;
471 
472 /** Abstraction that describes a Mesh Model instance.
473  *  This structure is associated with struct bt_mesh_model in mesh_access.h
474  */
475 struct esp_ble_mesh_model {
476     /** Model ID */
477     union {
478         const uint16_t model_id; /*!< 16-bit model identifier */
479         struct {
480             uint16_t company_id; /*!< 16-bit company identifier */
481             uint16_t model_id; /*!< 16-bit model identifier */
482         } vnd; /*!< Structure encapsulating a model ID with a company ID */
483     };
484 
485     /** Internal information, mainly for persistent storage */
486     uint8_t  element_idx;   /*!< Belongs to Nth element */
487     uint8_t  model_idx;     /*!< Is the Nth model in the element */
488     uint16_t flags;         /*!< Information about what has changed */
489 
490     /** The Element to which this Model belongs */
491     esp_ble_mesh_elem_t *element;
492 
493     /** Model Publication */
494     esp_ble_mesh_model_pub_t *const pub;
495 
496     /** AppKey List */
497     uint16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT];
498 
499     /** Subscription List (group or virtual addresses) */
500     uint16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT];
501 
502     /** Model operation context */
503     esp_ble_mesh_model_op_t *op;
504 
505     /** Model callback structure */
506     esp_ble_mesh_model_cbs_t *cb;
507 
508     /** Model-specific user data */
509     void *user_data;
510 };
511 
512 /** Helper to define an empty model array.
513  *  This structure is associated with BLE_MESH_MODEL_NONE in mesh_access.h
514  */
515 #define ESP_BLE_MESH_MODEL_NONE ((esp_ble_mesh_model_t []){})
516 
517 /** Message sending context.
518  *  This structure is associated with struct bt_mesh_msg_ctx in mesh_access.h
519  */
520 typedef struct {
521     /** NetKey Index of the subnet through which to send the message. */
522     uint16_t net_idx;
523 
524     /** AppKey Index for message encryption. */
525     uint16_t app_idx;
526 
527     /** Remote address. */
528     uint16_t addr;
529 
530     /** Destination address of a received message. Not used for sending. */
531     uint16_t recv_dst;
532 
533     /** RSSI of received packet. Not used for sending. */
534     int8_t   recv_rssi;
535 
536     /** Received TTL value. Not used for sending. */
537     uint8_t  recv_ttl: 7;
538 
539     /** Force sending reliably by using segment acknowledgement */
540     uint8_t  send_rel: 1;
541 
542     /** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */
543     uint8_t  send_ttl;
544 
545     /** Opcode of a received message. Not used for sending message. */
546     uint32_t recv_op;
547 
548     /** Model corresponding to the message, no need to be initialized before sending message */
549     esp_ble_mesh_model_t *model;
550 
551     /** Indicate if the message is sent by a node server model, no need to be initialized before sending message */
552     bool srv_send;
553 } esp_ble_mesh_msg_ctx_t;
554 
555 /** Provisioning properties & capabilities.
556  *  This structure is associated with struct bt_mesh_prov in mesh_access.h
557  */
558 typedef struct {
559 #if CONFIG_BLE_MESH_NODE
560     /** The UUID that is used when advertising as an unprovisioned device */
561     const uint8_t *uuid;
562 
563     /** Optional URI. This will be advertised separately from the
564      *  unprovisioned beacon, however the unprovisioned beacon will
565      *  contain a hash of it so the two can be associated by the
566      *  provisioner.
567      */
568     const char *uri;
569 
570     /** Out of Band information field. */
571     esp_ble_mesh_prov_oob_info_t oob_info;
572 
573     /* NOTE: In order to avoid suffering brute-forcing attack (CVE-2020-26559).
574      * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners
575      * support an out-of-band mechanism to exchange the public keys.
576      * So as an unprovisioned device, it should enable this flag to support
577      * using an out-of-band mechanism to exchange Public Key.
578      */
579     /** Flag indicates whether unprovisioned devices support OOB public key */
580     bool oob_pub_key;
581 
582     /** Callback used to notify to set OOB Public Key. Initialized by the stack. */
583     esp_ble_mesh_cb_t oob_pub_key_cb;
584 
585     /** Static OOB value */
586     const uint8_t *static_val;
587     /** Static OOB value length */
588     uint8_t        static_val_len;
589 
590     /** Maximum size of Output OOB supported */
591     uint8_t        output_size;
592     /** Supported Output OOB Actions */
593     uint16_t       output_actions;
594 
595     /** Maximum size of Input OOB supported */
596     uint8_t        input_size;
597     /** Supported Input OOB Actions */
598     uint16_t       input_actions;
599 
600     /** Callback used to output the number. Initialized by the stack. */
601     esp_ble_mesh_cb_t  output_num_cb;
602     /** Callback used to output the string. Initialized by the stack. */
603     esp_ble_mesh_cb_t  output_str_cb;
604     /** Callback used to notify to input number/string. Initialized by the stack. */
605     esp_ble_mesh_cb_t  input_cb;
606     /** Callback used to indicate that link is opened. Initialized by the stack. */
607     esp_ble_mesh_cb_t  link_open_cb;
608     /** Callback used to indicate that link is closed. Initialized by the stack. */
609     esp_ble_mesh_cb_t  link_close_cb;
610     /** Callback used to indicate that provisioning is completed. Initialized by the stack. */
611     esp_ble_mesh_cb_t  complete_cb;
612     /** Callback used to indicate that node has been reset. Initialized by the stack. */
613     esp_ble_mesh_cb_t  reset_cb;
614 #endif /* CONFIG_BLE_MESH_NODE */
615 
616 #ifdef CONFIG_BLE_MESH_PROVISIONER
617     /** Provisioner device UUID */
618     const uint8_t *prov_uuid;
619 
620     /** Primary element address of the provisioner */
621     const uint16_t prov_unicast_addr;
622 
623     /** Pre-incremental unicast address value to be assigned to the first device */
624     uint16_t       prov_start_address;
625 
626     /** Attention timer contained in Provisioning Invite PDU */
627     uint8_t        prov_attention;
628 
629     /** Provisioning Algorithm for the Provisioner */
630     uint8_t        prov_algorithm;
631 
632     /* NOTE: In order to avoid suffering brute-forcing attack (CVE-2020-26559).
633      * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners
634      * use an out-of-band mechanism to exchange the public keys.
635      */
636     /** Provisioner public key oob */
637     uint8_t        prov_pub_key_oob;
638 
639     /** Callback used to notify to set device OOB Public Key. Initialized by the stack. */
640     esp_ble_mesh_cb_t provisioner_prov_read_oob_pub_key;
641 
642     /* NOTE: The Bluetooth SIG recommends that mesh implementations enforce a randomly
643      * selected AuthValue using all of the available bits, where permitted by the
644      * implementation. A large entropy helps ensure that a brute-force of the AuthValue,
645      * even a static AuthValue, cannot normally be completed in a reasonable time (CVE-2020-26557).
646      *
647      * AuthValues selected using a cryptographically secure random or pseudorandom number
648      * generator and having the maximum permitted entropy (128-bits) will be most difficult
649      * to brute-force. AuthValues with reduced entropy or generated in a predictable manner
650      * will not grant the same level of protection against this vulnerability. Selecting a
651      * new AuthValue with each provisioning attempt can also make it more difficult to launch
652      * a brute-force attack by requiring the attacker to restart the search with each
653      * provisioning attempt (CVE-2020-26556).
654      */
655     /** Provisioner static oob value */
656     uint8_t        *prov_static_oob_val;
657     /** Provisioner static oob value length */
658     uint8_t         prov_static_oob_len;
659 
660     /** Callback used to notify to input number/string. Initialized by the stack. */
661     esp_ble_mesh_cb_t provisioner_prov_input;
662     /** Callback used to output number/string. Initialized by the stack. */
663     esp_ble_mesh_cb_t provisioner_prov_output;
664 
665     /** Key refresh and IV update flag */
666     uint8_t        flags;
667 
668     /** IV index */
669     uint32_t       iv_index;
670 
671     /** Callback used to indicate that link is opened. Initialized by the stack. */
672     esp_ble_mesh_cb_t  provisioner_link_open;
673     /** Callback used to indicate that link is closed. Initialized by the stack. */
674     esp_ble_mesh_cb_t  provisioner_link_close;
675     /** Callback used to indicate that a device is provisioned. Initialized by the stack. */
676     esp_ble_mesh_cb_t  provisioner_prov_comp;
677 #endif /* CONFIG_BLE_MESH_PROVISIONER */
678 } esp_ble_mesh_prov_t;
679 
680 /** Node Composition data context.
681  *  This structure is associated with struct bt_mesh_comp in mesh_access.h
682  */
683 typedef struct {
684     uint16_t cid;   /*!< 16-bit SIG-assigned company identifier */
685     uint16_t pid;   /*!< 16-bit vendor-assigned product identifier */
686     uint16_t vid;   /*!< 16-bit vendor-assigned product version identifier */
687 
688     size_t element_count;           /*!< Element count */
689     esp_ble_mesh_elem_t *elements;  /*!< A sequence of elements */
690 } esp_ble_mesh_comp_t;
691 
692 /*!< This enum value is the role of the device */
693 typedef enum {
694     ROLE_NODE = 0,
695     ROLE_PROVISIONER,
696     ROLE_FAST_PROV,
697 } esp_ble_mesh_dev_role_t;
698 
699 /*!< Flag which will be set when device is going to be added. */
700 typedef uint8_t esp_ble_mesh_dev_add_flag_t;
701 #define ADD_DEV_RM_AFTER_PROV_FLAG  BIT(0)  /*!< Device will be removed from queue after provisioned successfully */
702 #define ADD_DEV_START_PROV_NOW_FLAG BIT(1)  /*!< Start provisioning device immediately */
703 #define ADD_DEV_FLUSHABLE_DEV_FLAG  BIT(2)  /*!< Device can be remove when queue is full and new device is going to added */
704 
705 /** Information of the device which is going to be added for provisioning. */
706 typedef struct {
707     esp_ble_mesh_bd_addr_t addr;                 /*!< Device address */
708     esp_ble_mesh_addr_type_t addr_type;      /*!< Device address type */
709     uint8_t  uuid[16];                  /*!< Device UUID */
710     uint16_t oob_info;                  /*!< Device OOB Info */
711     /*!< ADD_DEV_START_PROV_NOW_FLAG shall not be set if the bearer has both PB-ADV and PB-GATT enabled */
712     esp_ble_mesh_prov_bearer_t bearer;  /*!< Provisioning Bearer */
713 } esp_ble_mesh_unprov_dev_add_t;
714 
715 #define DEL_DEV_ADDR_FLAG BIT(0)
716 #define DEL_DEV_UUID_FLAG BIT(1)
717 /** Information of the device which is going to be deleted. */
718 typedef struct {
719     union {
720         struct {
721             esp_ble_mesh_bd_addr_t addr;         /*!< Device address */
722             esp_ble_mesh_addr_type_t addr_type;  /*!< Device address type */
723         };
724         uint8_t uuid[16];                   /*!< Device UUID */
725     };
726     uint8_t flag;                           /*!< BIT0: device address; BIT1: device UUID */
727 } esp_ble_mesh_device_delete_t;
728 
729 #define PROV_DATA_NET_IDX_FLAG  BIT(0)
730 #define PROV_DATA_FLAGS_FLAG    BIT(1)
731 #define PROV_DATA_IV_INDEX_FLAG BIT(2)
732 /** Information of the provisioner which is going to be updated. */
733 typedef struct {
734     union {
735         uint16_t net_idx;   /*!< NetKey Index */
736         uint8_t  flags;     /*!< Flags */
737         uint32_t iv_index;  /*!< IV Index */
738     };
739     uint8_t flag;           /*!< BIT0: net_idx; BIT1: flags; BIT2: iv_index */
740 } esp_ble_mesh_prov_data_info_t;
741 
742 /** Information of the provisioned node */
743 typedef struct {
744     /* Device information */
745     esp_ble_mesh_bd_addr_t   addr;      /*!< Node device address */
746     esp_ble_mesh_addr_type_t addr_type; /*!< Node device address type */
747     uint8_t  dev_uuid[16];  /*!< Device UUID */
748     uint16_t oob_info;      /*!< Node OOB information */
749 
750     /* Provisioning information */
751     uint16_t unicast_addr;  /*!< Node unicast address */
752     uint8_t  element_num;   /*!< Node element number */
753     uint16_t net_idx;       /*!< Node NetKey Index */
754     uint8_t  flags;         /*!< Node key refresh flag and iv update flag */
755     uint32_t iv_index;      /*!< Node IV Index */
756     uint8_t  dev_key[16];   /*!< Node device key */
757 
758     /* Additional information */
759     char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN + 1]; /*!< Node name */
760     uint16_t comp_length;  /*!< Length of Composition Data */
761     uint8_t *comp_data;    /*!< Value of Composition Data */
762 } __attribute__((packed)) esp_ble_mesh_node_t;
763 
764 /** Context of fast provisioning which need to be set. */
765 typedef struct {
766     uint16_t unicast_min;   /*!< Minimum unicast address used for fast provisioning */
767     uint16_t unicast_max;   /*!< Maximum unicast address used for fast provisioning */
768     uint16_t net_idx;       /*!< Netkey index used for fast provisioning */
769     uint8_t  flags;         /*!< Flags used for fast provisioning */
770     uint32_t iv_index;      /*!< IV Index used for fast provisioning */
771     uint8_t  offset;        /*!< Offset of the UUID to be compared */
772     uint8_t  match_len;     /*!< Length of the UUID to be compared */
773     uint8_t  match_val[16]; /*!< Value of UUID to be compared */
774 } esp_ble_mesh_fast_prov_info_t;
775 
776 /*!< This enum value is the action of fast provisioning */
777 typedef enum {
778     FAST_PROV_ACT_NONE,
779     FAST_PROV_ACT_ENTER,
780     FAST_PROV_ACT_SUSPEND,
781     FAST_PROV_ACT_EXIT,
782     FAST_PROV_ACT_MAX,
783 } esp_ble_mesh_fast_prov_action_t;
784 
785 /*!< This enum value is the type of proxy filter */
786 typedef enum {
787     PROXY_FILTER_WHITELIST,
788     PROXY_FILTER_BLACKLIST,
789 } esp_ble_mesh_proxy_filter_type_t;
790 
791 /*!< Provisioner heartbeat filter type */
792 #define ESP_BLE_MESH_HEARTBEAT_FILTER_ACCEPTLIST    0x00
793 #define ESP_BLE_MESH_HEARTBEAT_FILTER_REJECTLIST    0x01
794 
795 /*!< Provisioner heartbeat filter operation */
796 #define ESP_BLE_MESH_HEARTBEAT_FILTER_ADD           0x00
797 #define ESP_BLE_MESH_HEARTBEAT_FILTER_REMOVE        0x01
798 
799 /** Context of Provisioner heartbeat filter information to be set */
800 typedef struct {
801     uint16_t hb_src;    /*!< Heartbeat source address (unicast address) */
802     uint16_t hb_dst;    /*!< Heartbeat destination address (unicast address or group address) */
803 } esp_ble_mesh_heartbeat_filter_info_t;
804 
805 /*!< This enum value is the event of node/provisioner/fast provisioning */
806 typedef enum {
807     ESP_BLE_MESH_PROV_REGISTER_COMP_EVT,                        /*!< Initialize BLE Mesh provisioning capabilities and internal data information completion event */
808     ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT,             /*!< Set the unprovisioned device name completion event */
809     ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT,                     /*!< Enable node provisioning functionality completion event */
810     ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT,                    /*!< Disable node provisioning functionality completion event */
811     ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT,                       /*!< Establish a BLE Mesh link event */
812     ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT,                      /*!< Close a BLE Mesh link event */
813     ESP_BLE_MESH_NODE_PROV_OOB_PUB_KEY_EVT,                     /*!< Generate Node input OOB public key event */
814     ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT,                   /*!< Generate Node Output Number event */
815     ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT,                   /*!< Generate Node Output String event */
816     ESP_BLE_MESH_NODE_PROV_INPUT_EVT,                           /*!< Event requiring the user to input a number or string */
817     ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT,                        /*!< Provisioning done event */
818     ESP_BLE_MESH_NODE_PROV_RESET_EVT,                           /*!< Provisioning reset event */
819     ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT,            /*!< Node set oob public key completion event */
820     ESP_BLE_MESH_NODE_PROV_INPUT_NUMBER_COMP_EVT,               /*!< Node input number completion event */
821     ESP_BLE_MESH_NODE_PROV_INPUT_STRING_COMP_EVT,               /*!< Node input string completion event */
822     ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT,           /*!< Enable BLE Mesh Proxy Identity advertising completion event */
823     ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT,               /*!< Enable BLE Mesh GATT Proxy Service completion event */
824     ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT,              /*!< Disable BLE Mesh GATT Proxy Service completion event */
825     ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT,               /*!< Node add NetKey locally completion event */
826     ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT,               /*!< Node add AppKey locally completion event */
827     ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT,           /*!< Node bind AppKey to model locally completion event */
828     ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT,              /*!< Provisioner enable provisioning functionality completion event */
829     ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT,             /*!< Provisioner disable provisioning functionality completion event */
830     ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT,           /*!< Provisioner receives unprovisioned device beacon event */
831     ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT,         /*!< Provisioner read unprovisioned device OOB public key event */
832     ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT,                    /*!< Provisioner input value for provisioning procedure event */
833     ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT,                   /*!< Provisioner output value for provisioning procedure event */
834     ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT,                /*!< Provisioner establish a BLE Mesh link event */
835     ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT,               /*!< Provisioner close a BLE Mesh link event */
836     ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT,                 /*!< Provisioner provisioning done event */
837     ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT,           /*!< Provisioner add a device to the list which contains devices that are waiting/going to be provisioned completion event */
838     ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT,       /*!< Provisioner start to provision an unprovisioned device completion event */
839     ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT,               /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */
840     ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT,       /*!< Provisioner set the value to be compared with part of the unprovisioned device UUID completion event */
841     ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT,       /*!< Provisioner set net_idx/flags/iv_index used for provisioning completion event */
842     ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT,     /*!< Provisioner set static oob value used for provisioning completion event */
843     ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT,    /*!< Provisioner set unicast address of primary element completion event */
844     ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT,    /*!< Provisioner read unprovisioned device OOB public key completion event */
845     ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT,        /*!< Provisioner input number completion event */
846     ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT,        /*!< Provisioner input string completion event */
847     ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT,            /*!< Provisioner set node name completion event */
848     ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT,        /*!< Provisioner add local app key completion event */
849     ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT,     /*!< Provisioner update local app key completion event */
850     ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT,    /*!< Provisioner bind local model with local app key completion event */
851     ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT,        /*!< Provisioner add local network key completion event */
852     ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT,     /*!< Provisioner update local network key completion event */
853     ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT,     /*!< Provisioner store node composition data completion event */
854     ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT,    /*!< Provisioner delete node with uuid completion event */
855     ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT,    /*!< Provisioner delete node with unicast address completion event */
856     ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT,     /*!< Provisioner start to receive heartbeat message completion event */
857     ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT, /*!< Provisioner set the heartbeat filter type completion event */
858     ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT, /*!< Provisioner set the heartbeat filter information completion event */
859     ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT,         /*!< Provisioner receive heartbeat message event */
860     ESP_BLE_MESH_PROVISIONER_DIRECT_ERASE_SETTINGS_COMP_EVT,        /*!< Provisioner directly erase settings completion event */
861     ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT,     /*!< Provisioner open settings with index completion event */
862     ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT,       /*!< Provisioner open settings with user id completion event */
863     ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT,    /*!< Provisioner close settings with index completion event */
864     ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT,      /*!< Provisioner close settings with user id completion event */
865     ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT,   /*!< Provisioner delete settings with index completion event */
866     ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT,     /*!< Provisioner delete settings with user id completion event */
867     ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT,                   /*!< Set fast provisioning information (e.g. unicast address range, net_idx, etc.) completion event */
868     ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT,                 /*!< Set fast provisioning action completion event */
869     ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT,                    /*!< Receive Heartbeat message event */
870     ESP_BLE_MESH_LPN_ENABLE_COMP_EVT,                           /*!< Enable Low Power Node completion event */
871     ESP_BLE_MESH_LPN_DISABLE_COMP_EVT,                          /*!< Disable Low Power Node completion event */
872     ESP_BLE_MESH_LPN_POLL_COMP_EVT,                             /*!< Low Power Node send Friend Poll completion event */
873     ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT,                  /*!< Low Power Node establishes friendship event */
874     ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT,                  /*!< Low Power Node terminates friendship event */
875     ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT,               /*!< Friend Node establishes friendship event */
876     ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT,               /*!< Friend Node terminates friendship event */
877     ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT,                 /*!< Proxy Client receives Network ID advertising packet event */
878     ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT,                    /*!< Proxy Client establishes connection successfully event */
879     ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT,                 /*!< Proxy Client terminates connection successfully event */
880     ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT,           /*!< Proxy Client receives Proxy Filter Status event */
881     ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT,                 /*!< Proxy Client connect completion event */
882     ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT,              /*!< Proxy Client disconnect completion event */
883     ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT,         /*!< Proxy Client set filter type completion event */
884     ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT,         /*!< Proxy Client add filter address completion event */
885     ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT,      /*!< Proxy Client remove filter address completion event */
886     ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT,                    /*!< Proxy Server establishes connection successfully event */
887     ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT,                 /*!< Proxy Server terminates connection successfully event */
888     ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT,           /*!< Local model subscribes group address completion event */
889     ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT,         /*!< Local model unsubscribes group address completion event */
890     ESP_BLE_MESH_DEINIT_MESH_COMP_EVT,                          /*!< De-initialize BLE Mesh stack completion event */
891     ESP_BLE_MESH_PROV_EVT_MAX,
892 } esp_ble_mesh_prov_cb_event_t;
893 
894 /**
895  * @brief BLE Mesh Node/Provisioner callback parameters union
896  */
897 typedef union {
898     /**
899      * @brief ESP_BLE_MESH_PROV_REGISTER_COMP_EVT
900      */
901     struct ble_mesh_prov_register_comp_param {
902         int err_code;                           /*!< Indicate the result of BLE Mesh initialization */
903     } prov_register_comp;                       /*!< Event parameter of ESP_BLE_MESH_PROV_REGISTER_COMP_EVT */
904     /**
905      * @brief ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT
906      */
907     struct ble_mesh_set_unprov_dev_name_comp_param {
908         int err_code;                           /*!< Indicate the result of setting BLE Mesh device name */
909     } node_set_unprov_dev_name_comp;            /*!< Event parameter of ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT */
910     /**
911      * @brief ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT
912      */
913     struct ble_mesh_prov_enable_comp_param {
914         int err_code;                           /*!< Indicate the result of enabling BLE Mesh device */
915     } node_prov_enable_comp;                    /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT */
916     /**
917      * @brief ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT
918      */
919     struct ble_mesh_prov_disable_comp_param {
920         int err_code;                           /*!< Indicate the result of disabling BLE Mesh device */
921     } node_prov_disable_comp;                   /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT */
922     /**
923      * @brief ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT
924      */
925     struct ble_mesh_link_open_evt_param {
926         esp_ble_mesh_prov_bearer_t bearer;      /*!< Type of the bearer used when device link is open */
927     } node_prov_link_open;                      /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT */
928     /**
929      * @brief ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT
930      */
931     struct ble_mesh_link_close_evt_param {
932         esp_ble_mesh_prov_bearer_t bearer;      /*!< Type of the bearer used when device link is closed */
933     } node_prov_link_close;                     /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT */
934     /**
935      * @brief ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT
936      */
937     struct ble_mesh_output_num_evt_param {
938         esp_ble_mesh_output_action_t action;    /*!< Action of Output OOB Authentication */
939         uint32_t number;                        /*!< Number of Output OOB Authentication  */
940     } node_prov_output_num;                     /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT */
941     /**
942      * @brief ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT
943      */
944     struct ble_mesh_output_str_evt_param {
945         char string[8];                         /*!< String of Output OOB Authentication */
946     } node_prov_output_str;                     /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT */
947     /**
948      * @brief ESP_BLE_MESH_NODE_PROV_INPUT_EVT
949      */
950     struct ble_mesh_input_evt_param {
951         esp_ble_mesh_input_action_t action;     /*!< Action of Input OOB Authentication */
952         uint8_t size;                           /*!< Size of Input OOB Authentication */
953     } node_prov_input;                          /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_EVT */
954     /**
955      * @brief ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT
956      */
957     struct ble_mesh_provision_complete_evt_param {
958         uint16_t net_idx;                       /*!< NetKey Index */
959         uint8_t  net_key[16];                   /*!< NetKey */
960         uint16_t addr;                          /*!< Primary address */
961         uint8_t  flags;                         /*!< Flags */
962         uint32_t iv_index;                      /*!< IV Index */
963     } node_prov_complete;                       /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT */
964     /**
965      * @brief ESP_BLE_MESH_NODE_PROV_RESET_EVT
966      */
967     struct ble_mesh_provision_reset_param {
968 
969     } node_prov_reset;                          /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_RESET_EVT */
970     /**
971      * @brief ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT
972      */
973     struct ble_mesh_set_oob_pub_key_comp_param {
974         int err_code;                           /*!< Indicate the result of setting OOB Public Key */
975     } node_prov_set_oob_pub_key_comp;           /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT */
976     /**
977      * @brief ESP_BLE_MESH_NODE_PROV_INPUT_NUM_COMP_EVT
978      */
979     struct ble_mesh_input_number_comp_param {
980         int err_code;                           /*!< Indicate the result of inputting number */
981     } node_prov_input_num_comp;                 /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_NUM_COMP_EVT */
982     /**
983      * @brief ESP_BLE_MESH_NODE_PROV_INPUT_STR_COMP_EVT
984      */
985     struct ble_mesh_input_string_comp_param {
986         int err_code;                           /*!< Indicate the result of inputting string */
987     } node_prov_input_str_comp;                 /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_STR_COMP_EVT */
988     /**
989      * @brief ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT
990      */
991     struct ble_mesh_proxy_identity_enable_comp_param {
992         int err_code;                           /*!< Indicate the result of enabling Mesh Proxy advertising */
993     } node_proxy_identity_enable_comp;          /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT */
994     /**
995      * @brief ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT
996      */
997     struct ble_mesh_proxy_gatt_enable_comp_param {
998         int err_code;                           /*!< Indicate the result of enabling Mesh Proxy Service */
999     } node_proxy_gatt_enable_comp;              /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT */
1000     /**
1001      * @brief ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT
1002      */
1003     struct ble_mesh_proxy_gatt_disable_comp_param {
1004         int err_code;                           /*!< Indicate the result of disabling Mesh Proxy Service */
1005     } node_proxy_gatt_disable_comp;             /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT */
1006     /**
1007      * @brief ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT
1008      */
1009     struct ble_mesh_node_add_local_net_key_comp_param {
1010         int err_code;                           /*!< Indicate the result of adding local NetKey by the node */
1011         uint16_t net_idx;                       /*!< NetKey Index */
1012     } node_add_net_key_comp;                    /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT */
1013     /**
1014      * @brief ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT
1015      */
1016     struct ble_mesh_node_add_local_app_key_comp_param {
1017         int err_code;                           /*!< Indicate the result of adding local AppKey by the node */
1018         uint16_t net_idx;                       /*!< NetKey Index */
1019         uint16_t app_idx;                       /*!< AppKey Index */
1020     } node_add_app_key_comp;                    /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT */
1021     /**
1022      * @brief ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT
1023      */
1024     struct ble_mesh_node_bind_local_mod_app_comp_param {
1025         int err_code;                           /*!< Indicate the result of binding AppKey with model by the node */
1026         uint16_t element_addr;                  /*!< Element address */
1027         uint16_t app_idx;                       /*!< AppKey Index */
1028         uint16_t company_id;                    /*!< Company ID */
1029         uint16_t model_id;                      /*!< Model ID */
1030     } node_bind_app_key_to_model_comp;          /*!< Event parameter of ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT */
1031     /**
1032      * @brief ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT
1033      */
1034     struct ble_mesh_provisioner_recv_unprov_adv_pkt_param {
1035         uint8_t  dev_uuid[16];                  /*!< Device UUID of the unprovisioned device */
1036         esp_ble_mesh_bd_addr_t addr;            /*!< Device address of the unprovisioned device */
1037         esp_ble_mesh_addr_type_t addr_type;     /*!< Device address type */
1038         uint16_t oob_info;                      /*!< OOB Info of the unprovisioned device */
1039         uint8_t  adv_type;                      /*!< Avertising type of the unprovisioned device */
1040         esp_ble_mesh_prov_bearer_t bearer;      /*!< Bearer of the unprovisioned device */
1041         int8_t   rssi;                          /*!< RSSI of the received advertising packet */
1042     } provisioner_recv_unprov_adv_pkt;          /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT */
1043     /**
1044      * @brief ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT
1045      */
1046     struct ble_mesh_provisioner_prov_enable_comp_param {
1047         int err_code;                           /*!< Indicate the result of enabling BLE Mesh Provisioner */
1048     } provisioner_prov_enable_comp;             /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT */
1049     /**
1050      * @brief ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT
1051      */
1052     struct ble_mesh_provisioner_prov_disable_comp_param {
1053         int err_code;                           /*!< Indicate the result of disabling BLE Mesh Provisioner */
1054     } provisioner_prov_disable_comp;            /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT */
1055     /**
1056      * @brief ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT
1057      */
1058     struct ble_mesh_provisioner_link_open_evt_param {
1059         esp_ble_mesh_prov_bearer_t bearer;      /*!< Type of the bearer used when Provisioner link is opened */
1060     } provisioner_prov_link_open;               /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT */
1061     /**
1062      * @brief ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT
1063      */
1064     struct ble_mesh_provisioner_prov_read_oob_pub_key_evt_param {
1065         uint8_t link_idx;                       /*!< Index of the provisioning link */
1066     } provisioner_prov_read_oob_pub_key;        /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT */
1067     /**
1068      * @brief ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT
1069      */
1070     struct ble_mesh_provisioner_prov_input_evt_param {
1071         esp_ble_mesh_oob_method_t method;       /*!< Method of device Output OOB Authentication */
1072         esp_ble_mesh_output_action_t action;    /*!< Action of device Output OOB Authentication */
1073         uint8_t size;                           /*!< Size of device Output OOB Authentication */
1074         uint8_t link_idx;                       /*!< Index of the provisioning link */
1075     } provisioner_prov_input;                   /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT */
1076     /**
1077      * @brief ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT
1078      */
1079     struct ble_mesh_provisioner_prov_output_evt_param {
1080         esp_ble_mesh_oob_method_t method;       /*!< Method of device Input OOB Authentication */
1081         esp_ble_mesh_input_action_t action;     /*!< Action of device Input OOB Authentication */
1082         uint8_t size;                           /*!< Size of device Input OOB Authentication */
1083         uint8_t link_idx;                       /*!< Index of the provisioning link */
1084         union {
1085             char string[8];                     /*!< String output by the Provisioner */
1086             uint32_t number;                    /*!< Number output by the Provisioner */
1087         };
1088     } provisioner_prov_output;                  /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT */
1089     /**
1090      * @brief ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT
1091      */
1092     struct ble_mesh_provisioner_link_close_evt_param {
1093         esp_ble_mesh_prov_bearer_t bearer;      /*!< Type of the bearer used when Provisioner link is closed */
1094         uint8_t reason;                         /*!< Reason of the closed provisioning link */
1095     } provisioner_prov_link_close;              /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT */
1096     /**
1097      * @brief ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT
1098      */
1099     struct ble_mesh_provisioner_prov_comp_param {
1100         uint16_t node_idx;                      /*!< Index of the provisioned device */
1101         esp_ble_mesh_octet16_t device_uuid;     /*!< Device UUID of the provisioned device */
1102         uint16_t unicast_addr;                  /*!< Primary address of the provisioned device */
1103         uint8_t element_num;                    /*!< Element count of the provisioned device */
1104         uint16_t netkey_idx;                    /*!< NetKey Index of the provisioned device */
1105     } provisioner_prov_complete;                /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT */
1106     /**
1107      * @brief ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT
1108      */
1109     struct ble_mesh_provisioner_add_unprov_dev_comp_param {
1110         int err_code;                           /*!< Indicate the result of adding device into queue by the Provisioner */
1111     } provisioner_add_unprov_dev_comp;          /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT */
1112     /**
1113      * @brief ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT
1114      */
1115     struct ble_mesh_provisioner_prov_dev_with_addr_comp_param {
1116         int err_code;                           /*!< Indicate the result of Provisioner starting to provision a device */
1117     } provisioner_prov_dev_with_addr_comp;      /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT */
1118     /**
1119      * @brief ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT
1120      */
1121     struct ble_mesh_provisioner_delete_dev_comp_param {
1122         int err_code;                           /*!< Indicate the result of deleting device by the Provisioner */
1123     } provisioner_delete_dev_comp;              /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT */
1124     /**
1125      * @brief ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT
1126      */
1127     struct ble_mesh_provisioner_set_dev_uuid_match_comp_param {
1128         int err_code;                           /*!< Indicate the result of setting Device UUID match value by the Provisioner */
1129     } provisioner_set_dev_uuid_match_comp;      /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT */
1130     /**
1131      * @brief ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT
1132      */
1133     struct ble_mesh_provisioner_set_prov_data_info_comp_param {
1134         int err_code;                           /*!< Indicate the result of setting provisioning info by the Provisioner */
1135     } provisioner_set_prov_data_info_comp;      /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT */
1136     /**
1137      * @brief ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT
1138      */
1139     struct ble_mesh_provisioner_set_static_oob_val_comp_param {
1140         int err_code;                           /*!< Indicate the result of setting static oob value by the Provisioner */
1141     } provisioner_set_static_oob_val_comp;      /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT */
1142     /**
1143      * @brief ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT
1144      */
1145     struct ble_mesh_provisioner_set_primary_elem_addr_comp_param {
1146         int err_code;                           /*!< Indicate the result of setting unicast address of primary element by the Provisioner */
1147     } provisioner_set_primary_elem_addr_comp;   /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT */
1148     /**
1149      * @brief ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT
1150      */
1151     struct ble_mesh_provisioner_prov_read_oob_pub_key_comp_param {
1152         int err_code;                           /*!< Indicate the result of setting OOB Public Key by the Provisioner */
1153     } provisioner_prov_read_oob_pub_key_comp;   /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT */
1154     /**
1155      * @brief ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT
1156      */
1157     struct ble_mesh_provisioner_prov_input_num_comp_param {
1158         int err_code;                           /*!< Indicate the result of inputting number by the Provisioner */
1159     } provisioner_prov_input_num_comp;          /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT */
1160     /**
1161      * @brief ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT
1162      */
1163     struct ble_mesh_provisioner_prov_input_str_comp_param {
1164         int err_code;                           /*!< Indicate the result of inputting string by the Provisioner */
1165     } provisioner_prov_input_str_comp;          /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT */
1166     /**
1167      * @brief ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT
1168      */
1169     struct ble_mesh_provisioner_set_node_name_comp_param {
1170         int err_code;                           /*!< Indicate the result of setting provisioned device name by the Provisioner */
1171         uint16_t node_index;                    /*!< Index of the provisioned device */
1172     } provisioner_set_node_name_comp;           /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT */
1173     /**
1174      * @brief ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT
1175      */
1176     struct ble_mesh_provisioner_add_local_app_key_comp_param {
1177         int err_code;                           /*!< Indicate the result of adding local AppKey by the Provisioner */
1178         uint16_t net_idx;                       /*!< NetKey Index */
1179         uint16_t app_idx;                       /*!< AppKey Index */
1180     } provisioner_add_app_key_comp;             /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT */
1181     /**
1182      * @brief ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT
1183      */
1184     struct ble_mesh_provisioner_update_local_app_key_comp_param {
1185         int err_code;                           /*!< Indicate the result of updating local AppKey by the Provisioner */
1186         uint16_t net_idx;                       /*!< NetKey Index */
1187         uint16_t app_idx;                       /*!< AppKey Index */
1188     } provisioner_update_app_key_comp;          /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT */
1189     /**
1190      * @brief ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT
1191      */
1192     struct ble_mesh_provisioner_bind_local_mod_app_comp_param {
1193         int err_code;                           /*!< Indicate the result of binding AppKey with model by the Provisioner */
1194         uint16_t element_addr;                  /*!< Element address */
1195         uint16_t app_idx;                       /*!< AppKey Index */
1196         uint16_t company_id;                    /*!< Company ID */
1197         uint16_t model_id;                      /*!< Model ID */
1198     } provisioner_bind_app_key_to_model_comp;   /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT */
1199     /**
1200      * @brief ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT
1201      */
1202     struct ble_mesh_provisioner_add_local_net_key_comp_param {
1203         int err_code;                           /*!< Indicate the result of adding local NetKey by the Provisioner */
1204         uint16_t net_idx;                       /*!< NetKey Index */
1205     } provisioner_add_net_key_comp;             /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT */
1206     /**
1207      * @brief ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT
1208      */
1209     struct ble_mesh_provisioner_update_local_net_key_comp_param {
1210         int err_code;                           /*!< Indicate the result of updating local NetKey by the Provisioner */
1211         uint16_t net_idx;                       /*!< NetKey Index */
1212     } provisioner_update_net_key_comp;          /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT */
1213     /**
1214      * @brief ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT
1215      */
1216     struct ble_mesh_provisioner_store_node_comp_data_comp_param {
1217         int err_code;                           /*!< Indicate the result of storing node composition data by the Provisioner */
1218         uint16_t addr;                          /*!< Node element address */
1219     } provisioner_store_node_comp_data_comp;    /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT */
1220     /**
1221      * @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT
1222      */
1223     struct ble_mesh_provisioner_delete_node_with_uuid_comp_param {
1224         int err_code;                           /*!< Indicate the result of deleting node with uuid by the Provisioner */
1225         uint8_t uuid[16];                       /*!< Node device uuid */
1226     } provisioner_delete_node_with_uuid_comp;   /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT */
1227     /**
1228      * @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT
1229      */
1230     struct ble_mesh_provisioner_delete_node_with_addr_comp_param {
1231         int err_code;                           /*!< Indicate the result of deleting node with unicast address by the Provisioner */
1232         uint16_t unicast_addr;                  /*!< Node unicast address */
1233     } provisioner_delete_node_with_addr_comp;   /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */
1234     /**
1235      * @brief ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT
1236      */
1237     struct {
1238         int err_code;                           /*!< Indicate the result of enabling/disabling to receive heartbeat messages by the Provisioner */
1239         bool enable;                            /*!< Indicate enabling or disabling receiving heartbeat messages */
1240     } provisioner_enable_heartbeat_recv_comp;   /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT */
1241     /**
1242      * @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT
1243      */
1244     struct {
1245         int err_code;                               /*!< Indicate the result of setting the heartbeat filter type by the Provisioner */
1246         uint8_t type;                               /*!< Type of the filter used for receiving heartbeat messages */
1247     } provisioner_set_heartbeat_filter_type_comp;   /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT */
1248     /**
1249      * @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT
1250      */
1251     struct {
1252         int err_code;                               /*!< Indicate the result of setting the heartbeat filter address by the Provisioner */
1253         uint8_t  op;                                /*!< Operation (add, remove, clean) */
1254         uint16_t hb_src;                            /*!< Heartbeat source address */
1255         uint16_t hb_dst;                            /*!< Heartbeat destination address */
1256     } provisioner_set_heartbeat_filter_info_comp;   /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT */
1257     /**
1258      * @brief ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT
1259      */
1260     struct {
1261         uint16_t hb_src;            /*!< Heartbeat source address */
1262         uint16_t hb_dst;            /*!< Heartbeat destination address */
1263         uint8_t  init_ttl;          /*!< Heartbeat InitTTL */
1264         uint8_t  rx_ttl;            /*!< Heartbeat RxTTL */
1265         uint8_t  hops;              /*!< Heartbeat hops (InitTTL - RxTTL + 1) */
1266         uint16_t feature;           /*!< Bit field of currently active features of the node */
1267         int8_t   rssi;              /*!< RSSI of the heartbeat message */
1268     } provisioner_recv_heartbeat;   /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT */
1269     /**
1270      * @brief ESP_BLE_MESH_PROVISIONER_DIRECT_ERASE_SETTINGS_COMP_EVT
1271      */
1272     struct {
1273         int err_code;                           /*!< Indicate the result of directly erasing settings by the Provisioner */
1274     } provisioner_direct_erase_settings_comp;   /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DIRECT_ERASE_SETTINGS_COMP_EVT */
1275     /**
1276      * @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT
1277      */
1278     struct {
1279         int err_code;                               /*!< Indicate the result of opening settings with index by the Provisioner */
1280         uint8_t index;                              /*!< Index of Provisioner settings */
1281     } provisioner_open_settings_with_index_comp;    /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT */
1282     /**
1283      * @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT
1284      */
1285     struct {
1286         int err_code;                                   /*!< Indicate the result of opening settings with user id by the Provisioner */
1287         uint8_t index;                                  /*!< Index of Provisioner settings */
1288         char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];   /*!< Provisioner settings user id */
1289     } provisioner_open_settings_with_uid_comp;          /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT */
1290     /**
1291      * @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT
1292      */
1293     struct {
1294         int err_code;                               /*!< Indicate the result of closing settings with index by the Provisioner */
1295         uint8_t index;                              /*!< Index of Provisioner settings */
1296     } provisioner_close_settings_with_index_comp;   /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT */
1297     /**
1298      * @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT
1299      */
1300     struct {
1301         int err_code;                                   /*!< Indicate the result of closing settings with user id by the Provisioner */
1302         uint8_t index;                                  /*!< Index of Provisioner settings */
1303         char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];   /*!< Provisioner settings user id */
1304     } provisioner_close_settings_with_uid_comp;         /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT */
1305     /**
1306      * @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT
1307      */
1308     struct {
1309         int err_code;                               /*!< Indicate the result of deleting settings with index by the Provisioner */
1310         uint8_t index;                              /*!< Index of Provisioner settings */
1311     } provisioner_delete_settings_with_index_comp;  /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT */
1312     /**
1313      * @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT
1314      */
1315     struct {
1316         int err_code;                                   /*!< Indicate the result of deleting settings with user id by the Provisioner */
1317         uint8_t index;                                  /*!< Index of Provisioner settings */
1318         char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];   /*!< Provisioner settings user id */
1319     } provisioner_delete_settings_with_uid_comp;        /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT */
1320     /**
1321      * @brief ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT
1322      */
1323     struct ble_mesh_set_fast_prov_info_comp_param {
1324         uint8_t status_unicast;                 /*!< Indicate the result of setting unicast address range of fast provisioning */
1325         uint8_t status_net_idx;                 /*!< Indicate the result of setting NetKey Index of fast provisioning */
1326         uint8_t status_match;                   /*!< Indicate the result of setting matching Device UUID of fast provisioning */
1327     } set_fast_prov_info_comp;                  /*!< Event parameter of ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT */
1328     /**
1329      * @brief ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT
1330      */
1331     struct ble_mesh_set_fast_prov_action_comp_param {
1332         uint8_t status_action;                  /*!< Indicate the result of setting action of fast provisioning */
1333     } set_fast_prov_action_comp;                /*!< Event parameter of ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT */
1334     /**
1335      * @brief ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT
1336      */
1337     struct ble_mesh_heartbeat_msg_recv_param {
1338         uint8_t  hops;                          /*!< Heartbeat hops (InitTTL - RxTTL + 1) */
1339         uint16_t feature;                       /*!< Bit field of currently active features of the node */
1340     } heartbeat_msg_recv;                       /*!< Event parameter of ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT */
1341     /**
1342      * @brief ESP_BLE_MESH_LPN_ENABLE_COMP_EVT
1343      */
1344     struct ble_mesh_lpn_enable_comp_param {
1345         int err_code;                           /*!< Indicate the result of enabling LPN functionality */
1346     } lpn_enable_comp;                          /*!< Event parameter of ESP_BLE_MESH_LPN_ENABLE_COMP_EVT */
1347     /**
1348      * @brief ESP_BLE_MESH_LPN_DISABLE_COMP_EVT
1349      */
1350     struct ble_mesh_lpn_disable_comp_param {
1351         int err_code;                           /*!< Indicate the result of disabling LPN functionality */
1352     } lpn_disable_comp;                         /*!< Event parameter of ESP_BLE_MESH_LPN_DISABLE_COMP_EVT */
1353     /**
1354      * @brief ESP_BLE_MESH_LPN_POLL_COMP_EVT
1355      */
1356     struct ble_mesh_lpn_poll_comp_param {
1357         int err_code;                           /*!< Indicate the result of sending Friend Poll */
1358     } lpn_poll_comp;                            /*!< Event parameter of ESP_BLE_MESH_LPN_POLL_COMP_EVT */
1359     /**
1360      * @brief ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT
1361      */
1362     struct ble_mesh_lpn_friendship_establish_param {
1363         uint16_t friend_addr;                   /*!< Friend Node unicast address */
1364     } lpn_friendship_establish;                 /*!< Event parameter of ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT */
1365     /**
1366      * @brief ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT
1367      */
1368     struct ble_mesh_lpn_friendship_terminate_param {
1369         uint16_t friend_addr;                   /*!< Friend Node unicast address */
1370     } lpn_friendship_terminate;                 /*!< Event parameter of ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT */
1371     /**
1372      * @brief ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT
1373      */
1374     struct ble_mesh_friend_friendship_establish_param {
1375         uint16_t lpn_addr;                      /*!< Low Power Node unicast address */
1376     } frnd_friendship_establish;                /*!< Event parameter of ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT */
1377     /**
1378      * @brief ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT
1379      */
1380     struct ble_mesh_friend_friendship_terminate_param {
1381         uint16_t lpn_addr;                      /*!< Low Power Node unicast address */
1382         /** This enum value is the reason of friendship termination on the friend node side */
1383         enum {
1384             ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_ESTABLISH_FAIL,  /*!< Friend Offer has been sent, but Friend Offer is not received within 1 second, friendship fails to be established */
1385             ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_POLL_TIMEOUT,    /*!< Friendship is established, PollTimeout timer expires and no Friend Poll/Sub Add/Sub Remove is received */
1386             ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_RECV_FRND_REQ,   /*!< Receive Friend Request from existing Low Power Node */
1387             ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_RECV_FRND_CLEAR, /*!< Receive Friend Clear from other friend node */
1388             ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_DISABLE,         /*!< Friend feature disabled or corresponding NetKey is deleted */
1389         } reason;                               /*!< Friendship terminated reason */
1390     } frnd_friendship_terminate;                /*!< Event parameter of ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT */
1391     /**
1392      * @brief ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT
1393      */
1394     struct ble_mesh_proxy_client_recv_adv_pkt_param {
1395         esp_ble_mesh_bd_addr_t addr;            /*!< Device address */
1396         esp_ble_mesh_addr_type_t addr_type;     /*!< Device address type */
1397         uint16_t net_idx;                       /*!< Network ID related NetKey Index */
1398         uint8_t  net_id[8];                     /*!< Network ID contained in the advertising packet */
1399         int8_t   rssi;                          /*!< RSSI of the received advertising packet */
1400     } proxy_client_recv_adv_pkt;                /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT */
1401     /**
1402      * @brief ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT
1403      */
1404     struct ble_mesh_proxy_client_connected_param {
1405         esp_ble_mesh_bd_addr_t addr;            /*!< Device address of the Proxy Server */
1406         esp_ble_mesh_addr_type_t addr_type;     /*!< Device address type */
1407         uint8_t conn_handle;                    /*!< Proxy connection handle */
1408         uint16_t net_idx;                       /*!< Corresponding NetKey Index */
1409     } proxy_client_connected;                   /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT */
1410     /**
1411      * @brief ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT
1412      */
1413     struct ble_mesh_proxy_client_disconnected_param {
1414         esp_ble_mesh_bd_addr_t addr;            /*!< Device address of the Proxy Server */
1415         esp_ble_mesh_addr_type_t addr_type;     /*!< Device address type */
1416         uint8_t conn_handle;                    /*!< Proxy connection handle */
1417         uint16_t net_idx;                       /*!< Corresponding NetKey Index */
1418         uint8_t reason;                         /*!< Proxy disconnect reason */
1419     } proxy_client_disconnected;                /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT */
1420     /**
1421      * @brief ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT
1422      */
1423     struct ble_mesh_proxy_client_recv_filter_status_param {
1424         uint8_t  conn_handle;                   /*!< Proxy connection handle */
1425         uint16_t server_addr;                   /*!< Proxy Server primary element address */
1426         uint16_t net_idx;                       /*!< Corresponding NetKey Index */
1427         uint8_t  filter_type;                   /*!< Proxy Server filter type(whitelist or blacklist) */
1428         uint16_t list_size;                     /*!< Number of addresses in the Proxy Server filter list */
1429     } proxy_client_recv_filter_status;          /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT */
1430     /**
1431      * @brief ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT
1432      */
1433     struct ble_mesh_proxy_client_connect_comp_param {
1434         int err_code;                           /*!< Indicate the result of Proxy Client connect */
1435         esp_ble_mesh_bd_addr_t addr;            /*!< Device address of the Proxy Server */
1436         esp_ble_mesh_addr_type_t addr_type;     /*!< Device address type */
1437         uint16_t net_idx;                       /*!< Corresponding NetKey Index */
1438     } proxy_client_connect_comp;                /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT */
1439     /**
1440      * @brief ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT
1441      */
1442     struct ble_mesh_proxy_client_disconnect_comp_param {
1443         int err_code;                           /*!< Indicate the result of Proxy Client disconnect */
1444         uint8_t conn_handle;                    /*!< Proxy connection handle */
1445     } proxy_client_disconnect_comp;             /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT */
1446     /**
1447      * @brief ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT
1448      */
1449     struct ble_mesh_proxy_client_set_filter_type_comp_param {
1450         int err_code;                           /*!< Indicate the result of Proxy Client set filter type */
1451         uint8_t conn_handle;                    /*!< Proxy connection handle */
1452         uint16_t net_idx;                       /*!< Corresponding NetKey Index */
1453     } proxy_client_set_filter_type_comp;        /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT */
1454     /**
1455      * @brief ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT
1456      */
1457     struct ble_mesh_proxy_client_add_filter_addr_comp_param {
1458         int err_code;                           /*!< Indicate the result of Proxy Client add filter address */
1459         uint8_t conn_handle;                    /*!< Proxy connection handle */
1460         uint16_t net_idx;                       /*!< Corresponding NetKey Index */
1461     } proxy_client_add_filter_addr_comp;        /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT */
1462     /**
1463      * @brief ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT
1464      */
1465     struct ble_mesh_proxy_client_remove_filter_addr_comp_param {
1466         int err_code;                           /*!< Indicate the result of Proxy Client remove filter address */
1467         uint8_t conn_handle;                    /*!< Proxy connection handle */
1468         uint16_t net_idx;                       /*!< Corresponding NetKey Index */
1469     } proxy_client_remove_filter_addr_comp;     /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT */
1470     /**
1471      * @brief ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT
1472      */
1473     struct ble_mesh_proxy_server_connected_param {
1474         uint8_t conn_handle;                    /*!< Proxy connection handle */
1475     } proxy_server_connected;                   /*!< Event parameter of ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT */
1476     /**
1477      * @brief ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT
1478      */
1479     struct ble_mesh_proxy_server_disconnected_param {
1480         uint8_t conn_handle;                    /*!< Proxy connection handle */
1481         uint8_t reason;                         /*!< Proxy disconnect reason */
1482     } proxy_server_disconnected;                /*!< Event parameter of ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT */
1483     /**
1484      * @brief ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT
1485      */
1486     struct ble_mesh_model_sub_group_addr_comp_param {
1487         int err_code;                           /*!< Indicate the result of local model subscribing group address */
1488         uint16_t element_addr;                  /*!< Element address */
1489         uint16_t company_id;                    /*!< Company ID */
1490         uint16_t model_id;                      /*!< Model ID */
1491         uint16_t group_addr;                    /*!< Group Address */
1492     } model_sub_group_addr_comp;                /*!< Event parameters of ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT */
1493     /**
1494      * @brief ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT
1495      */
1496     struct ble_mesh_model_unsub_group_addr_comp_param {
1497         int err_code;                           /*!< Indicate the result of local model unsubscribing group address */
1498         uint16_t element_addr;                  /*!< Element address */
1499         uint16_t company_id;                    /*!< Company ID */
1500         uint16_t model_id;                      /*!< Model ID */
1501         uint16_t group_addr;                    /*!< Group Address */
1502     } model_unsub_group_addr_comp;              /*!< Event parameters of ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT */
1503     /**
1504      * @brief ESP_BLE_MESH_DEINIT_MESH_COMP_EVT
1505      */
1506     struct ble_mesh_deinit_mesh_comp_param {
1507         int err_code;                           /*!< Indicate the result of BLE Mesh deinitialization */
1508     } deinit_mesh_comp;                         /*!< Event parameter of ESP_BLE_MESH_DEINIT_MESH_COMP_EVT */
1509 } esp_ble_mesh_prov_cb_param_t;
1510 
1511 /**
1512  * @brief BLE Mesh models related Model ID and Opcode definitions
1513  */
1514 
1515 /*!< Foundation Models */
1516 #define ESP_BLE_MESH_MODEL_ID_CONFIG_SRV                            0x0000
1517 #define ESP_BLE_MESH_MODEL_ID_CONFIG_CLI                            0x0001
1518 #define ESP_BLE_MESH_MODEL_ID_HEALTH_SRV                            0x0002
1519 #define ESP_BLE_MESH_MODEL_ID_HEALTH_CLI                            0x0003
1520 
1521 /*!< Models from the Mesh Model Specification */
1522 #define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV                         0x1000
1523 #define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI                         0x1001
1524 #define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV                         0x1002
1525 #define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_CLI                         0x1003
1526 #define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV                0x1004
1527 #define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI                0x1005
1528 #define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV                   0x1006
1529 #define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV             0x1007
1530 #define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI                   0x1008
1531 #define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV                   0x1009
1532 #define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV             0x100a
1533 #define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI                   0x100b
1534 #define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV                       0x100c
1535 #define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI                       0x100d
1536 #define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV                      0x100e
1537 #define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV                0x100f
1538 #define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI                      0x1010
1539 #define ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV                    0x1011
1540 #define ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV             0x1012
1541 #define ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV                     0x1013
1542 #define ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV                   0x1014
1543 #define ESP_BLE_MESH_MODEL_ID_GEN_PROP_CLI                          0x1015
1544 #define ESP_BLE_MESH_MODEL_ID_SENSOR_SRV                            0x1100
1545 #define ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV                      0x1101
1546 #define ESP_BLE_MESH_MODEL_ID_SENSOR_CLI                            0x1102
1547 #define ESP_BLE_MESH_MODEL_ID_TIME_SRV                              0x1200
1548 #define ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV                        0x1201
1549 #define ESP_BLE_MESH_MODEL_ID_TIME_CLI                              0x1202
1550 #define ESP_BLE_MESH_MODEL_ID_SCENE_SRV                             0x1203
1551 #define ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV                       0x1204
1552 #define ESP_BLE_MESH_MODEL_ID_SCENE_CLI                             0x1205
1553 #define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV                         0x1206
1554 #define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV                   0x1207
1555 #define ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI                         0x1208
1556 #define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV                   0x1300
1557 #define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV             0x1301
1558 #define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI                   0x1302
1559 #define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SRV                         0x1303
1560 #define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV                   0x1304
1561 #define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_CLI                         0x1305
1562 #define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV                    0x1306
1563 #define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SRV                         0x1307
1564 #define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV                   0x1308
1565 #define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_CLI                         0x1309
1566 #define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV                     0x130a
1567 #define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV                     0x130b
1568 #define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SRV                         0x130c
1569 #define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV                   0x130d
1570 #define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI                         0x130e
1571 #define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV                          0x130f
1572 #define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV                    0x1310
1573 #define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI                          0x1311
1574 
1575 /**
1576  * esp_ble_mesh_opcode_config_client_get_t belongs to esp_ble_mesh_opcode_t, this typedef is only
1577  * used to locate the opcodes used by esp_ble_mesh_config_client_get_state.
1578  * The following opcodes will only be used in the esp_ble_mesh_config_client_get_state function.
1579  */
1580 typedef uint32_t esp_ble_mesh_opcode_config_client_get_t;
1581 
1582 #define ESP_BLE_MESH_MODEL_OP_BEACON_GET                            ESP_BLE_MESH_MODEL_OP_2(0x80, 0x09) /*!< Config Beacon Get */
1583 #define ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET                  ESP_BLE_MESH_MODEL_OP_2(0x80, 0x08) /*!< Config Composition Data Get */
1584 #define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET                       ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0C) /*!< Config Default TTL Get */
1585 #define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET                        ESP_BLE_MESH_MODEL_OP_2(0x80, 0x12) /*!< Config GATT Proxy Get */
1586 #define ESP_BLE_MESH_MODEL_OP_RELAY_GET                             ESP_BLE_MESH_MODEL_OP_2(0x80, 0x26) /*!< Config Relay Get */
1587 #define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET                         ESP_BLE_MESH_MODEL_OP_2(0x80, 0x18) /*!< Config Model Publication Get */
1588 #define ESP_BLE_MESH_MODEL_OP_FRIEND_GET                            ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0F) /*!< Config Friend Get */
1589 #define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x38) /*!< Config Heartbeat Publication Get */
1590 #define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3a) /*!< Config Heartbeat Subscription Get */
1591 #define ESP_BLE_MESH_MODEL_OP_NET_KEY_GET                           ESP_BLE_MESH_MODEL_OP_2(0x80, 0x42) /*!< Config NetKey Get */
1592 #define ESP_BLE_MESH_MODEL_OP_APP_KEY_GET                           ESP_BLE_MESH_MODEL_OP_2(0x80, 0x01) /*!< Config AppKey Get */
1593 #define ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x46) /*!< Config Node Identity Get */
1594 #define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x29) /*!< Config SIG Model Subscription Get */
1595 #define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET                  ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2B) /*!< Config Vendor Model Subscription Get */
1596 #define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4B) /*!< Config SIG Model App Get */
1597 #define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET                  ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4D) /*!< Config Vendor Model App Get */
1598 #define ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET                 ESP_BLE_MESH_MODEL_OP_2(0x80, 0x15) /*!< Config Key Refresh Phase Get */
1599 #define ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET                   ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2D) /*!< Config Low Power Node PollTimeout Get */
1600 #define ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET                  ESP_BLE_MESH_MODEL_OP_2(0x80, 0x23) /*!< Config Network Transmit Get */
1601 
1602 /**
1603  * esp_ble_mesh_opcode_config_client_set_t belongs to esp_ble_mesh_opcode_t, this typedef is
1604  * only used to locate the opcodes used by esp_ble_mesh_config_client_set_state.
1605  * The following opcodes will only be used in the esp_ble_mesh_config_client_set_state function.
1606  */
1607 typedef uint32_t esp_ble_mesh_opcode_config_client_set_t;
1608 
1609 #define ESP_BLE_MESH_MODEL_OP_BEACON_SET                            ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0A) /*!< Config Beacon Set */
1610 #define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET                       ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0D) /*!< Config Default TTL Set */
1611 #define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET                        ESP_BLE_MESH_MODEL_OP_2(0x80, 0x13) /*!< Config GATT Proxy Set */
1612 #define ESP_BLE_MESH_MODEL_OP_RELAY_SET                             ESP_BLE_MESH_MODEL_OP_2(0x80, 0x27) /*!< Config Relay Set */
1613 #define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET                         ESP_BLE_MESH_MODEL_OP_1(0x03)       /*!< Config Model Publication Set */
1614 #define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD                         ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1B) /*!< Config Model Subscription Add */
1615 #define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD            ESP_BLE_MESH_MODEL_OP_2(0x80, 0x20) /*!< Config Model Subscription Virtual Address Add */
1616 #define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE                      ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1C) /*!< Config Model Subscription Delete */
1617 #define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE         ESP_BLE_MESH_MODEL_OP_2(0x80, 0x21) /*!< Config Model Subscription Virtual Address Delete */
1618 #define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE                   ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1E) /*!< Config Model Subscription Overwrite */
1619 #define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE      ESP_BLE_MESH_MODEL_OP_2(0x80, 0x22) /*!< Config Model Subscription Virtual Address Overwrite */
1620 #define ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD                           ESP_BLE_MESH_MODEL_OP_2(0x80, 0x40) /*!< Config NetKey Add */
1621 #define ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD                           ESP_BLE_MESH_MODEL_OP_1(0x00)       /*!< Config AppKey Add */
1622 #define ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND                        ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3D) /*!< Config Model App Bind */
1623 #define ESP_BLE_MESH_MODEL_OP_NODE_RESET                            ESP_BLE_MESH_MODEL_OP_2(0x80, 0x49) /*!< Config Node Reset */
1624 #define ESP_BLE_MESH_MODEL_OP_FRIEND_SET                            ESP_BLE_MESH_MODEL_OP_2(0x80, 0x10) /*!< Config Friend Set */
1625 #define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x39) /*!< Config Heartbeat Publication Set */
1626 #define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3B) /*!< Config Heartbeat Subscription Set */
1627 #define ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE                        ESP_BLE_MESH_MODEL_OP_2(0x80, 0x45) /*!< Config NetKey Update */
1628 #define ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE                        ESP_BLE_MESH_MODEL_OP_2(0x80, 0x41) /*!< Config NetKey Delete */
1629 #define ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE                        ESP_BLE_MESH_MODEL_OP_1(0x01)       /*!< Config AppKey Update */
1630 #define ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE                        ESP_BLE_MESH_MODEL_OP_2(0x80, 0x00) /*!< Config AppKey Delete */
1631 #define ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x47) /*!< Config Node Identity Set */
1632 #define ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET                 ESP_BLE_MESH_MODEL_OP_2(0x80, 0x16) /*!< Config Key Refresh Phase Set */
1633 #define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET            ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1A) /*!< Config Model Publication Virtual Address Set */
1634 #define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL                  ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1D) /*!< Config Model Subscription Delete All */
1635 #define ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND                      ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3F) /*!< Config Model App Unbind */
1636 #define ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET                  ESP_BLE_MESH_MODEL_OP_2(0x80, 0x24) /*!< Config Network Transmit Set */
1637 
1638 /**
1639  * esp_ble_mesh_opcode_config_status_t belongs to esp_ble_mesh_opcode_t, this typedef is only
1640  * used to locate the opcodes used by the Config Model messages
1641  * The following opcodes are used by the BLE Mesh Config Server Model internally to respond
1642  * to the Config Client Model's request messages.
1643  */
1644 typedef uint32_t esp_ble_mesh_opcode_config_status_t;
1645 
1646 #define ESP_BLE_MESH_MODEL_OP_BEACON_STATUS                         ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0B)
1647 #define ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_STATUS               ESP_BLE_MESH_MODEL_OP_1(0x02)
1648 #define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_STATUS                    ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0E)
1649 #define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_STATUS                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x14)
1650 #define ESP_BLE_MESH_MODEL_OP_RELAY_STATUS                          ESP_BLE_MESH_MODEL_OP_2(0x80, 0x28)
1651 #define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x80, 0x19)
1652 #define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1F)
1653 #define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_LIST                    ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2A)
1654 #define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_LIST                 ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2C)
1655 #define ESP_BLE_MESH_MODEL_OP_NET_KEY_STATUS                        ESP_BLE_MESH_MODEL_OP_2(0x80, 0x44)
1656 #define ESP_BLE_MESH_MODEL_OP_NET_KEY_LIST                          ESP_BLE_MESH_MODEL_OP_2(0x80, 0x43)
1657 #define ESP_BLE_MESH_MODEL_OP_APP_KEY_STATUS                        ESP_BLE_MESH_MODEL_OP_2(0x80, 0x03)
1658 #define ESP_BLE_MESH_MODEL_OP_APP_KEY_LIST                          ESP_BLE_MESH_MODEL_OP_2(0x80, 0x02)
1659 #define ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_STATUS                  ESP_BLE_MESH_MODEL_OP_2(0x80, 0x48)
1660 #define ESP_BLE_MESH_MODEL_OP_MODEL_APP_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3E)
1661 #define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_LIST                    ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4C)
1662 #define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_LIST                 ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4E)
1663 #define ESP_BLE_MESH_MODEL_OP_NODE_RESET_STATUS                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4A)
1664 #define ESP_BLE_MESH_MODEL_OP_FRIEND_STATUS                         ESP_BLE_MESH_MODEL_OP_2(0x80, 0x11)
1665 #define ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_STATUS              ESP_BLE_MESH_MODEL_OP_2(0x80, 0x17)
1666 #define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_STATUS                  ESP_BLE_MESH_MODEL_OP_1(0x06)
1667 #define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_STATUS                  ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3C)
1668 #define ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_STATUS                ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2E)
1669 #define ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_STATUS               ESP_BLE_MESH_MODEL_OP_2(0x80, 0x25)
1670 
1671 /**
1672  * This typedef is only used to indicate the status code contained in some of
1673  * the Configuration Server Model status message.
1674  */
1675 typedef uint8_t esp_ble_mesh_cfg_status_t;
1676 
1677 #define ESP_BLE_MESH_CFG_STATUS_SUCCESS                             0x00
1678 #define ESP_BLE_MESH_CFG_STATUS_INVALID_ADDRESS                     0x01
1679 #define ESP_BLE_MESH_CFG_STATUS_INVALID_MODEL                       0x02
1680 #define ESP_BLE_MESH_CFG_STATUS_INVALID_APPKEY                      0x03
1681 #define ESP_BLE_MESH_CFG_STATUS_INVALID_NETKEY                      0x04
1682 #define ESP_BLE_MESH_CFG_STATUS_INSUFFICIENT_RESOURCES              0x05
1683 #define ESP_BLE_MESH_CFG_STATUS_KEY_INDEX_ALREADY_STORED            0x06
1684 #define ESP_BLE_MESH_CFG_STATUS_INVALID_PUBLISH_PARAMETERS          0x07
1685 #define ESP_BLE_MESH_CFG_STATUS_NOT_A_SUBSCRIBE_MODEL               0x08
1686 #define ESP_BLE_MESH_CFG_STATUS_STORAGE_FAILURE                     0x09
1687 #define ESP_BLE_MESH_CFG_STATUS_FEATURE_NOT_SUPPORTED               0x0A
1688 #define ESP_BLE_MESH_CFG_STATUS_CANNOT_UPDATE                       0x0B
1689 #define ESP_BLE_MESH_CFG_STATUS_CANNOT_REMOVE                       0x0C
1690 #define ESP_BLE_MESH_CFG_STATUS_CANNOT_BIND                         0x0D
1691 #define ESP_BLE_MESH_CFG_STATUS_TEMP_UNABLE_TO_CHANGE_STATE         0x0E
1692 #define ESP_BLE_MESH_CFG_STATUS_CANNOT_SET                          0x0F
1693 #define ESP_BLE_MESH_CFG_STATUS_UNSPECIFIED_ERROR                   0x10
1694 #define ESP_BLE_MESH_CFG_STATUS_INVALID_BINDING                     0x11
1695 
1696 /**
1697  * esp_ble_mesh_opcode_health_client_get_t belongs to esp_ble_mesh_opcode_t, this typedef is
1698  * only used to locate the opcodes used by esp_ble_mesh_health_client_get_state.
1699  * The following opcodes will only be used in the esp_ble_mesh_health_client_get_state function.
1700  */
1701 typedef uint32_t esp_ble_mesh_opcode_health_client_get_t;
1702 
1703 #define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET                      ESP_BLE_MESH_MODEL_OP_2(0x80, 0x31) /*!< Health Fault Get */
1704 #define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x34) /*!< Health Period Get */
1705 #define ESP_BLE_MESH_MODEL_OP_ATTENTION_GET                         ESP_BLE_MESH_MODEL_OP_2(0x80, 0x04) /*!< Health Attention Get */
1706 
1707 /**
1708  * esp_ble_mesh_opcode_health_client_set_t belongs to esp_ble_mesh_opcode_t, this typedef is
1709  * only used to locate the opcodes used by esp_ble_mesh_health_client_set_state.
1710  * The following opcodes will only be used in the esp_ble_mesh_health_client_set_state function.
1711  */
1712 typedef uint32_t esp_ble_mesh_opcode_health_client_set_t;
1713 
1714 #define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR                    ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2F) /*!< Health Fault Clear */
1715 #define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK              ESP_BLE_MESH_MODEL_OP_2(0x80, 0x30) /*!< Health Fault Clear Unacknowledged */
1716 #define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x32) /*!< Health Fault Test */
1717 #define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK               ESP_BLE_MESH_MODEL_OP_2(0x80, 0x33) /*!< Health Fault Test Unacknowledged */
1718 #define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET                     ESP_BLE_MESH_MODEL_OP_2(0x80, 0x35) /*!< Health Period Set */
1719 #define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK               ESP_BLE_MESH_MODEL_OP_2(0x80, 0x36) /*!< Health Period Set Unacknowledged */
1720 #define ESP_BLE_MESH_MODEL_OP_ATTENTION_SET                         ESP_BLE_MESH_MODEL_OP_2(0x80, 0x05) /*!< Health Attention Set */
1721 #define ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK                   ESP_BLE_MESH_MODEL_OP_2(0x80, 0x06) /*!< Health Attention Set Unacknowledged */
1722 
1723 /**
1724  * esp_ble_mesh_health_model_status_t belongs to esp_ble_mesh_opcode_t, this typedef is
1725  * only used to locate the opcodes used by the Health Model messages.
1726  * The following opcodes are used by the BLE Mesh Health Server Model internally to
1727  * respond to the Health Client Model's request messages.
1728  */
1729 typedef uint32_t esp_ble_mesh_health_model_status_t;
1730 
1731 #define ESP_BLE_MESH_MODEL_OP_HEALTH_CURRENT_STATUS                 ESP_BLE_MESH_MODEL_OP_1(0x04)
1732 #define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_STATUS                   ESP_BLE_MESH_MODEL_OP_1(0x05)
1733 #define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_STATUS                  ESP_BLE_MESH_MODEL_OP_2(0x80, 0x37)
1734 #define ESP_BLE_MESH_MODEL_OP_ATTENTION_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x80, 0x07)
1735 
1736 /**
1737  * esp_ble_mesh_generic_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is
1738  * only used to locate the opcodes used by functions esp_ble_mesh_generic_client_get_state
1739  * & esp_ble_mesh_generic_client_set_state.
1740  */
1741 typedef uint32_t esp_ble_mesh_generic_message_opcode_t;
1742 
1743 /*!< Generic OnOff Message Opcode */
1744 #define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x01)
1745 #define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x02)
1746 #define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x03)
1747 #define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x82, 0x04)
1748 
1749 /*!< Generic Level Message Opcode */
1750 #define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_GET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x05)
1751 #define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x06)
1752 #define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x07)
1753 #define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x82, 0x08)
1754 #define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x09)
1755 #define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0A)
1756 #define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET                          ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0B)
1757 #define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0C)
1758 
1759 /*!< Generic Default Transition Time Message Opcode */
1760 #define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET                ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0D)
1761 #define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET                ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0E)
1762 #define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK          ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0F)
1763 #define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x10)
1764 
1765 /*!< Generic Power OnOff Message Opcode */
1766 #define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x11)
1767 #define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS                  ESP_BLE_MESH_MODEL_OP_2(0x82, 0x12)
1768 
1769 /*!< Generic Power OnOff Setup Message Opcode */
1770 #define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x13)
1771 #define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK               ESP_BLE_MESH_MODEL_OP_2(0x82, 0x14)
1772 
1773 /*!< Generic Power Level Message Opcode */
1774 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x15)
1775 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x16)
1776 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x17)
1777 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS                ESP_BLE_MESH_MODEL_OP_2(0x82, 0x18)
1778 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_GET                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x19)
1779 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1A)
1780 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_GET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1B)
1781 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1C)
1782 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_GET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1D)
1783 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS                ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1E)
1784 
1785 /*!< Generic Power Level Setup Message Opcode */
1786 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1F)
1787 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x20)
1788 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x21)
1789 #define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x22)
1790 
1791 /*!< Generic Battery Message Opcode */
1792 #define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_GET                       ESP_BLE_MESH_MODEL_OP_2(0x82, 0x23)
1793 #define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x24)
1794 
1795 /*!< Generic Location Message Opcode */
1796 #define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x25)
1797 #define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS                 ESP_BLE_MESH_MODEL_OP_1(0x40)
1798 #define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x26)
1799 #define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS                  ESP_BLE_MESH_MODEL_OP_2(0x82, 0x27)
1800 
1801 /*!< Generic Location Setup Message Opcode */
1802 #define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET                    ESP_BLE_MESH_MODEL_OP_1(0x41)
1803 #define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK              ESP_BLE_MESH_MODEL_OP_1(0x42)
1804 #define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x28)
1805 #define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK               ESP_BLE_MESH_MODEL_OP_2(0x82, 0x29)
1806 
1807 /*!< Generic Manufacturer Property Message Opcode */
1808 #define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_GET       ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2A)
1809 #define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_STATUS    ESP_BLE_MESH_MODEL_OP_1(0x43)
1810 #define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2B)
1811 #define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET         ESP_BLE_MESH_MODEL_OP_1(0x44)
1812 #define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET_UNACK   ESP_BLE_MESH_MODEL_OP_1(0x45)
1813 #define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_STATUS      ESP_BLE_MESH_MODEL_OP_1(0x46)
1814 
1815 /*!< Generic Admin Property Message Opcode */
1816 #define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2C)
1817 #define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS           ESP_BLE_MESH_MODEL_OP_1(0x47)
1818 #define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET                ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2D)
1819 #define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET                ESP_BLE_MESH_MODEL_OP_1(0x48)
1820 #define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK          ESP_BLE_MESH_MODEL_OP_1(0x49)
1821 #define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS             ESP_BLE_MESH_MODEL_OP_1(0x4A)
1822 
1823 /*!< Generic User Property Message Opcode */
1824 #define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET               ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2E)
1825 #define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS            ESP_BLE_MESH_MODEL_OP_1(0x4B)
1826 #define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2F)
1827 #define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET                 ESP_BLE_MESH_MODEL_OP_1(0x4C)
1828 #define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK           ESP_BLE_MESH_MODEL_OP_1(0x4D)
1829 #define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS              ESP_BLE_MESH_MODEL_OP_1(0x4E)
1830 
1831 /*!< Generic Client Property Message Opcode */
1832 #define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET             ESP_BLE_MESH_MODEL_OP_1(0x4F)
1833 #define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS          ESP_BLE_MESH_MODEL_OP_1(0x50)
1834 
1835 /**
1836  * esp_ble_mesh_sensor_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is
1837  * only used to locate the opcodes used by functions esp_ble_mesh_sensor_client_get_state
1838  * & esp_ble_mesh_sensor_client_set_state.
1839  */
1840 typedef uint32_t esp_ble_mesh_sensor_message_opcode_t;
1841 
1842 /*!< Sensor Message Opcode */
1843 #define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x30)
1844 #define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS              ESP_BLE_MESH_MODEL_OP_1(0x51)
1845 #define ESP_BLE_MESH_MODEL_OP_SENSOR_GET                            ESP_BLE_MESH_MODEL_OP_2(0x82, 0x31)
1846 #define ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS                         ESP_BLE_MESH_MODEL_OP_1(0x52)
1847 #define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x32)
1848 #define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS                  ESP_BLE_MESH_MODEL_OP_1(0x53)
1849 #define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x33)
1850 #define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS                  ESP_BLE_MESH_MODEL_OP_1(0x54)
1851 
1852 /*!< Sensor Setup Message Opcode */
1853 #define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x34)
1854 #define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET                    ESP_BLE_MESH_MODEL_OP_1(0x55)
1855 #define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK              ESP_BLE_MESH_MODEL_OP_1(0x56)
1856 #define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS                 ESP_BLE_MESH_MODEL_OP_1(0x57)
1857 #define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x35)
1858 #define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS                ESP_BLE_MESH_MODEL_OP_1(0x58)
1859 #define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_GET                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x36)
1860 #define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET                    ESP_BLE_MESH_MODEL_OP_1(0x59)
1861 #define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK              ESP_BLE_MESH_MODEL_OP_1(0x5A)
1862 #define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS                 ESP_BLE_MESH_MODEL_OP_1(0x5B)
1863 
1864 /**
1865  * esp_ble_mesh_time_scene_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is
1866  * only used to locate the opcodes used by functions esp_ble_mesh_time_scene_client_get_state
1867  * & esp_ble_mesh_time_scene_client_set_state.
1868  */
1869 typedef uint32_t esp_ble_mesh_time_scene_message_opcode_t;
1870 
1871 /*!< Time Message Opcode */
1872 #define ESP_BLE_MESH_MODEL_OP_TIME_GET                              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x37)
1873 #define ESP_BLE_MESH_MODEL_OP_TIME_SET                              ESP_BLE_MESH_MODEL_OP_1(0x5C)
1874 #define ESP_BLE_MESH_MODEL_OP_TIME_STATUS                           ESP_BLE_MESH_MODEL_OP_1(0x5D)
1875 #define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_GET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x38)
1876 #define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x39)
1877 #define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3A)
1878 #define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_GET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3B)
1879 #define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3C)
1880 #define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3D)
1881 #define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_GET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3E)
1882 #define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3F)
1883 #define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS                  ESP_BLE_MESH_MODEL_OP_2(0x82, 0x40)
1884 
1885 /*!< Scene Message Opcode */
1886 #define ESP_BLE_MESH_MODEL_OP_SCENE_GET                             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x41)
1887 #define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL                          ESP_BLE_MESH_MODEL_OP_2(0x82, 0x42)
1888 #define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x43)
1889 #define ESP_BLE_MESH_MODEL_OP_SCENE_STATUS                          ESP_BLE_MESH_MODEL_OP_1(0x5E)
1890 #define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x44)
1891 #define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x45)
1892 
1893 /*!< Scene Setup Message Opcode */
1894 #define ESP_BLE_MESH_MODEL_OP_SCENE_STORE                           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x46)
1895 #define ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x47)
1896 #define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE                          ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9E)
1897 #define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9F)
1898 
1899 /*!< Scheduler Message Opcode */
1900 #define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x48)
1901 #define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS                  ESP_BLE_MESH_MODEL_OP_1(0x5F)
1902 #define ESP_BLE_MESH_MODEL_OP_SCHEDULER_GET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x49)
1903 #define ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4A)
1904 
1905 /*!< Scheduler Setup Message Opcode */
1906 #define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET                     ESP_BLE_MESH_MODEL_OP_1(0x60)
1907 #define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK               ESP_BLE_MESH_MODEL_OP_1(0x61)
1908 
1909 /**
1910  * esp_ble_mesh_light_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is
1911  * only used to locate the opcodes used by functions esp_ble_mesh_light_client_get_state
1912  * & esp_ble_mesh_light_client_set_state.
1913  */
1914 typedef uint32_t esp_ble_mesh_light_message_opcode_t;
1915 
1916 /*!< Light Lightness Message Opcode */
1917 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4B)
1918 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4C)
1919 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4D)
1920 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS                ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4E)
1921 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_GET            ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4F)
1922 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET            ESP_BLE_MESH_MODEL_OP_2(0x82, 0x50)
1923 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK      ESP_BLE_MESH_MODEL_OP_2(0x82, 0x51)
1924 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x52)
1925 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_GET              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x53)
1926 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x54)
1927 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_GET           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x55)
1928 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS        ESP_BLE_MESH_MODEL_OP_2(0x82, 0x56)
1929 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_GET             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x57)
1930 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS          ESP_BLE_MESH_MODEL_OP_2(0x82, 0x58)
1931 
1932 /*!< Light Lightness Setup Message Opcode */
1933 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x59)
1934 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5A)
1935 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5B)
1936 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK       ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5C)
1937 
1938 /*!< Light CTL Message Opcode */
1939 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_GET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5D)
1940 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5E)
1941 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5F)
1942 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x82, 0x60)
1943 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x61)
1944 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET       ESP_BLE_MESH_MODEL_OP_2(0x82, 0x62)
1945 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x63)
1946 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x64)
1947 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK       ESP_BLE_MESH_MODEL_OP_2(0x82, 0x65)
1948 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS          ESP_BLE_MESH_MODEL_OP_2(0x82, 0x66)
1949 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_GET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x67)
1950 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x68)
1951 
1952 /*!< Light CTL Setup Message Opcode */
1953 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x69)
1954 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6A)
1955 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET       ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6B)
1956 #define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6C)
1957 
1958 /*!< Light HSL Message Opcode */
1959 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_GET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6D)
1960 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6E)
1961 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6F)
1962 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK               ESP_BLE_MESH_MODEL_OP_2(0x82, 0x70)
1963 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS                  ESP_BLE_MESH_MODEL_OP_2(0x82, 0x71)
1964 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x72)
1965 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x73)
1966 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK        ESP_BLE_MESH_MODEL_OP_2(0x82, 0x74)
1967 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x75)
1968 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x76)
1969 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x77)
1970 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x82, 0x78)
1971 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_GET                  ESP_BLE_MESH_MODEL_OP_2(0x82, 0x79)
1972 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS               ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7A)
1973 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_GET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7B)
1974 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7C)
1975 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_GET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7D)
1976 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS                ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7E)
1977 
1978 /*!< Light HSL Setup Message Opcode */
1979 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7F)
1980 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x80)
1981 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x81)
1982 #define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x82)
1983 
1984 /*!< Light xyL Message Opcode */
1985 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_GET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x83)
1986 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET                         ESP_BLE_MESH_MODEL_OP_2(0x82, 0x84)
1987 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x85)
1988 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS                      ESP_BLE_MESH_MODEL_OP_2(0x82, 0x86)
1989 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_GET                  ESP_BLE_MESH_MODEL_OP_2(0x82, 0x87)
1990 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS               ESP_BLE_MESH_MODEL_OP_2(0x82, 0x88)
1991 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_GET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x89)
1992 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8A)
1993 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_GET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8B)
1994 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS                ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8C)
1995 
1996 /*!< Light xyL Setup Message Opcode */
1997 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8D)
1998 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8E)
1999 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET                   ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8F)
2000 #define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK             ESP_BLE_MESH_MODEL_OP_2(0x82, 0x90)
2001 
2002 /*!< Light Control Message Opcode */
2003 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x91)
2004 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET                     ESP_BLE_MESH_MODEL_OP_2(0x82, 0x92)
2005 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK               ESP_BLE_MESH_MODEL_OP_2(0x82, 0x93)
2006 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS                  ESP_BLE_MESH_MODEL_OP_2(0x82, 0x94)
2007 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET                       ESP_BLE_MESH_MODEL_OP_2(0x82, 0x95)
2008 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET                       ESP_BLE_MESH_MODEL_OP_2(0x82, 0x96)
2009 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x97)
2010 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS                    ESP_BLE_MESH_MODEL_OP_2(0x82, 0x98)
2011 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x99)
2012 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET              ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9A)
2013 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK        ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9B)
2014 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS           ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9C)
2015 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET                 ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9D)
2016 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET                 ESP_BLE_MESH_MODEL_OP_1(0x62)
2017 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK           ESP_BLE_MESH_MODEL_OP_1(0x63)
2018 #define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS              ESP_BLE_MESH_MODEL_OP_1(0x64)
2019 
2020 typedef uint32_t esp_ble_mesh_opcode_t;
2021 /*!< End of defines of esp_ble_mesh_opcode_t */
2022 
2023 /**
2024  * This typedef is only used to indicate the status code contained in some of the
2025  * server models (e.g. Generic Server Model) status message.
2026  */
2027 typedef uint8_t esp_ble_mesh_model_status_t;
2028 
2029 #define ESP_BLE_MESH_MODEL_STATUS_SUCCESS                           0x00
2030 #define ESP_BLE_MESH_MODEL_STATUS_CANNOT_SET_RANGE_MIN              0x01
2031 #define ESP_BLE_MESH_MODEL_STATUS_CANNOT_SET_RANGE_MAX              0x02
2032 
2033 /**
2034  * @brief BLE Mesh client models related definitions
2035  */
2036 
2037 /** Client model Get/Set message opcode and corresponding Status message opcode */
2038 typedef struct {
2039     uint32_t cli_op;        /*!< The client message opcode */
2040     uint32_t status_op;     /*!< The server status opcode corresponding to the client message opcode */
2041 } esp_ble_mesh_client_op_pair_t;
2042 
2043 /** Client Model user data context. */
2044 typedef struct {
2045     esp_ble_mesh_model_t *model;                    /*!< Pointer to the client model. Initialized by the stack. */
2046     int op_pair_size;                               /*!< Size of the op_pair */
2047     const esp_ble_mesh_client_op_pair_t *op_pair;   /*!< Table containing get/set message opcode and corresponding status message opcode */
2048     uint32_t publish_status;                        /*!< Callback used to handle the received unsolicited message. Initialized by the stack. */
2049     void *internal_data;                            /*!< Pointer to the internal data of client model */
2050     uint8_t msg_role;                               /*!< Role of the device (Node/Provisioner) that is going to send messages */
2051 } esp_ble_mesh_client_t;
2052 
2053 /** Common parameters of the messages sent by Client Model. */
2054 typedef struct {
2055     esp_ble_mesh_opcode_t opcode;   /*!< Message opcode */
2056     esp_ble_mesh_model_t *model;    /*!< Pointer to the client model structure */
2057     esp_ble_mesh_msg_ctx_t ctx;     /*!< The context used to send message */
2058     int32_t msg_timeout;            /*!< Timeout value (ms) to get response to the sent message */
2059     /*!< Note: if using default timeout value in menuconfig, make sure to set this value to 0 */
2060     uint8_t msg_role;               /*!< Role of the device - Node/Provisioner */
2061 } esp_ble_mesh_client_common_param_t;
2062 
2063 /**
2064  * @brief BLE Mesh server models related definitions
2065  */
2066 
2067 /** This enum value is the flag of transition timer operation */
2068 enum {
2069     ESP_BLE_MESH_SERVER_TRANS_TIMER_START,  /* Proper transition timer has been started */
2070     ESP_BLE_MESH_SERVER_FLAG_MAX,
2071 };
2072 
2073 /** Parameters of the server model state transition */
2074 typedef struct {
2075     bool just_started;          /*!< Indicate if the state transition has just started */
2076 
2077     uint8_t  trans_time;        /*!< State transition time */
2078     uint8_t  remain_time;       /*!< Remaining time of state transition */
2079     uint8_t  delay;             /*!< Delay before starting state transition */
2080     uint32_t quo_tt;            /*!< Duration of each divided transition step */
2081     uint32_t counter;           /*!< Number of steps which the transition duration is divided */
2082     uint32_t total_duration;    /*!< State transition total duration */
2083     int64_t  start_timestamp;   /*!< Time when the state transition is started */
2084 
2085     /**
2086      * Flag used to indicate if the transition timer has been started internally.
2087      *
2088      * If the model which contains esp_ble_mesh_state_transition_t sets "set_auto_rsp"
2089      * to ESP_BLE_MESH_SERVER_RSP_BY_APP, the handler of the timer shall be initialized
2090      * by the users.
2091      *
2092      * And users can use this flag to indicate whether the timer is started or not.
2093      */
2094     BLE_MESH_ATOMIC_DEFINE(flag, ESP_BLE_MESH_SERVER_FLAG_MAX);
2095     struct k_delayed_work timer;    /*!< Timer used for state transition */
2096 } esp_ble_mesh_state_transition_t;
2097 
2098 /** Parameters of the server model received last same set message. */
2099 typedef struct {
2100     uint8_t  tid;       /*!< Transaction number of the last message */
2101     uint16_t src;       /*!< Source address of the last message */
2102     uint16_t dst;       /*!< Destination address of the last message */
2103     int64_t  timestamp; /*!< Time when the last message is received */
2104 } esp_ble_mesh_last_msg_info_t;
2105 
2106 #define ESP_BLE_MESH_SERVER_RSP_BY_APP  0   /*!< Response need to be sent in the application */
2107 #define ESP_BLE_MESH_SERVER_AUTO_RSP    1   /*!< Response will be sent internally */
2108 
2109 /** Parameters of the Server Model response control */
2110 typedef struct {
2111     /**
2112      * @brief BLE Mesh Server Response Option
2113      *        1. If get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, then the
2114      *           response of Client Get messages need to be replied by the application;
2115      *        2. If get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, then the
2116      *           response of Client Get messages will be replied by the server models;
2117      *        3. If set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, then the
2118      *           response of Client Set messages need to be replied by the application;
2119      *        4. If set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, then the
2120      *           response of Client Set messages will be replied by the server models;
2121      *        5. If status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, then the
2122      *           response of Server Status messages need to be replied by the application;
2123      *        6. If status_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, then the
2124      *           response of Server Status messages will be replied by the server models;
2125      */
2126     uint8_t get_auto_rsp : 1,       /*!< Response control for Client Get messages */
2127             set_auto_rsp : 1,       /*!< Response control for Client Set messages */
2128             status_auto_rsp : 1;    /*!< Response control for Server Status messages */
2129 } esp_ble_mesh_server_rsp_ctrl_t;
2130 
2131 /**
2132  * @brief Server model state value union
2133  */
2134 typedef union {
2135     struct {
2136         uint8_t onoff;          /*!< The value of the Generic OnOff state */
2137     } gen_onoff;                /*!< The Generic OnOff state */
2138     struct {
2139         int16_t level;          /*!< The value of the Generic Level state */
2140     } gen_level;                /*!< The Generic Level state */
2141     struct {
2142         uint8_t onpowerup;      /*!< The value of the Generic OnPowerUp state */
2143     } gen_onpowerup;            /*!< The Generic OnPowerUp state */
2144     struct {
2145         uint16_t power;         /*!< The value of the Generic Power Actual state */
2146     } gen_power_actual;         /*!< The Generic Power Actual state */
2147     struct {
2148         uint16_t lightness;     /*!< The value of the Light Lightness Actual state */
2149     } light_lightness_actual;   /*!< The Light Lightness Actual state */
2150     struct {
2151         uint16_t lightness;     /*!< The value of the Light Lightness Linear state */
2152     } light_lightness_linear;   /*!< The Light Lightness Linear state */
2153     struct {
2154         uint16_t lightness;     /*!< The value of the Light CTL Lightness state */
2155     } light_ctl_lightness;      /*!< The Light CTL Lightness state */
2156     struct {
2157         uint16_t temperature;   /*!< The value of the Light CTL Temperature state */
2158         int16_t  delta_uv;      /*!< The value of the Light CTL Delta UV state */
2159     } light_ctl_temp_delta_uv;  /*!< The Light CTL Temperature & Delta UV states */
2160     struct {
2161         uint16_t lightness;     /*!< The value of the Light HSL Lightness state */
2162         uint16_t hue;           /*!< The value of the Light HSL Hue state */
2163         uint16_t saturation;    /*!< The value of the Light HSL Saturation state */
2164     } light_hsl;                /*!< The Light HSL composite state */
2165     struct {
2166         uint16_t lightness;     /*!< The value of the Light HSL Lightness state */
2167     } light_hsl_lightness;      /*!< The Light HSL Lightness state */
2168     struct {
2169         uint16_t hue;           /*!< The value of the Light HSL Hue state */
2170     } light_hsl_hue;            /*!< The Light HSL Hue state */
2171     struct {
2172         uint16_t saturation;    /*!< The value of the Light HSL Saturation state */
2173     } light_hsl_saturation;     /*!< The Light HSL Saturation state */
2174     struct {
2175         uint16_t lightness;     /*!< The value of the Light xyL Lightness state */
2176     } light_xyl_lightness;      /*!< The Light xyL Lightness state */
2177     struct {
2178         uint8_t onoff;          /*!< The value of the Light LC Light OnOff state */
2179     } light_lc_light_onoff;     /*!< The Light LC Light OnOff state */
2180 } esp_ble_mesh_server_state_value_t;
2181 
2182 /** This enum value is the type of server model states */
2183 typedef enum {
2184     ESP_BLE_MESH_GENERIC_ONOFF_STATE,
2185     ESP_BLE_MESH_GENERIC_LEVEL_STATE,
2186     ESP_BLE_MESH_GENERIC_ONPOWERUP_STATE,
2187     ESP_BLE_MESH_GENERIC_POWER_ACTUAL_STATE,
2188     ESP_BLE_MESH_LIGHT_LIGHTNESS_ACTUAL_STATE,
2189     ESP_BLE_MESH_LIGHT_LIGHTNESS_LINEAR_STATE,
2190     ESP_BLE_MESH_LIGHT_CTL_LIGHTNESS_STATE,
2191     ESP_BLE_MESH_LIGHT_CTL_TEMP_DELTA_UV_STATE,
2192     ESP_BLE_MESH_LIGHT_HSL_STATE,
2193     ESP_BLE_MESH_LIGHT_HSL_LIGHTNESS_STATE,
2194     ESP_BLE_MESH_LIGHT_HSL_HUE_STATE,
2195     ESP_BLE_MESH_LIGHT_HSL_SATURATION_STATE,
2196     ESP_BLE_MESH_LIGHT_XYL_LIGHTNESS_STATE,
2197     ESP_BLE_MESH_LIGHT_LC_LIGHT_ONOFF_STATE,
2198     ESP_BLE_MESH_SERVER_MODEL_STATE_MAX,
2199 } esp_ble_mesh_server_state_type_t;
2200 
2201 /*!< This enum value is the event of undefined SIG models and vendor models */
2202 typedef enum {
2203     ESP_BLE_MESH_MODEL_OPERATION_EVT,                   /*!< User-defined models receive messages from peer devices (e.g. get, set, status, etc) event */
2204     ESP_BLE_MESH_MODEL_SEND_COMP_EVT,                   /*!< User-defined models send messages completion event */
2205     ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT,                /*!< User-defined models publish messages completion event */
2206     ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT,     /*!< User-defined client models receive publish messages event */
2207     ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT,         /*!< Timeout event for the user-defined client models that failed to receive response from peer server models */
2208     ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT,              /*!< When a model is configured to publish messages periodically, this event will occur during every publish period */
2209     ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT,    /*!< Server models update state value completion event */
2210     ESP_BLE_MESH_MODEL_EVT_MAX,
2211 } esp_ble_mesh_model_cb_event_t;
2212 
2213 /**
2214  * @brief BLE Mesh model callback parameters union
2215  */
2216 typedef union {
2217     /**
2218      * @brief ESP_BLE_MESH_MODEL_OPERATION_EVT
2219      */
2220     struct ble_mesh_model_operation_evt_param {
2221         uint32_t opcode;                /*!< Opcode of the received message */
2222         esp_ble_mesh_model_t *model;    /*!< Pointer to the model which receives the message */
2223         esp_ble_mesh_msg_ctx_t *ctx;    /*!< Pointer to the context of the received message */
2224         uint16_t length;                /*!< Length of the received message */
2225         uint8_t *msg;                   /*!< Value of the received message */
2226     } model_operation;                  /*!< Event parameter of ESP_BLE_MESH_MODEL_OPERATION_EVT */
2227     /**
2228      * @brief ESP_BLE_MESH_MODEL_SEND_COMP_EVT
2229      */
2230     struct ble_mesh_model_send_comp_param {
2231         int err_code;                   /*!< Indicate the result of sending a message */
2232         uint32_t opcode;                /*!< Opcode of the message */
2233         esp_ble_mesh_model_t *model;    /*!< Pointer to the model which sends the message */
2234         esp_ble_mesh_msg_ctx_t *ctx;    /*!< Context of the message */
2235     } model_send_comp;                  /*!< Event parameter of ESP_BLE_MESH_MODEL_SEND_COMP_EVT */
2236     /**
2237      * @brief ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT
2238      */
2239     struct ble_mesh_model_publish_comp_param {
2240         int err_code;                   /*!< Indicate the result of publishing a message */
2241         esp_ble_mesh_model_t *model;    /*!< Pointer to the model which publishes the message */
2242     } model_publish_comp;               /*!< Event parameter of ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT */
2243     /**
2244      * @brief ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT
2245      */
2246     struct ble_mesh_mod_recv_publish_msg_param {
2247         uint32_t opcode;                /*!< Opcode of the unsolicited received message */
2248         esp_ble_mesh_model_t *model;    /*!< Pointer to the model which receives the message */
2249         esp_ble_mesh_msg_ctx_t *ctx;    /*!< Pointer to the context of the message */
2250         uint16_t length;                /*!< Length of the received message */
2251         uint8_t *msg;                   /*!< Value of the received message */
2252     } client_recv_publish_msg;          /*!< Event parameter of ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT */
2253     /**
2254      * @brief ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT
2255      */
2256     struct ble_mesh_client_model_send_timeout_param {
2257         uint32_t opcode;                /*!< Opcode of the previously sent message */
2258         esp_ble_mesh_model_t *model;    /*!< Pointer to the model which sends the previous message */
2259         esp_ble_mesh_msg_ctx_t *ctx;    /*!< Pointer to the context of the previous message */
2260     } client_send_timeout;              /*!< Event parameter of ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT */
2261     /**
2262      * @brief ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT
2263      */
2264     struct ble_mesh_model_publish_update_evt_param {
2265         esp_ble_mesh_model_t *model;    /*!< Pointer to the model which is going to update its publish message */
2266     } model_publish_update;             /*!< Event parameter of ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT */
2267     /**
2268      * @brief ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT
2269      */
2270     struct ble_mesh_server_model_update_state_comp_param {
2271         int err_code;                           /*!< Indicate the result of updating server model state */
2272         esp_ble_mesh_model_t *model;            /*!< Pointer to the server model which state value is updated */
2273         esp_ble_mesh_server_state_type_t type;  /*!< Type of the updated server state */
2274     } server_model_update_state;                /*!< Event parameter of ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT */
2275 } esp_ble_mesh_model_cb_param_t;
2276 
2277 #ifdef __cplusplus
2278 }
2279 #endif
2280 
2281 #endif /* _ESP_BLE_MESH_DEFS_H_ */
2282