-
Notifications
You must be signed in to change notification settings - Fork 7.3k
/
esp_ble_mesh_defs.h
2255 lines (2044 loc) · 132 KB
/
esp_ble_mesh_defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _ESP_BLE_MESH_DEFS_H_
#define _ESP_BLE_MESH_DEFS_H_
#include <stdint.h>
#include "mesh_config.h"
#include "mesh_common.h"
#include "proxy_server.h"
#include "provisioner_main.h"
#ifdef CONFIG_BT_BLUEDROID_ENABLED
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#define ESP_BLE_HOST_STATUS_ENABLED ESP_BLUEDROID_STATUS_ENABLED
#define ESP_BLE_HOST_STATUS_CHECK(status) ESP_BLUEDROID_STATUS_CHECK(status)
#else
#define ESP_BLE_HOST_STATUS_ENABLED 0
#define ESP_BLE_HOST_STATUS_CHECK(status) do {} while (0)
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*!< The maximum length of a BLE Mesh message, including Opcode, Payload and TransMIC */
#define ESP_BLE_MESH_SDU_MAX_LEN 384
/*!< Length of a short Mesh MIC. */
#define ESP_BLE_MESH_MIC_SHORT 4
/*!< Length of a long Mesh MIC. */
#define ESP_BLE_MESH_MIC_LONG 8
/*!< The maximum length of a BLE Mesh provisioned node name */
#define ESP_BLE_MESH_NODE_NAME_MAX_LEN 31
/*!< The maximum length of a BLE Mesh unprovisioned device name */
#define ESP_BLE_MESH_DEVICE_NAME_MAX_LEN DEVICE_NAME_SIZE
/*!< The maximum length of settings user id */
#define ESP_BLE_MESH_SETTINGS_UID_SIZE 20
/*!< Invalid settings index */
#define ESP_BLE_MESH_INVALID_SETTINGS_IDX 0xFF
/*!< Define the BLE Mesh octet 16 bytes size */
#define ESP_BLE_MESH_OCTET16_LEN 16
typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN];
/*!< Define the BLE Mesh octet 8 bytes size */
#define ESP_BLE_MESH_OCTET8_LEN 8
typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
/*!< Invalid Company ID */
#define ESP_BLE_MESH_CID_NVAL 0xFFFF
/*!< Special TTL value to request using configured default TTL */
#define ESP_BLE_MESH_TTL_DEFAULT 0xFF
/*!< Maximum allowed TTL value */
#define ESP_BLE_MESH_TTL_MAX 0x7F
#define ESP_BLE_MESH_ADDR_UNASSIGNED 0x0000
#define ESP_BLE_MESH_ADDR_ALL_NODES 0xFFFF
#define ESP_BLE_MESH_ADDR_PROXIES 0xFFFC
#define ESP_BLE_MESH_ADDR_FRIENDS 0xFFFD
#define ESP_BLE_MESH_ADDR_RELAYS 0xFFFE
#define ESP_BLE_MESH_KEY_UNUSED 0xFFFF
#define ESP_BLE_MESH_KEY_DEV 0xFFFE
#define ESP_BLE_MESH_KEY_PRIMARY 0x0000
#define ESP_BLE_MESH_KEY_ANY 0xFFFF
/*!< Primary Network Key index */
#define ESP_BLE_MESH_NET_PRIMARY 0x000
/*!< Relay state value */
#define ESP_BLE_MESH_RELAY_DISABLED 0x00
#define ESP_BLE_MESH_RELAY_ENABLED 0x01
#define ESP_BLE_MESH_RELAY_NOT_SUPPORTED 0x02
/*!< Beacon state value */
#define ESP_BLE_MESH_BEACON_DISABLED 0x00
#define ESP_BLE_MESH_BEACON_ENABLED 0x01
/*!< GATT Proxy state value */
#define ESP_BLE_MESH_GATT_PROXY_DISABLED 0x00
#define ESP_BLE_MESH_GATT_PROXY_ENABLED 0x01
#define ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED 0x02
/*!< Friend state value */
#define ESP_BLE_MESH_FRIEND_DISABLED 0x00
#define ESP_BLE_MESH_FRIEND_ENABLED 0x01
#define ESP_BLE_MESH_FRIEND_NOT_SUPPORTED 0x02
/*!< Node identity state value */
#define ESP_BLE_MESH_NODE_IDENTITY_STOPPED 0x00
#define ESP_BLE_MESH_NODE_IDENTITY_RUNNING 0x01
#define ESP_BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED 0x02
/*!< Supported features */
#define ESP_BLE_MESH_FEATURE_RELAY BIT(0)
#define ESP_BLE_MESH_FEATURE_PROXY BIT(1)
#define ESP_BLE_MESH_FEATURE_FRIEND BIT(2)
#define ESP_BLE_MESH_FEATURE_LOW_POWER BIT(3)
#define ESP_BLE_MESH_FEATURE_ALL_SUPPORTED (ESP_BLE_MESH_FEATURE_RELAY | \
ESP_BLE_MESH_FEATURE_PROXY | \
ESP_BLE_MESH_FEATURE_FRIEND | \
ESP_BLE_MESH_FEATURE_LOW_POWER)
#define ESP_BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000)
#define ESP_BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xC000 && (addr) <= 0xFF00)
#define ESP_BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xC000)
#define ESP_BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xFF00 && (addr) <= 0xFFFB)
#define ESP_BLE_MESH_INVALID_NODE_INDEX 0xFFFF
/** @def ESP_BLE_MESH_TRANSMIT
*
* @brief Encode transmission count & interval steps.
*
* @note For example, ESP_BLE_MESH_TRANSMIT(2, 20) means that the message
* will be sent about 90ms(count is 3, step is 1, interval is 30 ms
* which includes 10ms of advertising interval random delay).
*
* @param count Number of retransmissions (first transmission is excluded).
* @param int_ms Interval steps in milliseconds. Must be greater than 0
* and a multiple of 10.
*
* @return BLE Mesh transmit value that can be used e.g. for the default
* values of the Configuration Model data.
*/
#define ESP_BLE_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3))
/** @def ESP_BLE_MESH_GET_TRANSMIT_COUNT
*
* @brief Decode transmit count from a transmit value.
*
* @param transmit Encoded transmit count & interval value.
*
* @return Transmission count (actual transmissions equal to N + 1).
*/
#define ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3)))
/** @def ESP_BLE_MESH_GET_TRANSMIT_INTERVAL
*
* @brief Decode transmit interval from a transmit value.
*
* @param transmit Encoded transmit count & interval value.
*
* @return Transmission interval in milliseconds.
*/
#define ESP_BLE_MESH_GET_TRANSMIT_INTERVAL(transmit) ((((transmit) >> 3) + 1) * 10)
/** @def ESP_BLE_MESH_PUBLISH_TRANSMIT
*
* @brief Encode Publish Retransmit count & interval steps.
*
* @param count Number of retransmissions (first transmission is excluded).
* @param int_ms Interval steps in milliseconds. Must be greater than 0
* and a multiple of 50.
*
* @return BLE Mesh transmit value that can be used e.g. for the default
* values of the Configuration Model data.
*/
#define ESP_BLE_MESH_PUBLISH_TRANSMIT(count, int_ms) ESP_BLE_MESH_TRANSMIT(count, (int_ms) / 5)
/** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT
*
* @brief Decode Publish Retransmit count from a given value.
*
* @param transmit Encoded Publish Retransmit count & interval value.
*
* @return Retransmission count (actual transmissions equal to N + 1).
*/
#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT(transmit) ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit)
/** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL
*
* @brief Decode Publish Retransmit interval from a given value.
*
* @param transmit Encoded Publish Retransmit count & interval value.
*
* @return Transmission interval in milliseconds.
*/
#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL(transmit) ((((transmit) >> 3) + 1) * 50)
/*!< Callbacks which are not needed to be initialized by users (set with 0 and will be initialized internally) */
typedef uint32_t esp_ble_mesh_cb_t;
typedef enum {
ESP_BLE_MESH_TYPE_PROV_CB,
ESP_BLE_MESH_TYPE_OUTPUT_NUM_CB,
ESP_BLE_MESH_TYPE_OUTPUT_STR_CB,
ESP_BLE_MESH_TYPE_INTPUT_CB,
ESP_BLE_MESH_TYPE_LINK_OPEN_CB,
ESP_BLE_MESH_TYPE_LINK_CLOSE_CB,
ESP_BLE_MESH_TYPE_COMPLETE_CB,
ESP_BLE_MESH_TYPE_RESET_CB,
} esp_ble_mesh_cb_type_t;
/*!< This enum value is provisioning authentication oob method */
typedef enum {
ESP_BLE_MESH_NO_OOB,
ESP_BLE_MESH_STATIC_OOB,
ESP_BLE_MESH_OUTPUT_OOB,
ESP_BLE_MESH_INPUT_OOB,
} esp_ble_mesh_oob_method_t;
/*!< This enum value is associated with bt_mesh_output_action_t in mesh_main.h */
typedef enum {
ESP_BLE_MESH_NO_OUTPUT = 0,
ESP_BLE_MESH_BLINK = BIT(0),
ESP_BLE_MESH_BEEP = BIT(1),
ESP_BLE_MESH_VIBRATE = BIT(2),
ESP_BLE_MESH_DISPLAY_NUMBER = BIT(3),
ESP_BLE_MESH_DISPLAY_STRING = BIT(4),
} esp_ble_mesh_output_action_t;
/*!< This enum value is associated with bt_mesh_input_action_t in mesh_main.h */
typedef enum {
ESP_BLE_MESH_NO_INPUT = 0,
ESP_BLE_MESH_PUSH = BIT(0),
ESP_BLE_MESH_TWIST = BIT(1),
ESP_BLE_MESH_ENTER_NUMBER = BIT(2),
ESP_BLE_MESH_ENTER_STRING = BIT(3),
} esp_ble_mesh_input_action_t;
/*!< This enum value is associated with bt_mesh_prov_bearer_t in mesh_main.h */
typedef enum {
ESP_BLE_MESH_PROV_ADV = BIT(0),
ESP_BLE_MESH_PROV_GATT = BIT(1),
} esp_ble_mesh_prov_bearer_t;
/*!< This enum value is associated with bt_mesh_prov_oob_info_t in mesh_main.h */
typedef enum {
ESP_BLE_MESH_PROV_OOB_OTHER = BIT(0),
ESP_BLE_MESH_PROV_OOB_URI = BIT(1),
ESP_BLE_MESH_PROV_OOB_2D_CODE = BIT(2),
ESP_BLE_MESH_PROV_OOB_BAR_CODE = BIT(3),
ESP_BLE_MESH_PROV_OOB_NFC = BIT(4),
ESP_BLE_MESH_PROV_OOB_NUMBER = BIT(5),
ESP_BLE_MESH_PROV_OOB_STRING = BIT(6),
/* 7 - 10 are reserved */
ESP_BLE_MESH_PROV_OOB_ON_BOX = BIT(11),
ESP_BLE_MESH_PROV_OOB_IN_BOX = BIT(12),
ESP_BLE_MESH_PROV_OOB_ON_PAPER = BIT(13),
ESP_BLE_MESH_PROV_OOB_IN_MANUAL = BIT(14),
ESP_BLE_MESH_PROV_OOB_ON_DEV = BIT(15),
} esp_ble_mesh_prov_oob_info_t;
/*!< Maximum length of value used by Static OOB authentication */
#define ESP_BLE_MESH_PROV_STATIC_OOB_MAX_LEN 16
/*!< Maximum length of string used by Output OOB authentication */
#define ESP_BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN 8
/*!< Maximum length of string used by Output OOB authentication */
#define ESP_BLE_MESH_PROV_INPUT_OOB_MAX_LEN 8
/*!< Macros used to define message opcode */
#define ESP_BLE_MESH_MODEL_OP_1(b0) (b0)
#define ESP_BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
#define ESP_BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xC00000) | (cid))
/*!< This macro is associated with BLE_MESH_MODEL_CB in mesh_access.h */
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
{ \
.model_id = (_id), \
.op = _op, \
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
ESP_BLE_MESH_KEY_UNUSED }, \
.pub = _pub, \
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
}
/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
{ \
.vnd.company_id = (_company), \
.vnd.model_id = (_id), \
.op = _op, \
.pub = _pub, \
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
ESP_BLE_MESH_KEY_UNUSED }, \
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
}
/** @brief Helper to define a BLE Mesh element within an array.
*
* In case the element has no SIG or Vendor models, the helper
* macro ESP_BLE_MESH_MODEL_NONE can be given instead.
*
* @note This macro is associated with BLE_MESH_ELEM in mesh_access.h
*
* @param _loc Location Descriptor.
* @param _mods Array of SIG models.
* @param _vnd_mods Array of vendor models.
*/
#define ESP_BLE_MESH_ELEMENT(_loc, _mods, _vnd_mods) \
{ \
.location = (_loc), \
.sig_model_count = ARRAY_SIZE(_mods), \
.sig_models = (_mods), \
.vnd_model_count = ARRAY_SIZE(_vnd_mods), \
.vnd_models = (_vnd_mods), \
}
#define ESP_BLE_MESH_PROV(uuid, sta_val, sta_val_len, out_size, out_act, in_size, in_act) { \
.uuid = uuid, \
.static_val = sta_val, \
.static_val_len = sta_val_len, \
.output_size = out_size, \
.output_action = out_act, \
.input_size = in_size, \
.input_action = in_act, \
}
typedef uint8_t UINT8;
typedef uint16_t UINT16;
typedef uint32_t UINT32;
typedef uint64_t UINT64;
#define BT_OCTET32_LEN 32
typedef UINT8 BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */
#ifndef BD_ADDR_LEN
#define BD_ADDR_LEN 6
typedef uint8_t BD_ADDR[BD_ADDR_LEN];
#endif
typedef uint8_t esp_ble_mesh_bd_addr_t[BD_ADDR_LEN];
#define ESP_BLE_MESH_ADDR_TYPE_PUBLIC 0x00
#define ESP_BLE_MESH_ADDR_TYPE_RANDOM 0x01
#define ESP_BLE_MESH_ADDR_TYPE_RPA_PUBLIC 0x02
#define ESP_BLE_MESH_ADDR_TYPE_RPA_RANDOM 0x03
/// BLE device address type
typedef uint8_t esp_ble_mesh_addr_type_t;
/** BLE Mesh deinit parameters */
typedef struct {
bool erase_flash; /*!< Indicate if erasing flash when deinit mesh stack */
} esp_ble_mesh_deinit_param_t;
typedef struct esp_ble_mesh_model esp_ble_mesh_model_t;
/** Abstraction that describes a BLE Mesh Element.
* This structure is associated with struct bt_mesh_elem in mesh_access.h
*/
typedef struct {
/** Element Address, assigned during provisioning. */
uint16_t element_addr;
/** Location Descriptor (GATT Bluetooth Namespace Descriptors) */
const uint16_t location;
const uint8_t sig_model_count; /*!< SIG Model count */
const uint8_t vnd_model_count; /*!< Vendor Model count */
esp_ble_mesh_model_t *sig_models; /*!< SIG Models */
esp_ble_mesh_model_t *vnd_models; /*!< Vendor Models */
} esp_ble_mesh_elem_t;
/** Abstraction that describes a model publication context.
* This structure is associated with struct bt_mesh_model_pub in mesh_access.h
*/
typedef struct {
/** Pointer to the model to which the context belongs. Initialized by the stack. */
esp_ble_mesh_model_t *model;
uint16_t publish_addr; /*!< Publish Address. */
uint16_t app_idx:12, /*!< Publish AppKey Index. */
cred:1, /*!< Friendship Credentials Flag. */
send_rel:1; /*!< Force reliable sending (segment acks) */
uint8_t ttl; /*!< Publish Time to Live. */
uint8_t retransmit; /*!< Retransmit Count & Interval Steps. */
uint8_t period; /*!< Publish Period. */
uint8_t period_div:4, /*!< Divisor for the Period. */
fast_period:1, /*!< Use FastPeriodDivisor */
count:3; /*!< Retransmissions left. */
uint32_t period_start; /*!< Start of the current period. */
/** @brief Publication buffer, containing the publication message.
*
* This will get correctly created when the publication context
* has been defined using the ESP_BLE_MESH_MODEL_PUB_DEFINE macro.
*
* ESP_BLE_MESH_MODEL_PUB_DEFINE(name, size);
*/
struct net_buf_simple *msg;
/** Callback used to update publish message. Initialized by the stack. */
esp_ble_mesh_cb_t update;
/** Publish Period Timer. Initialized by the stack. */
struct k_delayed_work timer;
/** Role of the device that is going to publish messages */
uint8_t dev_role;
} esp_ble_mesh_model_pub_t;
/** @def ESP_BLE_MESH_MODEL_PUB_DEFINE
*
* Define a model publication context.
*
* @param _name Variable name given to the context.
* @param _msg_len Length of the publication message.
* @param _role Role of the device which contains the model.
*/
#define ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, _msg_len, _role) \
NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
static esp_ble_mesh_model_pub_t _name = { \
.update = (uint32_t)NULL, \
.msg = &bt_mesh_pub_msg_##_name, \
.dev_role = _role, \
}
/** @def ESP_BLE_MESH_MODEL_OP
*
* Define a model operation context.
*
* @param _opcode Message opcode.
* @param _min_len Message minimum length.
*/
#define ESP_BLE_MESH_MODEL_OP(_opcode, _min_len) \
{ \
.opcode = _opcode, \
.min_len = _min_len, \
.param_cb = (uint32_t)NULL, \
}
/** Abstraction that describes a model operation context.
* This structure is associated with struct bt_mesh_model_op in mesh_access.h
*/
typedef struct {
const uint32_t opcode; /*!< Message opcode */
const size_t min_len; /*!< Message minimum length */
esp_ble_mesh_cb_t param_cb; /*!< Callback used to handle message. Initialized by the stack. */
} esp_ble_mesh_model_op_t;
/** Define the terminator for the model operation table.
* Each model operation struct array must use this terminator as
* the end tag of the operation unit.
*/
#define ESP_BLE_MESH_MODEL_OP_END {0, 0, 0}
/** Abstraction that describes a model callback structure.
* This structure is associated with struct bt_mesh_model_cb in mesh_access.h.
*/
typedef struct {
/** Callback used during model initialization. Initialized by the stack. */
esp_ble_mesh_cb_t init_cb;
#if CONFIG_BLE_MESH_DEINIT
/** Callback used during model deinitialization. Initialized by the stack. */
esp_ble_mesh_cb_t deinit_cb;
#endif /* CONFIG_BLE_MESH_DEINIT */
} esp_ble_mesh_model_cbs_t;
/** Abstraction that describes a Mesh Model instance.
* This structure is associated with struct bt_mesh_model in mesh_access.h
*/
struct esp_ble_mesh_model {
/** Model ID */
union {
const uint16_t model_id; /*!< 16-bit model identifier */
struct {
uint16_t company_id; /*!< 16-bit company identifier */
uint16_t model_id; /*!< 16-bit model identifier */
} vnd; /*!< Structure encapsulating a model ID with a company ID */
};
/** Internal information, mainly for persistent storage */
uint8_t element_idx; /*!< Belongs to Nth element */
uint8_t model_idx; /*!< Is the Nth model in the element */
uint16_t flags; /*!< Information about what has changed */
/** The Element to which this Model belongs */
esp_ble_mesh_elem_t *element;
/** Model Publication */
esp_ble_mesh_model_pub_t *const pub;
/** AppKey List */
uint16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT];
/** Subscription List (group or virtual addresses) */
uint16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT];
/** Model operation context */
esp_ble_mesh_model_op_t *op;
/** Model callback structure */
esp_ble_mesh_model_cbs_t *cb;
/** Model-specific user data */
void *user_data;
};
/** Helper to define an empty model array.
* This structure is associated with BLE_MESH_MODEL_NONE in mesh_access.h
*/
#define ESP_BLE_MESH_MODEL_NONE ((esp_ble_mesh_model_t []){})
/** Message sending context.
* This structure is associated with struct bt_mesh_msg_ctx in mesh_access.h
*/
typedef struct {
/** NetKey Index of the subnet through which to send the message. */
uint16_t net_idx;
/** AppKey Index for message encryption. */
uint16_t app_idx;
/** Remote address. */
uint16_t addr;
/** Destination address of a received message. Not used for sending. */
uint16_t recv_dst;
/** RSSI of received packet. Not used for sending. */
int8_t recv_rssi;
/** Received TTL value. Not used for sending. */
uint8_t recv_ttl: 7;
/** Force sending reliably by using segment acknowledgement */
uint8_t send_rel: 1;
/** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */
uint8_t send_ttl;
/** Opcode of a received message. Not used for sending message. */
uint32_t recv_op;
/** Model corresponding to the message, no need to be initialized before sending message */
esp_ble_mesh_model_t *model;
/** Indicate if the message is sent by a node server model, no need to be initialized before sending message */
bool srv_send;
} esp_ble_mesh_msg_ctx_t;
/** Provisioning properties & capabilities.
* This structure is associated with struct bt_mesh_prov in mesh_access.h
*/
typedef struct {
#if CONFIG_BLE_MESH_NODE
/** The UUID that is used when advertising as an unprovisioned device */
const uint8_t *uuid;
/** Optional URI. This will be advertised separately from the
* unprovisioned beacon, however the unprovisioned beacon will
* contain a hash of it so the two can be associated by the
* provisioner.
*/
const char *uri;
/** Out of Band information field. */
esp_ble_mesh_prov_oob_info_t oob_info;
/** Flag indicates whether unprovisioned devices support OOB public key */
bool oob_pub_key;
/** Callback used to notify to set OOB Public Key. Initialized by the stack. */
esp_ble_mesh_cb_t oob_pub_key_cb;
/** Static OOB value */
const uint8_t *static_val;
/** Static OOB value length */
uint8_t static_val_len;
/** Maximum size of Output OOB supported */
uint8_t output_size;
/** Supported Output OOB Actions */
uint16_t output_actions;
/** Maximum size of Input OOB supported */
uint8_t input_size;
/** Supported Input OOB Actions */
uint16_t input_actions;
/** Callback used to output the number. Initialized by the stack. */
esp_ble_mesh_cb_t output_num_cb;
/** Callback used to output the string. Initialized by the stack. */
esp_ble_mesh_cb_t output_str_cb;
/** Callback used to notify to input number/string. Initialized by the stack. */
esp_ble_mesh_cb_t input_cb;
/** Callback used to indicate that link is opened. Initialized by the stack. */
esp_ble_mesh_cb_t link_open_cb;
/** Callback used to indicate that link is closed. Initialized by the stack. */
esp_ble_mesh_cb_t link_close_cb;
/** Callback used to indicate that provisioning is completed. Initialized by the stack. */
esp_ble_mesh_cb_t complete_cb;
/** Callback used to indicate that node has been reset. Initialized by the stack. */
esp_ble_mesh_cb_t reset_cb;
#endif /* CONFIG_BLE_MESH_NODE */
#ifdef CONFIG_BLE_MESH_PROVISIONER
/** Provisioner device UUID */
const uint8_t *prov_uuid;
/** Primary element address of the provisioner */
const uint16_t prov_unicast_addr;
/** Pre-incremental unicast address value to be assigned to the first device */
uint16_t prov_start_address;
/** Attention timer contained in Provisioning Invite PDU */
uint8_t prov_attention;
/** Provisioning Algorithm for the Provisioner */
uint8_t prov_algorithm;
/** Provisioner public key oob */
uint8_t prov_pub_key_oob;
/** Callback used to notify to set device OOB Public Key. Initialized by the stack. */
esp_ble_mesh_cb_t provisioner_prov_read_oob_pub_key;
/** Provisioner static oob value */
uint8_t *prov_static_oob_val;
/** Provisioner static oob value length */
uint8_t prov_static_oob_len;
/** Callback used to notify to input number/string. Initialized by the stack. */
esp_ble_mesh_cb_t provisioner_prov_input;
/** Callback used to output number/string. Initialized by the stack. */
esp_ble_mesh_cb_t provisioner_prov_output;
/** Key refresh and IV update flag */
uint8_t flags;
/** IV index */
uint32_t iv_index;
/** Callback used to indicate that link is opened. Initialized by the stack. */
esp_ble_mesh_cb_t provisioner_link_open;
/** Callback used to indicate that link is closed. Initialized by the stack. */
esp_ble_mesh_cb_t provisioner_link_close;
/** Callback used to indicate that a device is provisioned. Initialized by the stack. */
esp_ble_mesh_cb_t provisioner_prov_comp;
#endif /* CONFIG_BLE_MESH_PROVISIONER */
} esp_ble_mesh_prov_t;
/** Node Composition data context.
* This structure is associated with struct bt_mesh_comp in mesh_access.h
*/
typedef struct {
uint16_t cid; /*!< 16-bit SIG-assigned company identifier */
uint16_t pid; /*!< 16-bit vendor-assigned product identifier */
uint16_t vid; /*!< 16-bit vendor-assigned product version identifier */
size_t element_count; /*!< Element count */
esp_ble_mesh_elem_t *elements; /*!< A sequence of elements */
} esp_ble_mesh_comp_t;
/*!< This enum value is the role of the device */
typedef enum {
ROLE_NODE = 0,
ROLE_PROVISIONER,
ROLE_FAST_PROV,
} esp_ble_mesh_dev_role_t;
/*!< Flag which will be set when device is going to be added. */
typedef uint8_t esp_ble_mesh_dev_add_flag_t;
#define ADD_DEV_RM_AFTER_PROV_FLAG BIT(0) /*!< Device will be removed from queue after provisioned successfully */
#define ADD_DEV_START_PROV_NOW_FLAG BIT(1) /*!< Start provisioning device immediately */
#define ADD_DEV_FLUSHABLE_DEV_FLAG BIT(2) /*!< Device can be remove when queue is full and new device is going to added */
/** Information of the device which is going to be added for provisioning. */
typedef struct {
esp_ble_mesh_bd_addr_t addr; /*!< Device address */
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
uint8_t uuid[16]; /*!< Device UUID */
uint16_t oob_info; /*!< Device OOB Info */
/*!< ADD_DEV_START_PROV_NOW_FLAG shall not be set if the bearer has both PB-ADV and PB-GATT enabled */
esp_ble_mesh_prov_bearer_t bearer; /*!< Provisioning Bearer */
} esp_ble_mesh_unprov_dev_add_t;
#define DEL_DEV_ADDR_FLAG BIT(0)
#define DEL_DEV_UUID_FLAG BIT(1)
/** Information of the device which is going to be deleted. */
typedef struct {
union {
struct {
esp_ble_mesh_bd_addr_t addr; /*!< Device address */
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
};
uint8_t uuid[16]; /*!< Device UUID */
};
uint8_t flag; /*!< BIT0: device address; BIT1: device UUID */
} esp_ble_mesh_device_delete_t;
#define PROV_DATA_NET_IDX_FLAG BIT(0)
#define PROV_DATA_FLAGS_FLAG BIT(1)
#define PROV_DATA_IV_INDEX_FLAG BIT(2)
/** Information of the provisioner which is going to be updated. */
typedef struct {
union {
uint16_t net_idx; /*!< NetKey Index */
uint8_t flags; /*!< Flags */
uint32_t iv_index; /*!< IV Index */
};
uint8_t flag; /*!< BIT0: net_idx; BIT1: flags; BIT2: iv_index */
} esp_ble_mesh_prov_data_info_t;
/** Information of the provisioned node */
typedef struct {
/* Device information */
esp_ble_mesh_bd_addr_t addr; /*!< Node device address */
esp_ble_mesh_addr_type_t addr_type; /*!< Node device address type */
uint8_t dev_uuid[16]; /*!< Device UUID */
uint16_t oob_info; /*!< Node OOB information */
/* Provisioning information */
uint16_t unicast_addr; /*!< Node unicast address */
uint8_t element_num; /*!< Node element number */
uint16_t net_idx; /*!< Node NetKey Index */
uint8_t flags; /*!< Node key refresh flag and iv update flag */
uint32_t iv_index; /*!< Node IV Index */
uint8_t dev_key[16]; /*!< Node device key */
/* Additional information */
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN + 1]; /*!< Node name */
uint16_t comp_length; /*!< Length of Composition Data */
uint8_t *comp_data; /*!< Value of Composition Data */
} __attribute__((packed)) esp_ble_mesh_node_t;
/** Context of fast provisioning which need to be set. */
typedef struct {
uint16_t unicast_min; /*!< Minimum unicast address used for fast provisioning */
uint16_t unicast_max; /*!< Maximum unicast address used for fast provisioning */
uint16_t net_idx; /*!< Netkey index used for fast provisioning */
uint8_t flags; /*!< Flags used for fast provisioning */
uint32_t iv_index; /*!< IV Index used for fast provisioning */
uint8_t offset; /*!< Offset of the UUID to be compared */
uint8_t match_len; /*!< Length of the UUID to be compared */
uint8_t match_val[16]; /*!< Value of UUID to be compared */
} esp_ble_mesh_fast_prov_info_t;
/*!< This enum value is the action of fast provisioning */
typedef enum {
FAST_PROV_ACT_NONE,
FAST_PROV_ACT_ENTER,
FAST_PROV_ACT_SUSPEND,
FAST_PROV_ACT_EXIT,
FAST_PROV_ACT_MAX,
} esp_ble_mesh_fast_prov_action_t;
/*!< This enum value is the type of proxy filter */
typedef enum {
PROXY_FILTER_WHITELIST,
PROXY_FILTER_BLACKLIST,
} esp_ble_mesh_proxy_filter_type_t;
/*!< Provisioner heartbeat filter type */
#define ESP_BLE_MESH_HEARTBEAT_FILTER_ACCEPTLIST 0x00
#define ESP_BLE_MESH_HEARTBEAT_FILTER_REJECTLIST 0x01
/*!< Provisioner heartbeat filter operation */
#define ESP_BLE_MESH_HEARTBEAT_FILTER_ADD 0x00
#define ESP_BLE_MESH_HEARTBEAT_FILTER_REMOVE 0x01
/** Context of Provisioner heartbeat filter information to be set */
typedef struct {
uint16_t hb_src; /*!< Heartbeat source address (unicast address) */
uint16_t hb_dst; /*!< Heartbeat destination address (unicast address or group address) */
} esp_ble_mesh_heartbeat_filter_info_t;
/*!< This enum value is the event of node/provisioner/fast provisioning */
typedef enum {
ESP_BLE_MESH_PROV_REGISTER_COMP_EVT, /*!< Initialize BLE Mesh provisioning capabilities and internal data information completion event */
ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT, /*!< Set the unprovisioned device name completion event */
ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT, /*!< Enable node provisioning functionality completion event */
ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT, /*!< Disable node provisioning functionality completion event */
ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT, /*!< Establish a BLE Mesh link event */
ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT, /*!< Close a BLE Mesh link event */
ESP_BLE_MESH_NODE_PROV_OOB_PUB_KEY_EVT, /*!< Generate Node input OOB public key event */
ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT, /*!< Generate Node Output Number event */
ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT, /*!< Generate Node Output String event */
ESP_BLE_MESH_NODE_PROV_INPUT_EVT, /*!< Event requiring the user to input a number or string */
ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT, /*!< Provisioning done event */
ESP_BLE_MESH_NODE_PROV_RESET_EVT, /*!< Provisioning reset event */
ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT, /*!< Node set oob public key completion event */
ESP_BLE_MESH_NODE_PROV_INPUT_NUMBER_COMP_EVT, /*!< Node input number completion event */
ESP_BLE_MESH_NODE_PROV_INPUT_STRING_COMP_EVT, /*!< Node input string completion event */
ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT, /*!< Enable BLE Mesh Proxy Identity advertising completion event */
ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT, /*!< Enable BLE Mesh GATT Proxy Service completion event */
ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT, /*!< Disable BLE Mesh GATT Proxy Service completion event */
ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Node add NetKey locally completion event */
ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Node add AppKey locally completion event */
ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Node bind AppKey to model locally completion event */
ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT, /*!< Provisioner enable provisioning functionality completion event */
ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT, /*!< Provisioner disable provisioning functionality completion event */
ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT, /*!< Provisioner receives unprovisioned device beacon event */
ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT, /*!< Provisioner read unprovisioned device OOB public key event */
ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT, /*!< Provisioner input value for provisioning procedure event */
ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT, /*!< Provisioner output value for provisioning procedure event */
ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT, /*!< Provisioner establish a BLE Mesh link event */
ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT, /*!< Provisioner close a BLE Mesh link event */
ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT, /*!< Provisioner provisioning done event */
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 */
ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT, /*!< Provisioner start to provision an unprovisioned device completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */
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 */
ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT, /*!< Provisioner set net_idx/flags/iv_index used for provisioning completion event */
ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT, /*!< Provisioner set static oob value used for provisioning completion event */
ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT, /*!< Provisioner set unicast address of primary element completion event */
ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT, /*!< Provisioner read unprovisioned device OOB public key completion event */
ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT, /*!< Provisioner input number completion event */
ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT, /*!< Provisioner input string completion event */
ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT, /*!< Provisioner set node name completion event */
ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Provisioner add local app key completion event */
ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT, /*!< Provisioner update local app key completion event */
ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Provisioner bind local model with local app key completion event */
ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Provisioner add local network key completion event */
ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT, /*!< Provisioner update local network key completion event */
ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT, /*!< Provisioner store node composition data completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT, /*!< Provisioner delete node with uuid completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT, /*!< Provisioner delete node with unicast address completion event */
ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT, /*!< Provisioner start to receive heartbeat message completion event */
ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT, /*!< Provisioner set the heartbeat filter type completion event */
ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT, /*!< Provisioner set the heartbeat filter information completion event */
ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT, /*!< Provisioner receive heartbeat message event */
ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT, /*!< Provisioner directly erase settings completion event */
ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner open settings with index completion event */
ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner open settings with user id completion event */
ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner close settings with index completion event */
ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner close settings with user id completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner delete settings with index completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner delete settings with user id completion event */
ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT, /*!< Set fast provisioning information (e.g. unicast address range, net_idx, etc.) completion event */
ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT, /*!< Set fast provisioning action completion event */
ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT, /*!< Receive Heartbeat message event */
ESP_BLE_MESH_LPN_ENABLE_COMP_EVT, /*!< Enable Low Power Node completion event */
ESP_BLE_MESH_LPN_DISABLE_COMP_EVT, /*!< Disable Low Power Node completion event */
ESP_BLE_MESH_LPN_POLL_COMP_EVT, /*!< Low Power Node send Friend Poll completion event */
ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT, /*!< Low Power Node establishes friendship event */
ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT, /*!< Low Power Node terminates friendship event */
ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT, /*!< Friend Node establishes friendship event */
ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT, /*!< Friend Node terminates friendship event */
ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT, /*!< Proxy Client receives Network ID advertising packet event */
ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT, /*!< Proxy Client establishes connection successfully event */
ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT, /*!< Proxy Client terminates connection successfully event */
ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT, /*!< Proxy Client receives Proxy Filter Status event */
ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT, /*!< Proxy Client connect completion event */
ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT, /*!< Proxy Client disconnect completion event */
ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT, /*!< Proxy Client set filter type completion event */
ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT, /*!< Proxy Client add filter address completion event */
ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT, /*!< Proxy Client remove filter address completion event */
ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model subscribes group address completion event */
ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model unsubscribes group address completion event */
ESP_BLE_MESH_DEINIT_MESH_COMP_EVT, /*!< De-initialize BLE Mesh stack completion event */
ESP_BLE_MESH_PROV_EVT_MAX,
} esp_ble_mesh_prov_cb_event_t;
/**
* @brief BLE Mesh Node/Provisioner callback parameters union
*/
typedef union {
/**
* @brief ESP_BLE_MESH_PROV_REGISTER_COMP_EVT
*/
struct ble_mesh_prov_register_comp_param {
int err_code; /*!< Indicate the result of BLE Mesh initialization */
} prov_register_comp; /*!< Event parameter of ESP_BLE_MESH_PROV_REGISTER_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT
*/
struct ble_mesh_set_unprov_dev_name_comp_param {
int err_code; /*!< Indicate the result of setting BLE Mesh device name */
} node_set_unprov_dev_name_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT
*/
struct ble_mesh_prov_enable_comp_param {
int err_code; /*!< Indicate the result of enabling BLE Mesh device */
} node_prov_enable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT
*/
struct ble_mesh_prov_disable_comp_param {
int err_code; /*!< Indicate the result of disabling BLE Mesh device */
} node_prov_disable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT
*/
struct ble_mesh_link_open_evt_param {
esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when device link is open */
} node_prov_link_open; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT
*/
struct ble_mesh_link_close_evt_param {
esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when device link is closed */
} node_prov_link_close; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT
*/
struct ble_mesh_output_num_evt_param {
esp_ble_mesh_output_action_t action; /*!< Action of Output OOB Authentication */
uint32_t number; /*!< Number of Output OOB Authentication */
} node_prov_output_num; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT
*/
struct ble_mesh_output_str_evt_param {
char string[8]; /*!< String of Output OOB Authentication */
} node_prov_output_str; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_INPUT_EVT
*/
struct ble_mesh_input_evt_param {
esp_ble_mesh_input_action_t action; /*!< Action of Input OOB Authentication */
uint8_t size; /*!< Size of Input OOB Authentication */
} node_prov_input; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT
*/
struct ble_mesh_provision_complete_evt_param {
uint16_t net_idx; /*!< NetKey Index */
uint8_t net_key[16]; /*!< NetKey */
uint16_t addr; /*!< Primary address */
uint8_t flags; /*!< Flags */
uint32_t iv_index; /*!< IV Index */
} node_prov_complete; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_RESET_EVT
*/
struct ble_mesh_provision_reset_param {
} node_prov_reset; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_RESET_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT
*/
struct ble_mesh_set_oob_pub_key_comp_param {
int err_code; /*!< Indicate the result of setting OOB Public Key */
} node_prov_set_oob_pub_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_INPUT_NUM_COMP_EVT
*/
struct ble_mesh_input_number_comp_param {
int err_code; /*!< Indicate the result of inputting number */
} node_prov_input_num_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_NUM_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROV_INPUT_STR_COMP_EVT
*/
struct ble_mesh_input_string_comp_param {
int err_code; /*!< Indicate the result of inputting string */
} node_prov_input_str_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_STR_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT
*/
struct ble_mesh_proxy_identity_enable_comp_param {
int err_code; /*!< Indicate the result of enabling Mesh Proxy advertising */
} node_proxy_identity_enable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT
*/
struct ble_mesh_proxy_gatt_enable_comp_param {
int err_code; /*!< Indicate the result of enabling Mesh Proxy Service */
} node_proxy_gatt_enable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT
*/
struct ble_mesh_proxy_gatt_disable_comp_param {
int err_code; /*!< Indicate the result of disabling Mesh Proxy Service */
} node_proxy_gatt_disable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT
*/
struct ble_mesh_node_add_local_net_key_comp_param {
int err_code; /*!< Indicate the result of adding local NetKey by the node */
uint16_t net_idx; /*!< NetKey Index */
} node_add_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT */
/**