forked from espressif/arduino-esp32
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbta_dm_int.h
1257 lines (1053 loc) · 39.6 KB
/
bta_dm_int.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 (C) 2003-2012 Broadcom Corporation
*
* 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.
*
******************************************************************************/
/******************************************************************************
*
* This is the private interface file for the BTA device manager.
*
******************************************************************************/
#ifndef BTA_DM_INT_H
#define BTA_DM_INT_H
#include "bt_target.h"
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
#include "bta_gatt_api.h"
#endif
/*****************************************************************************
** Constants and data types
*****************************************************************************/
#define BTA_COPY_DEVICE_CLASS(coddst, codsrc) {((UINT8 *)(coddst))[0] = ((UINT8 *)(codsrc))[0]; \
((UINT8 *)(coddst))[1] = ((UINT8 *)(codsrc))[1]; \
((UINT8 *)(coddst))[2] = ((UINT8 *)(codsrc))[2];}
#define BTA_DM_MSG_LEN 50
#define BTA_SERVICE_ID_TO_SERVICE_MASK(id) (1 << (id))
/* DM events */
enum {
/* device manager local device API events */
BTA_DM_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_DM),
BTA_DM_API_DISABLE_EVT,
BTA_DM_API_SET_NAME_EVT,
BTA_DM_API_SET_VISIBILITY_EVT,
BTA_DM_ACL_CHANGE_EVT,
BTA_DM_API_ADD_DEVICE_EVT,
BTA_DM_API_REMOVE_ACL_EVT,
#if (SMP_INCLUDED == TRUE)
/* security API events */
BTA_DM_API_BOND_EVT,
BTA_DM_API_BOND_CANCEL_EVT,
BTA_DM_API_PIN_REPLY_EVT,
#endif ///SMP_INCLUDED == TRUE
#if (BTM_SSR_INCLUDED == TRUE)
/* power manger events */
BTA_DM_PM_BTM_STATUS_EVT,
BTA_DM_PM_TIMER_EVT,
#endif ///BTM_SSR_INCLUDED == TRUE
#if (SMP_INCLUDED == TRUE)
/* simple pairing events */
BTA_DM_API_CONFIRM_EVT,
BTA_DM_API_SET_ENCRYPTION_EVT,
#endif ///SMP_INCLUDED == TRUE
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
BTA_DM_API_LOC_OOB_EVT,
BTA_DM_CI_IO_REQ_EVT,
BTA_DM_CI_RMT_OOB_EVT,
#endif /* BTM_OOB_INCLUDED */
#if BLE_INCLUDED == TRUE
#if SMP_INCLUDED == TRUE
BTA_DM_API_ADD_BLEKEY_EVT,
BTA_DM_API_ADD_BLEDEVICE_EVT,
BTA_DM_API_BLE_PASSKEY_REPLY_EVT,
BTA_DM_API_BLE_CONFIRM_REPLY_EVT,
BTA_DM_API_BLE_SEC_GRANT_EVT,
#endif ///SMP_INCLUDED == TRUE
BTA_DM_API_BLE_SET_BG_CONN_TYPE,
BTA_DM_API_BLE_CONN_PARAM_EVT,
BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT,
BTA_DM_API_BLE_SCAN_PARAM_EVT,
/*******This event added by Yulong at 2016/10/25 to
support the scan filter setting for the APP******/
BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT,
BTA_DM_API_BLE_OBSERVE_EVT,
BTA_DM_API_BLE_SCAN_EVT,
BTA_DM_API_UPDATE_CONN_PARAM_EVT,
/*******This event added by Yulong at 2016/9/9 to
support the random address setting for the APP******/
BTA_DM_API_SET_RAND_ADDR_EVT,
/*******This event added by Yulong at 2016/10/19 to
support stop the ble advertising setting by the APP******/
BTA_DM_API_BLE_STOP_ADV_EVT,
#if BLE_PRIVACY_SPT == TRUE
BTA_DM_API_LOCAL_PRIVACY_EVT,
#endif
BTA_DM_API_BLE_ADV_PARAM_EVT,
/*******This event added by Yulong at 2016/10/20 to
support setting the ble advertising param by the APP******/
BTA_DM_API_BLE_ADV_PARAM_All_EVT,
BTA_DM_API_BLE_SET_ADV_CONFIG_EVT,
/* Add for set raw advertising data */
BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT,
BTA_DM_API_BLE_SET_SCAN_RSP_EVT,
/* Add for set raw scan response data */
BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT,
BTA_DM_API_BLE_BROADCAST_EVT,
BTA_DM_API_SET_DATA_LENGTH_EVT,
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
BTA_DM_API_CFG_FILTER_COND_EVT,
BTA_DM_API_SCAN_FILTER_SETUP_EVT,
BTA_DM_API_SCAN_FILTER_ENABLE_EVT,
#endif
BTA_DM_API_BLE_MULTI_ADV_ENB_EVT,
BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT,
BTA_DM_API_BLE_MULTI_ADV_DATA_EVT,
BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT,
BTA_DM_API_BLE_SETUP_STORAGE_EVT,
BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT,
BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT,
BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT,
BTA_DM_API_BLE_TRACK_ADVERTISER_EVT,
BTA_DM_API_BLE_ENERGY_INFO_EVT,
BTA_DM_API_BLE_DISCONNECT_EVT,
#endif
BTA_DM_API_ENABLE_TEST_MODE_EVT,
BTA_DM_API_DISABLE_TEST_MODE_EVT,
BTA_DM_API_EXECUTE_CBACK_EVT,
BTA_DM_API_REMOVE_ALL_ACL_EVT,
BTA_DM_API_REMOVE_DEVICE_EVT,
BTA_DM_API_UPDATE_WHITE_LIST_EVT,
BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT,
BTA_DM_API_BLE_READ_RSSI_EVT,
BTA_DM_MAX_EVT
};
/* DM search events */
enum {
/* DM search API events */
BTA_DM_API_SEARCH_EVT = BTA_SYS_EVT_START(BTA_ID_DM_SEARCH),
BTA_DM_API_SEARCH_CANCEL_EVT,
BTA_DM_API_DISCOVER_EVT,
BTA_DM_INQUIRY_CMPL_EVT,
BTA_DM_REMT_NAME_EVT,
BTA_DM_SDP_RESULT_EVT,
BTA_DM_SEARCH_CMPL_EVT,
BTA_DM_DISCOVERY_RESULT_EVT,
BTA_DM_API_DI_DISCOVER_EVT,
BTA_DM_DISC_CLOSE_TOUT_EVT,
};
/* data type for BTA_DM_API_ENABLE_EVT */
typedef struct {
BT_HDR hdr;
tBTA_DM_SEC_CBACK *p_sec_cback;
} tBTA_DM_API_ENABLE;
/* data type for BTA_DM_API_SET_NAME_EVT */
typedef struct {
BT_HDR hdr;
BD_NAME name; /* max 248 bytes name, plus must be Null terminated */
} tBTA_DM_API_SET_NAME;
typedef struct {
BT_HDR hdr;
BOOLEAN add_remove;
BD_ADDR remote_addr;
tBTA_ADD_WHITELIST_CBACK *add_wl_cb;
}tBTA_DM_API_UPDATE_WHITE_LIST;
typedef struct {
BT_HDR hdr;
tBTA_CMPL_CB *read_tx_power_cb;
}tBTA_DM_API_READ_ADV_TX_POWER;
typedef struct {
BT_HDR hdr;
BD_ADDR remote_addr;
tBTA_CMPL_CB *read_rssi_cb;
}tBTA_DM_API_READ_RSSI;
/* data type for BTA_DM_API_SET_VISIBILITY_EVT */
typedef struct {
BT_HDR hdr;
tBTA_DM_DISC disc_mode;
tBTA_DM_CONN conn_mode;
UINT8 pair_mode;
UINT8 conn_paired_only;
} tBTA_DM_API_SET_VISIBILITY;
enum {
BTA_DM_RS_NONE, /* straight API call */
BTA_DM_RS_OK, /* the role switch result - successful */
BTA_DM_RS_FAIL /* the role switch result - failed */
};
typedef UINT8 tBTA_DM_RS_RES;
/* data type for BTA_DM_API_SEARCH_EVT */
typedef struct {
BT_HDR hdr;
tBTA_DM_INQ inq_params;
tBTA_SERVICE_MASK services;
tBTA_DM_SEARCH_CBACK *p_cback;
tBTA_DM_RS_RES rs_res;
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
UINT8 num_uuid;
tBT_UUID *p_uuid;
#endif
} tBTA_DM_API_SEARCH;
#if (SDP_INCLUDED == TRUE)
/* data type for BTA_DM_API_DISCOVER_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
tBTA_SERVICE_MASK services;
tBTA_DM_SEARCH_CBACK *p_cback;
BOOLEAN sdp_search;
tBTA_TRANSPORT transport;
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
UINT8 num_uuid;
tBT_UUID *p_uuid;
#endif
tSDP_UUID uuid;
} tBTA_DM_API_DISCOVER;
#endif ///SDP_INCLUDED == TRUE
/* data type for BTA_DM_API_DI_DISC_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
#if (SDP_INCLUDED == TRUE)
tBTA_DISCOVERY_DB *p_sdp_db;
#endif ///SDP_INCLUDED == TRUE
UINT32 len;
tBTA_DM_SEARCH_CBACK *p_cback;
} tBTA_DM_API_DI_DISC;
/* data type for BTA_DM_API_BOND_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
tBTA_TRANSPORT transport;
} tBTA_DM_API_BOND;
/* data type for BTA_DM_API_BOND_CANCEL_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
tBTA_TRANSPORT transport;
} tBTA_DM_API_BOND_CANCEL;
/* data type for BTA_DM_API_PIN_REPLY_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
BOOLEAN accept;
UINT8 pin_len;
UINT8 p_pin[PIN_CODE_LEN];
} tBTA_DM_API_PIN_REPLY;
/* data type for BTA_DM_API_LOC_OOB_EVT */
typedef struct {
BT_HDR hdr;
} tBTA_DM_API_LOC_OOB;
/* data type for BTA_DM_API_CONFIRM_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
BOOLEAN accept;
} tBTA_DM_API_CONFIRM;
/* data type for BTA_DM_CI_IO_REQ_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
tBTA_IO_CAP io_cap;
tBTA_OOB_DATA oob_data;
tBTA_AUTH_REQ auth_req;
} tBTA_DM_CI_IO_REQ;
/* data type for BTA_DM_CI_RMT_OOB_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
BT_OCTET16 c;
BT_OCTET16 r;
BOOLEAN accept;
} tBTA_DM_CI_RMT_OOB;
/* data type for BTA_DM_REMT_NAME_EVT */
typedef struct {
BT_HDR hdr;
tBTA_DM_SEARCH result;
} tBTA_DM_REM_NAME;
/* data type for tBTA_DM_DISC_RESULT */
typedef struct {
BT_HDR hdr;
tBTA_DM_SEARCH result;
} tBTA_DM_DISC_RESULT;
/* data type for BTA_DM_INQUIRY_CMPL_EVT */
typedef struct {
BT_HDR hdr;
UINT8 num;
} tBTA_DM_INQUIRY_CMPL;
/* data type for BTA_DM_SDP_RESULT_EVT */
typedef struct {
BT_HDR hdr;
UINT16 sdp_result;
} tBTA_DM_SDP_RESULT;
/* data type for BTA_DM_ACL_CHANGE_EVT */
typedef struct {
BT_HDR hdr;
tBTM_BL_EVENT event;
UINT8 busy_level;
UINT8 busy_level_flags;
BOOLEAN is_new;
UINT8 new_role;
BD_ADDR bd_addr;
UINT8 hci_status;
#if BLE_INCLUDED == TRUE
UINT16 handle;
tBT_TRANSPORT transport;
#endif
} tBTA_DM_ACL_CHANGE;
/* data type for BTA_DM_PM_BTM_STATUS_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
tBTM_PM_STATUS status;
UINT16 value;
UINT8 hci_status;
} tBTA_DM_PM_BTM_STATUS;
/* data type for BTA_DM_PM_TIMER_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
tBTA_DM_PM_ACTION pm_request;
} tBTA_DM_PM_TIMER;
/* data type for BTA_DM_API_ADD_DEVICE_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
DEV_CLASS dc;
LINK_KEY link_key;
tBTA_SERVICE_MASK tm;
BOOLEAN is_trusted;
UINT8 key_type;
tBTA_IO_CAP io_cap;
BOOLEAN link_key_known;
BOOLEAN dc_known;
BD_NAME bd_name;
UINT8 features[BTA_FEATURE_BYTES_PER_PAGE * (BTA_EXT_FEATURES_PAGE_MAX + 1)];
UINT8 pin_length;
} tBTA_DM_API_ADD_DEVICE;
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
} tBTA_DM_API_REMOVE_DEVICE;
/* data type for BTA_DM_API_EXECUTE_CBACK_EVT */
typedef struct {
BT_HDR hdr;
void *p_param;
tBTA_DM_EXEC_CBACK *p_exec_cback;
} tBTA_DM_API_EXECUTE_CBACK;
/* data type for tBTA_DM_API_SET_ENCRYPTION */
typedef struct {
BT_HDR hdr;
tBTA_TRANSPORT transport;
tBTA_DM_ENCRYPT_CBACK *p_callback;
tBTA_DM_BLE_SEC_ACT sec_act;
BD_ADDR bd_addr;
} tBTA_DM_API_SET_ENCRYPTION;
#if BLE_INCLUDED == TRUE
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
tBTA_LE_KEY_VALUE blekey;
tBTA_LE_KEY_TYPE key_type;
} tBTA_DM_API_ADD_BLEKEY;
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
tBT_DEVICE_TYPE dev_type ;
tBLE_ADDR_TYPE addr_type;
} tBTA_DM_API_ADD_BLE_DEVICE;
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
BOOLEAN accept;
UINT32 passkey;
} tBTA_DM_API_PASSKEY_REPLY;
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
tBTA_DM_BLE_SEC_GRANT res;
} tBTA_DM_API_BLE_SEC_GRANT;
typedef struct {
BT_HDR hdr;
tBTA_DM_BLE_CONN_TYPE bg_conn_type;
tBTA_DM_BLE_SEL_CBACK *p_select_cback;
} tBTA_DM_API_BLE_SET_BG_CONN_TYPE;
/* set prefered BLE connection parameters for a device */
typedef struct {
BT_HDR hdr;
BD_ADDR peer_bda;
UINT16 conn_int_min;
UINT16 conn_int_max;
UINT16 supervision_tout;
UINT16 slave_latency;
} tBTA_DM_API_BLE_CONN_PARAMS;
typedef struct {
BT_HDR hdr;
BD_ADDR peer_bda;
BOOLEAN privacy_enable;
} tBTA_DM_API_ENABLE_PRIVACY;
typedef struct {
BT_HDR hdr;
BOOLEAN privacy_enable;
tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
} tBTA_DM_API_LOCAL_PRIVACY;
/* set scan parameter for BLE connections */
typedef struct {
BT_HDR hdr;
tBTA_GATTC_IF client_if;
UINT32 scan_int;
UINT32 scan_window;
tBLE_SCAN_MODE scan_mode;
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback;
} tBTA_DM_API_BLE_SCAN_PARAMS;
typedef struct {
BT_HDR hdr;
tBTA_GATTC_IF client_if;
UINT32 scan_int;
UINT32 scan_window;
tBLE_SCAN_MODE scan_mode;
UINT8 addr_type_own;
UINT8 scan_filter_policy;
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback;
} tBTA_DM_API_BLE_SCAN_FILTER_PARAMS;
/* set scan parameter for BLE connections */
typedef struct {
BT_HDR hdr;
UINT16 scan_int;
UINT16 scan_window;
} tBTA_DM_API_BLE_CONN_SCAN_PARAMS;
/* Data type for start/stop observe */
typedef struct {
BT_HDR hdr;
BOOLEAN start;
UINT32 duration;
tBTA_DM_SEARCH_CBACK *p_cback;
tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_scan_cback;
tBTA_START_STOP_SCAN_CMPL_CBACK *p_stop_scan_cback;
tBTA_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback;
} tBTA_DM_API_BLE_OBSERVE;
/* Data type for start/stop scan */
typedef struct {
BT_HDR hdr;
BOOLEAN start;
UINT32 duration;
tBTA_DM_SEARCH_CBACK *p_cback;
tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_scan_cback;
tBTA_START_STOP_SCAN_CMPL_CBACK *p_stop_scan_cback;
tBTA_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback;
} tBTA_DM_API_BLE_SCAN;
typedef struct {
BT_HDR hdr;
BD_ADDR remote_bda;
UINT16 tx_data_length;
tBTA_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback;
} tBTA_DM_API_BLE_SET_DATA_LENGTH;
/* set the address for BLE device
this type added by Yulong at 2016/9/9*/
typedef struct {
BT_HDR hdr;
tBLE_ADDR_TYPE addr_type;
BD_ADDR address;
tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback;
} tBTA_DM_APT_SET_DEV_ADDR;
/* set adv parameter for BLE advertising */
typedef struct {
BT_HDR hdr;
UINT16 adv_int_min;
UINT16 adv_int_max;
tBLE_BD_ADDR *p_dir_bda;
} tBTA_DM_API_BLE_ADV_PARAMS;
/* set adv parameter for BLE advertising */
typedef struct {
BT_HDR hdr;
UINT16 adv_int_min;
UINT16 adv_int_max;
UINT8 adv_type;
tBLE_ADDR_TYPE addr_type_own;
tBTM_BLE_ADV_CHNL_MAP channel_map;
tBTM_BLE_AFP adv_filter_policy;
tBLE_BD_ADDR *p_dir_bda;
tBTA_START_ADV_CMPL_CBACK *p_start_adv_cback;
} tBTA_DM_API_BLE_ADV_PARAMS_ALL;
typedef struct {
BT_HDR hdr;
BOOLEAN enable;
} tBTA_DM_API_BLE_FEATURE;
/* multi adv data structure */
typedef struct {
BT_HDR hdr;
tBTA_BLE_MULTI_ADV_CBACK *p_cback;
void *p_ref;
tBTA_BLE_ADV_PARAMS *p_params;
} tBTA_DM_API_BLE_MULTI_ADV_ENB;
typedef struct {
BT_HDR hdr;
UINT8 inst_id;
tBTA_BLE_ADV_PARAMS *p_params;
} tBTA_DM_API_BLE_MULTI_ADV_PARAM;
typedef struct {
BT_HDR hdr;
UINT8 inst_id;
BOOLEAN is_scan_rsp;
tBTA_BLE_AD_MASK data_mask;
tBTA_BLE_ADV_DATA *p_data;
} tBTA_DM_API_BLE_MULTI_ADV_DATA;
typedef struct {
BT_HDR hdr;
UINT8 inst_id;
} tBTA_DM_API_BLE_MULTI_ADV_DISABLE;
typedef struct {
BT_HDR hdr;
UINT32 data_mask;
tBTA_BLE_ADV_DATA *p_adv_cfg;
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback;
} tBTA_DM_API_SET_ADV_CONFIG;
/* raw scan response and raw advertising data use
the same structure */
typedef struct {
BT_HDR hdr;
UINT8 *p_raw_adv;
UINT32 raw_adv_len;
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback;
} tBTA_DM_API_SET_ADV_CONFIG_RAW;
typedef struct {
BT_HDR hdr;
UINT8 batch_scan_full_max;
UINT8 batch_scan_trunc_max;
UINT8 batch_scan_notify_threshold;
tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback;
tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback;
tBTA_BLE_SCAN_REP_CBACK *p_read_rep_cback;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_SET_STORAGE_CONFIG;
typedef struct {
BT_HDR hdr;
tBTA_BLE_BATCH_SCAN_MODE scan_mode;
UINT32 scan_int;
UINT32 scan_window;
tBTA_BLE_DISCARD_RULE discard_rule;
tBLE_ADDR_TYPE addr_type;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_ENABLE_SCAN;
typedef struct {
BT_HDR hdr;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_DISABLE_SCAN;
typedef struct {
BT_HDR hdr;
tBTA_BLE_BATCH_SCAN_MODE scan_type;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_READ_SCAN_REPORTS;
typedef struct {
BT_HDR hdr;
tBTA_DM_BLE_REF_VALUE ref_value;
tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback;
} tBTA_DM_API_TRACK_ADVERTISER;
typedef struct {
BT_HDR hdr;
tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback;
} tBTA_DM_API_ENERGY_INFO;
typedef struct {
BT_HDR hdr;
BD_ADDR remote_bda;
} tBTA_DM_API_BLE_DISCONNECT;
#endif /* BLE_INCLUDED */
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
BOOLEAN remove_dev;
tBTA_TRANSPORT transport;
} tBTA_DM_API_REMOVE_ACL;
/* data type for BTA_DM_API_REMOVE_ALL_ACL_EVT */
typedef struct {
BT_HDR hdr;
tBTA_DM_LINK_TYPE link_type;
} tBTA_DM_API_REMOVE_ALL_ACL;
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
UINT16 min_int;
UINT16 max_int;
UINT16 latency;
UINT16 timeout;
} tBTA_DM_API_UPDATE_CONN_PARAM;
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
typedef struct {
BT_HDR hdr;
tBTA_DM_BLE_SCAN_COND_OP action;
tBTA_DM_BLE_PF_COND_TYPE cond_type;
tBTA_DM_BLE_PF_FILT_INDEX filt_index;
tBTA_DM_BLE_PF_COND_PARAM *p_cond_param;
tBTA_DM_BLE_PF_CFG_CBACK *p_filt_cfg_cback;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_CFG_FILTER_COND;
typedef struct {
BT_HDR hdr;
UINT8 action;
tBTA_DM_BLE_PF_STATUS_CBACK *p_filt_status_cback;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_ENABLE_SCAN_FILTER;
typedef struct {
BT_HDR hdr;
UINT8 action;
tBTA_DM_BLE_PF_FILT_INDEX filt_index;
tBTA_DM_BLE_PF_FILT_PARAMS filt_params;
tBLE_BD_ADDR *p_target;
tBTA_DM_BLE_PF_PARAM_CBACK *p_filt_param_cback;
tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_SCAN_FILTER_PARAM_SETUP;
#endif
/* union of all data types */
typedef union {
/* event buffer header */
BT_HDR hdr;
tBTA_DM_API_ENABLE enable;
tBTA_DM_API_SET_NAME set_name;
tBTA_DM_API_UPDATE_WHITE_LIST white_list;
tBTA_DM_API_READ_ADV_TX_POWER read_tx_power;
tBTA_DM_API_READ_RSSI rssi;
tBTA_DM_API_SET_VISIBILITY set_visibility;
tBTA_DM_API_ADD_DEVICE add_dev;
tBTA_DM_API_REMOVE_DEVICE remove_dev;
tBTA_DM_API_SEARCH search;
#if (SDP_INCLUDED == TRUE)
tBTA_DM_API_DISCOVER discover;
#endif ///SDP_INCLUDED == TRUE
tBTA_DM_API_BOND bond;
tBTA_DM_API_BOND_CANCEL bond_cancel;
tBTA_DM_API_PIN_REPLY pin_reply;
tBTA_DM_API_LOC_OOB loc_oob;
tBTA_DM_API_CONFIRM confirm;
tBTA_DM_CI_IO_REQ ci_io_req;
tBTA_DM_CI_RMT_OOB ci_rmt_oob;
tBTA_DM_REM_NAME rem_name;
tBTA_DM_DISC_RESULT disc_result;
tBTA_DM_INQUIRY_CMPL inq_cmpl;
tBTA_DM_SDP_RESULT sdp_event;
tBTA_DM_ACL_CHANGE acl_change;
tBTA_DM_PM_BTM_STATUS pm_status;
tBTA_DM_PM_TIMER pm_timer;
tBTA_DM_API_DI_DISC di_disc;
tBTA_DM_API_EXECUTE_CBACK exec_cback;
tBTA_DM_API_SET_ENCRYPTION set_encryption;
#if BLE_INCLUDED == TRUE
tBTA_DM_API_ADD_BLEKEY add_ble_key;
tBTA_DM_API_ADD_BLE_DEVICE add_ble_device;
tBTA_DM_API_PASSKEY_REPLY ble_passkey_reply;
tBTA_DM_API_BLE_SEC_GRANT ble_sec_grant;
tBTA_DM_API_BLE_SET_BG_CONN_TYPE ble_set_bd_conn_type;
tBTA_DM_API_BLE_CONN_PARAMS ble_set_conn_params;
tBTA_DM_API_BLE_CONN_SCAN_PARAMS ble_set_conn_scan_params;
tBTA_DM_API_BLE_SCAN_PARAMS ble_set_scan_params;
tBTA_DM_API_BLE_SCAN_FILTER_PARAMS ble_set_scan_fil_params;
tBTA_DM_API_BLE_OBSERVE ble_observe;
tBTA_DM_API_BLE_SCAN ble_scan;
tBTA_DM_API_ENABLE_PRIVACY ble_remote_privacy;
tBTA_DM_API_LOCAL_PRIVACY ble_local_privacy;
tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params;
tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all;
tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data;
tBTA_DM_API_SET_ADV_CONFIG_RAW ble_set_adv_data_raw;
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
tBTA_DM_API_SCAN_FILTER_PARAM_SETUP ble_scan_filt_param_setup;
tBTA_DM_API_CFG_FILTER_COND ble_cfg_filter_cond;
tBTA_DM_API_ENABLE_SCAN_FILTER ble_enable_scan_filt;
#endif
tBTA_DM_API_UPDATE_CONN_PARAM ble_update_conn_params;
tBTA_DM_API_BLE_SET_DATA_LENGTH ble_set_data_length;
tBTA_DM_APT_SET_DEV_ADDR set_addr;
tBTA_DM_API_BLE_MULTI_ADV_ENB ble_multi_adv_enb;
tBTA_DM_API_BLE_MULTI_ADV_PARAM ble_multi_adv_param;
tBTA_DM_API_BLE_MULTI_ADV_DATA ble_multi_adv_data;
tBTA_DM_API_BLE_MULTI_ADV_DISABLE ble_multi_adv_disable;
tBTA_DM_API_SET_STORAGE_CONFIG ble_set_storage;
tBTA_DM_API_ENABLE_SCAN ble_enable_scan;
tBTA_DM_API_READ_SCAN_REPORTS ble_read_reports;
tBTA_DM_API_DISABLE_SCAN ble_disable_scan;
tBTA_DM_API_TRACK_ADVERTISER ble_track_advert;
tBTA_DM_API_ENERGY_INFO ble_energy_info;
tBTA_DM_API_BLE_DISCONNECT ble_disconnect;
#endif
tBTA_DM_API_REMOVE_ACL remove_acl;
tBTA_DM_API_REMOVE_ALL_ACL remove_all_acl;
} tBTA_DM_MSG;
#define BTA_DM_NUM_PEER_DEVICE 7
#define BTA_DM_NOT_CONNECTED 0
#define BTA_DM_CONNECTED 1
#define BTA_DM_UNPAIRING 2
typedef UINT8 tBTA_DM_CONN_STATE;
#define BTA_DM_DI_NONE 0x00 /* nothing special */
#define BTA_DM_DI_USE_SSR 0x10 /* set this bit if ssr is supported for this link */
#define BTA_DM_DI_AV_ACTIVE 0x20 /* set this bit if AV is active for this link */
#define BTA_DM_DI_SET_SNIFF 0x01 /* set this bit if call BTM_SetPowerMode(sniff) */
#define BTA_DM_DI_INT_SNIFF 0x02 /* set this bit if call BTM_SetPowerMode(sniff) & enter sniff mode */
#define BTA_DM_DI_ACP_SNIFF 0x04 /* set this bit if peer init sniff */
typedef UINT8 tBTA_DM_DEV_INFO;
/* set power mode request type */
#define BTA_DM_PM_RESTART 1
#define BTA_DM_PM_NEW_REQ 2
#define BTA_DM_PM_EXECUTE 3
typedef UINT8 tBTA_DM_PM_REQ;
typedef struct {
BD_ADDR peer_bdaddr;
UINT16 link_policy;
tBTA_DM_CONN_STATE conn_state;
tBTA_PREF_ROLES pref_role;
BOOLEAN in_use;
tBTA_DM_DEV_INFO info;
tBTA_DM_ENCRYPT_CBACK *p_encrypt_cback;
#if (BTM_SSR_INCLUDED == TRUE)
tBTM_PM_STATUS prev_low; /* previous low power mode used */
#endif
tBTA_DM_PM_ACTION pm_mode_attempted;
tBTA_DM_PM_ACTION pm_mode_failed;
BOOLEAN remove_dev_pending;
#if BLE_INCLUDED == TRUE
UINT16 conn_handle;
tBT_TRANSPORT transport;
#endif
} tBTA_DM_PEER_DEVICE;
/* structure to store list of
active connections */
typedef struct {
tBTA_DM_PEER_DEVICE peer_device[BTA_DM_NUM_PEER_DEVICE];
UINT8 count;
#if BLE_INCLUDED == TRUE
UINT8 le_count;
#endif
} tBTA_DM_ACTIVE_LINK;
typedef struct {
BD_ADDR peer_bdaddr;
tBTA_SYS_ID id;
UINT8 app_id;
tBTA_SYS_CONN_STATUS state;
BOOLEAN new_request;
} tBTA_DM_SRVCS;
#ifndef BTA_DM_NUM_CONN_SRVS
#define BTA_DM_NUM_CONN_SRVS 10
#endif
typedef struct {
UINT8 count;
tBTA_DM_SRVCS conn_srvc[BTA_DM_NUM_CONN_SRVS];
} tBTA_DM_CONNECTED_SRVCS;
typedef struct {
#define BTA_DM_PM_SNIFF_TIMER_IDX 0
#define BTA_DM_PM_PARK_TIMER_IDX 1
#define BTA_DM_PM_SUSPEND_TIMER_IDX 2
#define BTA_DM_PM_MODE_TIMER_MAX 3
/*
* Keep three different timers for PARK, SNIFF and SUSPEND if TBFC is
* supported.
*/
TIMER_LIST_ENT timer[BTA_DM_PM_MODE_TIMER_MAX];
UINT8 srvc_id[BTA_DM_PM_MODE_TIMER_MAX];
UINT8 pm_action[BTA_DM_PM_MODE_TIMER_MAX];
UINT8 active; /* number of active timer */
BD_ADDR peer_bdaddr;
BOOLEAN in_use;
} tBTA_PM_TIMER;
extern tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
#define BTA_DM_NUM_PM_TIMER 7
/* DM control block */
typedef struct {
BOOLEAN is_bta_dm_active;
tBTA_DM_ACTIVE_LINK device_list;
tBTA_DM_SEC_CBACK *p_sec_cback;
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback;
tBTA_DM_BLE_PF_CFG_CBACK *p_scan_filt_cfg_cback;
tBTA_DM_BLE_PF_STATUS_CBACK *p_scan_filt_status_cback;
tBTA_DM_BLE_PF_PARAM_CBACK *p_scan_filt_param_cback;
tBTA_BLE_MULTI_ADV_CBACK *p_multi_adv_cback;
tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback;
#endif
UINT16 state;
BOOLEAN disabling;
TIMER_LIST_ENT disable_timer;
UINT32 wbt_sdp_handle; /* WIDCOMM Extensions SDP record handle */
UINT8 wbt_scn; /* WIDCOMM Extensions SCN */
UINT8 num_master_only;
#if BTM_SSR_INCLUDED == TRUE
UINT8 pm_id;
tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER];
#endif ///BTM_SSR_INCLUDED == TRUE
UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */
UINT16 cur_policy; /* current default link policy */
UINT16 rs_event; /* the event waiting for role switch */
UINT8 cur_av_count; /* current AV connecions */
BOOLEAN disable_pair_mode; /* disable pair mode or not */
BOOLEAN conn_paired_only; /* allow connectable to paired device only or not */
tBTA_DM_API_SEARCH search_msg;
UINT16 page_scan_interval;
UINT16 page_scan_window;
UINT16 inquiry_scan_interval;
UINT16 inquiry_scan_window;
/* Storage for pin code request parameters */
BD_ADDR pin_bd_addr;
DEV_CLASS pin_dev_class;
tBTA_DM_SEC_EVT pin_evt;
UINT32 num_val; /* the numeric value for comparison. If just_works, do not show this number to UI */
BOOLEAN just_works; /* TRUE, if "Just Works" association model */
#if ( BTA_EIR_CANNED_UUID_LIST != TRUE )
/* store UUID list for EIR */
TIMER_LIST_ENT app_ready_timer;
UINT32 eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE];
#if (BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
tBT_UUID custom_uuid[BTA_EIR_SERVER_NUM_CUSTOM_UUID];
#endif
#endif
tBTA_DM_ENCRYPT_CBACK *p_encrypt_cback;
TIMER_LIST_ENT switch_delay_timer;
} tBTA_DM_CB;
#ifndef BTA_DM_SDP_DB_SIZE
#define BTA_DM_SDP_DB_SIZE 250
#endif
/* DM search control block */
typedef struct {
tBTA_DM_SEARCH_CBACK *p_search_cback;
tBTM_INQ_INFO *p_btm_inq_info;
tBTA_SERVICE_MASK services;
tBTA_SERVICE_MASK services_to_search;
tBTA_SERVICE_MASK services_found;
#if (SDP_INCLUDED == TRUE)
tSDP_DISCOVERY_DB *p_sdp_db;
#endif ///SDP_INCLUDED == TRUE
UINT16 state;
BD_ADDR peer_bdaddr;
BOOLEAN name_discover_done;
BD_NAME peer_name;
TIMER_LIST_ENT search_timer;
UINT8 service_index;
tBTA_DM_MSG *p_search_queue; /* search or discover commands during search cancel stored here */
BOOLEAN wait_disc;
BOOLEAN sdp_results;
#if (SDP_INCLUDED == TRUE)
tSDP_UUID uuid;
#endif ///SDP_INCLUDED == TRUE
UINT8 peer_scn;
BOOLEAN sdp_search;
BOOLEAN cancel_pending; /* inquiry cancel is pending */
tBTA_TRANSPORT transport;
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
tBTA_DM_SEARCH_CBACK *p_scan_cback;
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
tBTA_GATTC_IF client_if;
UINT8 num_uuid;