me.h
65.1 KB
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
#ifndef __ME_H
#define __ME_H
/****************************************************************************
*
* File:
* $Workfile:me.h$ for iAnywhere Blue SDK, Version 2.1.1
* $Revision:203$
*
* Description:
* Public types, defines, and prototypes for accessing the
* upper layer of the Management Entity.
*
* Copyright 1999-2005 Extended Systems, Inc.
* Portions copyright 2005 iAnywhere Solutions, Inc.
* All rights reserved. All unpublished rights reserved.
*
* Unpublished Confidential Information of iAnywhere Solutions, Inc.
* Do Not Disclose.
*
* No part of this work may be used or reproduced in any form or by any
* means, or stored in a database or retrieval system, without prior written
* permission of iAnywhere Solutions, Inc.
*
* Use of this work is governed by a license granted by iAnywhere Solutions,
* Inc. This work contains confidential and proprietary information of
* iAnywhere Solutions, Inc. which is protected by copyright, trade secret,
* trademark and other intellectual property rights.
*
****************************************************************************/
#include "me_adp.h"
#include "bttypes.h"
#include "config.h"
#include "xatypes.h"
#include "osapi.h"
/****************************************************************************
*
* Function Reference
*
****************************************************************************/
/*---------------------------------------------------------------------------
* ME_RegisterGlobalHandler()
*
* Register a callback handler with the Management Entity to
* receive global events. The protocol stack sends a number
* of global events to all registered handlers (who have the
* proper event mask set). Clients must register a handler
* in order to receive events. The list of global events for
* which the callback will be called are listed in the
* Callback section below. The event mask for the handler is
* initialized to BEM_NO_EVENTS.
*
* Parameters:
* handler - pointer to a BtHandler structure. The callback
* field of the handler must point to a valid callback function.
* The handler must be initialized using ME_InitHandler.
*
* Returns:
* BT_STATUS_SUCCESS - operation completed successfully.
*
* BT_STATUS_FAILED - the operation failed because the handle is
* already registered, the handle is not initialized properly.
*/
BtStatus ME_RegisterGlobalHandler(BtHandler *handler);
/*---------------------------------------------------------------------------
* ME_InitHandler()
*
* Initialize a handler. All global handlers must be initialized
* before they can be passed to ME functions. This function
* can be used or filling the contents of the handler with 0
* will also suffice. A handler should only need to be initialized
* once.
*
* Parameters:
* handler - pointer to a BtHandler structure.
*/
void ME_InitHandler(BtHandler *handler);
#define ME_InitHandler(h) InitializeListEntry(&((h)->node))
/*---------------------------------------------------------------------------
* ME_UnregisterGlobalHandler()
*
* Unregister a global handler. Upon successful completion of this
* function the handler is initialized and can be registered again
* without the need for calling ME_InitHandler.
*
* Parameters:
* handler - pointer to handler to unregister
*
* Returns
* BT_STATUS_SUCCESS - operation successful
*
* BT_STATUS_FAILED - operations failed because handler
* was not registered or 0 (error check only).
*/
BtStatus ME_UnregisterGlobalHandler(BtHandler *handler);
/*---------------------------------------------------------------------------
* ME_SetEventMask()
*
* Set the event mask for the global handler. The event mask
* is for global events.
*
* Parameters:
* handler - pointer to handler.
*
* mask - event mask.
*
* Returns
* BT_STATUS_SUCCESS - operation successful
*
* BT_STATUS_FAILED - operations failed because handler
* was not registered or 0 (error check only).
*/
#if XA_ERROR_CHECK == XA_ENABLED
BtStatus ME_SetEventMask(BtHandler *handler, BtEventMask mask);
#else /* XA_ERROR_CHECK */
#define ME_SetEventMask(h,m) ((h)->eMask = (m),BT_STATUS_SUCCESS)
#endif /* XA_ERROR_CHECK */
/*---------------------------------------------------------------------------
* ME_GetEventMask()
*
* Get the event mask for the global handler. The event mask
* is for global events. This function does not check to
* see if the handler is valid.
*
* Parameters:
* handler - pointer to handler.
*
* Returns:
* The event mask
*/
BtEventMask ME_GetEventMask(BtHandler *handler);
#define ME_GetEventMask(h) ((h)->eMask)
/*---------------------------------------------------------------------------
* ME_Inquiry()
*
* Start a Bluetooth Inquiry procedure. If BT_STATUS_PENDING is
* returned then the results of the operation will be returned
* to all clients with registered global handlers. The following
* events will be sent to all registered handlers:
*
* BTEVENT_INQUIRY_RESULT - indicates that a device was found. The
* "p.inqResult" field of the BtEvent contains the result.
*
* BTEVENT_INQUIRY_COMPLETE - indicates that the inquiry process is
* complete. The "errCode" field of the BtEvent indicates whether
* the operation completed without error.
*
* BTEVENT_INQUIRY_CANCELED - this will be returned if the inquiry
* operation is canceled. BTEVENT_INQUIRY_COMPLETE will not be
* returned.
*
* BTEVENT_HCI_FATAL_ERROR - indicates fatal radio or HCI
* transport error. Assume all pending operations have failed.
*
* Parameters:
* lap - LAP used for the Inquiry (General or Limited)
*
* length - Maximum amount of time before the Inquiry is
* halted. Range is 0x01 to 0x30. Time is length * 1.28 sec.
* The Generic Access profile specifies using the value
* BT_INQ_TIME_GAP100.
*
* maxResp - The maximum number of responses. Specify zero to receive
* an unlimited number of responses.
*
* Returns:
* BT_STATUS_PENDING - The Inquiry process is started results
* will be sent via the handler. A BTEVENT_HCI_FATAL_ERROR event
* indicates a fatal radio or HCI transport error and that all
* pending operations have failed.
*
* BT_STATUS_IN_PROGRESS - An inquiry process is already in
* progress. Only one Inquiry can be in progress at a time.
* Keep track of the general events to get the results from
* the current Inquiry or to see when it ends. If it has just
* ended then a cancel is also in progress so wait for
* the cancel to complete to start another inquiry.
*
* BT_STATUS_FAILED - The operation failed.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_Inquiry(BtIac lap, U8 Length, U8 maxResp);
/*---------------------------------------------------------------------------
* ME_CancelInquiry()
*
* Cancel the current Inquiry process. When the inquiry
* operation is canceled all registered handlers will
* receive the BTEVENT_INQUIRY_CANCELED event. The "errCode"
* field of the BtEvent indicates the status of the
* operation.
*
* Returns:
* BT_STATUS_PENDING - The cancel operation was started
* successfully. The results will be sent to all clients
* with registered handlers. A BTEVENT_HCI_FATAL_ERROR event
* indicates a fatal radio or HCI transport error and that all
* pending operations have failed.
*
* BT_STATUS_SUCCESS - The inquiry process was canceled
* immediately. It actually never was started.
* BTEVENT_INQUIRY_CANCELED event will be sent to all handlers
* before this function returns.
*
* BT_STATUS_IN_PROGRESS - A cancel Inquiry is already in
* progress. Only one cancel can be in progress at a time.
* Keep track of the general events to see when the cancel
* is complete.
*
* BT_STATUS_FAILED - The operation failed because an inquiry
* operation was not in progress.
*/
BtStatus ME_CancelInquiry(void);
/*---------------------------------------------------------------------------
* ME_GetRemoteDeviceName()
*
* Get the name of the remote device. If an ACL connection
* does not exist then a temporary one will be created to
* get the name. If this function returns BT_STATUS_PENDING
* then the result will be returned via the callback in the
* token with the BTEVENT_NAME_RESULT event. The "errCode" field
* indicates the status of the operation. "p.meToken" points
* to the token passed into the function. The output field of
* token contains the results if the status indicates success.
*
* If a request to the same remote device is already in progress
* only one request will be made. This token will receive the
* results of the request in progress.
*
* Parameters:
* token - pointer to token containing input parameters and
* storage for output parameters. The token must be initialized
* before calling this function as follows:
*
* "token.callback" must be set to the callback function.
*
* "token.p.name.bdAddr" must contain the 48-bit address of
* the remote device.
*
* "token.p.name.io.in.psi" must contain the page scan information.
* If the page scan information is not known then all fields should
* be 0.
*
* Returns:
* BT_STATUS_PENDING - Operation is started and results will
* be sent to the callback.
*
* BT_STATUS_FAILED - operation failed because the token was
* not properly initialized or already active (XA_ERROR_CHECK only).
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_GetRemoteDeviceName(MeCommandToken *token);
/*---------------------------------------------------------------------------
* ME_CancelGetRemoteDeviceName()
*
* Request cancellation of a pending ME_GetRemoteDeviceName request.
* If this function returns BT_STATUS_SUCCESS, then "token" is
* free and no further events will be returned. If this function
* returns BT_STATUS_PENDING, then the result will be returned
* via the callback in "p.meToken" with the BTEVENT_NAME_RESULT event.
* The "errCode" field will indicate status BEC_REQUEST_CANCELLED
* if cancelled or BEC_NO_ERROR if the name was returned before the
* cancel completed.
*
* Parameters:
* token - pointer to token passed in to ME_GetRemoteDeviceName.
*
* Returns:
* BT_STATUS_SUCCESS - the operation has completed successfully.
* The "token" is free and no further events will be returned.
*
* BT_STATUS_PENDING - Operation is started and results will
* be sent to the callback.
*
* BT_STATUS_FAILED - operation failed because the get remote
* device name request is no longer in progress.
*/
BtStatus ME_CancelGetRemoteDeviceName(MeCommandToken *token);
/*---------------------------------------------------------------------------
* ME_SetLocalDeviceName()
*
* Set the local device name. This is the name that other devices will
* get when performing a GetRemoteDeviceName to this device. The name
* is a UTF-8 encoded string. The name can be up to 248 bytes in length.
* If the name is less than 248 bytes it must be null-terminated.
*
* Parameters:
* name - pointer to a UTF-8 encoded string. The name will remain in use
* until the stack is deinitialized, or until this function is called
* with a different name. The name string should not be modified and
* the pointer must remain valid while it is in use.
*
* len - indicates the number of bytes in the name including the null
* termination byte if the name is less than 248 bytes.
*
* Returns:
* BT_STATUS_SUCCESS - The operation is successful.
*
* BT_STATUS_INVALID_PARM - The operation failed because the name or
* length were not properly initialized (XA_ERROR_CHECK only).
*/
BtStatus ME_SetLocalDeviceName(const U8 *name, U8 len);
/*---------------------------------------------------------------------------
* ME_ReadLocalBdAddr()
*
* Get the 48-bit Bluetooth device address of the local device. This
* request cannot be issued until the radio has been initialized. Check
* ME_GetStackInitState for BTSS_INITIALIZED. If it's not initialized
* wait for the BTEVENT_HCI_INITIALIZED event on a global handler.
*
* Parameters:
* Addr - Pointer to a BD_ADDR structure to receive the address.
*
* Returns:
* BT_STATUS_SUCCESS - Operation was successful.
*
* BT_STATUS_FAILED - Operation failed because the radio is not
* initialized yet. Monitor the global events to be notified
* when the radio is initialized (BTEVENT_HCI_INITIALIZED).
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_ReadLocalBdAddr(BD_ADDR *Addr);
/*---------------------------------------------------------------------------
* ME_SetClassOfDevice()
*
* Set the class of device. The class of device is sent out as part of
* the response to inquiry. The actual bit pattern that is sent out is
* a composite of the value set using this function and the service
* class information found in registered SDP records.
*
* Parameters:
* classOfDevice - A 32-bit integer where the lower 3 bytes represents
* the class of device. The most significant 8 bits are ignored.
*
* Returns:
* BT_STATUS_SUCCESS - Operation is successful.
*/
BtStatus ME_SetClassOfDevice(BtClassOfDevice classOfDevice);
#if defined (__BT_2_1_ENTENDED_INQUIRY_RESPONSE__)
BtStatus ME_StartWriteEIR(void);
#endif
#ifdef __GAP_TESTER_
BtStatus ME_DisableAFH(void);
#endif
/*---------------------------------------------------------------------------
* ME_FindRemoteDevice()
*
* Return a pointer to the BtRemoteDevice structure corresponding to
* the device with given BD_ADDR. 0 is returned if a match is not found.
*
* When this function returns successfully, the BtRemoteDevice structure
* returned always refers to a connected or connecting device. Use
* caution, as it will also return successfully if the device is in the
* process of disconnecting, but has not yet completed. This typically
* occurs if called during the notification of a link failure.
*
* Parameters:
* bdAddr - pointer to 48-bit address of the device
*
* Returns:
* Pointer to BtRemoteDevice structure if found. 0 is returned if the
* device is not found.
*/
BtRemoteDevice *ME_FindRemoteDevice(BD_ADDR *bdAddr);
/* Prototype for actual ME_FindRemoteDevice implementation */
BtRemoteDevice *ME_FindRemoteDeviceP(U8 *bdAddr);
#define ME_FindRemoteDevice(bd) (ME_FindRemoteDeviceP((bd)->addr))
/*---------------------------------------------------------------------------
* ME_CreateLink()
*
* Create an ACL link to the device specified by "bdAddr". If
* this function returns BT_STATUS_PENDING the results will be sent to
* the handler. When the operation is complete all registered global
* handlers will receive BTEVENT_LINK_CONNECT_CNF as will the handler
* passed to this function. The "errCode" field of the BtEvent will
* indicate if the operation was successful or not. If an incoming
* connection is in progress to this device then the handler will be
* bound and when the incoming connection is complete the handler will
* receive the BTEVENT_LINK_CONNECT_CNF event. In this case all global
* registered handlers will receive BTEVENT_LINK_CONNECT_IND instead of
* BTEVENT_LINK_CONNECT_CNF.
*
* If connections already exist to other devices, then ME will attempt
* to put all other connections on hold, then begin a connection
* to the specified device.
*
* If a connection already exists to the device indicated by bdAddr,
* this function will register the handler with the BtRemoteDevice
* and return BT_STATUS_SUCCESS immediately. In this way, many local
* handlers can be registered to the same connection. Be aware that
* ME_DisconnectLink will not take effect until it is called for
* ALL registered handlers of the BtRemoteDevice. To determine whether
* a connection already exists without registering a handler,
* use ME_FindRemoteDevice instead.
*
* A slave device does not need to use this API unless it needs
* to register a local handler or initiate a disconnection of the link
* (see ME_DisconnectLink).
*
* The type of connection created to the remote device uses
* the quality of service parameters necessary for the RFCOMM
* based profiles or profiles requiring reliable, non
* real-time critical links. For other types of connections, use
* ME_CreateRestrictedLink.
*
* Parameters:
* handler - pointer to an unregistered handler to receive
* events. This handler cannot be the global handler though
* they both can point to the same callback. The handler
* must be initialized using ME_InitHandler. The handler
* is in use until the link is disconnected and should not
* be modified while in use.
*
* bdAddr - pointer to address of remote device.
*
* psi - pointer to page scan information obtained during
* Inquiry. Initial links to a device should set this parameter
* to ensure a reliable connection. If the psi is not known, a
* default "psi" of 0 on an initial link will use clockOffset = 0,
* psMode = 0, and psRepMode = 1. If a client is binding to an
* existing remote device, then "psi" can be set to 0.
*
* remDev - pointer to memory to receive remote device pointer.
*
* Returns:
* BT_STATUS_PENDING - operation has started successfully
* result will be sent to handler.
*
* BT_STATUS_SUCCESS - client is successfully bound to the remote device.
*
* BT_STATUS_RESTRICTED - the operation failed because this remote
* device already has a restricted link. The handler is free.
*
* BT_STATUS_IN_PROGRESS - the operation failed because this remote
* device is in the process of being disconnected. The handler
* is free.
*
* BT_STATUS_NO_RESOURCES - the operation failed because
* the maximum number of connections already exist. The
* handler is free.
*
* BT_STATUS_FAILED - operation failed because the handler is 0, the
* callback is 0 or the handler is not initialized (XA_ERROR_CHECK
* only). The handler is free.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_CreateLink(BtHandler *handler, BD_ADDR *bdAddr, BtPageScanInfo *psi, BtRemoteDevice **remDev);
/*---------------------------------------------------------------------------
* ME_CheckCreatingLink()
*
* Check if the BT Chip is creating ACL link or not.
*/
BOOL ME_CheckCreatingLink(void);
/*---------------------------------------------------------------------------
* ME_CreateRestrictedLink()
*
* (Not implemented.)
*
* Create a restricted Link to a remote device. A restricted
* link is one where only the client specified by the handler
* is allowed to bind to the connection. The client also has
* the ability to specify the quality of service parameters
* so a time bounded link with specific latency and bandwidth
* can be created.
*
* If this function returns BT_STATUS_PENDING the results will be sent
* to the handler. When the operation is complete all registered global
* handlers will receive BTEVENT_LINK_CONNECT_CNF as will the handler
* passed to this function. The "errCode" field of the BtEvent will
* indicate if the operation was successful or not. If an incoming
* connection is in progress to this device then the handler will be
* bound and when the incoming connection is complete the handler will
* receive the BTEVENT_LINK_CONNECT_CNF event. In this case all global
* registered handlers will receive BTEVENT_LINK_CONNECT_IND instead of
* BTEVENT_LINK_CONNECT_CNF.
*
* If connections already exist to another devices then all
* existing connections will be put on hold while this operation
* takes place.
*
* Parameters:
* handler - pointer to registered handler to receive events.
*
* bdAddr - address of remote device.
*
* psi - pointer to page scan information obtained during
* Inquiry. If this information is not known then "psi" should be
* set to 0.
*
* Returns:
* BT_STATUS_PENDING - operation was started successfully and
* results will be sent to the handler.
*
* BT_STATUS_RESTRICTED - operation failed because this remote
* device already has a restricted link.
*
* BT_STATUS_IN_PROGRESS - the operation failed because this
* remote device is in the process of being disconnected.
*
* BT_STATUS_NO_RESOURCES - the operation failed because
* the maximum number of connections already exist. The
* handler is free.
*
* BT_STATUS_FAILED - operation failed because the handler
* is 0, the callback is 0 or the handler is not initialized
* (XA_ERROR_CHECK only). The handler is free.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_CreateRestrictedLink(
BtHandler *handler,
BD_ADDR *bdAddr,
BtPageScanInfo *psi,
BtRestrictedInfo *resInfo);
/*---------------------------------------------------------------------------
* ME_ForceDisconnectLinkWithReason()
*
* Force disconnection of the link regardless of registered handlers.
* See ME_DisconnectLink for additional information.
*
* Parameters:
* handler - pointer to registered handler (can be 0).
*
* remDev - pointer to the remote device to be disconnected.
*
* reason - disconnect reason. Must be one of: BEC_AUTHENTICATE_FAILURE,
* BEC_USER_TERMINATED, BEC_LOW_RESOURCES, BEC_POWER_OFF,
* BEC_UNSUPPORTED_REMOTE, or BEC_PAIR_UNITKEY_NO_SUPP.
*
* forceDisconnect - If TRUE, will attempt to disconnect regardless of
* whether other handlers are still registered. If FALSE, behaves as
* ME_DisconnectLinkWithReason.
*
* Returns:
* BT_STATUS_INVALID_PARM - the operation failed because the "reason"
* parameter is invalid for a disconnect link operation.
*
* See ME_DisconnectLink for additional returns.
*/
BtStatus ME_ForceDisconnectLinkWithReason(
BtHandler *handler,
BtRemoteDevice *remDev,
BtErrorCode reason,
BOOL forceDisconnect);
/*---------------------------------------------------------------------------
* ME_DisconnectLinkWithReason()
*
* Request disconnection of the link with a non-default reason code.
* See ME_DisconnectLink for additional information.
*
* Parameters:
* handler - pointer to registered handler.
*
* remDev - pointer to the remote device to be disconnected.
*
* reason - disconnect reason. If multiple handlers call this
* function or ME_DisconnectLink, the last handler's reason code
* will be used. If reason is BEC_POWER_OFF, disconnect is
* more forceful in that all the handlers need not have already
* been freed.
*
* Returns:
* BT_STATUS_INVALID_PARM - the operation failed because the "reason"
* parameter is invalid for a disconnect link operation.
*
* See ME_DisconnectLink for additional returns.
*/
BtStatus ME_DisconnectLinkWithReason(BtHandler *handler, BtRemoteDevice *remDev, BtErrorCode reason);
#define ME_DisconnectLinkWithReason(ha, rd, rs) \
(ME_ForceDisconnectLinkWithReason(ha, rd, rs, FALSE))
/*---------------------------------------------------------------------------
* ME_DisconnectLink()
*
* Request disconnection of the link, using the default reason code
* (BEC_USER_TERMINATED). This function also deregisters the
* specified handler, which was previously registered with ME_CreateLink
* or ME_CreateRestrictedLink.
*
* The link is actually closed only when all registered handlers have
* requested disconnection and all L2CAP connections are closed. If
* a device needs to know exactly when the disconnection occurs,
* it should use a global handler to monitor connection state. The
* handler specified in this API is freed by this function, so it
* will not be notified of any disconnection events.
*
* If the remote device initiated the connection, the local
* device may have no registered handler for the connection. In this
* case, the local device must call ME_CreateLink or
* ME_CreateRestrictedLink to register a handler, then call this function
* to request disconnection.
*
* Parameters:
* handler - pointer to registered handler.
*
* remDev - pointer to the remote device to be disconnected.
*
* Returns:
* BT_STATUS_SUCCESS - the operation has completed successfully.
* The caller's handler is unbound from the link. When the link
* is actually disconnected the BTEVENT_LINK_DISCONNECT event will
* be sent to all registered global handlers, unless the link had
* not actually come up yet, in which case no event will be
* generated. The handler is free upon return from this function.
*
* BT_STATUS_IN_PROGRESS - the operation failed because the
* link is the process of coming up. The connect request has
* been made by a remote device. Wait until the
* BTEVENT_LINK_CONNECT_CNF event has been received. The handler
* is not free.
*
* BT_STATUS_FAILED - the operation failed. The link is
* already disconnected, disconnect has already been
* issued for this handler, or the handler is not
* bound to the link (XA_ERROR_CHECK only).
*/
BtStatus ME_DisconnectLink(BtHandler *handler, BtRemoteDevice *remDev);
#define ME_DisconnectLink(ha, rd) \
(ME_ForceDisconnectLinkWithReason(ha, rd, BEC_USER_TERMINATED, FALSE))
/*---------------------------------------------------------------------------
* ME_CancelCreateLink()
*
* Request cancellation of the pending ME_CreateLink. This function
* also deregisters the specified handler, which was previously
* registered when the ME_CreateLink was initiated.
*
* Parameters:
* handler - pointer to registered handler.
*
* remDev - pointer to the remote device associated with the
* ME_CreateLink to be canceled.
*
* Returns:
* BT_STATUS_SUCCESS - the operation has completed successfully.
* The caller's handler is unbound from the link. If more than one
* handler is bound to the link, no further events will occur.
* Otherwise, the BTEVENT_LINK_CREATE_CANCEL event will be sent to
* all registered global handlers when the cancel completes. The
* global handler must still check the BtEvent "errCode" field
* in the event structure, as the cancel may fail and the link may
* require further maintenance. The handler is free upon return
* from this function.
*
* BT_STATUS_FAILED - the operation failed. The link is already
* connected or disconnected, or the handler is not bound to
* the link (XA_ERROR_CHECK only).
*/
BtStatus ME_CancelCreateLink(BtHandler *handler, BtRemoteDevice *remDev);
/*---------------------------------------------------------------------------
* ME_RegisterAcceptHandler()
*
* Register the handler that will accept incoming connections.
* If no handler is registered then the Management Entity will
* accept all incoming connections automatically. If the
* handler is set it will be responsible for accepting
* connections by calling ME_AcceptIncomingLink. The handler
* will be notified with the BTEVENT_LINK_CONNECT_REQ event. The
* p.remDev field of the btEvent will contain a pointer to the
* remote device.
*
* Parameters:
* handler - pointer to handler. This can be a registered global
* handler but does not have to be.
*
* Returns:
* Pointer to old handler.
*/
BtHandler *ME_RegisterAcceptHandler(BtHandler *handler);
/*---------------------------------------------------------------------------
* ME_AcceptIncomingLink()
*
* Accept an incoming link. The incoming link is signaled by
* a call to the accept handler with the event
* BTEVENT_LINK_CONNECT_REQ.
*
* Parameters:
* remDev - pointer to the remote device structure representing
* the incoming connection. This was passed in the
* "btEvent.p.remDev" field of the BTEVENT_LINK_CONNECT_REQ event.
*
* role - desired role. BCR_MASTER cause a master/slave switch
* with the local device becoming the master. BCR_SLAVE will
* cause the local device to remain the slave.
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully
* and the result will be sent to the accept handler via
* the BTEVENT_LINK_ACCEPT_RSP event. When complete all registered
* global handlers will receive the BTEVENT_LINK_CONNECT_IND event.
* The "errCode" field of the BtEvent will indicate the success.
*
* BT_STATUS_FAILED - the operation failed because the remote
* device is not in a state to accept an incoming connection.
*
* BT_STATUS_INVALID_PARM - the operation failed because the
* "remDev" parameter is invalid or 0 or the role parameter
* is invalid (XA_ERROR_CHECK only).
*
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_AcceptIncomingLink(BtRemoteDevice *remDev, BtConnectionRole role);
/*---------------------------------------------------------------------------
* ME_RejectIncomingLink()
*
* Reject an incoming link. The incoming link is signaled by
* a call to the accept handler with the event
* BTEVENT_LINK_CONNECT_REQ.
*
* Parameters:
* remDev - pointer to the remote device structure representing
* the incoming connection. This was passed in the
* "btEvent.p.remDev" field of the BTEVENT_LINK_CONNECT_REQ event.
*
* reason - reason for the rejection. The only reasons allowed
* are as follows:
*
* BEC_LIMITED_RESOURCE - Host rejected due to limited resources
*
* BEC_SECURITY_ERROR - Host rejected due to security reasons
*
* BEC_PERSONAL_DEVICE - Host rejected (remote is personal device)
*
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully
* and the result will be sent to the accept handler via
* the BTEVENT_LINK_REJECT_RSP event.
*
* BT_STATUS_FAILED - the operation failed because the remote
* device is not in a state to reject an incoming connection.
*
* BT_STATUS_INVALID_PARM - the operation failed because the
* "remDev" parameter is invalid or 0 or the reason is not
* valid (XA_ERROR_CHECK only).
*
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_RejectIncomingLink(BtRemoteDevice *remDev, BtErrorCode reason);
/*---------------------------------------------------------------------------
* ME_GetCurrentMode()
*
* Get the current mode of the link to the remote device. The
* value is meaningless if a connection does not exist to
* the remote device. This function does not check for a valid
* remDev pointer.
*
* Parameters:
* rm - pointer to remote device.
*
* Returns:
* The current mode if a link exists otherwise the value
* is meaningless.
*/
BtLinkMode ME_GetCurrentMode(BtRemoteDevice *rm);
#define ME_GetCurrentMode(r) ((r)->mode)
/*---------------------------------------------------------------------------
* ME_GetCurrentRole()
*
* Get the current role played by the local device. The
* value is meaningless if a connection does not exist to
* the remote device. This function does not check for a valid
* remDev pointer. When the role is currently being discovered,
* the role BCR_UNKNOWN will be returned. When the role discovery
* completes, the BTEVENT_ROLE_CHANGE event will be indicated.
*
* Parameters:
* rm - pointer to remote device.
*
* Returns:
* The current role if a link exists otherwise the value
* is meaningless.
*/
BtConnectionRole ME_GetCurrentRole(BtRemoteDevice *rm);
#define ME_GetCurrentRole(r) ((r)->role > BCR_UNKNOWN ? BCR_UNKNOWN : (r)->role)
/*---------------------------------------------------------------------------
* ME_Hold()
*
* Put the ACL link associated with remDev in hold mode. When the
* link is actually placed in hold all registered and bound handlers
* will receive a BTEVENT_MODE_CHANGE event signaling the change.
*
* Parameters:
* remDev - pointer to remote device
*
* max - maximum length of the hold interval. The hold time
* is calculated as max * 0.625 ms. Range is 0.625ms to 40.9 sec.
*
* min - minimum length of the hold interval. The hold time
* is calculated as min * 0.625 ms. Range is 0.625ms to 40.9 sec.
* The parameter min should not be greater than max.
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully.
* All registered handlers and handlers bound to the remote device
* will receive the BTEVENT_MODE_CHANGE event. The "errCode" field
* of the BtEvent will indicate the success or failure of the mode
* change event. The "p.modeChange" field indicates for which remote
* Device the change has occurred along with the new mode and
* interval. It is possible that link is disconnected before the
* mode change has occurred. In that case the handlers will not
* receive BTEVENT_MODE_CHANGE but instead will receive
* BTEVENT_LINK_DISCONNECT.
*
* BT_STATUS_INVALID_PARM - Invalid parameter (XA_ERROR_CHECK only).
*
* BT_STATUS_IN_PROGRESS - the operation failed because a mode
* change or disconnect operation is already in progress.
*
* BT_STATUS_FAILED - the operation failed because ACL link is
* in wrong state.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_Hold(BtRemoteDevice *remDev, U16 max, U16 min);
/*---------------------------------------------------------------------------
* ME_StartSniff()
*
* Start sniff mode for the ACL link specified by "remDev".
*
* Parameters:
* remDev - pointer to remote device
*
* info - pointer to the sniff mode parameters. This structure may
* be freed after ME_StartSniff returns.
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully.
* All registered handlers and handlers bound to the remote device
* will receive the BTEVENT_MODE_CHANGE event. The "errCode" field
* of the BtEvent will indicate the success or failure of the mode
* change event. The "p.modeChange" field indicates for which remote
* Device the change has occurred along with the new mode and
* interval. It is possible that link is disconnected before the
* mode change has occurred. In that case the handlers will not
* receive BTEVENT_MODE_CHANGE but instead will receive
* BTEVENT_LINK_DISCONNECT.
*
* BT_STATUS_INVALID_PARM - Invalid parameter (XA_ERROR_CHECK only).
*
* BT_STATUS_IN_PROGRESS - the operation failed because a mode
* change or disconnect operation is already in progress.
*
* BT_STATUS_FAILED - the operation failed.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_StartSniff(BtRemoteDevice *remDev, const BtSniffInfo *info);
/*---------------------------------------------------------------------------
* ME_StopSniff()
*
* Stop sniff mode and enter active mode for the ACL link
* specified by remDev.
*
* Parameters:
* remDev - pointer to remote device.
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully.
* All registered handlers and handlers bound to the remote device
* will receive the BTEVENT_MODE_CHANGE event. The "errCode" field
* of the BtEvent will indicate the success or failure of the mode
* change event. The "p.modeChange" field indicates for which remote
* Device the change has occurred along with the new mode and
* interval. It is possible that link is disconnected before the
* mode change has occurred. In that case the handlers will not
* receive BTEVENT_MODE_CHANGE but instead will receive
* BTEVENT_LINK_DISCONNECT.
*
* BT_STATUS_INVALID_PARM - the parameters are not valid
* (XA_ERROR_CHECK only).
*
* BT_STATUS_IN_PROGRESS - the operation failed because a mode
* change or disconnect operation is already in progress.
*
* BT_STATUS_FAILED - the operation failed. Device is not in
* sniff mode.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_StopSniff(BtRemoteDevice *remDev);
/*---------------------------------------------------------------------------
* ME_StartSniffSubrating()
*
* Start to make the sniff subrating for the ACL link specified by "remDev".
*
* Parameters:
* remDev - pointer to remote device
*
* maxLatency - It is used to calculate the max sniff subrate that the
* remote device may use.
* minRemoteTimeout - The min base sniff subrate timeout the remote device
* may use.
* minLocalTimeout - The min base sniff subrate timeout the local device
* may use.
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully.
* BT_STATUS_FAILED - the operation failed.
*
*/
#if defined (__BT_2_1_SNIFF_SUBRATING__)
BtStatus ME_StartSniffSubrating(BtRemoteDevice *remDev);
#endif
/*---------------------------------------------------------------------------
* ME_StartPark()
*
* Start park mode for the ACL link specified by "remDev".
*
* Parameters:
* rm - pointer to remote device
*
* max - acceptable longest period between beacons. The time
* is calculated as max * 0.625 ms. Range is 0.625ms to 40.9 sec.
*
* min - acceptable shortest period between beacons. The time
* is calculated as min * 0.625 ms. Range is 0.625ms to 40.9 sec.
* The parameter min should not be greater than max,
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully.
* All registered handlers and handlers bound to the remote device
* will receive the BTEVENT_MODE_CHANGE event. The "errCode" field
* of the BtEvent will indicate the success or failure of the mode
* change event. The "p.modeChange" field indicates for which remote
* Device the change has occurred along with the new mode and
* interval. It is possible that link is disconnected before the
* mode change has occurred. In that case the handlers will not
* receive BTEVENT_MODE_CHANGE but instead will receive
* BTEVENT_LINK_DISCONNECT.
*
* BT_STATUS_INVALID_PARM - the parameters are not valid
* (XA_ERROR_CHECK only).
*
* BT_STATUS_IN_PROGRESS - the operation failed because a mode
* change or disconnect operation is already in progress.
*
* BT_STATUS_FAILED - the operation failed.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_StartPark(BtRemoteDevice *remDev, U16 max, U16 min);
/*---------------------------------------------------------------------------
* ME_StopPark()
*
* Stop park mode and enter active mode for the ACL link
* specified by "remDev".
*
* Parameters:
* remDev - pointer to remote device.
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully.
* All registered handlers and handlers bound to the remote device
* will receive the BTEVENT_MODE_CHANGE event. The "errCode" field
* of the BtEvent will indicate the success or failure of the mode
* change event. The "p.modeChange" field indicates for which remote
* Device the change has occurred along with the new mode and
* interval. It is possible that link is disconnected before the
* mode change has occurred. In that case the handlers will not
* receive BTEVENT_MODE_CHANGE but instead will receive
* BTEVENT_LINK_DISCONNECT.
*
* BT_STATUS_INVALID_PARM - the parameters are not valid
* (XA_ERROR_CHECK only).
*
* BT_STATUS_IN_PROGRESS - the operation failed because a mode
* change or disconnect operation is already in progress.
*
* BT_STATUS_FAILED - the operation failed because the link is
* not in park.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_StopPark(BtRemoteDevice *remDev);
/*---------------------------------------------------------------------------
* ME_StartParkAll()
*
* Start park mode for all ACL links.
*
* Parameters:
* max - acceptable longest period between beacons. The time
* is calculated as max * 0.625 ms. Range is 0.625ms to 40.9 sec.
*
* min - acceptable shortest period between beacons. The time
* is calculated as min * 0.625 ms. Range is 0.625ms to 40.9 sec.
* The parameter min should not be greater than max,
*
* num - pointer to an integer that receives the number of devices
* that were requested to enter park mode. This count can be
* used in conjunction with BTEVENT_MODE_CHANGE events to determine
* when all devices are parked.
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully.
* All registered handlers and handlers bound to the remote devices
* will receive the BTEVENT_MODE_CHANGE event. The "errCode" field
* of the BtEvent will indicate the success or failure of the mode
* change event. The "p.modeChange" field indicates for which remote
* device the change has occurred along with the new mode and
* interval. It is possible that link is disconnected before the
* mode change has occurred. In that case the handlers will not
* receive BTEVENT_MODE_CHANGE but instead will receive
* BTEVENT_LINK_DISCONNECT.
*
* BT_STATUS_INVALID_PARM - the parameters are not valid
* (XA_ERROR_CHECK only).
*
* BT_STATUS_IN_PROGRESS - the operation failed because a mode
* change or disconnect operation is already in progress.
*
* BT_STATUS_FAILED - the operation failed.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_StartParkAll(U16 max, U16 min, U8 *num);
/*---------------------------------------------------------------------------
* ME_StopParkAll()
*
* Return all parked ACL links to active mode.
*
* Parameters:
* num - pointer to an integer that receives the number of devices
* that were requested to exit park mode. This count can be
* used in conjunction with BTEVENT_MODE_CHANGE events to determine
* when all devices are unparked.
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully.
* All registered handlers and handlers bound to the remote device
* will receive the BTEVENT_MODE_CHANGE event. The "errCode" field
* of the BtEvent will indicate the success or failure of the mode
* change event. The "p.modeChange" field indicates for which remote
* Device the change has occurred along with the new mode and
* interval. It is possible that link is disconnected before the
* mode change has occurred. In that case the handlers will not
* receive BTEVENT_MODE_CHANGE but instead will receive
* BTEVENT_LINK_DISCONNECT.
*
* BT_STATUS_INVALID_PARM - the parameters are not valid
* (XA_ERROR_CHECK only).
*
* BT_STATUS_IN_PROGRESS - the operation failed because a mode
* change or disconnect operation is already in progress.
*
* BT_STATUS_FAILED - the operation failed because the link is
* not in park.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_StopParkAll(U8 *num);
/*---------------------------------------------------------------------------
* ME_SwitchRole()
*
* Switch the current role the device is performing for the ACL link
* specified by remDev. If the current role is slave then switch to
* master. If the current role is master then switch to slave. The
* current role can be found via remDev.role. The result of the
* operation will be returned via the BTEVENT_ROLE_CHANGE event.
*
* Parameters:
* remDev - pointer to remote device
*
* Returns:
* BT_STATUS_PENDING - the operation was started successfully.
* All registered handlers and handlers bound to the remote device
* will receive the BTEVENT_ROLE_CHANGE event. The "errCode" field
* of the BtEvent will indicate the success or failure of the role
* change event. The "p.roleChange" field indicates for which remote
* Device the change has occurred along with the new role. It is
* possible that link is disconnected before the role change has
* occurred. In that case the handlers will not receive
* BTEVENT_ROLE_CHANGE but instead will receive
* BTEVENT_LINK_DISCONNECT.
*
* BT_STATUS_INVALID_PARM - the parameters are not valid
* (XA_ERROR_CHECK only).
*
* BT_STATUS_IN_PROGRESS - the operation failed because a mode
* change or disconnect operation is already in progress.
*
* BT_STATUS_FAILED - the operation failed.
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_SwitchRole(BtRemoteDevice *remDev);
/*---------------------------------------------------------------------------
* ME_SetAccessibleModeNC()
*
* Set the accessibility mode when the device is not
* connected. If the mode is set to a value other than
* BAM_NOT_ACCESSIBLE and there are no connections then the
* Bluetooth radio will enter inquiry and/or page scan mode
* using the information passed in info. If info is 0 or the
* values in info are set to defaults (BT_DEFAULT_SCAN_INTERVAL
* and BT_DEFAULT_SCAN_WINDOW) the radio module default values
* are used. It is assumed that the macro defaults
* match the radio defaults (see BT_DEFAULT_PAGE_SCAN_WINDOW
* documentation.) So, the first call to ME_SetAccessibleModeNC
* with info set to 0 will not change the settings as the radio has
* already been initialized to its default settings. If there is
* a connection or a connection is in the process of being created
* then mode and info are saved and applied when all connections are
* disconnected.
*
* To keep other devices from finding and connecting to this
* device set the mode to BAM_NOT_ACCESSIBLE. The default mode when
* the stack is first loaded and initialized is controlled by
* BT_DEFAULT_ACCESS_MODE_NC.
*
* Any time the scan interval or window is different from
* the current settings in the radio, the radio will be
* instructed to change to the new settings. This means that
* if there are different settings for the connected state
* versus the non-connected state, the radio module will be
* instructed to change the settings when the first connection
* comes up and when the last connection goes down
* (automatically). This also means that if different values
* for window and interval are set when going from any setting
* of accessible to non-accessible then the radio will be
* instructed to change. In most cases it is best to use
* the radio defaults. In this way the radio is never told
* to change the scan interval or window.
*
* Parameters:
* mode - desired accessibility mode
*
*
* Returns:
* BT_STATUS_PENDING - the mode is being set. All registered
* global handlers with the BEM_ACCESSIBLE_CHANGE mask set will
* receive BTEVENT_ACCESSIBLE_CHANGE event when the mode change
* actually takes affect or an error has occurred. The "errCode"
* field of the BtEvent indicates the status of the operation.
* If the operation is successful the "aMode" field of BtEvent
* indicates the new mode. A BTEVENT_HCI_FATAL_ERROR event
* indicates a fatal radio or HCI transport error and that all
* pending operations have failed.
*
* BT_STATUS_SUCCESS - Accessible mode is set. No event
* is sent out. This is returned if a connection exists and
* the values are only saved or info already matches the current
* setting.
*
* BT_STATUS_IN_PROGRESS - operation failed because a change
* is already in progress. Monitor the global events to
* determine when the change has taken place.
*
* BT_STATUS_INVALID_PARM - operation failed. The mode or info
* parameter contains bad values (XA_ERROR_CHECK only)
*
* BT_STATUS_HCI_INIT_ERR - operation failed because the HCI has
* an initialization error. Monitor the global events to
* be notified when the error has been corrected.
*/
BtStatus ME_SetAccessibleModeNC(BtAccessibleMode mode);
/*---------------------------------------------------------------------------
* ME_GetAccessibleModeNC()
*
* Return the current accessibility mode that is used when no
* connections exist. This is not necessarily the current mode.
*
* Parameters:
* mode - pointer to memory to receive accessibility mode. If
* mode is 0 then mode is not returned. If the accessible mode
* has not yet been set, and therefore unknown, 0xff will be returned.
*
*
* Returns:
* BT_STATUS_SUCCESS - operation was successful
*
* BT_STATUS_IN_PROGRESS - operation failed because a change
* is in progress. Monitor the global events to determine when
* the change is finished.
*
* BT_STATUS_FAILED - operation failed.
*/
BtStatus ME_GetAccessibleModeNC(BtAccessibleMode *mode);
/*---------------------------------------------------------------------------
* ME_GetCurAccessibleMode()
*
* Return the current accessibility mode. This is the mode
* at the very instant that call is made. It may be about
* to change so it is important to check the global events.
*
* Parameters:
* mode - pointer to memory to receive accessibility mode. If
* mode is 0 then mode is not returned. If the accessible mode
* has not yet been set, and therefore unknown, 0xff will be returned.
*
*
* Returns:
* BT_STATUS_SUCCESS - operation was successful
*
* BT_STATUS_FAILED - operation failed.
*/
BtStatus ME_GetCurAccessibleMode(BtAccessibleMode *mode);
/*---------------------------------------------------------------------------
* ME_SetDefaultLinkPolicy()
*
* Set the default link policy used on outgoing and incoming ACL
* connections. The link policy determines the behavior of the local
* link manager when it receives a request from a remote device or it
* determines itself to change the master-slave role or to enter hold,
* sniff, or park mode. The default if this function is not called
* is to disable all modes.
*
* Policy for incoming ACL connections is set independent of policy
* for outgoing connections. The default policy is applied immediately
* after the link comes up. An higher level Management Entity should
* use this function, not applications. It should be called before any
* ACL connections exist and does not effect existing
* ACL connections.
*
* Parameters:
* inACL - default link policy applied to all incoming ACL connections.
* Incoming ACL connections are those initiated by a remote device.
*
* outACL - default link policy applied to all outgoing ACL connections.
* Outgoing ACL connections are those initiated by the local device.
*
* Returns:
* BT_STATUS_SUCCESS - operation was successful.
*
* BT_STATUS_FAILED - operation failed because the policy settings are
* not valid (error checking only).
*/
BtStatus ME_SetDefaultLinkPolicy(BtLinkPolicy inACL, BtLinkPolicy outACL);
void MeEnabledLocalLoopback(void);
/*---------------------------------------------------------------------------
* ME_GetHciConnectionHandle()
*
* Get the HCI connection handle for the link to the remote device. The
* value is meaningless if a connection does not exist to the remote
* device.
*
* Parameters:
* rm - pointer to remote device.
*
* Returns:
* The HCI connection handle a link exists otherwise the value
* is meaningless.
*/
U16 ME_GetHciConnectionHandle(BtRemoteDevice *rm);
/*---------------------------------------------------------------------------
* ME_GetBdAddr()
*
* Get the 48-bit address of the remote device. The value is meaningless
* if a connection does not exist to the remote device.
*
* Parameters:
* rm - pointer to remote device.
*
* bdAddr - pointer to a BD_ADDR structure to receive the result.
*/
void ME_GetBdAddr(BtRemoteDevice *rm, BD_ADDR *bdAddr);
/*---------------------------------------------------------------------------
* ME_GetRemDevState()
*
* Get the connection state of the remote device. This function
* does not check for a valid remDev pointer.
*
* Parameters:
* remDev - pointer to remote device.
*
* Returns:
* BtRemDevState
*/
BtRemDevState ME_GetRemDevState(BtRemoteDevice *remDev);
#define ME_GetRemDevState(r) ((r)->state)
/*---------------------------------------------------------------------------
* ME_GetRemDevCOD()
*
* Get the Class of Device for the remote device. This function
* does not check for a valid remDev pointer.
*
* Parameters:
* remDev - pointer to remDev.
*
* Returns:
* BtClassOfDevice
*/
BtClassOfDevice ME_GetRemDevCOD(BtRemoteDevice *remDev);
#define ME_GetRemDevCOD(r) ((r)->cod)
/*---------------------------------------------------------------------------
* ME_GetRemDevEncryptState()
*
* Get the encryption state of the remote device. This function
* does not check for a valid remDev pointer.
*
* Parameters:
* remDev - pointer to remDev.
*
* Returns:
* Zero for no encryption, non-zero for encryption.
*/
BtEncryptState ME_GetRemDevEncryptState(BtRemoteDevice *remDev);
#define ME_GetRemDevEncryptState(r) ((r)->encryptState)
/*---------------------------------------------------------------------------
* ME_GetStackInitState()
*
* Reads the initialization state of the stack.
*
* Returns:
* BtStackState - If the value is BTSS_INITIALIZED the stack is
* initialized and ready.
*/
BtStackState ME_GetStackInitState(void);
/*---------------------------------------------------------------------------
* ME_GetBtVersion()
*
* Gets the Bluetooth version of the local radio.
*
* Returns:
* 0 for BT v1.0.
* 1 for BT v1.1.
* 2 for BT v1.2.
* 3 for BT v2.0.
*/
U8 ME_GetBtVersion(void);
/*---------------------------------------------------------------------------
* ME_GetBtFeatures()
*
* Gets the value of the specified byte of the Bluetooth features
* bitmask from the local radio. See the Bluetooth specification for
* a description of the features bitmask.
*
* Parameters:
* byte - byte to retrieve. Must be between 0 and 7.
*
* Returns:
* Value of the specified byte of the BT features bitmask.
*/
U8 ME_GetBtFeatures(U8 byte);
/*---------------------------------------------------------------------------
* ME_HasPendingTask()
*
* Checks for pending ME tasks. The ME task is set when an HCI command
* is sent to the controller. ME_HasPendingTask will return the event
* expected to complete the pending HCI command.
*
* Returns:
* Pending HCI event associated with the completion of the current
* task or 0 for no pending tasks. See HciEventType in hci.h for possible
* return values. If not enough information is available to determine the
* completion event, ME_HasPendingTask returns 0xFF00.
*/
U16 ME_HasPendingTask(void);
/*---------------------------------------------------------------------------
* ME_GetChannelClassification()
*
* Gets the channel classification currently stored in ME for Adaptive
* Frequency Hopping (AFH.) See ME_SetChannelClassification.
*
* Parameters:
* channelClass - BtChannelClass structure containing buffer to receive
* the stored channel classification.
*
* Returns:
* BT_STATUS_SUCCESS - The current channel classification has been
* copied to the BtChannelClass structure.
*/
BtStatus ME_GetChannelClassification(BtChannelClass *channelClass);
/*---------------------------------------------------------------------------
* ME_SetChannelClassification()
*
* Sets the channel classification for Adaptive Frequency Hopping (AFH.)
* Each of the 79 1-MHz channels in the Bluetooth 2.4-GHz band may be
* marked bad or unknown. The AFH controller will not use channels
* marked bad. The AFH controller will evaluate for use any channels
* marked unknown (if automatic classification mode is enabled.) Bad
* channels are indicated with a 0 value. Unknown channels are
* indicated with a 1 value in the bit-mask.
*
* Parameters:
* channelClass - 79 1-bit fields in a 10-byte array, indicating channels
* marked bad or unknown. The nth field (0 - 78) indicates the value
* for channel n. Bit 79 is unused and must be 0.
*
* autoMode - Boolean value indicating whether the controller should
* automatically determine channel classification for the channels
* marked unknown.
*
* Returns:
* BT_STATUS_SUCCESS - the channel classification has been sent to the
* controller.
*
* BT_STATUS_IN_PROGRESS - another ME_SetChannelClassification operation
* is currently in progress. Try again later.
*
* BT_STATUS_INVALID_PARM - The parameters are not valid
* (XA_ERROR_CHECK only).
*/
BtStatus ME_SetChannelClassification(BtChannelClass *channelClass, BOOL autoMode);
void MeChangePacketType(BtRemoteDevice *remDev);
void MeReadRemoteSupportedFeature(BtRemoteDevice *remDev);
void MeReadRemoteVersion(BtRemoteDevice *remDev);
/*---------------------------------------------------------------------------
* ME_MarkAfhChannels()
*
* Sets or clears the bits associated with the indicated range of
* channels in the BtChannelClass map. If the "initialize" parameter is
* TRUE, also initializes the BtChannelClass map to the "Unknown" state.
*
* Parameters:
* channelClass - BtChannelClass structure containing buffer to be
* modified.
*
* begin - the first channel (0 - 78) in the range to set.
*
* count - the number of channels to set starting at "begin".
*
* state - If TRUE, the Bluetooth channel will be set to the "Unknown"
* state. If FALSE, the Bluetooth channel will be set to the "Bad"
* state.
*
* initialize - If TRUE, the BtChannelClass structure will be initialized
* to the "Unknown" state. If FALSE, the structure will be modified
* as is.
*
* Returns:
* BT_STATUS_SUCCESS - The channels have been marked successfully.
*/
BtStatus ME_MarkAfhChannels(BtChannelClass *channelClass, U8 begin, U8 count, BOOL state, BOOL initialize);
/*---------------------------------------------------------------------------
* ME_MarkWiFiChannel()
*
* Sets or clears the bits associated with the indicated WiFi channel in
* the BtChannelClass map. If the "initialize" parameter is TRUE, also
* initializes the BtChannelClass map to the "Unknown" state.
*
* Parameters:
* channelClass - BtChannelClass structure containing buffer to be
* modified.
*
* wifiChannel - WiFi channel (1-14) to set.
*
* state - If TRUE, the WiFi channel will be set to the "Unknown"
* state. If FALSE, the WiFi channel will be set to the "Bad"
* state.
*
* initialize - If TRUE, the BtChannelClass structure will be initialized
* to the "Unknown" state and then set as indicated. If FALSE, the
* structure will be modified as is.
*
* Returns:
* BT_STATUS_SUCCESS - The channels have been marked successfully.
*/
BtStatus ME_MarkWiFiChannel(BtChannelClass *channelClass, U8 wifiChannel, BOOL state, BOOL initialize);
/*---------------------------------------------------------------------------
* ME_RadioInit()
*
* Called to initialize the radio module, including the HCI
* transport drivers, the HCI, and the radio module. This function is
* called by the Event Manager in EVM_Init() when the stack initialization
* sequence begins, but can be called by applications afterwards if
* necessary (ME_RadioShutdown() has been called). When initialization
* is successful, the BTEVENT_HCI_INITIALIZED event will be received.
*
* Parameters: void
*
* Returns:
* BT_STATUS_SUCCESS - Initialization was successful. The application will
* be notified during the call that initialization is complete with
* BTEVENT_HCI_INITIALIZED.
* BT_STATUS_PENDING - Initialization was started successfully. The
* application will be notified when initialization is complete. If
* initialization is successful, BTEVENT_HCI_INTIALIZED will be
* received. If initialization fails, BTEVENT_HCI_INIT_ERROR will be
* received. Initialization will be retried BT_HCI_NUM_INIT_RETRIES
* times when an error occurs. After initialization has been retried
* and has failed the maximum number of times, BTEVENT_HCI_FAILED will
* be received.
* BT_STATUS_FAILED - Initialization failed to start.
*/
BtStatus ME_RadioInit(void);
#define ME_RadioInit() RMGR_RadioInit()
/*---------------------------------------------------------------------------
* ME_RadioShutdown()
*
* Gracefully shuts down the radio module, including the transports and
* the HCI. ME_RadioShutdown will wait 1 second for pending operations
* before shutting down. (Note: Use ME_RadioShutdownTime if you need to
* specify the wait time.) When the shutdown is complete, the global
* handler will receive a BTEVENT_HCI_DEINITIALIZED event.
*
* This function must not be called during a callback.
*
* Returns:
* BT_STATUS_SUCCESS - The radio is down. The application will be notified
* during the call that the shutdown was complete with
* BTEVENT_HCI_DEINITIALIZED.
* BT_STATUS_FAILED - The radio is already down.
* BT_STATUS_PENDING - The radio will be shut down. The application will
* be notified when shutdown is complete with BTEVENT_HCI_DEINITIALIZED.
*/
BtStatus ME_RadioShutdown(void);
BtStatus ME_RadioShutdownTime(TimeT time);
#define ME_RadioShutdown() ME_RadioShutdownTime(1000)
void Me_ChangeLinkPolicy(BtRemoteDevice *remDev, BtEnableOption roleSwitch, BtEnableOption sniff);
#endif /* __ME_H */