summaryrefslogtreecommitdiffstats
path: root/bta/include/bta_hl_api.h
blob: e7febf8a13f504e77edab39c1f7ece1e2d1cb556 (plain)
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
/******************************************************************************
 *
 *  Copyright (C) 2009-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 public interface file for the HeaLth device profile (HL)
 *  subsystem of BTA, Broadcom's Bluetooth application layer for mobile
 *  phones.
 *
 ******************************************************************************/
#ifndef BTA_HL_API_H
#define BTA_HL_API_H

#include "bta_api.h"
#include "btm_api.h"
#include "mca_api.h"

/*****************************************************************************
**  Constants and data types
*****************************************************************************/
/* Extra Debug Code */
#ifndef BTA_HL_DEBUG
#define BTA_HL_DEBUG           TRUE
#endif

#ifndef BTA_HL_NUM_APPS
#define BTA_HL_NUM_APPS                 3
#endif

#ifndef BTA_HL_NUM_MDEPS
#define BTA_HL_NUM_MDEPS                5
#endif

#ifndef BTA_HL_NUM_MCLS
#define BTA_HL_NUM_MCLS                 7
#endif

#ifndef BTA_HL_NUM_MDLS_PER_MDEP
#define BTA_HL_NUM_MDLS_PER_MDEP        4
#endif

#ifndef BTA_HL_NUM_MDLS_PER_MCL
#define BTA_HL_NUM_MDLS_PER_MCL         10
#endif

#ifndef BTA_HL_NUM_DATA_TYPES
#define BTA_HL_NUM_DATA_TYPES            5   /* maximum number of data types can be supported
                                                per MDEP ID */
#endif

#define BTA_HL_MCAP_RSP_TOUT            2    /* 2 seconds */

#ifndef BTA_HL_CCH_NUM_FILTER_ELEMS
#define BTA_HL_CCH_NUM_FILTER_ELEMS     3
#endif

#ifndef BTA_HL_NUM_SDP_CBACKS
#define BTA_HL_NUM_SDP_CBACKS           7
#endif

#ifndef BTA_HL_NUM_SDP_RECS
#define BTA_HL_NUM_SDP_RECS             3
#endif

#ifndef BTA_HL_NUM_SDP_MDEPS
#define BTA_HL_NUM_SDP_MDEPS            10
#endif

#ifndef BTA_HL_NUM_SVC_ELEMS
#define BTA_HL_NUM_SVC_ELEMS            2
#endif

#ifndef BTA_HL_NUM_PROTO_ELEMS
#define BTA_HL_NUM_PROTO_ELEMS          2
#endif

#define BTA_HL_VERSION_01_00            0x0100
#define BTA_HL_NUM_ADD_PROTO_LISTS      1
#define BTA_HL_NUM_ADD_PROTO_ELEMS      2
#define BTA_HL_MDEP_SEQ_SIZE            20
#define BTA_HL_VAL_ARRY_SIZE            320

#ifndef BTA_HL_NUM_MDL_CFGS
#define BTA_HL_NUM_MDL_CFGS             16    /* numer of MDL cfg saved in the persistent memory*/
#endif

#define BTA_HL_NUM_TIMERS               7

#define BTA_HL_CCH_RSP_TOUT             2000
#define BTA_HL_LRG_POOL_ID              GKI_POOL_ID_7
#define BTA_HL_MAX_TIME                 255
#define BTA_HL_MIN_TIME                 1
#define BTA_HL_INVALID_APP_HANDLE       0xFF
#define BTA_HL_INVALID_MCL_HANDLE       0xFF
#define BTA_HL_INVALID_MDL_HANDLE       0xFFFF

#define BTA_HL_STATUS_OK                    0
#define BTA_HL_STATUS_FAIL                  1   /* Used to pass all other errors */
#define BTA_HL_STATUS_ABORTED               2
#define BTA_HL_STATUS_NO_RESOURCE           3
#define BTA_HL_STATUS_LAST_ITEM             4
#define BTA_HL_STATUS_DUPLICATE_APP_ID      5
#define BTA_HL_STATUS_INVALID_APP_HANDLE    6
#define BTA_HL_STATUS_INVALID_MCL_HANDLE    7
#define BTA_HL_STATUS_MCAP_REG_FAIL         8
#define BTA_HL_STATUS_MDEP_CO_FAIL          9
#define BTA_HL_STATUS_ECHO_CO_FAIL          10
#define BTA_HL_STATUS_MDL_CFG_CO_FAIL       11
#define BTA_HL_STATUS_SDP_NO_RESOURCE       12
#define BTA_HL_STATUS_SDP_FAIL              13
#define BTA_HL_STATUS_NO_CCH                14
#define BTA_HL_STATUS_NO_MCL                15

#define BTA_HL_STATUS_NO_FIRST_RELIABLE     17
#define BTA_HL_STATUS_INVALID_DCH_CFG       18
#define BTA_HL_STATUS_INVALID_MDL_HANDLE    19
#define BTA_HL_STATUS_INVALID_BD_ADDR       20
#define BTA_HL_STATUS_INVALID_RECONNECT_CFG 21
#define BTA_HL_STATUS_ECHO_TEST_BUSY        22
#define BTA_HL_STATUS_INVALID_LOCAL_MDEP_ID 23
#define BTA_HL_STATUS_INVALID_MDL_ID        24
#define BTA_HL_STATUS_NO_MDL_ID_FOUND       25
#define BTA_HL_STATUS_DCH_BUSY              26  /* DCH is congested*/
#define BTA_HL_STATUS_INVALID_CTRL_PSM      27

typedef UINT8 tBTA_HL_STATUS;
typedef tMCA_HANDLE tBTA_HL_APP_HANDLE;
typedef tMCA_CL     tBTA_HL_MCL_HANDLE;
typedef tMCA_DL     tBTA_HL_MDL_HANDLE;
enum
{
    BTA_HL_DEVICE_TYPE_SINK,
    BTA_HL_DEVICE_TYPE_SOURCE,
    BTA_HL_DEVICE_TYPE_DUAL
};

typedef UINT8 tBTA_HL_DEVICE_TYPE;



#define BTA_HL_SDP_IEEE_11073_20601             0x01

#define BTA_HL_MCAP_SUP_RECONNECT_MASK_INIT          2 /* 0x02 */
#define BTA_HL_MCAP_SUP_RECONNECT_MASK_ACCEPT        4 /* 0x04 */
#define BTA_HL_MCAP_SUP_CSP_MASK_SYNC_SLAVE          0 /* 0x08 */
#define BTA_HL_MCAP_SUP_CSP_MASK_SYNC_MASTER         0 /* 0x10 */

#define BTA_HL_MCAP_SUP_PROC_MASK  (BTA_HL_MCAP_SUP_RECONNECT_MASK_INIT | \
                                    BTA_HL_MCAP_SUP_RECONNECT_MASK_ACCEPT | \
                                    BTA_HL_MCAP_SUP_CSP_MASK_SYNC_SLAVE | \
                                    BTA_HL_MCAP_SUP_CSP_MASK_SYNC_MASTER)
#define BTA_HL_MDEP_ROLE_SOURCE         0x00
#define BTA_HL_MDEP_ROLE_SINK           0x01

typedef UINT8 tBTA_HL_MDEP_ROLE;

#define BTA_HL_MDEP_ROLE_MASK_SOURCE    0x01     /* bit mask */
#define BTA_HL_MDEP_ROLE_MASK_SINK      0x02
typedef UINT8 tBTA_HL_MDEP_ROLE_MASK;


#define BTA_HL_ECHO_TEST_MDEP_ID        0
#define BTA_HL_ECHO_TEST_MDEP_CFG_IDX   0

#define BTA_HL_INVALID_MDEP_ID     0xFF
typedef tMCA_DEP tBTA_HL_MDEP_ID; /* 0 is for echo test,
                                   0x01-0x7F availave for use,
                                   0x80-0xFF reserved*/


#define BTA_HL_DELETE_ALL_MDL_IDS   0xFFFF
#define BTA_HL_MAX_MDL_VAL          0xFEFF
typedef UINT16 tBTA_HL_MDL_ID;  /* 0x0000 reserved,
                                   0x0001-0xFEFF dynamic range,
                                   0xFF00-0xFFFE reserved,
                                   0xFFFF indicates all MDLs*/

#define BTA_HL_MDEP_DESP_LEN       35

#define BTA_HL_DCH_MODE_RELIABLE    0
#define BTA_HL_DCH_MODE_STREAMING   1

typedef UINT8 tBTA_HL_DCH_MODE;

#define BTA_HL_DCH_CFG_NO_PREF      0
#define BTA_HL_DCH_CFG_RELIABLE     1
#define BTA_HL_DCH_CFG_STREAMING    2
#define BTA_HL_DCH_CFG_UNKNOWN      0xFF

typedef UINT8 tBTA_HL_DCH_CFG;

/* The Default DCH CFG for the echo test when the device is a Source */
#define BTA_HL_DEFAULT_ECHO_TEST_SRC_DCH_CFG BTA_HL_DCH_CFG_RELIABLE

#define BTA_HL_DCH_CREATE_RSP_SUCCESS 0
#define BTA_HL_DCH_CREATE_RSP_CFG_REJ 1

typedef UINT8 tBTA_HL_DCH_CREATE_RSP;

#define BTA_HL_MCAP_SUP_PROC_RECONNECT_INIT 0x02
#define BTA_HL_MCAP_SUP_PROC_RECONNECT_APT  0x04
#define BTA_HL_MCAP_SUP_PROC_CSP_SLAVE      0x08
#define BTA_HL_MCAP_SUP_PROC_CSP_MASTER     0x10

typedef UINT8 tBTA_HL_SUP_PROC_MASK;

typedef struct
{
    UINT16                  max_rx_apdu_size;  /* local rcv MTU */
    UINT16                  max_tx_apdu_size;  /* maximum TX APDU size*/
} tBTA_HL_ECHO_CFG;


typedef struct
{
    UINT16                  data_type;
    UINT16                  max_rx_apdu_size;  /* local rcv MTU */
    UINT16                  max_tx_apdu_size;  /* maximum TX APDU size*/
    char                    desp[BTA_HL_MDEP_DESP_LEN+1];
} tBTA_HL_MDEP_DATA_TYPE_CFG;


typedef struct
{
    tBTA_HL_MDEP_ROLE           mdep_role;
    UINT8                       num_of_mdep_data_types;
    tBTA_HL_MDEP_DATA_TYPE_CFG  data_cfg[BTA_HL_NUM_DATA_TYPES];
} tBTA_HL_MDEP_CFG;

typedef struct
{
    tBTA_HL_MDEP_ID         mdep_id;  /* MDEP ID 0x01-0x7F */
    tBTA_HL_MDEP_CFG        mdep_cfg;
} tBTA_HL_MDEP;

typedef struct
{
    tBTA_HL_MDEP            mdep[BTA_HL_NUM_MDEPS];
    tBTA_HL_ECHO_CFG        echo_cfg;
    tBTA_HL_MDEP_ROLE_MASK  app_role_mask;
    BOOLEAN                 advertize_source_sdp;
    UINT8                   num_of_mdeps;
} tBTA_HL_SUP_FEATURE;

typedef struct
{
    BOOLEAN                 delete_req_pending;
    tBTA_HL_MDL_ID          mdl_id;
    tBTA_HL_MCL_HANDLE      mcl_handle;
} tBTA_HL_DELETE_MDL;

typedef struct
{
    UINT8                   time;
    UINT16                  mtu;
    tBTA_HL_MDL_ID          mdl_id;
    tBTA_HL_MDEP_ID         local_mdep_id;
    tBTA_HL_MDEP_ROLE       local_mdep_role;
    BOOLEAN                 active;     /* true if this item is in use */
    tBTA_HL_DCH_MODE        dch_mode;
    UINT8                   fcs;
    BD_ADDR                 peer_bd_addr;
} tBTA_HL_MDL_CFG;


/* Maximum number of supported feature list items (list_elem in tSDP_SUP_FEATURE_ELEM) */
#define BTA_HL_NUM_SUP_FEATURE_ELEMS     10
#define BTA_HL_SUP_FEATURE_SDP_BUF_SIZE  512
/* This structure is used to add supported feature lists and find supported feature elements */
typedef struct
{
    UINT8       mdep_id;
    UINT16      data_type;
    tBTA_HL_MDEP_ROLE       mdep_role;
    char        *p_mdep_desp;
} tBTA_HL_SUP_FEATURE_ELEM;

typedef struct
{
    UINT16                      num_elems;
    tBTA_HL_SUP_FEATURE_ELEM   list_elem[BTA_HL_NUM_SUP_FEATURE_ELEMS];
} tBTA_HL_SUP_FEATURE_LIST_ELEM;


typedef struct
{
    tBTA_HL_DEVICE_TYPE     dev_type;           /* sink, source or dual roles */
    tBTA_SEC                sec_mask;           /* security mask for accepting conenction*/
    const char              *p_srv_name;        /* service name to be used in the SDP; null terminated*/
    const char              *p_srv_desp;        /* service description to be used in the SDP; null terminated */
    const char              *p_provider_name;   /* provide name to be used in the SDP; null terminated */
} tBTA_HL_REG_PARAM;

typedef struct
{
    UINT16                  ctrl_psm;
    BD_ADDR                 bd_addr;           /* Address of peer device */
    tBTA_SEC                sec_mask;          /* security mask for initiating connection*/
} tBTA_HL_CCH_OPEN_PARAM;


typedef struct
{
    UINT16                  ctrl_psm;
    tBTA_HL_MDEP_ID         local_mdep_id;     /* local MDEP ID */
    tBTA_HL_MDEP_ID         peer_mdep_id;      /* peer mdep id */
    tBTA_HL_DCH_CFG         local_cfg;
    tBTA_SEC                sec_mask;          /* security mask for initiating connection*/
} tBTA_HL_DCH_OPEN_PARAM;


typedef struct
{
    UINT16                  ctrl_psm;
    tBTA_HL_MDL_ID          mdl_id;
} tBTA_HL_DCH_RECONNECT_PARAM;


typedef struct
{
    UINT16                  ctrl_psm;
    UINT16                  pkt_size;
    tBTA_HL_DCH_CFG         local_cfg;
} tBTA_HL_DCH_ECHO_TEST_PARAM;

typedef struct
{
    UINT16                  buf_size;
    UINT8                   p_buf;        /* buffer pointer */
} tBTA_HL_DCH_BUF_INFO;

typedef struct
{
    tBTA_HL_MDEP_ID         local_mdep_id;  /* local MDEP ID */
    tBTA_HL_MDL_ID          mdl_id;
    tBTA_HL_DCH_CREATE_RSP  rsp_code;
    tBTA_HL_DCH_CFG         cfg_rsp;
} tBTA_HL_DCH_CREATE_RSP_PARAM;

typedef struct
{
    UINT16              data_type;
    UINT8               mdep_id;
    tBTA_HL_MDEP_ROLE   mdep_role;
    char                mdep_desp[BTA_HL_MDEP_DESP_LEN+1];
}tBTA_HL_SDP_MDEP_CFG;

typedef struct
{
    UINT16                  ctrl_psm;
    UINT16                  data_psm;
    UINT8                   mcap_sup_proc;
    UINT8                   num_mdeps; /* number of mdep elements from SDP*/
    char                    srv_name[BTA_SERVICE_NAME_LEN+1];
    char                    srv_desp[BTA_SERVICE_DESP_LEN+1];
    char                    provider_name[BTA_PROVIDER_NAME_LEN+1];
    tBTA_HL_SDP_MDEP_CFG    mdep_cfg[BTA_HL_NUM_SDP_MDEPS];
} tBTA_HL_SDP_REC;

typedef struct
{
    UINT8                num_recs;
    tBTA_HL_SDP_REC      sdp_rec[BTA_HL_NUM_SDP_RECS];
} tBTA_HL_SDP;

/* HL control callback function events */
enum
{
    BTA_HL_CTRL_ENABLE_CFM_EVT            = 0,
    BTA_HL_CTRL_DISABLE_CFM_EVT
};
typedef UINT8 tBTA_HL_CTRL_EVT;
/* Structure associated with BTA_HL_ENABLE_EVT
   BTA_HL_DISABLE_EVT */

typedef struct
{
    tBTA_HL_STATUS  status;
} tBTA_HL_CTRL_ENABLE_DISABLE;

typedef union
{
    tBTA_HL_CTRL_ENABLE_DISABLE  enable_cfm;
    tBTA_HL_CTRL_ENABLE_DISABLE  disable_cfm;
} tBTA_HL_CTRL;

/* HL instance callback function events */
enum
{
    BTA_HL_REGISTER_CFM_EVT           =0,
    BTA_HL_DEREGISTER_CFM_EVT,
    BTA_HL_CCH_OPEN_IND_EVT,
    BTA_HL_CCH_OPEN_CFM_EVT,
    BTA_HL_CCH_CLOSE_IND_EVT,
    BTA_HL_CCH_CLOSE_CFM_EVT,
    BTA_HL_DCH_CREATE_IND_EVT,
    BTA_HL_DCH_OPEN_IND_EVT,
    BTA_HL_DCH_OPEN_CFM_EVT,
    BTA_HL_DCH_CLOSE_IND_EVT,
    BTA_HL_DCH_CLOSE_CFM_EVT,
    BTA_HL_DCH_RECONNECT_IND_EVT,
    BTA_HL_DCH_RECONNECT_CFM_EVT,

    BTA_HL_DCH_ABORT_IND_EVT,
    BTA_HL_DCH_ABORT_CFM_EVT,
    BTA_HL_DELETE_MDL_IND_EVT,
    BTA_HL_DELETE_MDL_CFM_EVT,
    BTA_HL_DCH_SEND_DATA_CFM_EVT,
    BTA_HL_DCH_RCV_DATA_IND_EVT,
    BTA_HL_CONG_CHG_IND_EVT,
    BTA_HL_DCH_ECHO_TEST_CFM_EVT,
    BTA_HL_SDP_QUERY_CFM_EVT,
    BTA_HL_SDP_INFO_IND_EVT
};
typedef UINT8 tBTA_HL_EVT;


typedef struct
{
    tBTA_HL_STATUS          status;        /* start status */
    UINT8                   app_id;
    tBTA_HL_APP_HANDLE      app_handle;
} tBTA_HL_REGISTER_CFM;


typedef struct
{
    tBTA_HL_STATUS          status;        /* start status */
    tBTA_HL_APP_HANDLE      app_handle;
} tBTA_HL_DEREGISTER_CFM;


typedef struct
{
    BOOLEAN                 intentional;
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
} tBTA_HL_CCH_CLOSE_IND;


typedef struct
{
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
} tBTA_HL_MCL_IND;

typedef struct
{
    tBTA_HL_STATUS          status;             /* connection status */
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
} tBTA_HL_MCL_CFM;

typedef struct
{
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
    BD_ADDR                 bd_addr; /* address of peer device */
} tBTA_HL_CCH_OPEN_IND;

typedef struct
{
    tBTA_HL_STATUS          status;             /* connection status */
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
    BD_ADDR                 bd_addr;            /* address of peer device */
} tBTA_HL_CCH_OPEN_CFM;

typedef struct
{
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
    tBTA_HL_MDEP_ID         local_mdep_id;
    tBTA_HL_MDL_ID          mdl_id;             /* MCAP data link ID for this
                                                   data channel conenction    */
    tBTA_HL_DCH_CFG         cfg;                /* dch cfg requested by the peer device */
} tBTA_HL_DCH_CREATE_IND;

typedef struct
{
    tBTA_HL_MDL_HANDLE      mdl_handle;
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
    tBTA_HL_MDEP_ID         local_mdep_id;
    tBTA_HL_MDL_ID          mdl_id;             /* MCAP data link ID for this
                                                   data channel conenction    */
    tBTA_HL_DCH_MODE        dch_mode;           /* data channel mode - reliable or streaming*/

    BOOLEAN                 first_reliable;  /* whether this is the first reliable data channel */
    UINT16                  mtu;
} tBTA_HL_DCH_OPEN_IND;

typedef struct
{
    tBTA_HL_STATUS          status;             /* connection status */
    tBTA_HL_MDL_HANDLE      mdl_handle;
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
    tBTA_HL_MDEP_ID         local_mdep_id;
    tBTA_HL_MDL_ID          mdl_id;             /* MCAP data link ID for this
                                                   data channel conenction    */
    tBTA_HL_DCH_MODE        dch_mode;           /* data channel mode - reliable or streaming*/
    BOOLEAN                 first_reliable;     /* whether this is the first reliable data channel */
    UINT16                  mtu;
} tBTA_HL_DCH_OPEN_CFM;


typedef struct
{
    BOOLEAN                 intentional;
    tBTA_HL_MDL_HANDLE      mdl_handle;
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
} tBTA_HL_DCH_CLOSE_IND;


typedef struct
{
    tBTA_HL_MDL_HANDLE      mdl_handle;
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
} tBTA_HL_MDL_IND;

typedef struct
{
    tBTA_HL_STATUS          status;
    tBTA_HL_MDL_HANDLE      mdl_handle;
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
} tBTA_HL_MDL_CFM;

typedef struct
{
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
    tBTA_HL_MDL_ID          mdl_id;
} tBTA_HL_DELETE_MDL_IND;

typedef struct
{
    tBTA_HL_STATUS          status;
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
    tBTA_HL_MDL_ID          mdl_id;
} tBTA_HL_DELETE_MDL_CFM;

typedef struct
{
    tBTA_HL_MDL_HANDLE      mdl_handle;
    tBTA_HL_MCL_HANDLE      mcl_handle;
    tBTA_HL_APP_HANDLE      app_handle;
    BOOLEAN                 cong;
} tBTA_HL_DCH_CONG_IND;

typedef struct
{
    tBTA_HL_APP_HANDLE      app_handle;
    UINT16                  ctrl_psm;
    UINT16                  data_psm;
    UINT8                   data_x_spec;
    UINT8                   mcap_sup_procs;
} tBTA_HL_SDP_INFO_IND;

typedef struct
{
    tBTA_HL_STATUS          status;
    tBTA_HL_APP_HANDLE      app_handle;
    BD_ADDR                 bd_addr;
    tBTA_HL_SDP             *p_sdp;
} tBTA_HL_SDP_QUERY_CFM;

typedef union
{
    tBTA_HL_REGISTER_CFM        reg_cfm;
    tBTA_HL_DEREGISTER_CFM      dereg_cfm;
    tBTA_HL_CCH_OPEN_IND        cch_open_ind;
    tBTA_HL_CCH_OPEN_CFM        cch_open_cfm;
    tBTA_HL_CCH_CLOSE_IND       cch_close_ind;
    tBTA_HL_MCL_CFM             cch_close_cfm;
    tBTA_HL_DCH_CREATE_IND      dch_create_ind;
    tBTA_HL_DCH_OPEN_IND        dch_open_ind;
    tBTA_HL_DCH_OPEN_CFM        dch_open_cfm;
    tBTA_HL_DCH_CLOSE_IND       dch_close_ind;
    tBTA_HL_MDL_CFM             dch_close_cfm;
    tBTA_HL_DCH_OPEN_IND        dch_reconnect_ind;
    tBTA_HL_DCH_OPEN_CFM        dch_reconnect_cfm;
    tBTA_HL_MCL_IND             dch_abort_ind;
    tBTA_HL_MCL_CFM             dch_abort_cfm;
    tBTA_HL_DELETE_MDL_IND      delete_mdl_ind;
    tBTA_HL_DELETE_MDL_CFM      delete_mdl_cfm;
    tBTA_HL_MDL_CFM             dch_send_data_cfm;
    tBTA_HL_MDL_IND             dch_rcv_data_ind;
    tBTA_HL_DCH_CONG_IND        dch_cong_ind;
    tBTA_HL_MCL_CFM             echo_test_cfm;
    tBTA_HL_SDP_QUERY_CFM       sdp_query_cfm;
    tBTA_HL_SDP_INFO_IND        sdp_info_ind;

} tBTA_HL;

/* HL callback functions */
typedef void tBTA_HL_CTRL_CBACK(tBTA_HL_CTRL_EVT event, tBTA_HL_CTRL *p_data);
typedef void tBTA_HL_CBACK(tBTA_HL_EVT event, tBTA_HL *p_data);


/*****************************************************************************
**  External Function Declarations
*****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif

/**************************
**  API Functions
***************************/

/*******************************************************************************
**
** Function         BTA_HlEnable
**
** Description      Enable the HL subsystems.  This function must be
**                  called before any other functions in the HL API are called.
**                  When the enable operation is completed the callback function
**                  will be called with an BTA_HL_CTRL_ENABLE_CFM_EVT event.
**
** Parameters       p_cback - HL event call back function
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern void BTA_HlEnable(tBTA_HL_CTRL_CBACK *p_ctrl_cback);
/*******************************************************************************
**
** Function         BTA_HlDisable
**
** Description     Disable the HL subsystem.
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern void BTA_HlDisable(void);
/*******************************************************************************
**
** Function         BTA_HlRegister
**
** Description      Register a HDP application
**
**
** Parameters       app_id        - hdp application ID
**                  p_reg_param   - non-platform related parameters for the
**                                  HDP application
**                  p_cback       - HL event callback fucntion
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern void BTA_HlRegister(UINT8  app_id,
                                       tBTA_HL_REG_PARAM *p_reg_param,
                                       tBTA_HL_CBACK *p_cback);

/*******************************************************************************
**
** Function         BTA_HlDeregister
**
** Description      Deregister an HDP application
**
** Parameters       app_handle - Application handle
**
** Returns         void
**
*******************************************************************************/
    BTA_API extern void BTA_HlDeregister(tBTA_HL_APP_HANDLE app_handle);

/*******************************************************************************
**
** Function         BTA_HlCchOpen
**
** Description      Open a Control channel connection with the specified BD address
**                  and the control PSM value is used to select which
**                  HDP insatnce should be used in case the peer device support
**                  multiple HDP instances.
**
**
** Parameters       app_handle - Application Handle
**                  p_open_param - parameters for opening a control channel
**
** Returns          void
**
**                  Note: If the control PSM value is zero then the first HDP
**                        instance is used for the control channel setup
*******************************************************************************/
    BTA_API extern void BTA_HlCchOpen(tBTA_HL_APP_HANDLE app_handle,
                                      tBTA_HL_CCH_OPEN_PARAM *p_open_param);

/*******************************************************************************
**
** Function         BTA_HlCchClose
**
** Description      Close a Control channel connection with the specified MCL
**                  handle
**
** Parameters       mcl_handle - MCL handle
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern  void BTA_HlCchClose(tBTA_HL_MCL_HANDLE mcl_handle);

/*******************************************************************************
**
** Function         BTA_HlDchOpen
**
** Description      Open a data channel connection with the specified DCH parameters
**
** Parameters       mcl_handle - MCL handle
**                  p_open_param - parameters for opening a data channel
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern  void BTA_HlDchOpen(tBTA_HL_MCL_HANDLE mcl_handle,
                                       tBTA_HL_DCH_OPEN_PARAM *p_open_param);
/*******************************************************************************
**
** Function         BTA_HlDchReconnect
**
** Description      Reconnect a data channel with the specified MDL_ID
**
** Parameters       mcl_handle      - MCL handle
*8                  p_recon_param   - parameters for reconnecting a data channel
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern void BTA_HlDchReconnect(tBTA_HL_MCL_HANDLE mcl_handle,
                                            tBTA_HL_DCH_RECONNECT_PARAM *p_recon_param);
/*******************************************************************************
**
** Function         BTA_HlDchClose
**
** Description      Close a data channel with the specified MDL handle
**
** Parameters       mdl_handle  - MDL handle
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern void BTA_HlDchClose(tBTA_HL_MDL_HANDLE mdl_handle);

/*******************************************************************************
**
** Function         BTA_HlDchAbort
**
** Description      Abort the current data channel setup with the specified MCL
**                  handle
**
** Parameters       mcl_handle  - MCL handle
**
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern void BTA_HlDchAbort(tBTA_HL_MCL_HANDLE mcl_handle);

/*******************************************************************************
**
** Function         BTA_HlSendData
**
** Description      Send an APDU to the peer device
**
** Parameters       mdl_handle  - MDL handle
**                  pkt_size    - size of the data packet to be sent
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern void BTA_HlSendData(tBTA_HL_MDL_HANDLE mdl_handle,
                                       UINT16           pkt_size);

/*******************************************************************************
**
** Function         BTA_HlDeleteMdl
**
** Description      Delete the specified MDL_ID within the specified MCL handle
**
** Parameters       mcl_handle  - MCL handle
**                  mdl_id      - MDL ID
**
** Returns          void
**
**                  note: If mdl_id = 0xFFFF then this means to delete all MDLs
**                        and this value can only be used with DeleteMdl request only
**                        not other requests
**
*******************************************************************************/
    BTA_API extern void BTA_HlDeleteMdl(tBTA_HL_MCL_HANDLE mcl_handle,
                                        tBTA_HL_MDL_ID mdl_id );

/*******************************************************************************
**
** Function         BTA_HlDchEchoTest
**
** Description      Initiate an echo test with the specified MCL handle
**
** Parameters       mcl_handle           - MCL handle
*8                  p_echo_test_param   -  parameters for echo testing
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern void BTA_HlDchEchoTest( tBTA_HL_MCL_HANDLE  mcl_handle,
                                           tBTA_HL_DCH_ECHO_TEST_PARAM *p_echo_test_param);

/*******************************************************************************
**
** Function         BTA_HlSdpQuery
**
** Description      SDP query request for the specified BD address
**
** Parameters       app_handle      - application handle
**                  bd_addr         - BD address
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern  void BTA_HlSdpQuery(tBTA_HL_APP_HANDLE app_handle,
                                        BD_ADDR bd_addr);

/*******************************************************************************
**
** Function         BTA_HlDchCreateMdlRsp
**
** Description      Set the Response and configuration values for the Create MDL
**                  request
**
** Parameters       mcl_handle  - MCL handle
**                  p_rsp_param - parameters specified whether the request should
**                                be accepted or not and if it should be accepted
**                                then it also specified the configuration response
**                                value
**
** Returns          void
**
*******************************************************************************/
    BTA_API extern void BTA_HlDchCreateRsp(tBTA_HL_MCL_HANDLE mcl_handle,
                                           tBTA_HL_DCH_CREATE_RSP_PARAM *p_rsp_param);



#ifdef __cplusplus

}
#endif

#endif /* BTA_HL_API_H */