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, 42 bt_status_t error, 43 const RawAddress* bd_addr, 44 int local_role, 45 int remote_role); 46 typedef void (*btpan_control_state_callback)(btpan_control_state_t state, 47 int local_role, bt_status_t error, 48 const char* ifname); 49 50 typedef struct { 51 size_t size; 52 btpan_control_state_callback control_state_cb; 53 btpan_connection_state_callback connection_state_cb; 54 } btpan_callbacks_t; 55 typedef struct { 56 /** set to size of this struct*/ 57 size_t size; 58 /** 59 * Initialize the pan interface and register the btpan callbacks 60 */ 61 bt_status_t (*init)(const btpan_callbacks_t* callbacks); 62 /* 63 * enable the pan service by specified role. The result state of 64 * enabl will be returned by btpan_control_state_callback. when pan-nap is 65 * enabled, the state of connecting panu device will be notified by 66 * btpan_connection_state_callback 67 */ 68 bt_status_t (*enable)(int local_role); 69 /* 70 * get current pan local role 71 */ 72 int (*get_local_role)(void); 73 /** 74 * start bluetooth pan connection to the remote device by specified pan role. 75 * The result state will be returned by btpan_connection_state_callback 76 */ 77 bt_status_t (*connect)(const RawAddress* bd_addr, int local_role, 78 int remote_role); 79 /** 80 * stop bluetooth pan connection. The result state will be returned by 81 * btpan_connection_state_callback 82 */ 83 bt_status_t (*disconnect)(const RawAddress* bd_addr); 84 85 /** 86 * Cleanup the pan interface 87 */ 88 void (*cleanup)(void); 89 90 } btpan_interface_t; 91 92 __END_DECLS 93 94 #endif /* ANDROID_INCLUDE_BT_PAN_H */ 95