1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. * Description: BT PAN module. 14 */ 15 16 /** 17 * @defgroup bluetooth_bts_pan PAN API 18 * @ingroup bluetooth 19 * @{ 20 */ 21 #ifndef BTS_PAN_H 22 #define BTS_PAN_H 23 24 #include "bts_def.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /** 31 * @if Eng 32 * @brief Enum of pan net state. 33 * @else 34 * @brief Pan 网络状态 35 * @endif 36 */ 37 typedef enum { 38 PAN_NET_STATE_OFF, /*!< @if Eng Offline. @else 离线 @endif */ 39 PAN_NET_STATE_ON, /*!< @if Eng Online. @else 在线 @endif */ 40 } pan_net_state_t; 41 42 /** 43 * @if Eng 44 * @brief Open the pan service. 45 * @par Description: 46 * Open the pan service. 47 * @param [in] bd_addr A poniter of the peer bluetooth device addresss. See @ref bd_addr_t 48 * @retval #ERRCODE_BT_SUCCESS Success. 49 * @retval Other Failure. For details, see @ref errcode_bt_t 50 * @else 51 * @brief 打开pan服务 52 * @par 说明: 53 * 打开pan服务 54 * @param [in] bd_addr 对端蓝牙设备的地址信息。参考 @ref bd_addr_t 55 * @retval #ERRCODE_BT_SUCCESS 成功. 56 * @retval Other 失败. 参考 @ref errcode_bt_t 57 * @endif 58 * @par Dependency: 59 * @li pan_service.h 60 */ 61 int pan_service_open(const bd_addr_t *bd_addr); 62 63 /** 64 * @if Eng 65 * @brief Close the pan service. 66 * @par Description: 67 * Close the pan service. 68 * @param [in] bd_addr A poniter of the peer bluetooth device addresss. See @ref bd_addr_t 69 * @retval #ERRCODE_BT_SUCCESS Success. 70 * @retval Other Failure. For details, see @ref errcode_bt_t 71 * @else 72 * @brief 关闭PAN服务 73 * @par 说明: 74 * 关闭PAN服务 75 * @param [in] bd_addr 对端蓝牙设备的地址信息。参考 @ref bd_addr_t 76 * @retval #ERRCODE_BT_SUCCESS 成功. 77 * @retval Other 失败. 参考 @ref errcode_bt_t 78 * @endif 79 * @par Dependency: 80 * @li pan_service.h 81 */ 82 int pan_service_close(const bd_addr_t *bd_addr); 83 84 /** 85 * @if Eng 86 * @brief Send the ethernet. 87 * @par Description: 88 * Send the ethernet. 89 * @param [in] ip_packet A poniter of the ethernet data. 90 * @param [in] ip_length The length of the ethernet data. 91 * @retval #ERRCODE_BT_SUCCESS Success. 92 * @retval Other Failure. For details, see @ref errcode_bt_t 93 * @else 94 * @brief 发送网络数据包 95 * @par 说明: 96 * 发送网络数据包 97 * @param [in] ip_packet 网络数据包指针 98 * @param [in] ip_length 网络数据包长度 99 * @retval #ERRCODE_BT_SUCCESS 成功. 100 * @retval Other 失败. 参考 @ref errcode_bt_t 101 * @endif 102 * @par Dependency: 103 * @li pan_service.h 104 */ 105 int pan_service_write_data(const unsigned char *ip_packet, const unsigned short ip_length); 106 107 /** 108 * @if Eng 109 * @brief Get the net state. 110 * @par Description: 111 * Get the net state. 112 * @retval #PAN_NET_STATE_OFF offline 113 * @retval #PAN_NET_STATE_ON online 114 * @else 115 * @brief 获取网络连接状态 116 * @par 说明: 117 * 获取网络连接状态 118 * @retval #PAN_NET_STATE_OFF 离线 119 * @retval #PAN_NET_STATE_ON 在线 120 * @endif 121 * @par Dependency: 122 * @li pan_service.h 123 */ 124 unsigned char pan_service_net_state_get(void); 125 126 /** 127 * @if Eng 128 * @brief The call back of net state change. 129 * @par Description: 130 * The call back of net state change. 131 * @param [in] net_state See @ref pan_net_state_t 132 * @retval No return value. See @ref void 133 * @else 134 * @brief pan 网络连接状态通知 135 * @par 说明: 136 * 注册该回调函数之后,pan服务网络连接状态反馈上层应用。 137 * @param [in] net_state 参考 @ref pan_net_state_t 138 * @retval 无返回值。参考 @ref void 139 * @endif 140 * @par Dependency: 141 * @li pan_service.h 142 */ 143 typedef void (*pan_net_state_callback)(unsigned char net_state); 144 145 /** 146 * @if Eng 147 * @brief The call back of ethernet. 148 * @par Description:The call back of ethernet. 149 * @param [in] packet a pointer to net data. 150 * @param [in] packet_length the length of net data. 151 * @retval No return value. See @ref void 152 * @else 153 * @brief 读取网络数据包通知 154 * @par 说明:注册该回调函数之后,读取网络数据包结果反馈上层应用。 155 * @param [in] packet 指针,指向网络数据包所在内存地址. 156 * @param [in] packet_length 网络数据包长度. 157 * @retval 无返回值。参考 @ref void 158 * @endif 159 * @par Dependency: 160 * @li pan_service.h 161 */ 162 typedef void (*pan_rpt_data_callback)(unsigned char *packet, unsigned short packet_length); 163 164 /** 165 * @if Eng 166 * @brief Struct of pan callback function. 167 * @else 168 * @brief pan回调接口定义。 169 * @endif 170 */ 171 typedef struct { 172 pan_net_state_callback net_state_cb; 173 pan_rpt_data_callback rpt_data_cb; 174 } pan_callbacks_t; 175 176 /** 177 * @if Eng 178 * @brief Use this funtion to register callback function of framework. 179 * @par Description: 180 * Use this funtion to register callback function of framework. 181 * @param [in] func A poniter of the callback function. See @ref pan_callbacks_t 182 * @retval #ERRCODE_BT_SUCCESS Success. 183 * @retval Other Failure. For details, see @ref errcode_bt_t 184 * @else 185 * @brief 注册上层应用的回调。 186 * @par 说明: 187 * 注册上层应用的回调。 188 * @param [in] func 回调函数指针。参考 @ref pan_callbacks_t 189 * @retval #ERRCODE_BT_SUCCESS 成功。 190 * @retval Other 失败,参考 @ref errcode_bt_t 191 * @endif 192 * @par Dependency: 193 * @li pan_service.h 194 */ 195 int pan_register_callbacks(pan_callbacks_t *func); 196 197 /** 198 * @if Eng 199 * @brief Use this funtion to deregister callback function of framework. 200 * @par Description: 201 * Use this funtion to deregister callback function of framework. 202 * @param [in] func A poniter of the callback function. See @ref pan_callbacks_t 203 * @retval #ERRCODE_BT_SUCCESS Success. 204 * @retval Other Failure. For details, see @ref errcode_bt_t 205 * @else 206 * @brief 去注册上层应用的回调。 207 * @par 说明: 208 * 去注册上层应用的回调。 209 * @param [in] func 回调函数指针。参考 @ref pan_callbacks_t 210 * @retval #ERRCODE_BT_SUCCESS 成功。 211 * @retval Other 失败,参考 @ref errcode_bt_t 212 * @endif 213 * @par Dependency: 214 * @li bts_a2dp_source.h 215 */ 216 int pan_deregister_callbacks(void); 217 218 /** 219 * @} 220 */ 221 #ifdef __cplusplus 222 } 223 #endif 224 #endif /* end of bts_pan.h */