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. 14 * Description: wifi_p2p.h 的头文件 15 */ 16 17 18 #ifndef SERVICE_WIFI_P2P_H 19 #define SERVICE_WIFI_P2P_H 20 #include "errcode.h" 21 #include "wifi_p2p_config.h" 22 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif 28 29 /** 30 * @defgroup middleware_service_wifi_p2p Wifi P2P 31 * @ingroup middleware_service_wifi 32 * @{ 33 */ 34 35 36 /** 37 * @if Eng 38 * @brief Start P2P interface. 39 * @retval ERRCODE_SUCC Execute successfully. 40 * @retval Other Execute failed. 41 * @else 42 * @brief P2P开启。 43 * @retval ERRCODE_SUCC 成功。 44 * @retval Other 失败。 45 * @endif 46 */ 47 errcode_t wifi_p2p_enable(void); 48 49 /** 50 * @if Eng 51 * @brief Close wifi p2p. 52 * @retval ERRCODE_SUCC Execute successfully. 53 * @retval Other Execute failed. 54 * @else 55 * @brief P2P关闭。 56 * @retval ERRCODE_SUCC 成功。 57 * @retval Other 失败。 58 * @endif 59 */ 60 errcode_t wifi_p2p_disable(void); 61 62 /** 63 * @if Eng 64 * @brief Get P2P enable status. 65 * @retval 1 P2P is initialized. 66 * @retval 0 P2P is not initialized. 67 * @else 68 * @brief 获取P2P使能状态。 69 * @retval 1 P2P已经初始化。 70 * @retval 0 P2P未初始化。 71 * @endif 72 */ 73 int32_t wifi_p2p_is_enabled(void); 74 75 /** 76 * @if Eng 77 * @brief Trigger P2P device scanning and search. 78 * @param [in] sec Scan time. 79 * @retval ERRCODE_SUCC Execute successfully. 80 * @retval Other Execute failed. 81 * @else 82 * @brief 触发p2p设备扫描搜索。 83 * @param [in] sec 表示扫描时间。 84 * @retval ERRCODE_SUCC 成功。 85 * @retval Other 失败。 86 * @endif 87 */ 88 errcode_t wifi_p2p_find(int32_t sec); 89 90 /** 91 * @if Eng 92 * @brief Stopping P2P Device Scanning. 93 * @retval ERRCODE_SUCC Execute successfully. 94 * @retval Other Execute failed. 95 * @else 96 * @brief 停止p2p设备扫描。 97 * @retval ERRCODE_SUCC 成功。 98 * @retval Other 失败。 99 * @endif 100 */ 101 errcode_t wifi_p2p_stop_find(void); 102 103 /** 104 * @if Eng 105 * @brief Stopping P2P Device Connecting. 106 * @retval ERRCODE_SUCC Execute successfully. 107 * @retval Other Execute failed. 108 * @else 109 * @brief 停止p2p设备连接。 110 * @retval ERRCODE_SUCC 成功。 111 * @retval Other 失败。 112 * @endif 113 */ 114 errcode_t wifi_p2p_connect_cancel(void); 115 116 /** 117 * @if Eng 118 * @brief Setting P2P Device listening time. 119 * @param [in] period Listen time. 120 * @param [in] interval Total time. 121 * @retval WIFI_SUCCESS Execute successfully. 122 * @retval Other Execute failed. 123 * @else 124 * @brief 停止p2p设备连接。 125 * @param [in] period 表示监听的时间。 126 * @param [in] interval 表示一个周期的总时间。 127 * @retval WIFI_SUCCESS 成功。 128 * @retval Other 失败。 129 * @endif 130 */ 131 errcode_t wifi_p2p_listen(uint32_t period, uint32_t interval); 132 133 /** 134 * @if Eng 135 * @brief Obtains the information about the discovered P2P device. 136 * @param [out] dev_list List of found P2P devices. 137 * @param [out] dev_num Maximum number of P2P devices with feedback and actual feedback. 138 * @retval ERRCODE_SUCC Execute successfully. 139 * @retval Other Execute failed. 140 * @else 141 * @brief 获取搜索到的p2p设备信息。 142 * @param [out] dev_list 表示搜索到的p2p设备列表。 143 * @param [out] dev_num 表示最大反馈与实际反馈的p2p设备数目。 144 * @retval ERRCODE_SUCC 成功。 145 * @retval Other 失败。 146 * @endif 147 */ 148 errcode_t wifi_p2p_get_peers_info(p2p_device_stru *dev_list, uint32_t *dev_num); 149 150 /** 151 * @if Eng 152 * @brief P2P active connection. 153 * @param [in] p2p_config Network information of the P2P device to be connected. 154 * @retval ERRCODE_SUCC Execute successfully. 155 * @retval Other Execute failed. 156 * @else 157 * @brief p2p主动连接。 158 * @param [in] p2p_config 待连接的p2p设备网络信息。 159 * @retval ERRCODE_SUCC 成功。 160 * @retval Other 失败。 161 * @endif 162 */ 163 errcode_t wifi_p2p_connect(const p2p_config_stru *p2p_config); 164 165 /** 166 * @if Eng 167 * @brief Indicates whether the P2P accepts the connection from the peer end. 168 * @param [in] p2p_config Network information of the P2P device to be connected. 169 * @param [in] assoc The value 0 indicates that the connection is rejected,1 indicates accepts. 170 * @retval ERRCODE_SUCC Execute successfully. 171 * @retval Other Execute failed. 172 * @else 173 * @brief p2p是否接受对端的连接。 174 * @param [in] p2p_config 表示待连接的p2p设备网络信息。 175 * @param [in] assoc 1表示接收连接;0表示拒绝连接。 176 * @retval ERRCODE_SUCC 成功。 177 * @retval Other 失败。 178 * @endif 179 */ 180 errcode_t wifi_p2p_connect_accept(const p2p_config_stru *p2p_config, int assoc); 181 182 /** 183 * @if Eng 184 * @brief P2P disconnection. 185 * @retval ERRCODE_SUCC Execute successfully. 186 * @retval Other Execute failed. 187 * @else 188 * @brief p2p断连。 189 * @retval ERRCODE_SUCC 成功。 190 * @retval Other 失败。 191 * @endif 192 */ 193 errcode_t wifi_p2p_disconnect(void); 194 195 /** 196 * @if Eng 197 * @brief The P2P go command is used to obtain information about connected clients. 198 * @param [in] client_list Gc information list. 199 * @param [in] client_num Indicates the maximum number of feedback GCs and the actual number of feedback GCs. 200 * @retval ERRCODE_SUCC Execute successfully. 201 * @retval Other Execute failed. 202 * @else 203 * @brief p2p go获取已连接的client的信息。 204 * @param [in] client_list 表示反馈的gc信息列表。 205 * @param [in] client_num 指示反馈gc的最大个数,指示实际反馈gc的个数。 206 * @retval ERRCODE_SUCC 成功。 207 * @retval Other 失败。 208 * @endif 209 */ 210 errcode_t wifi_p2p_go_get_gc_info(p2p_client_info_stru *client_list, uint32_t *client_num); 211 212 /** 213 * @if Eng 214 * @brief Setting P2P Device Information. 215 * @param [in] p2p_dev_set_info P2P setting information. 216 * @retval ERRCODE_SUCC Execute successfully. 217 * @retval Other Execute failed. 218 * @else 219 * @brief 设置p2p设备信息。 220 * @param [in] p2p_dev_set_info 表示p2p设置信息。 221 * @retval ERRCODE_SUCC 成功。 222 * @retval Other 失败。 223 * @endif 224 */ 225 errcode_t wifi_p2p_set_device_config(const p2p_device_config_stru *p2p_dev_set_info); 226 227 /** 228 * @if Eng 229 * @brief Obtaining P2P Device Information. 230 * @param [in] p2p_dev_set_info P2P setting information. 231 * @retval ERRCODE_SUCC Execute successfully. 232 * @retval Other Execute failed. 233 * @else 234 * @brief 获取p2p设备信息。 235 * @param [in] p2p_dev_set_info 表示p2p设置信息。 236 * @retval ERRCODE_SUCC 成功。 237 * @retval Other 失败。 238 * @endif 239 */ 240 errcode_t wifi_p2p_get_device_config(p2p_device_config_stru *p2p_dev_set_info); 241 242 /** 243 * @if Eng 244 * @brief Displays the P2P connection status. 245 * @param [in] status P2P connection status information to be fed back. 246 * @retval ERRCODE_SUCC Execute successfully. 247 * @retval Other Execute failed. 248 * @else 249 * @brief 显示p2p的连接状态信息。 250 * @param [in] status 表示待反馈的p2p的连接状态信息。 251 * @retval ERRCODE_SUCC 成功。 252 * @retval Other 失败。 253 * @endif 254 */ 255 errcode_t wifi_p2p_get_connect_info(p2p_status_info_stru *status); 256 257 /** 258 * @} 259 */ 260 261 #ifdef __cplusplus 262 #if __cplusplus 263 } 264 #endif 265 #endif 266 267 #endif // SERVICE_WIFI_P2P_H 268