Select one of the symbols to view example projects that use it.
 
Outline
#include "bta/bta_api.h"
#include "bta/bta_sys.h"
#include "bta/bta_jv_api.h"
#include "bta_jv_int.h"
#include "osi/allocator.h"
#include <string.h>
#include "stack/port_api.h"
#include "stack/sdp_api.h"
#include "bta/utl.h"
#include "stack/gap_api.h"
#include "common/bt_target.h"
#include "stack/sdp_api.h"
Files
loading (2/5)...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/bt/host/bluedroid/bta/jv/bta_jv_api.c
 
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/****************************************************************************** * * Copyright (C) 2006-2012 Broadcom Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************//* ... */ /****************************************************************************** * * This is the implementation of the JAVA API for Bluetooth Wireless * Technology (JABWT) as specified by the JSR82 specification * ******************************************************************************//* ... */ #include "bta/bta_api.h" #include "bta/bta_sys.h" #include "bta/bta_jv_api.h" #include "bta_jv_int.h" #include "osi/allocator.h" #include <string.h> #include "stack/port_api.h" #include "stack/sdp_api.h" #include "bta/utl.h" #include "stack/gap_api.h" #include "common/bt_target.h" #include "stack/sdp_api.h"12 includes #if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE) /***************************************************************************** ** Constants *****************************************************************************//* ... */ static const tBTA_SYS_REG bta_jv_reg = { bta_jv_sm_execute, NULL }{...}; /******************************************************************************* ** ** Function BTA_JvEnable ** ** Description Enable the Java I/F service. When the enable ** operation is complete the callback function will be ** called with a BTA_JV_ENABLE_EVT. This function must ** be called before other function in the JV API are ** called. ** ** Returns BTA_JV_SUCCESS if successful. ** BTA_JV_FAIL if internal failure. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_ENABLE *p_buf; int i; APPL_TRACE_API( "BTA_JvEnable"); #if BTA_DYNAMIC_MEMORY == TRUE /* Malloc buffer for JV configuration structure */ p_bta_jv_cfg->p_sdp_raw_data = (UINT8 *)osi_malloc(p_bta_jv_cfg->sdp_raw_size); p_bta_jv_cfg->p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(p_bta_jv_cfg->sdp_db_size); if (p_bta_jv_cfg->p_sdp_raw_data == NULL || p_bta_jv_cfg->p_sdp_db == NULL) { return BTA_JV_NO_DATA; }{...} /* ... */#endif if (p_cback && FALSE == bta_sys_is_register(BTA_ID_JV)) { memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB)); /* set handle to invalid value by default */ for (i = 0; i < BTA_JV_PM_MAX_NUM; i++) { bta_jv_cb.pm_cb[i].handle = BTA_JV_PM_HANDLE_CLEAR; }{...} /* register with BTA system manager */ bta_sys_register(BTA_ID_JV, &bta_jv_reg); if (p_cback && (p_buf = (tBTA_JV_API_ENABLE *) osi_malloc(sizeof(tBTA_JV_API_ENABLE))) != NULL) { p_buf->hdr.event = BTA_JV_API_ENABLE_EVT; p_buf->p_cback = p_cback; bta_sys_sendmsg(p_buf); status = BTA_JV_SUCCESS; }{...} }{...} else if (p_cback == NULL) { APPL_TRACE_ERROR("No p_cback."); }{...} else { APPL_TRACE_WARNING("No need to Init again."); status = BTA_JV_ALREADY_DONE; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvDisable ** ** Description Disable the Java I/F ** ** Returns void ** *******************************************************************************//* ... */ void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback) { tBTA_JV_API_DISABLE *p_buf; APPL_TRACE_API( "BTA_JvDisable"); bta_sys_deregister(BTA_ID_JV); memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB)); /* set handle to invalid value by default */ for (int i = 0; i < BTA_JV_PM_MAX_NUM; i++) { bta_jv_cb.pm_cb[i].handle = BTA_JV_PM_HANDLE_CLEAR; }{...} if ((p_buf = (tBTA_JV_API_DISABLE *) osi_malloc(sizeof(tBTA_JV_API_DISABLE))) != NULL) { p_buf->hdr.event = BTA_JV_API_DISABLE_EVT; p_buf->p_cback = p_cback; bta_sys_sendmsg(p_buf); }{...} }{...} /******************************************************************************* ** ** Function BTA_JvFree ** ** Description Free JV configuration ** ** Returns void ** *******************************************************************************//* ... */ void BTA_JvFree(void) { #if BTA_DYNAMIC_MEMORY == TRUE /* Free buffer for JV configuration structure */ osi_free(p_bta_jv_cfg->p_sdp_raw_data); osi_free(p_bta_jv_cfg->p_sdp_db); p_bta_jv_cfg->p_sdp_raw_data = NULL; p_bta_jv_cfg->p_sdp_db = NULL;/* ... */ #endif }{...} /******************************************************************************* ** ** Function BTA_JvIsEnable ** ** Description Get the JV registration status. ** ** Returns TRUE, if registered ** *******************************************************************************//* ... */ BOOLEAN BTA_JvIsEnable(void) { return bta_sys_is_register(BTA_ID_JV); }{...} /******************************************************************************* ** ** Function BTA_JvIsEncrypted ** ** Description This function checks if the link to peer device is encrypted ** ** Returns TRUE if encrypted. ** FALSE if not. ** *******************************************************************************//* ... */ BOOLEAN BTA_JvIsEncrypted(BD_ADDR bd_addr) { BOOLEAN is_encrypted = FALSE; UINT8 sec_flags, le_flags; if (BTM_GetSecurityFlags(bd_addr, &sec_flags) && BTM_GetSecurityFlagsByTransport(bd_addr, &le_flags, BT_TRANSPORT_LE)) { if (sec_flags & BTM_SEC_FLAG_ENCRYPTED || le_flags & BTM_SEC_FLAG_ENCRYPTED) { is_encrypted = TRUE; }{...} }{...} return is_encrypted; }{...} /******************************************************************************* ** ** Function BTA_JvGetChannelId ** ** Description This function reserves a SCN (server channel number) for ** applications running over RFCOMM, L2CAP of L2CAP_LE. ** It is primarily called by server profiles/applications to ** register their SCN into the SDP database. The SCN is reported ** by the tBTA_JV_DM_CBACK callback with a BTA_JV_GET_SCN_EVT ** for RFCOMM channels and BTA_JV_GET_PSM_EVT for L2CAP and LE. ** If the SCN/PSM reported is 0, that means all resources are ** exhausted. ** Parameters ** conn_type one of BTA_JV_CONN_TYPE_ ** user_data Any uservalue - will be returned in the resulting event. ** channel Only used for RFCOMM - to try to allocate a specific RFCOMM ** channel. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data, INT32 channel) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_ALLOC_CHANNEL *p_msg; APPL_TRACE_API( "%s", __func__); if ((p_msg = (tBTA_JV_API_ALLOC_CHANNEL *)osi_malloc(sizeof(tBTA_JV_API_ALLOC_CHANNEL))) != NULL) { p_msg->hdr.event = BTA_JV_API_GET_CHANNEL_EVT; p_msg->type = conn_type; p_msg->channel = channel; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvFreeChannel ** ** Description This function frees a server channel number that was used ** by an application running over RFCOMM. ** Parameters ** channel The channel to free ** conn_type one of BTA_JV_CONN_TYPE_ ** p_cback tBTA_JV_RFCOMM_CBACK is called with when server ** user_data indicate the RFCOMM server status ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_FREE_CHANNEL *p_msg; APPL_TRACE_API( "%s", __func__); if ((p_msg = (tBTA_JV_API_FREE_CHANNEL *)osi_malloc(sizeof(tBTA_JV_API_FREE_CHANNEL))) != NULL) { p_msg->hdr.event = BTA_JV_API_FREE_SCN_EVT; p_msg->scn = channel; p_msg->type = conn_type; p_msg->p_cback = p_cback; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvStartDiscovery ** ** Description This function performs service discovery for the services ** provided by the given peer device. When the operation is ** complete the tBTA_JV_DM_CBACK callback function will be ** called with a BTA_JV_DISCOVERY_COMP_EVT. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, UINT16 num_uuid, tSDP_UUID *p_uuid_list, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_START_DISCOVERY *p_msg; APPL_TRACE_API( "BTA_JvStartDiscovery"); if ((p_msg = (tBTA_JV_API_START_DISCOVERY *)osi_malloc(sizeof(tBTA_JV_API_START_DISCOVERY))) != NULL) { p_msg->hdr.event = BTA_JV_API_START_DISCOVERY_EVT; bdcpy(p_msg->bd_addr, bd_addr); p_msg->num_uuid = num_uuid; memcpy(p_msg->uuid_list, p_uuid_list, num_uuid * sizeof(tSDP_UUID)); p_msg->num_attr = 0; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvCreateRecord ** ** Description Create a service record in the local SDP database. ** When the operation is complete the tBTA_JV_DM_CBACK callback ** function will be called with a BTA_JV_CREATE_RECORD_EVT. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvCreateRecordByUser(const char *name, UINT32 channel, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_CREATE_RECORD *p_msg; APPL_TRACE_API( "BTA_JvCreateRecordByUser"); if ((p_msg = (tBTA_JV_API_CREATE_RECORD *)osi_malloc(sizeof(tBTA_JV_API_CREATE_RECORD))) != NULL) { p_msg->hdr.event = BTA_JV_API_CREATE_RECORD_EVT; p_msg->user_data = user_data; strcpy(p_msg->name, name); p_msg->channel = channel; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvDeleteRecord ** ** Description Delete a service record in the local SDP database. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_ADD_ATTRIBUTE *p_msg; APPL_TRACE_API( "BTA_JvDeleteRecord"); if ((p_msg = (tBTA_JV_API_ADD_ATTRIBUTE *)osi_malloc(sizeof(tBTA_JV_API_ADD_ATTRIBUTE))) != NULL) { p_msg->hdr.event = BTA_JV_API_DELETE_RECORD_EVT; p_msg->handle = handle; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} #if BTA_JV_L2CAP_INCLUDED /******************************************************************************* ** ** Function BTA_JvL2capConnectLE ** ** Description Initiate an LE connection as a L2CAP client to the given BD ** Address. ** When the connection is initiated or failed to initiate, ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT ** When the connection is established or failed, ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role, const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_chan, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_CONNECT *p_msg; APPL_TRACE_API( "%s", __func__); if (p_cback && (p_msg = (tBTA_JV_API_L2CAP_CONNECT *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_CONNECT_LE_EVT; p_msg->sec_mask = sec_mask; p_msg->role = role; p_msg->remote_chan = remote_chan; p_msg->rx_mtu = rx_mtu; if (cfg != NULL) { p_msg->has_cfg = TRUE; p_msg->cfg = *cfg; }{...} else { p_msg->has_cfg = FALSE; }{...} if (ertm_info != NULL) { p_msg->has_ertm_info = TRUE; p_msg->ertm_info = *ertm_info; }{...} else { p_msg->has_ertm_info = FALSE; }{...} memcpy(p_msg->peer_bd_addr, peer_bd_addr, sizeof(BD_ADDR)); p_msg->p_cback = p_cback; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capConnect ** ** Description Initiate a connection as a L2CAP client to the given BD ** Address. ** When the connection is initiated or failed to initiate, ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT ** When the connection is established or failed, ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role, const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_psm, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_CONNECT *p_msg; APPL_TRACE_API( "%s", __func__); if (p_cback && (p_msg = (tBTA_JV_API_L2CAP_CONNECT *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_CONNECT_EVT; p_msg->sec_mask = sec_mask; p_msg->role = role; p_msg->remote_psm = remote_psm; p_msg->rx_mtu = rx_mtu; if (cfg != NULL) { p_msg->has_cfg = TRUE; p_msg->cfg = *cfg; }{...} else { p_msg->has_cfg = FALSE; }{...} if (ertm_info != NULL) { p_msg->has_ertm_info = TRUE; p_msg->ertm_info = *ertm_info; }{...} else { p_msg->has_ertm_info = FALSE; }{...} memcpy(p_msg->peer_bd_addr, peer_bd_addr, sizeof(BD_ADDR)); p_msg->p_cback = p_cback; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capClose ** ** Description This function closes an L2CAP client connection ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capClose(UINT32 handle, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_CLOSE *p_msg; APPL_TRACE_API( "%s", __func__); if (handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback && (p_msg = (tBTA_JV_API_L2CAP_CLOSE *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_CLOSE_EVT; p_msg->handle = handle; p_msg->p_cb = &bta_jv_cb.l2c_cb[handle]; p_msg->p_cback = p_cback; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capCloseLE ** ** Description This function closes an L2CAP client connection for Fixed Channels ** Function is idempotent and no callbacks are called! ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capCloseLE(UINT32 handle) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_CLOSE *p_msg; APPL_TRACE_API( "%s", __func__); if ((p_msg = (tBTA_JV_API_L2CAP_CLOSE *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_CLOSE_FIXED_EVT; p_msg->handle = handle; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capStartServer ** ** Description This function starts an L2CAP server and listens for an L2CAP ** connection from a remote Bluetooth device. When the server ** is started successfully, tBTA_JV_L2CAP_CBACK is called with ** BTA_JV_L2CAP_START_EVT. When the connection is established, ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, const tL2CAP_ERTM_INFO *ertm_info, UINT16 local_psm, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_SERVER *p_msg; APPL_TRACE_API( "%s", __func__); if (p_cback && (p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_START_SERVER_EVT; p_msg->sec_mask = sec_mask; p_msg->role = role; p_msg->local_psm = local_psm; p_msg->rx_mtu = rx_mtu; if (cfg != NULL) { p_msg->has_cfg = TRUE; p_msg->cfg = *cfg; }{...} else { p_msg->has_cfg = FALSE; }{...} if (ertm_info != NULL) { p_msg->has_ertm_info = TRUE; p_msg->ertm_info = *ertm_info; }{...} else { p_msg->has_ertm_info = FALSE; }{...} p_msg->p_cback = p_cback; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capStartServerLE ** ** Description This function starts an LE L2CAP server and listens for an L2CAP ** connection from a remote Bluetooth device. When the server ** is started successfully, tBTA_JV_L2CAP_CBACK is called with ** BTA_JV_L2CAP_START_EVT. When the connection is established, ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capStartServerLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role, const tL2CAP_ERTM_INFO *ertm_info, UINT16 local_chan, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_SERVER *p_msg; APPL_TRACE_API( "%s", __func__); if (p_cback && (p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_START_SERVER_LE_EVT; p_msg->sec_mask = sec_mask; p_msg->role = role; p_msg->local_chan = local_chan; p_msg->rx_mtu = rx_mtu; if (cfg != NULL) { p_msg->has_cfg = TRUE; p_msg->cfg = *cfg; }{...} else { p_msg->has_cfg = FALSE; }{...} if (ertm_info != NULL) { p_msg->has_ertm_info = TRUE; p_msg->ertm_info = *ertm_info; }{...} else { p_msg->has_ertm_info = FALSE; }{...} p_msg->p_cback = p_cback; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capStopServer ** ** Description This function stops the L2CAP server. If the server has an ** active connection, it would be closed. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capStopServer(UINT16 local_psm, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_SERVER *p_msg; APPL_TRACE_API( "%s", __func__); if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_STOP_SERVER_EVT; p_msg->local_psm = local_psm; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capStopServerLE ** ** Description This function stops the LE L2CAP server. If the server has an ** active connection, it would be closed. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capStopServerLE(UINT16 local_chan, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_SERVER *p_msg; APPL_TRACE_API( "%s", __func__); if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT; p_msg->local_chan = local_chan; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capRead ** ** Description This function reads data from an L2CAP connecti; tBTA_JV_RFC_CB *p_cb = rc->p_cb; on ** When the operation is complete, tBTA_JV_L2CAP_CBACK is ** called with BTA_JV_L2CAP_READ_EVT. ** ** Returns Length of read data. ** *******************************************************************************//* ... */ int BTA_JvL2capRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len) { tBTA_JV_L2CAP_READ evt_data; APPL_TRACE_API( "%s", __func__); if (handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback) { evt_data.status = BTA_JV_FAILURE; evt_data.handle = handle; evt_data.req_id = req_id; evt_data.p_data = p_data; evt_data.len = 0; if (BT_PASS == GAP_ConnReadData((UINT16)handle, p_data, len, &evt_data.len)) { evt_data.status = BTA_JV_SUCCESS; }{...} bta_jv_cb.l2c_cb[handle].p_cback( BTA_JV_L2CAP_READ_EVT, (tBTA_JV *)&evt_data, bta_jv_cb.l2c_cb[handle].user_data); }{...} return (evt_data.len); }{...} /******************************************************************************* ** ** Function BTA_JvL2capReceive ** ** Description This function reads data from an L2CAP connection ** When the operation is complete, tBTA_JV_L2CAP_CBACK is ** called with BTA_JV_L2CAP_RECEIVE_EVT. ** If there are more data queued in L2CAP than len, the extra data will be discarded. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capReceive(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_L2CAP_RECEIVE evt_data; UINT32 left_over = 0; UINT16 max_len, read_len; APPL_TRACE_API( "%s", __func__); if (handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback) { status = BTA_JV_SUCCESS; evt_data.status = BTA_JV_FAILURE; evt_data.handle = handle; evt_data.req_id = req_id; evt_data.p_data = p_data; evt_data.len = 0; if (BT_PASS == GAP_ConnReadData((UINT16)handle, p_data, len, &evt_data.len)) { evt_data.status = BTA_JV_SUCCESS; GAP_GetRxQueueCnt ((UINT16)handle, &left_over); while (left_over) { max_len = (left_over > 0xFFFF) ? 0xFFFF : left_over; GAP_ConnReadData ((UINT16)handle, NULL, max_len, &read_len); left_over -= read_len; }{...} }{...} bta_jv_cb.l2c_cb[handle].p_cback( BTA_JV_L2CAP_RECEIVE_EVT, (tBTA_JV *)&evt_data, bta_jv_cb.l2c_cb[handle].user_data); }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capReady ** ** Description This function determined if there is data to read from ** an L2CAP connection ** ** Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size. ** BTA_JV_FAILURE, if error. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capReady(UINT32 handle, UINT32 *p_data_size) { tBTA_JV_STATUS status = BTA_JV_FAILURE; APPL_TRACE_API( "%s: %d", __func__, handle); if (p_data_size && handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback) { *p_data_size = 0; if (BT_PASS == GAP_GetRxQueueCnt((UINT16)handle, p_data_size) ) { status = BTA_JV_SUCCESS; }{...} }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capWrite ** ** Description This function writes data to an L2CAP connection ** When the operation is complete, tBTA_JV_L2CAP_CBACK is ** called with BTA_JV_L2CAP_WRITE_EVT. Works for ** PSM-based connections ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_WRITE *p_msg; APPL_TRACE_API( "%s", __func__); if (handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback && (p_msg = (tBTA_JV_API_L2CAP_WRITE *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_WRITE))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_WRITE_EVT; p_msg->handle = handle; p_msg->req_id = req_id; p_msg->p_data = p_data; p_msg->p_cb = &bta_jv_cb.l2c_cb[handle]; p_msg->len = len; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvL2capWriteFixed ** ** Description This function writes data to an L2CAP connection ** When the operation is complete, tBTA_JV_L2CAP_CBACK is ** called with BTA_JV_L2CAP_WRITE_EVT. Works for ** fixed-channel connections ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id, tBTA_JV_L2CAP_CBACK *p_cback, UINT8 *p_data, UINT16 len, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_L2CAP_WRITE_FIXED *p_msg; APPL_TRACE_API( "%s", __func__); if ((p_msg = (tBTA_JV_API_L2CAP_WRITE_FIXED *)osi_malloc(sizeof(tBTA_JV_API_L2CAP_WRITE_FIXED))) != NULL) { p_msg->hdr.event = BTA_JV_API_L2CAP_WRITE_FIXED_EVT; p_msg->channel = channel; memcpy(p_msg->addr, addr, sizeof(p_msg->addr)); p_msg->req_id = req_id; p_msg->p_data = p_data; p_msg->p_cback = p_cback; p_msg->len = len; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /* ... */#endif /* BTA_JV_L2CAP_INCLUDED */ #if BTA_JV_RFCOMM_INCLUDED /******************************************************************************* ** ** Function BTA_JvRfcommConfig ** ** Description This function is to configure RFCOMM. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvRfcommConfig(BOOLEAN enable_l2cap_ertm) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_RFCOMM_CONFIG *p_msg; APPL_TRACE_API( "%s", __func__); if ((p_msg = (tBTA_JV_API_RFCOMM_CONFIG *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_CONFIG))) != NULL) { p_msg->hdr.event = BTA_JV_API_RFCOMM_CONFIG_EVT; p_msg->enable_l2cap_ertm = enable_l2cap_ertm; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvRfcommConnect ** ** Description This function makes an RFCOMM connection to a remote BD ** Address. ** When the connection is initiated or failed to initiate, ** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CL_INIT_EVT ** When the connection is established or failed, ** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_OPEN_EVT ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role, UINT8 remote_scn, BD_ADDR peer_bd_addr, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_RFCOMM_CONNECT *p_msg; APPL_TRACE_API( "BTA_JvRfcommConnect"); if (p_cback && (p_msg = (tBTA_JV_API_RFCOMM_CONNECT *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_CONNECT))) != NULL) { p_msg->hdr.event = BTA_JV_API_RFCOMM_CONNECT_EVT; p_msg->sec_mask = sec_mask; p_msg->role = role; p_msg->remote_scn = remote_scn; memcpy(p_msg->peer_bd_addr, peer_bd_addr, sizeof(BD_ADDR)); p_msg->p_cback = p_cback; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvRfcommClose ** ** Description This function closes an RFCOMM connection ** When the connection is established or failed, ** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CLOSE_EVT ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_RFCOMM_CLOSE *p_msg; UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle); APPL_TRACE_API( "%s", __func__); if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback && si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] && (p_msg = (tBTA_JV_API_RFCOMM_CLOSE *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_CLOSE))) != NULL) { p_msg->hdr.event = BTA_JV_API_RFCOMM_CLOSE_EVT; p_msg->handle = handle; p_msg->p_cb = &bta_jv_cb.rfc_cb[hi]; p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1]; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvRfcommStartServer ** ** Description This function starts listening for an RFCOMM connection ** request from a remote Bluetooth device. When the server is ** started successfully, tBTA_JV_RFCOMM_CBACK is called ** with BTA_JV_RFCOMM_START_EVT. ** When the connection is established, tBTA_JV_RFCOMM_CBACK ** is called with BTA_JV_RFCOMM_OPEN_EVT. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, UINT8 local_scn, UINT8 max_session, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_RFCOMM_SERVER *p_msg; APPL_TRACE_API( "BTA_JvRfcommStartServer"); if (p_cback && (p_msg = (tBTA_JV_API_RFCOMM_SERVER *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL) { if (max_session == 0) { max_session = 1; }{...} if (max_session > BTA_JV_MAX_RFC_SR_SESSION) { APPL_TRACE_DEBUG( "max_session (%d) is too big. use max (%d)", max_session, BTA_JV_MAX_RFC_SR_SESSION); max_session = BTA_JV_MAX_RFC_SR_SESSION; }{...} p_msg->hdr.event = BTA_JV_API_RFCOMM_START_SERVER_EVT; p_msg->sec_mask = sec_mask; p_msg->role = role; p_msg->local_scn = local_scn; p_msg->max_session = max_session; p_msg->p_cback = p_cback; p_msg->user_data = user_data; //caller's private data bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvRfcommStopServer ** ** Description This function stops the RFCOMM server. If the server has an ** active connection, it would be closed. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_RFCOMM_SERVER *p_msg; APPL_TRACE_API( "BTA_JvRfcommStopServer"); if ((p_msg = (tBTA_JV_API_RFCOMM_SERVER *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL) { p_msg->hdr.event = BTA_JV_API_RFCOMM_STOP_SERVER_EVT; p_msg->handle = handle; p_msg->user_data = user_data; //caller's private data bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvRfcommRead ** ** Description This function reads data from an RFCOMM connection ** The actual size of data read is returned in p_len. ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_RFCOMM_READ *p_msg; UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle); APPL_TRACE_API( "BTA_JvRfcommRead"); if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback && si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] && (p_msg = (tBTA_JV_API_RFCOMM_READ *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_READ))) != NULL) { p_msg->hdr.event = BTA_JV_API_RFCOMM_READ_EVT; p_msg->handle = handle; p_msg->req_id = req_id; p_msg->p_data = p_data; p_msg->len = len; p_msg->p_cb = &bta_jv_cb.rfc_cb[hi]; p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1]; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvRfcommGetPortHdl ** ** Description This function fetches the rfcomm port handle ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ UINT16 BTA_JvRfcommGetPortHdl(UINT32 handle) { UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle); if (hi < BTA_JV_MAX_RFC_CONN && si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) { return bta_jv_cb.port_cb[bta_jv_cb.rfc_cb[hi].rfc_hdl[si] - 1].port_handle; }{...} else { return 0xffff; }{...} }{...} /******************************************************************************* ** ** Function BTA_JvRfcommReady ** ** Description This function determined if there is data to read from ** an RFCOMM connection ** ** Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size. ** BTA_JV_FAILURE, if error. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvRfcommReady(UINT32 handle, UINT32 *p_data_size) { tBTA_JV_STATUS status = BTA_JV_FAILURE; UINT16 size = 0; UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle); APPL_TRACE_API( "BTA_JvRfcommReady"); if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback && si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) { if (PORT_GetRxQueueCnt(bta_jv_cb.rfc_cb[hi].rfc_hdl[si], &size) == PORT_SUCCESS) { status = BTA_JV_SUCCESS; }{...} }{...} *p_data_size = size; return (status); }{...} /******************************************************************************* ** ** Function BTA_JvRfcommWrite ** ** Description This function writes data to an RFCOMM connection ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_RFCOMM_WRITE *p_msg; UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle); APPL_TRACE_API( "BTA_JvRfcommWrite"); APPL_TRACE_DEBUG( "handle:0x%x, hi:%d, si:%d", handle, hi, si); if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback && si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] && (p_msg = (tBTA_JV_API_RFCOMM_WRITE *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_WRITE))) != NULL) { p_msg->hdr.event = BTA_JV_API_RFCOMM_WRITE_EVT; p_msg->handle = handle; p_msg->req_id = req_id; p_msg->p_cb = &bta_jv_cb.rfc_cb[hi]; p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1]; p_msg->p_data = p_data; p_msg->len = len; APPL_TRACE_API( "write ok"); bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /******************************************************************************* ** ** Function BTA_JvRfcommFlowControl ** ** Description This function gives credits to the peer ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvRfcommFlowControl(UINT32 handle, UINT16 credits_given) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_RFCOMM_FLOW_CONTROL *p_msg; UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle); APPL_TRACE_API( "BTA_JvRfcommFlowControl"); APPL_TRACE_DEBUG( "handle:0x%x, hi:%d, si:%d", handle, hi, si); if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback && si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] && (p_msg = (tBTA_JV_API_RFCOMM_FLOW_CONTROL *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_FLOW_CONTROL))) != NULL) { p_msg->hdr.event = BTA_JV_API_RFCOMM_FLOW_CONTROL_EVT; p_msg->p_cb = &bta_jv_cb.rfc_cb[hi]; p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1]; p_msg->credits_given = credits_given; APPL_TRACE_API( "credits given %d", credits_given); bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /* ... */#endif /* BTA_JV_RFCOMM_INCLUDED */ /******************************************************************************* ** ** Function BTA_JVSetPmProfile ** ** Description This function set or free power mode profile for different JV application ** ** Parameters: handle, JV handle from RFCOMM or L2CAP ** app_id: app specific pm ID, can be BTA_JV_PM_ALL, see bta_dm_cfg.c for details ** BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st is ignored and ** BTA_JV_CONN_CLOSE is called implicitly ** init_st: state after calling this API. typically it should be BTA_JV_CONN_OPEN ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** ** NOTE: BTA_JV_PM_ID_CLEAR: In general no need to be called as jv pm calls automatically ** BTA_JV_CONN_CLOSE to remove in case of connection close! ** *******************************************************************************//* ... */ tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_STATE init_st) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_SET_PM_PROFILE *p_msg; APPL_TRACE_API("BTA_JVSetPmProfile handle:0x%x, app_id:%d", handle, app_id); if ((p_msg = (tBTA_JV_API_SET_PM_PROFILE *)osi_malloc(sizeof(tBTA_JV_API_SET_PM_PROFILE))) != NULL) { p_msg->hdr.event = BTA_JV_API_SET_PM_PROFILE_EVT; p_msg->handle = handle; p_msg->app_id = app_id; p_msg->init_st = init_st; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; }{...} return (status); }{...} /* ... */ #endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.