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