Imported Upstream version 4.2.2-2
[deb_android-headers.git] / hardware / bt_pan.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_PAN_H
18 #define ANDROID_INCLUDE_BT_PAN_H
19
20 __BEGIN_DECLS
21
22 #define BTPAN_ROLE_NONE 0
23 #define BTPAN_ROLE_PANNAP 1
24 #define BTPAN_ROLE_PANU 2
25
26 typedef enum {
27 BTPAN_STATE_CONNECTED = 0,
28 BTPAN_STATE_CONNECTING = 1,
29 BTPAN_STATE_DISCONNECTED = 2,
30 BTPAN_STATE_DISCONNECTING = 3
31 } btpan_connection_state_t;
32
33 typedef enum {
34 BTPAN_STATE_ENABLED = 0,
35 BTPAN_STATE_DISABLED = 1
36 } btpan_control_state_t;
37
38 /**
39 * Callback for pan connection state
40 */
41 typedef void (*btpan_connection_state_callback)(btpan_connection_state_t state, bt_status_t error,
42 const bt_bdaddr_t *bd_addr, int local_role, int remote_role);
43 typedef void (*btpan_control_state_callback)(btpan_control_state_t state, bt_status_t error,
44 int local_role, const char* ifname);
45
46 typedef struct {
47 size_t size;
48 btpan_control_state_callback control_state_cb;
49 btpan_connection_state_callback connection_state_cb;
50 } btpan_callbacks_t;
51 typedef struct {
52 /** set to size of this struct*/
53 size_t size;
54 /**
55 * Initialize the pan interface and register the btpan callbacks
56 */
57 bt_status_t (*init)(const btpan_callbacks_t* callbacks);
58 /*
59 * enable the pan service by specified role. The result state of
60 * enabl will be returned by btpan_control_state_callback. when pan-nap is enabled,
61 * the state of connecting panu device will be notified by btpan_connection_state_callback
62 */
63 bt_status_t (*enable)(int local_role);
64 /*
65 * get current pan local role
66 */
67 int (*get_local_role)(void);
68 /**
69 * start bluetooth pan connection to the remote device by specified pan role. The result state will be
70 * returned by btpan_connection_state_callback
71 */
72 bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, int local_role, int remote_role);
73 /**
74 * stop bluetooth pan connection. The result state will be returned by btpan_connection_state_callback
75 */
76 bt_status_t (*disconnect)(const bt_bdaddr_t *bd_addr);
77
78 /**
79 * Cleanup the pan interface
80 */
81 void (*cleanup)(void);
82
83 } btpan_interface_t;
84
85 __END_DECLS
86
87 #endif /* ANDROID_INCLUDE_BT_PAN_H */