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
|
/*
* Copyright 1999-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 file contains the Bluetooth Manager (BTM) API function external
* definitions.
*
******************************************************************************/
#ifndef BTM_API_H
#define BTM_API_H
#include <cstdint>
#include <functional>
#include "device/include/esco_parameters.h"
#include "stack/btm/neighbor_inquiry.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_octets.h"
#include "stack/include/btm_api_types.h"
#include "stack/include/btm_log_history.h"
#include "stack/include/btm_status.h"
#include "stack/include/sco_client_callbacks.h"
#include "stack/include/sdp_api.h"
#include "types/bluetooth/uuid.h"
#include "types/bt_transport.h"
#include "types/raw_address.h"
void btm_init();
void btm_free();
/*****************************************************************************
* DEVICE CONTROL and COMMON
****************************************************************************/
/*****************************************************************************
* EXTERNAL FUNCTION DECLARATIONS
****************************************************************************/
/*****************************************************************************
* DEVICE CONTROL and COMMON FUNCTIONS
****************************************************************************/
void BTM_reset_complete();
/*******************************************************************************
*
* Function BTM_IsDeviceUp
*
* Description This function is called to check if the device is up.
*
* Returns true if device is up, else false
*
******************************************************************************/
bool BTM_IsDeviceUp(void);
/*******************************************************************************
*
* Function BTM_SetLocalDeviceName
*
* Description This function is called to set the local device name.
*
* Returns BTM_CMD_STARTED if successful, otherwise an error
*
******************************************************************************/
tBTM_STATUS BTM_SetLocalDeviceName(const char* p_name);
/*******************************************************************************
*
* Function BTM_SetDeviceClass
*
* Description This function is called to set the local device class
*
* Returns BTM_SUCCESS if successful, otherwise an error
*
******************************************************************************/
tBTM_STATUS BTM_SetDeviceClass(DEV_CLASS dev_class);
/*******************************************************************************
*
* Function BTM_ReadLocalDeviceName
*
* Description This function is called to read the local device name.
*
* Returns status of the operation
* If success, BTM_SUCCESS is returned and p_name points stored
* local device name
* If BTM doesn't store local device name, BTM_NO_RESOURCES is
* is returned and p_name is set to NULL
*
******************************************************************************/
tBTM_STATUS BTM_ReadLocalDeviceName(const char** p_name);
/*******************************************************************************
*
* Function BTM_ReadLocalDeviceNameFromController
*
* Description Get local device name from controller. Do not use cached
* name (used to get chip-id prior to btm reset complete).
*
* Returns BTM_CMD_STARTED if successful, otherwise an error
*
******************************************************************************/
tBTM_STATUS BTM_ReadLocalDeviceNameFromController(
tBTM_CMPL_CB* p_rln_cmpl_cback);
/*******************************************************************************
*
* Function BTM_ReadDeviceClass
*
* Description This function is called to read the local device class
*
* Returns pointer to the device class
*
******************************************************************************/
uint8_t* BTM_ReadDeviceClass(void);
/*******************************************************************************
*
* Function BTM_RegisterForVSEvents
*
* Description This function is called to register/deregister for vendor
* specific HCI events.
*
* If is_register=true, then the function will be registered;
* otherwise the function will be deregistered.
*
* Returns BTM_SUCCESS if successful,
* BTM_BUSY if maximum number of callbacks have already been
* registered.
*
******************************************************************************/
tBTM_STATUS BTM_RegisterForVSEvents(tBTM_VS_EVT_CB* p_cb, bool is_register);
/*******************************************************************************
*
* Function BTM_VendorSpecificCommand
*
* Description Send a vendor specific HCI command to the controller.
*
******************************************************************************/
void BTM_VendorSpecificCommand(uint16_t opcode, uint8_t param_len,
uint8_t* p_param_buf, tBTM_VSC_CMPL_CB* p_cb);
/*******************************************************************************
*
* Function BTM_AllocateSCN
*
* Description Look through the Server Channel Numbers for a free one to be
* used with an RFCOMM connection.
*
* Returns Allocated SCN number or 0 if none.
*
******************************************************************************/
uint8_t BTM_AllocateSCN(void);
/*******************************************************************************
*
* Function BTM_TryAllocateSCN
*
* Description Try to allocate a fixed server channel
*
* Returns Returns true if server channel was available
*
******************************************************************************/
bool BTM_TryAllocateSCN(uint8_t scn);
/*******************************************************************************
*
* Function BTM_FreeSCN
*
* Description Free the specified SCN.
*
* Returns true if successful, false if SCN is not in use or invalid
*
******************************************************************************/
bool BTM_FreeSCN(uint8_t scn);
/*******************************************************************************
*
* Function BTM_SetTraceLevel
*
* Description This function sets the trace level for BTM. If called with
* a value of 0xFF, it simply returns the current trace level.
*
* Returns The new or current trace level
*
******************************************************************************/
uint8_t BTM_SetTraceLevel(uint8_t new_level);
/*******************************************************************************
*
* Function BTM_WritePageTimeout
*
* Description Send HCI Wite Page Timeout.
*
******************************************************************************/
void BTM_WritePageTimeout(uint16_t timeout);
/*******************************************************************************
*
* Function BTM_WriteVoiceSettings
*
* Description Send HCI Write Voice Settings command.
* See hcidefs.h for settings bitmask values.
*
******************************************************************************/
void BTM_WriteVoiceSettings(uint16_t settings);
/*******************************************************************************
*
* Function BTM_EnableTestMode
*
* Description Send HCI the enable device under test command.
*
* Note: Controller can only be taken out of this mode by
* resetting the controller.
*
* Returns
* BTM_SUCCESS Command sent.
* BTM_NO_RESOURCES If out of resources to send the command.
*
*
******************************************************************************/
tBTM_STATUS BTM_EnableTestMode(void);
/*******************************************************************************
* DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device
******************************************************************************/
/*******************************************************************************
*
* Function BTM_SetDiscoverability
*
* Description This function is called to set the device into or out of
* discoverable mode. Discoverable mode means inquiry
* scans are enabled. If a value of '0' is entered for window
* or interval, the default values are used.
*
* Returns BTM_SUCCESS if successful
* BTM_BUSY if a setting of the filter is already in progress
* BTM_NO_RESOURCES if couldn't get a memory pool buffer
* BTM_ILLEGAL_VALUE if a bad parameter was detected
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode);
/*******************************************************************************
*
* Function BTM_StartInquiry
*
* Description This function is called to start an inquiry.
*
* Parameters: p_inqparms - pointer to the inquiry information
* mode - GENERAL or LIMITED inquiry
* duration - length in 1.28 sec intervals (If '0', the
* inquiry is CANCELLED)
* filter_cond_type - BTM_CLR_INQUIRY_FILTER,
* BTM_FILTER_COND_DEVICE_CLASS, or
* BTM_FILTER_COND_BD_ADDR
* filter_cond - value for the filter (based on
* filter_cond_type)
*
* p_results_cb - Pointer to the callback routine which gets
* called upon receipt of an inquiry result. If
* this field is NULL, the application is not
* notified.
*
* p_cmpl_cb - Pointer to the callback routine which gets
* called upon completion. If this field is
* NULL, the application is not notified when
* completed.
* Returns tBTM_STATUS
* BTM_CMD_STARTED if successfully initiated
* BTM_BUSY if already in progress
* BTM_ILLEGAL_VALUE if parameter(s) are out of range
* BTM_NO_RESOURCES if could not allocate resources to start
* the command
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb,
tBTM_CMPL_CB* p_cmpl_cb);
/*******************************************************************************
*
* Function BTM_IsInquiryActive
*
* Description Return a bit mask of the current inquiry state
*
* Returns BTM_INQUIRY_INACTIVE if inactive (0)
* BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
*
******************************************************************************/
uint16_t BTM_IsInquiryActive(void);
/*******************************************************************************
*
* Function BTM_CancelInquiry
*
* Description This function cancels an inquiry if active
*
******************************************************************************/
void BTM_CancelInquiry(void);
void BTM_CancelInquiryNotifyWhenComplete(std::function<void()>);
/*******************************************************************************
*
* Function BTM_SetConnectability
*
* Description This function is called to set the device into or out of
* connectable mode. Discoverable mode means page scans are
* enabled.
*
* Returns BTM_SUCCESS if successful
* BTM_ILLEGAL_VALUE if a bad parameter is detected
* BTM_NO_RESOURCES if could not allocate a message buffer
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_SetConnectability(uint16_t page_mode);
/*******************************************************************************
*
* Function BTM_SetInquiryMode
*
* Description This function is called to set standard, with RSSI
* mode or extended of the inquiry for local device.
*
* Input Params: BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
* BTM_INQ_RESULT_EXTENDED
*
* Returns BTM_SUCCESS if successful
* BTM_NO_RESOURCES if couldn't get a memory pool buffer
* BTM_ILLEGAL_VALUE if a bad parameter was detected
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_SetInquiryMode(uint8_t mode);
void BTM_EnableInterlacedInquiryScan();
void BTM_EnableInterlacedPageScan();
/*******************************************************************************
*
* Function BTM_ReadRemoteDeviceName
*
* Description This function initiates a remote device HCI command to the
* controller and calls the callback when the process has
* completed.
*
* Input Params: remote_bda - device address of name to retrieve
* p_cb - callback function called when
* BTM_CMD_STARTED is returned.
* A pointer to tBTM_REMOTE_DEV_NAME is
* passed to the callback.
*
* Returns
* BTM_CMD_STARTED is returned if the request was successfully
* sent to HCI.
* BTM_BUSY if already in progress
* BTM_UNKNOWN_ADDR if device address is bad
* BTM_NO_RESOURCES if resources could not be allocated to
* start the command
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda,
tBTM_CMPL_CB* p_cb,
tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_CancelRemoteDeviceName
*
* Description This function initiates the cancel request for the specified
* remote device.
*
* Input Params: None
*
* Returns
* BTM_CMD_STARTED is returned if the request was successfully
* sent to HCI.
* BTM_NO_RESOURCES if resources could not be allocated to
* start the command
* BTM_WRONG_MODE if there is no active remote name request.
*
******************************************************************************/
tBTM_STATUS BTM_CancelRemoteDeviceName(void);
/*******************************************************************************
*
* Function BTM_ReadRemoteVersion
*
* Description This function is called to read a remote device's version
*
* Returns true if data valid, false otherwise
*
******************************************************************************/
bool BTM_ReadRemoteVersion(const RawAddress& addr, uint8_t* lmp_version,
uint16_t* manufacturer, uint16_t* lmp_sub_version);
/*******************************************************************************
*
* Function BTM_ReadRemoteFeatures
*
* Description This function is called to read a remote device's
* supported features mask (features mask located at page 0)
*
* Returns pointer to the remote supported features mask
* The size of device features mask page is
* HCI_FEATURE_BYTES_PER_PAGE bytes.
*
******************************************************************************/
uint8_t* BTM_ReadRemoteFeatures(const RawAddress& addr);
/*******************************************************************************
*
* Function BTM_InqDbRead
*
* Description This function looks through the inquiry database for a match
* based on Bluetooth Device Address. This is the application's
* interface to get the inquiry details of a specific BD
* address.
*
* Returns pointer to entry, or NULL if not found
*
******************************************************************************/
tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda);
/*******************************************************************************
*
* Function BTM_InqDbFirst
*
* Description This function looks through the inquiry database for the
* first used entry, and returns that. This is used in
* conjunction with BTM_InqDbNext by applications as a way to
* walk through the inquiry database.
*
* Returns pointer to first in-use entry, or NULL if DB is empty
*
******************************************************************************/
tBTM_INQ_INFO* BTM_InqDbFirst(void);
/*******************************************************************************
*
* Function BTM_InqDbNext
*
* Description This function looks through the inquiry database for the
* next used entry, and returns that. If the input parameter
* is NULL, the first entry is returned.
*
* Returns pointer to next in-use entry, or NULL if no more found.
*
******************************************************************************/
tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur);
/*******************************************************************************
*
* Function BTM_ClearInqDb
*
* Description This function is called to clear out a device or all devices
* from the inquiry database.
*
* Parameter p_bda - (input) BD_ADDR -> Address of device to clear
* (NULL clears all entries)
*
* Returns BTM_BUSY if an inquiry, get remote name, or event filter
* is active, otherwise BTM_SUCCESS
*
******************************************************************************/
tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda);
/*****************************************************************************
* (e)SCO CHANNEL MANAGEMENT FUNCTIONS
****************************************************************************/
/*******************************************************************************
*
* Function BTM_CreateSco
*
* Description This function is called to create an SCO connection. If the
* "is_orig" flag is true, the connection will be originated,
* otherwise BTM will wait for the other side to connect.
*
* Returns BTM_UNKNOWN_ADDR if the ACL connection is not up
* BTM_BUSY if another SCO being set up to
* the same BD address
* BTM_NO_RESOURCES if the max SCO limit has been reached
* BTM_CMD_STARTED if the connection establishment is started.
* In this case, "*p_sco_inx" is filled in
* with the sco index used for the connection.
*
******************************************************************************/
tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig,
uint16_t pkt_types, uint16_t* p_sco_inx,
tBTM_SCO_CB* p_conn_cb, tBTM_SCO_CB* p_disc_cb);
/*******************************************************************************
*
* Function BTM_RemoveSco
*
* Description This function is called to remove a specific SCO connection.
*
* Returns BTM_CMD_STARTED if successfully initiated, otherwise error
*
******************************************************************************/
tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx);
void BTM_RemoveSco(const RawAddress& bda);
/*******************************************************************************
*
* Function BTM_ReadScoBdAddr
*
* Description This function is read the remote BD Address for a specific
* SCO connection,
*
* Returns pointer to BD address or NULL if not known
*
******************************************************************************/
const RawAddress* BTM_ReadScoBdAddr(uint16_t sco_inx);
/*******************************************************************************
*
* Function BTM_SetEScoMode
*
* Description This function sets up the negotiated parameters for SCO or
* eSCO, and sets as the default mode used for calls to
* BTM_CreateSco. It can be called only when there are no
* active (e)SCO links.
*
* Returns BTM_SUCCESS if the successful.
* BTM_BUSY if there are one or more active (e)SCO links.
*
******************************************************************************/
tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms);
/*******************************************************************************
*
* Function BTM_RegForEScoEvts
*
* Description This function registers a SCO event callback with the
* specified instance. It should be used to received
* connection indication events and change of link parameter
* events.
*
* Returns BTM_SUCCESS if the successful.
* BTM_ILLEGAL_VALUE if there is an illegal sco_inx
*
******************************************************************************/
tBTM_STATUS BTM_RegForEScoEvts(uint16_t sco_inx, tBTM_ESCO_CBACK* p_esco_cback);
/*******************************************************************************
*
* Function BTM_EScoConnRsp
*
* Description This function is called upon receipt of an (e)SCO connection
* request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
* the request. Parameters used to negotiate eSCO links.
* If p_parms is NULL, then values set through BTM_SetEScoMode
* are used.
* If the link type of the incoming request is SCO, then only
* the tx_bw, max_latency, content format, and packet_types are
* valid. The hci_status parameter should be
* ([0x0] to accept, [0x0d..0x0f] to reject)
*
*
* Returns void
*
******************************************************************************/
void BTM_EScoConnRsp(uint16_t sco_inx, uint8_t hci_status,
enh_esco_params_t* p_parms);
/*******************************************************************************
*
* Function BTM_GetNumScoLinks
*
* Description This function returns the number of active SCO links.
*
* Returns uint8_t
*
******************************************************************************/
uint8_t BTM_GetNumScoLinks(void);
/*****************************************************************************
* SECURITY MANAGEMENT FUNCTIONS
****************************************************************************/
/*******************************************************************************
*
* Function BTM_SecAddDevice
*
* Description Add/modify device. This function will be normally called
* during host startup to restore all required information
* stored in the NVRAM.
* dev_class, bd_name, link_key, and features are NULL if
* unknown
*
* Returns true if added OK, else false
*
******************************************************************************/
bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
const BD_NAME& bd_name, uint8_t* features,
LinkKey* link_key, uint8_t key_type, uint8_t pin_length);
/** Free resources associated with the device associated with |bd_addr| address.
*
* *** WARNING ***
* tBTM_SEC_DEV_REC associated with bd_addr becomes invalid after this function
* is called, also any of it's fields. i.e. if you use p_dev_rec->bd_addr, it is
* no longer valid!
* *** WARNING ***
*
* Returns true if removed OK, false if not found or ACL link is active.
*/
bool BTM_SecDeleteDevice(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_SecClearSecurityFlags
*
* Description Reset the security flags (mark as not-paired) for a given
* remove device.
*
******************************************************************************/
void BTM_SecClearSecurityFlags(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function btm_sec_is_a_bonded_dev
*
* Description Is the specified device is a bonded device
*
* Returns true - dev is bonded
*
******************************************************************************/
extern bool btm_sec_is_a_bonded_dev(const RawAddress& bda);
/*******************************************************************************
*
* Function BTM_GetPeerDeviceTypeFromFeatures
*
* Description This function is called to retrieve the peer device type
* by referencing the remote features.
*
* Parameters: bd_addr - address of the peer
*
* Returns BT_DEVICE_TYPE_DUMO if both BR/EDR and BLE transports are
* supported by the peer,
* BT_DEVICE_TYPE_BREDR if only BR/EDR transport is supported,
* BT_DEVICE_TYPE_BLE if only BLE transport is supported.
*
******************************************************************************/
extern tBT_DEVICE_TYPE BTM_GetPeerDeviceTypeFromFeatures(
const RawAddress& bd_addr);
/*****************************************************************************
* POWER MANAGEMENT FUNCTIONS
****************************************************************************/
/*******************************************************************************
*
* Function BTM_PmRegister
*
* Description register or deregister with power manager
*
* Returns BTM_SUCCESS if successful,
* BTM_NO_RESOURCES if no room to hold registration
* BTM_ILLEGAL_VALUE
*
******************************************************************************/
tBTM_STATUS BTM_PmRegister(uint8_t mask, uint8_t* p_pm_id,
tBTM_PM_STATUS_CBACK* p_cb);
// Notified by ACL that a new link is connected
void BTM_PM_OnConnected(uint16_t handle, const RawAddress& remote_bda);
// Notified by ACL that a link is disconnected
void BTM_PM_OnDisconnected(uint16_t handle);
/*******************************************************************************
*
* Function BTM_SetPowerMode
*
* Description store the mode in control block or
* alter ACL connection behavior.
*
* Returns BTM_SUCCESS if successful,
* BTM_UNKNOWN_ADDR if bd addr is not active or bad
*
******************************************************************************/
tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda,
const tBTM_PM_PWR_MD* p_mode);
bool BTM_SetLinkPolicyActiveMode(const RawAddress& remote_bda);
/*******************************************************************************
*
* Function BTM_SetSsrParams
*
* Description This sends the given SSR parameters for the given ACL
* connection if it is in ACTIVE mode.
*
* Input Param remote_bda - device address of desired ACL connection
* max_lat - maximum latency (in 0.625ms)(0-0xFFFE)
* min_rmt_to - minimum remote timeout
* min_loc_to - minimum local timeout
*
*
* Returns BTM_SUCCESS if the HCI command is issued successful,
* BTM_UNKNOWN_ADDR if bd addr is not active or bad
* BTM_CMD_STORED if the command is stored
*
******************************************************************************/
tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda, uint16_t max_lat,
uint16_t min_rmt_to, uint16_t min_loc_to);
/*******************************************************************************
*
* Function BTM_GetHCIConnHandle
*
* Description This function is called to get the handle for an ACL
* connection to a specific remote BD Address.
*
* Returns the handle of the connection, or 0xFFFF if none.
*
******************************************************************************/
uint16_t BTM_GetHCIConnHandle(const RawAddress& remote_bda,
tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_IsPhy2mSupported
*
* Description This function is called to check PHY 2M support
* from peer device
* Returns True when PHY 2M supported false otherwise
*
******************************************************************************/
bool BTM_IsPhy2mSupported(const RawAddress& remote_bda, tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_RequestPeerSCA
*
* Description This function is called to request sleep clock accuracy
* from peer device
*
******************************************************************************/
extern void BTM_RequestPeerSCA(const RawAddress& remote_bda,
tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_GetPeerSCA
*
* Description This function is called to get peer sleep clock accuracy
*
* Returns SCA or 0xFF if SCA was never previously requested, request
* is not supported by peer device or ACL does not exist
*
******************************************************************************/
extern uint8_t BTM_GetPeerSCA(const RawAddress& remote_bda,
tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_DeleteStoredLinkKey
*
* Description This function is called to delete link key for the specified
* device addresses from the NVRAM storage attached to the
* Bluetooth controller.
*
* Parameters: bd_addr - Addresses of the devices
* p_cb - Call back function to be called to return
* the results
*
******************************************************************************/
tBTM_STATUS BTM_DeleteStoredLinkKey(const RawAddress* bd_addr,
tBTM_CMPL_CB* p_cb);
/*******************************************************************************
*
* Function BTM_WriteEIR
*
* Description This function is called to write EIR data to controller.
*
* Parameters p_buff - allocated HCI command buffer including extended
* inquriry response
*
* Returns BTM_SUCCESS - if successful
* BTM_MODE_UNSUPPORTED - if local device cannot support it
*
******************************************************************************/
tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff);
/*******************************************************************************
*
* Function BTM_HasEirService
*
* Description This function is called to know if UUID in bit map of UUID.
*
* Parameters p_eir_uuid - bit map of UUID list
* uuid16 - UUID 16-bit
*
* Returns true - if found
* false - if not found
*
******************************************************************************/
bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16);
/*******************************************************************************
*
* Function BTM_HasInquiryEirService
*
* Description Return if a UUID is in the bit map of a UUID list.
*
* Parameters p_results - inquiry results
* uuid16 - UUID 16-bit
*
* Returns BTM_EIR_FOUND - if found
* BTM_EIR_NOT_FOUND - if not found and it is a complete list
* BTM_EIR_UNKNOWN - if not found and it is not complete list
*
******************************************************************************/
tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService(tBTM_INQ_RESULTS* p_results,
uint16_t uuid16);
/*******************************************************************************
*
* Function BTM_AddEirService
*
* Description This function is called to add a service in the bit map UUID
* list.
*
* Parameters p_eir_uuid - bit mask of UUID list for EIR
* uuid16 - UUID 16-bit
*
* Returns None
*
******************************************************************************/
void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
/*******************************************************************************
*
* Function BTM_RemoveEirService
*
* Description This function is called to remove a service from the bit map
* UUID list.
*
* Parameters p_eir_uuid - bit mask of UUID list for EIR
* uuid16 - UUID 16-bit
*
* Returns None
*
******************************************************************************/
void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
/*******************************************************************************
*
* Function BTM_GetEirSupportedServices
*
* Description This function is called to get UUID list from bit map UUID
* list.
*
* Parameters p_eir_uuid - bit mask of UUID list for EIR
* p - reference of current pointer of EIR
* max_num_uuid16 - max number of UUID can be written in EIR
* num_uuid16 - number of UUID have been written in EIR
*
* Returns HCI_EIR_MORE_16BITS_UUID_TYPE, if it has more than max
* HCI_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise
*
******************************************************************************/
uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p,
uint8_t max_num_uuid16,
uint8_t* p_num_uuid16);
/*******************************************************************************
*
* Function BTM_GetEirUuidList
*
* Description This function parses EIR and returns UUID list.
*
* Parameters p_eir - EIR
* eirl_len - EIR len
* uuid_size - Uuid::kNumBytes16, Uuid::kNumBytes32,
* Uuid::kNumBytes128
* p_num_uuid - return number of UUID in found list
* p_uuid_list - return UUID 16-bit list
* max_num_uuid - maximum number of UUID to be returned
*
* Returns 0 - if not found
* HCI_EIR_COMPLETE_16BITS_UUID_TYPE
* HCI_EIR_MORE_16BITS_UUID_TYPE
* HCI_EIR_COMPLETE_32BITS_UUID_TYPE
* HCI_EIR_MORE_32BITS_UUID_TYPE
* HCI_EIR_COMPLETE_128BITS_UUID_TYPE
* HCI_EIR_MORE_128BITS_UUID_TYPE
*
******************************************************************************/
uint8_t BTM_GetEirUuidList(const uint8_t* p_eir, size_t eir_len,
uint8_t uuid_size, uint8_t* p_num_uuid,
uint8_t* p_uuid_list, uint8_t max_num_uuid);
/*******************************************************************************
*
* Function BTM_PM_ReadControllerState
*
* Description This function is called to obtain the controller state
*
* Returns Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and
* BTM_CONTRL_IDLE)
*
******************************************************************************/
tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
/**
* Send remote name request, either to legacy HCI, or to GD shim Name module
*/
void SendRemoteNameRequest(const RawAddress& raw_address);
bool BTM_IsScoActiveByBdaddr(const RawAddress& remote_bda);
uint16_t BTM_GetClockOffset(const RawAddress& remote_bda);
/* Read maximum data packet that can be sent over current connection */
uint16_t BTM_GetMaxPacketSize(const RawAddress& addr);
extern tBTM_STATUS BTM_BT_Quality_Report_VSE_Register(
bool is_register, tBTM_BT_QUALITY_REPORT_RECEIVER* p_bqr_report_receiver);
uint8_t btm_ble_read_sec_key_size(const RawAddress& bd_addr);
#endif /* BTM_API_H */
|