1 /****************************************************************************** 2 * 3 * Copyright 2004-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * This is the public interface file for the Personal Area Networking (PAN) 22 * subsystem of BTA, Broadcom's Bluetooth application layer for mobile 23 * phones. 24 * 25 ******************************************************************************/ 26 #ifndef BTA_PAN_API_H 27 #define BTA_PAN_API_H 28 29 #include <cstdint> 30 31 #include "types/raw_address.h" 32 33 /***************************************************************************** 34 * Constants and data types 35 ****************************************************************************/ 36 constexpr bool BTA_PAN_SUCCESS = true; 37 constexpr bool BTA_PAN_FAIL = false; 38 typedef bool tBTA_PAN_STATUS; 39 40 /* PAN Callback events */ 41 typedef enum : uint8_t { 42 BTA_PAN_ENABLE_EVT = 0, /* PAN service is enabled. */ 43 BTA_PAN_SET_ROLE_EVT = 1, /* PAN roles registered */ 44 BTA_PAN_OPENING_EVT = 2, /* Connection is being opened. */ 45 BTA_PAN_OPEN_EVT = 3, /* Connection has been opened. */ 46 BTA_PAN_CLOSE_EVT = 4, /* Connection has been closed. */ 47 } tBTA_PAN_EVT; 48 49 /* pan roles */ 50 #define BTA_PAN_ROLE_PANU PAN_ROLE_CLIENT 51 #define BTA_PAN_ROLE_NAP PAN_ROLE_NAP_SERVER 52 53 typedef uint8_t tBTA_PAN_ROLE; 54 55 /* information regarding PAN roles */ 56 struct tBTA_PAN_ROLE_INFO { 57 const std::string p_srv_name; /* service name for the PAN role */ 58 const uint8_t app_id; /* application id */ 59 }; 60 61 /* Event associated with BTA_PAN_SET_ROLE_EVT */ 62 typedef struct { 63 tBTA_PAN_STATUS status; /* status of set role event */ 64 tBTA_PAN_ROLE role; /* PAN roles successfully registered */ 65 } tBTA_PAN_SET_ROLE; 66 67 /* Event associated with BTA_PAN_OPENING_EVT */ 68 typedef struct { 69 RawAddress bd_addr; /* BD address of peer device. */ 70 uint16_t handle; /* Handle associated with this connection. */ 71 72 } tBTA_PAN_OPENING; 73 74 /* Event associated with BTA_PAN_OPEN_EVT */ 75 typedef struct { 76 RawAddress bd_addr; /* BD address of peer device. */ 77 uint16_t handle; /* Handle associated with this connection. */ 78 tBTA_PAN_STATUS status; /* status of open event */ 79 tBTA_PAN_ROLE local_role; /* Local device PAN role for the connection */ 80 tBTA_PAN_ROLE peer_role; /* Peer device PAN role for the connection */ 81 82 } tBTA_PAN_OPEN; 83 84 /* Event associated with BTA_PAN_CLOSE_EVT */ 85 typedef struct { 86 uint16_t handle; /* Handle associated with the connection. */ 87 } tBTA_PAN_CLOSE; 88 89 /* Union of all PAN callback structures */ 90 typedef union { 91 tBTA_PAN_SET_ROLE set_role; /* set_role event */ 92 tBTA_PAN_OPEN open; /* Connection has been opened. */ 93 tBTA_PAN_OPENING opening; /* Connection being opened */ 94 tBTA_PAN_CLOSE close; /* Connection has been closed. */ 95 } tBTA_PAN; 96 97 /* Number of PAN connections */ 98 #ifndef BTA_PAN_NUM_CONN 99 #define BTA_PAN_NUM_CONN 4 100 #endif 101 102 /* PAN callback */ 103 typedef void(tBTA_PAN_CBACK)(tBTA_PAN_EVT event, tBTA_PAN* p_data); 104 105 /***************************************************************************** 106 * External Function Declarations 107 ****************************************************************************/ 108 109 /******************************************************************************* 110 * 111 * Function BTA_PanEnable 112 * 113 * Description Enable PAN service. This function must be 114 * called before any other functions in the PAN API are called. 115 * When the enable operation is complete the callback function 116 * will be called with a BTA_PAN_ENABLE_EVT. 117 * 118 * Returns void 119 * 120 ******************************************************************************/ 121 void BTA_PanEnable(tBTA_PAN_CBACK p_cback); 122 123 /******************************************************************************* 124 * 125 * Function BTA_PanDisable 126 * 127 * Description Disable PAN service. 128 * 129 * Returns void 130 * 131 ******************************************************************************/ 132 void BTA_PanDisable(void); 133 134 /******************************************************************************* 135 * 136 * Function BTA_PanSetRole 137 * 138 * Description Sets PAN roles. When the enable operation is complete 139 * the callback function will be called with a 140 * BTA_PAN_SET_ROLE_EVT. 141 * 142 * Returns void 143 * 144 ******************************************************************************/ 145 void BTA_PanSetRole(tBTA_PAN_ROLE role, const tBTA_PAN_ROLE_INFO p_user_info, 146 const tBTA_PAN_ROLE_INFO p_nap_info); 147 148 /******************************************************************************* 149 * 150 * Function BTA_PanOpen 151 * 152 * Description Opens a connection to a peer device. 153 * When connection is open callback function is called 154 * with a BTA_PAN_OPEN_EVT. 155 * 156 * 157 * Returns void 158 * 159 ******************************************************************************/ 160 void BTA_PanOpen(const RawAddress& bd_addr, tBTA_PAN_ROLE local_role, 161 tBTA_PAN_ROLE peer_role); 162 163 /******************************************************************************* 164 * 165 * Function BTA_PanClose 166 * 167 * Description Close a PAN connection to a peer device. 168 * 169 * 170 * Returns void 171 * 172 ******************************************************************************/ 173 void BTA_PanClose(uint16_t handle); 174 175 #endif /* BTA_PAN_API_H */ 176