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