1 /* 2 * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved. 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. 14 */ 15 16 /** 17 * @file wm_bt_spp.h 18 * 19 * @brief Bluetooth API 20 * 21 * @author WinnerMicro 22 * 23 * Copyright (c) 2020 Winner Microelectronics Co., Ltd. 24 */ 25 26 #ifndef __WM_BT_SPP_H__ 27 #define __WM_BT_SPP_H__ 28 29 #include "wm_bt.h" 30 31 /** 32 * @defgroup BT_APIs Bluetooth APIs 33 * @brief Bluetooth related APIs 34 */ 35 36 /** 37 * @addtogroup BT_APIs 38 * @{ 39 */ 40 41 /** 42 * @defgroup BT_SPP_APIs 43 * @brief BT_SPP APIs 44 */ 45 46 /** 47 * @addtogroup BT_SPP_APIs 48 * @{ 49 */ 50 51 /**spp realed api*/ 52 /** 53 * @brief Initializes the SPP interface 54 * 55 * @param[in] callback pointer on callback function 56 * 57 * @retval @ref tls_bt_status_t 58 * 59 * @note None 60 */ 61 tls_bt_status_t tls_bt_spp_init(tls_bt_spp_callback_t callback); 62 63 /** 64 * @brief Shuts down the SPP interface and does the cleanup 65 * 66 * @param None 67 * 68 * @retval @ref tls_bt_status_t 69 * 70 * @note None 71 */ 72 tls_bt_status_t tls_bt_spp_deinit(void); 73 74 /** 75 * @brief Enable the bta jv interface 76 * 77 * @param[in] None 78 * 79 * @retval @ref tls_bt_status_t 80 * 81 * @note None 82 */ 83 tls_bt_status_t tls_bt_spp_enable(void); 84 85 /** 86 * @brief Disable the bta jv interface and cleanup internal resource 87 * 88 * @param[in] None 89 * 90 * @retval @ref tls_bt_status_t 91 * 92 * @note None 93 */ 94 95 tls_bt_status_t tls_bt_spp_disable(void); 96 97 /** 98 * @brief Discovery the spp service by the given peer device. 99 * 100 * @param[in] *bd_addr remote device bluetooth device address 101 * 102 * @retval @ref tls_bt_status_t 103 * 104 * @note None 105 */ 106 107 tls_bt_status_t tls_bt_spp_start_discovery(tls_bt_addr_t *bd_addr, tls_bt_uuid_t *uuid); 108 109 /** 110 * @brief Create a spp connection to the remote device 111 * 112 * @param[in] sec_mask: Security Setting Mask 113 * @param[in] role: Server or client 114 * @param[in] remote_scn: Remote device bluetooth device SCN 115 * @param[in] *bd_addr remote device bluetooth device address 116 * 117 * @retval @ref tls_bt_status_t 118 * 119 * @note None 120 */ 121 tls_bt_status_t tls_bt_spp_connect(wm_spp_sec_t sec_mask, 122 tls_spp_role_t role, uint8_t remote_scn, tls_bt_addr_t *bd_addr); 123 124 /** 125 * @brief Close a spp connection 126 * 127 * @param[in] handle: The connection handle 128 * 129 * @retval @ref tls_bt_status_t 130 * 131 * @note None 132 */ 133 tls_bt_status_t tls_bt_spp_disconnect(uint32_t handle); 134 135 /** 136 * @brief This function create a SPP server and starts listening for an 137 * SPP connection request from a remote Bluetooth device 138 * 139 * @param[in] sec_mask: Security Setting Mask . 140 * @param[in] role: Server or client. 141 * @param[in] local_scn: The specific channel you want to get. 142 * If channel is 0, means get any channel. 143 * @param[in] name: Server's name. 144 * 145 * @retval @ref tls_bt_status_t 146 147 */ 148 tls_bt_status_t tls_bt_spp_start_server(wm_spp_sec_t sec_mask, 149 tls_spp_role_t role, uint8_t local_scn, const char *name); 150 151 /** 152 * @brief This function is used to write data 153 * 154 * @param[in] handle: The connection handle. 155 * @param[in] len: The length of the data written. 156 * @param[in] p_data: The data written. 157 * 158 * @retval @ref tls_bt_status_t 159 160 */ 161 tls_bt_status_t tls_bt_spp_write(uint32_t handle, uint8_t *p_data, int length); 162 163 #endif 164 165