resolved the code rule warnings
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / hardware / bt_hl.h
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef ANDROID_INCLUDE_BT_HL_H
18 #define ANDROID_INCLUDE_BT_HL_H
19
20 __BEGIN_DECLS
21
22 /* HL connection states */
23
24 typedef enum {
25         BTHL_MDEP_ROLE_SOURCE,
26         BTHL_MDEP_ROLE_SINK
27 } bthl_mdep_role_t;
28
29 typedef enum {
30         BTHL_APP_REG_STATE_REG_SUCCESS,
31         BTHL_APP_REG_STATE_REG_FAILED,
32         BTHL_APP_REG_STATE_DEREG_SUCCESS,
33         BTHL_APP_REG_STATE_DEREG_FAILED
34 } bthl_app_reg_state_t;
35
36 typedef enum {
37         BTHL_CHANNEL_TYPE_RELIABLE,
38         BTHL_CHANNEL_TYPE_STREAMING,
39         BTHL_CHANNEL_TYPE_ANY
40 } bthl_channel_type_t;
41
42
43 /* HL connection states */
44 typedef enum {
45         BTHL_CONN_STATE_CONNECTING,
46         BTHL_CONN_STATE_CONNECTED,
47         BTHL_CONN_STATE_DISCONNECTING,
48         BTHL_CONN_STATE_DISCONNECTED,
49         BTHL_CONN_STATE_DESTROYED
50 } bthl_channel_state_t;
51
52 typedef struct {
53         bthl_mdep_role_t        mdep_role;
54         int                     data_type;
55         bthl_channel_type_t     channel_type;
56         const char                   *mdep_description; /* MDEP description to be used in the SDP (optional); null terminated */
57 } bthl_mdep_cfg_t;
58
59 typedef struct {
60         const char      *application_name;
61         const char      *provider_name;   /* provider name to be used in the SDP (optional); null terminated */
62         const char      *srv_name;        /* service name to be used in the SDP (optional); null terminated*/
63         const char      *srv_desp;        /* service description to be used in the SDP (optional); null terminated */
64         int             number_of_mdeps;
65         bthl_mdep_cfg_t *mdep_cfg;  /* Dynamic array */
66 } bthl_reg_param_t;
67
68 /** Callback for application registration status.
69  *  state will have one of the values from  bthl_app_reg_state_t
70  */
71 typedef void (*bthl_app_reg_state_callback)(int app_id, bthl_app_reg_state_t state);
72
73 /** Callback for channel connection state change.
74  *  state will have one of the values from
75  *  bthl_connection_state_t and fd (file descriptor)
76  */
77 typedef void (*bthl_channel_state_callback)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int channel_id, bthl_channel_state_t state, int fd);
78
79 /** BT-HL callback structure. */
80 typedef struct {
81         /** set to sizeof(bthl_callbacks_t) */
82         size_t      size;
83         bthl_app_reg_state_callback     app_reg_state_cb;
84         bthl_channel_state_callback     channel_state_cb;
85 } bthl_callbacks_t;
86
87
88 /** Represents the standard BT-HL interface. */
89 typedef struct {
90
91         /** set to sizeof(bthl_interface_t)  */
92         size_t          size;
93
94         /**
95          * Register the Bthl callbacks
96          */
97         bt_status_t (*init)(bthl_callbacks_t* callbacks);
98
99         /** Register HL application */
100         bt_status_t (*register_application) (bthl_reg_param_t *p_reg_param, int *app_id);
101
102         /** Unregister HL application */
103         bt_status_t (*unregister_application) (int app_id);
104
105         /** connect channel */
106         bt_status_t (*connect_channel)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int *channel_id);
107
108         /** destroy channel */
109         bt_status_t (*destroy_channel)(int channel_id);
110
111         /** Close the  Bthl callback **/
112         void (*cleanup)(void);
113
114 } bthl_interface_t;
115 __END_DECLS
116
117 #endif /* ANDROID_INCLUDE_BT_HL_H */