zw.wang | 0047780 | 2025-06-12 19:48:37 +0800 | [diff] [blame] | 1 | /** |
| 2 | * @file : gsw_wifi_interface_sdk.h |
| 3 | * @brief : wifi abstract_sdk |
| 4 | * @date : 2022-08-14 |
| 5 | * @author : zhaohua |
| 6 | * @version : v1.0 |
| 7 | * @copyright Copyright (c) 2022 www.gosuncn.com |
| 8 | */ |
| 9 | #ifndef __GSW_WIFI_INTERFACE_SDK_H__ |
| 10 | #define __GSW_WIFI_INTERFACE_SDK_H__ |
| 11 | |
| 12 | #include "gsw_hal_errcode.h" |
| 13 | |
| 14 | #define GSW_WIFI_AP_DEVICE_NUM 8 /**< ap device max num */ |
| 15 | #define GSW_WIFI_STA_REMEMBER_HOST_NUM 50 /**< sta save ap max num */ |
| 16 | #define GSW_WIFI_STA_SCANLIST_NUM 100 /**< sta scan list max num */ |
| 17 | |
| 18 | /** |
| 19 | * @brief ap callback event type |
| 20 | */ |
| 21 | typedef enum { |
| 22 | GSW_WIFI_STATUS_DISCONNECT = 0, /**< sta disconnect */ |
| 23 | GSW_WIFI_STATUS_CONNECT, /**< sta connect */ |
| 24 | } gsw_wifi_ap_status_e; |
| 25 | |
| 26 | /** |
| 27 | * @brief sta callback event type |
| 28 | */ |
| 29 | typedef enum { |
| 30 | GSW_WIFI_STA_STATUS_DISCONNECT = 0, /**< sta disconnect */ |
| 31 | GSW_WIFI_STA_STATUS_CONNECT, /**< sta connect */ |
| 32 | GSW_WIFI_STA_STATUS_SCAN_RESULT, /**< sta scan finish */ |
| 33 | } gsw_wifi_sta_status_e; |
| 34 | |
| 35 | /** |
| 36 | * @brief wifi ability type |
| 37 | */ |
| 38 | typedef enum { |
| 39 | WIFI_MODE_ABILITY_NOWLAN = 1, /**< no wlan */ |
| 40 | WIFI_MODE_ABILITY_STA_ONLY = 2, /**< sta only */ |
| 41 | WIFI_MODE_ABILITY_AP_ONLY = 3, /**< ap only */ |
| 42 | WIFI_MODE_ABILITY_APANDSTA = 4, /**< ap and sta */ |
| 43 | } wifi_mode_ability_e; |
| 44 | |
| 45 | /** |
| 46 | * @brief ap bandwidth type |
| 47 | */ |
| 48 | typedef enum { |
| 49 | GSW_WIFI_BANDWIDTH_HT10 = 0, /**< 10Mhz */ |
| 50 | GSW_WIFI_BANDWIDTH_HT20, /**< 20Mhz */ |
| 51 | GSW_WIFI_BANDWIDTH_HT40, /**< 40Mhz */ |
| 52 | GSW_WIFI_BANDWIDTH_HT80, /**< 80Mhz */ |
| 53 | } gsw_wifi_bandwidth_type_e; |
| 54 | |
| 55 | /** |
| 56 | * @brief authentication type |
| 57 | */ |
| 58 | typedef enum { |
| 59 | GSW_WIFI_AUTH_OPEN = 0, /**< OPEN */ |
| 60 | GSW_WIFI_AUTH_WEP, /**< WEP */ |
| 61 | GSW_WIFI_AUTH_WPA_PSK, /**< WPA_PSK */ |
| 62 | GSW_WIFI_AUTH_WPA2_PSK, /**< WPA2_PSK */ |
| 63 | GSW_WIFI_AUTH_WPA3_PSK, /**< WPA3_PSK */ |
| 64 | } gsw_wifi_auth_e; |
| 65 | |
| 66 | /** |
| 67 | * @brief ap state |
| 68 | */ |
| 69 | typedef enum { |
| 70 | GSW_WIFI_AP_STATUS_DISABLE = 0, /**< not running */ |
| 71 | GSW_WIFI_AP_STATUS_ENABLE, /**< running */ |
| 72 | } gsw_wifi_ap_run_status_e; |
| 73 | |
| 74 | /** |
| 75 | * @brief sta state |
| 76 | */ |
| 77 | typedef enum { |
| 78 | GSW_WIFI_STA_STATUS_DISABLE = 0, /**< not running */ |
| 79 | GSW_WIFI_STA_STATUS_ENABLE, /**< running */ |
| 80 | } gsw_wifi_sta_run_status_e; |
| 81 | |
| 82 | /** |
| 83 | * @brief wifi interface idx |
| 84 | */ |
| 85 | typedef enum { |
| 86 | GSW_WIFI_INTERFACE_0 = 0, /**< STA */ |
| 87 | GSW_WIFI_INTERFACE_1, /**< AP */ |
| 88 | }gsw_wifi_index_e; |
| 89 | |
| 90 | /** |
| 91 | * @brief band type |
| 92 | */ |
| 93 | typedef enum { |
| 94 | GSW_WIFI_2G_band = 1, /**< 2.4G */ |
| 95 | GSW_WIFI_5G_band, /**< 5G */ |
| 96 | GSW_WIFI_2_and_5G_band, /**< 2.4G and 5G */ |
| 97 | } gsw_wifi_band_e; |
| 98 | |
| 99 | /** |
| 100 | * @brief sta mode dns info |
| 101 | */ |
| 102 | typedef struct gsw_sta_dns_info |
| 103 | { |
| 104 | char dnsp[46]; //Primary DNS server address |
| 105 | char dnss[46]; //Secondary DNS server address |
| 106 | } gsw_sta_dns_info_s; |
| 107 | |
| 108 | /** |
| 109 | * @brief ap info |
| 110 | */ |
| 111 | typedef struct gsw_ap_info |
| 112 | { |
| 113 | char ap_ip[32]; /**< IP Addr */ |
| 114 | char ap_mac[32]; /**< IP Addr */ |
| 115 | char ap_ssid[32]; /**< ssid */ |
| 116 | char psw[64]; /**< password */ |
| 117 | gsw_wifi_auth_e auth; /**< authentication */ |
| 118 | gsw_wifi_band_e band; /**< band */ |
| 119 | } gsw_ap_info_s; |
| 120 | |
| 121 | typedef struct gsw_ap_detail_info |
| 122 | { |
| 123 | struct gsw_ap_info base_info; /**< ap info */ |
| 124 | gsw_wifi_ap_run_status_e status; /**< ap run state */ |
| 125 | int rssi; /**< rssi[0~199] */ |
| 126 | } gsw_ap_detail_info_s; |
| 127 | |
| 128 | /** |
| 129 | * @brief device info |
| 130 | */ |
| 131 | typedef struct gsw_device_info |
| 132 | { |
| 133 | char sta_ip[32]; /**< IP Addr */ |
| 134 | char sta_mac[32]; /**< IP Addr */ |
| 135 | char hostname[32]; /**< device name */ |
| 136 | gsw_wifi_ap_status_e status; /**< connect state */ |
| 137 | } gsw_device_info_s; |
| 138 | |
| 139 | typedef struct gsw_saved_ap_info |
| 140 | { |
| 141 | struct gsw_ap_info base_info; |
| 142 | } gsw_saved_ap_info_s; |
| 143 | |
| 144 | /** |
| 145 | * @brief error code of sta connect fail |
| 146 | * current only support errcode 1,2 |
| 147 | */ |
| 148 | typedef enum |
| 149 | { |
| 150 | GSW_REASON_IP_NOT_ACCESS = 0, /**< IP connect not access */ |
| 151 | GSW_REASON_UNSPECIFIED = 1, /**< Unspecified reason */ |
| 152 | GSW_REASON_PREV_AUTH_NOT_VALID = 2, /**< Previous authentication no longer valid */ |
| 153 | GSW_REASON_DEAUTH_LEAVING = 3, /**< Deauthenticated because sending STA is leaving (or has left) IBSS or ESS */ |
| 154 | GSW_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, /**< Disassociated due to inactivity */ |
| 155 | GSW_REASON_DISASSOC_AP_BUSY = 5, /**< Disassociated because AP is unable to handle all currently associated STA */ |
| 156 | GSW_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, /**< Class 2 frame received from nonauthenticated STA */ |
| 157 | GSW_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, /**< Class 3 frame received from nonassociated STA */ |
| 158 | GSW_REASON_DISASSOC_STA_HAS_LEFT = 8, /**< Disassociated because sending STA is leaving (or has left) BSS */ |
| 159 | GSW_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, /**< STA requesting (re)association is not authenticated with responding STA */ |
| 160 | GSW_REASON_PWR_CAPABILITY_NOT_VALID = 10, /**< Disassociated because the information in the Power Capability element is unacceptable */ |
| 161 | GSW_REASON_SUPPORTED_CHANNEL_NOT_VALID = 11, /**< Disassociated because the information in the Supported Channels is unacceptable */ |
| 162 | GSW_REASON_BSS_TRANSITION_DISASSOC = 12, /**< Disassociated due to BSS Transition Management */ |
| 163 | GSW_REASON_INVALID_IE = 13, /**< Invalid element, i.e., an element defined in this standard for which the content |
| 164 | does not meet the specifications in Clause 8 */ |
| 165 | GSW_REASON_MICHAEL_MIC_FAILURE = 14, /**< Message integrity code (MIC) failure */ |
| 166 | GSW_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, /**< 4-Way Handshake timeout */ |
| 167 | GSW_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, /**< Group Key Handshake timeout */ |
| 168 | GSW_REASON_IE_IN_4WAY_DIFFERS = 17, /**< Element in 4-Way handshake different from (Re)Association |
| 169 | Request/Probe Response/Beacon frame */ |
| 170 | GSW_REASON_GROUP_CIPHER_NOT_VALID = 18, /**< Invalid group cipher */ |
| 171 | GSW_REASON_PAIRWISE_CIPHER_NOT_VALID = 19, /**< Invalid pairwise cipher */ |
| 172 | GSW_REASON_AKMP_NOT_VALID = 20, /**< Invalid AKMP */ |
| 173 | GSW_REASON_UNSUPPORTED_RSN_IE_VERSION = 21, /**< Unsupproted RSNE version */ |
| 174 | GSW_REASON_INVALID_RSN_IE_CAPAB = 22, /**< Invalid RSNE capabilities */ |
| 175 | GSW_REASON_IEEE_802_1X_AUTH_FAILED = 23, /**< IEEE 802.1X authentication failed */ |
| 176 | GSW_REASON_CIPHER_SUITE_REJECTED = 24, /**< Cipher suite rejected because of the security policy */ |
| 177 | GSW_REASON_TDLS_TEARDOWN_UNREACHABLE = 25, /**< TDLS direct-link teardown due to TDLS peer STA unreachable via the TDLS direct link */ |
| 178 | GSW_REASON_TDLS_TEARDOWN_UNSPECIFIED = 26, /**< TDLS direct-link teardown for unspecified reason */ |
| 179 | GSW_REASON_SSP_REQUESTED_DISASSOC = 27, /**< Disassocited because session terminated by SSP request */ |
| 180 | GSW_REASON_NO_SSP_ROAMING_AGREEMENT = 28, /**< Disassocited because of lack of SSP roaming agreement */ |
| 181 | GSW_REASON_BAD_CIPHER_OR_AKM = 29, /**< Requested service rejected because of SSP cipher suite or AKM requirment */ |
| 182 | GSW_REASON_NOT_AUTHORIZED_THIS_LOCATION = 30, /**< requested service not authorized in this location */ |
| 183 | GSW_REASON_SERVICE_CHANGE_PRECLUDES_TS = 31, /**< TS deleted because QoS AP lacks sufficient bandwidth for |
| 184 | this QoS STA due to a change in BSS service characteristics or operational mode |
| 185 | (e.g., an HT BSS change from 40 MHz channel to 20 MHz channel) */ |
| 186 | GSW_REASON_UNSPECIFIED_QOS_REASON = 32, /**< Disassocited for unspecified QoS-related reason */ |
| 187 | GSW_REASON_NOT_ENOUGH_BANDWIDTH = 33, /**< Disassocited because QoS AP lacks sufficient bandwidth for this QoS STA */ |
| 188 | GSW_REASON_DISASSOC_LOW_ACK = 34, /**< Disassociated because excessive number of frames need to be acknowledged, |
| 189 | but are not acknowledged due to AP transmissions and/or poor channel conditions */ |
| 190 | GSW_REASON_EXCEEDED_TXOP = 35, /**< Disassociated because STA is transmitting outside the limits of its TXOPs */ |
| 191 | GSW_REASON_STA_LEAVING = 36, /**< Requested from peer STA as the STA is leaving the BSS (or resetting) */ |
| 192 | GSW_REASON_END_TS_BA_DLS = 37, /**< Requested from peer STA as it does not want to use the mechanism */ |
| 193 | GSW_REASON_UNKNOWN_TS_BA = 38, /**< Requested from peer STA as the STA received frames using |
| 194 | the mechanism for which a setup is required */ |
| 195 | GSW_REASON_TIMEOUT = 39, /**< Requested from peer STA due to timeout */ |
| 196 | GSW_REASON_PEERKEY_MISMATCH = 45, /**< Peer STA does not support the requested cipher suite */ |
| 197 | GSW_REASON_AUTHORIZED_ACCESS_LIMIT_REACHED = 46, /**< In a DLS Teardown frame: The teardown was initiated by the DLS peer in |
| 198 | a disassociation frame: disassociated because authorized access limit reached*/ |
| 199 | GSW_REASON_EXTERNAL_SERVICE_REQUIREMENTS = 47, /**< In a DLS Teardown frame: The teardown was initiated by the AP |
| 200 | In a disassociation frame: disassociated due to external service requirments */ |
| 201 | GSW_REASON_INVALID_FT_ACTION_FRAME_COUNT = 48, /**< Invalid FT action frame count */ |
| 202 | GSW_REASON_INVALID_PMKID = 49, /**< Invalid pairwise master key identifier (PMKI) */ |
| 203 | GSW_REASON_INVALID_MDE = 50, /**< Invalid MDE */ |
| 204 | GSW_REASON_INVALID_FTE = 51, /**< Invalid FTE */ |
| 205 | GSW_REASON_MESH_PEERING_CANCELLED = 52, /**< SME cancels the mesh peering instance with the reason |
| 206 | other than reaching the maximum number of peer mesh STAs */ |
| 207 | GSW_REASON_MESH_MAX_PEERS = 53, /**< The mesh STA has reached the supported maximum number of peer mesh STAs */ |
| 208 | GSW_REASON_MESH_CONFIG_POLICY_VIOLATION = 54, /**< The received information violates the Mesh Configuration policy configured in the mesh STA profile */ |
| 209 | GSW_REASON_MESH_CLOSE_RCVD = 55, /**< The mesh STA has received a Mesh Peering Close message requesting to close the mesh peering*/ |
| 210 | GSW_REASON_MESH_MAX_RETRIES = 56, /**< the mesh STA has resent dot11MeshMaxRetries Mesh Peering Open messages |
| 211 | without receiveing a Mesh Peering Confirm messa*/ |
| 212 | GSW_REASON_MESH_CONFIRM_TIMEOU = 57, /**< The confirm Timer for the mesh peering instance times out */ |
| 213 | GSW_REASON_MESH_INVALID_GTK = 58, /**< The mesh STA fails to unwrap the GTK or the values in the wrapped contents do not match */ |
| 214 | GSW_REASON_MESH_INCONSISTENT_PARAMS = 59, /**< The mesh STA receives inconsistent information about the mesh parameters |
| 215 | between mesh peering management frames */ |
| 216 | GSW_REASON_MESH_INVALID_SECURITY_CAP = 60, /**< The mesh STA fails the authenticated mesh peering exchange because due to failure |
| 217 | in selecting either in the pairwise ciphersuite or group ciphersuite*/ |
| 218 | GSW_REASON_MESH_PATH_ERROR_NO_PROXY_INFO = 61, /**< The mesh STA does not have proxy information for this external destination */ |
| 219 | GSW_REASON_MESH_PATH_ERROR_NO_FORWARDING_INFO = 62, /**< The mesh STA does not have forwarding infromation for this destination */ |
| 220 | GSW_REASON_MESH_PATH_ERROR_DEST_UNREACHABLE = 63, /**< The mesh STA determines that the link to the next hop of an active path in |
| 221 | its forwarding information is no longer usable */ |
| 222 | GSW_REASON_MAC_ADDRESS_ALREADY_EXISTS_IN_MBSS = 64, /**< The deauthentication frame was sent because the MAC address |
| 223 | of the STA already exists in the mesh BSS.Scc10.3.6 */ |
| 224 | GSW_REASON_MESH_CHANNEL_SWITCH_REGULATORY_REQ = 65, /**< The mesh STA performs channel switch to meet regulatory requirments */ |
| 225 | GSW_REASON_MESH_CHANNEL_SWITCH_UNSPECIFIED = 66, /**< The mesh STA performs channel switch with unspecified reason */ |
| 226 | GSW_REASON_LOW_SECURITY = 67, /**< Low level of network security */ |
| 227 | } error_number_e; |
| 228 | |
| 229 | typedef struct gsw_scan_info |
| 230 | { |
| 231 | char mac[32]; /**< MAC addr */ |
| 232 | char ssid[33]; /**< ssid */ |
| 233 | gsw_wifi_band_e band; /**< band */ |
| 234 | gsw_wifi_auth_e auth; /**< authentication */ |
| 235 | int rssi; /**< rssi */ |
| 236 | } gsw_scan_info_s; |
| 237 | |
| 238 | |
| 239 | /** |
| 240 | * @brief modem sdk wifi service init |
| 241 | * @retval 0: success |
| 242 | * @retval other: fail |
| 243 | */ |
| 244 | int gsw_wifi_sdk_interface_init(void); |
| 245 | |
| 246 | /** |
| 247 | * @brief load wifi driver |
| 248 | * @retval 0: success |
| 249 | * @retval other: fail |
| 250 | */ |
| 251 | int gsw_wifi_enable(void); |
| 252 | |
| 253 | /** |
| 254 | * @brief uninstall wifi driver |
| 255 | * @retval 0: success |
| 256 | * @retval other: fail |
| 257 | */ |
| 258 | int gsw_wifi_disable(void); |
| 259 | |
| 260 | /** |
| 261 | * @brief start ap mode |
| 262 | * @retval 0: success |
| 263 | * @retval other: fail |
| 264 | */ |
| 265 | int gsw_wifi_ap_start(void); |
| 266 | |
| 267 | /** |
| 268 | * @brief stop ap mode |
| 269 | * @retval 0: success |
| 270 | * @retval other: fail |
| 271 | */ |
| 272 | int gsw_wifi_ap_stop(void); |
| 273 | |
| 274 | /** |
| 275 | * @brief restart ap |
| 276 | * @retval 0: success |
| 277 | * @retval other: fail |
| 278 | */ |
| 279 | int gsw_wifi_ap_restart(void); |
| 280 | |
| 281 | int gsw_wifi_stop_ap(wifi_mode_ability_e mode_ability); |
| 282 | |
| 283 | /** |
| 284 | * @brief set ap ssid |
| 285 | * @param [in] ssid ssid |
| 286 | * @retval 0: success |
| 287 | * @retval other: fail |
| 288 | */ |
| 289 | int gsw_wifi_ap_ssid_set(char *ssid); |
| 290 | |
| 291 | /** |
| 292 | * @brief get ap ssid |
| 293 | * @param [out] ssid ssid |
| 294 | * @retval 0: success |
| 295 | * @retval other: fail |
| 296 | */ |
| 297 | int gsw_wifi_ap_ssid_get(char *ssid); |
| 298 | |
| 299 | /** |
| 300 | * @brief set ap frequency |
| 301 | * @param [in] gsw_wifi_frequency 1 is 2.4G,2 is 5G |
| 302 | * @retval 0: success |
| 303 | * @retval other: fail |
| 304 | */ |
| 305 | int gsw_wifi_ap_frequency_set(int gsw_wifi_frequency); |
| 306 | |
| 307 | /** |
| 308 | * @brief get ap frequency |
| 309 | * @param [out] gsw_wifi_frequency 1 is 2.4G,2 is 5G |
| 310 | * @retval 0: success |
| 311 | * @retval other: fail |
| 312 | */ |
| 313 | int gsw_wifi_ap_frequency_get(int *gsw_wifi_frequency); |
| 314 | |
| 315 | /** |
| 316 | * @brief set ap bandwidth |
| 317 | * @param [in] bandwidth bandwidth |
| 318 | * @retval 0: success |
| 319 | * @retval other: fail |
| 320 | */ |
| 321 | int gsw_wifi_ap_bandwidth_set(gsw_wifi_bandwidth_type_e bandwidth); |
| 322 | |
| 323 | /** |
| 324 | * @brief get ap bandwidth |
| 325 | * @param [out] bandwidth bandwidth |
| 326 | * @retval 0: success |
| 327 | * @retval other: fail |
| 328 | */ |
| 329 | int gsw_wifi_ap_bandwidth_get(gsw_wifi_bandwidth_type_e *bandwidth); |
| 330 | |
| 331 | /** |
| 332 | * @brief set ap channel |
| 333 | * @param [in] channel channel |
| 334 | * @retval 0: success |
| 335 | * @retval other: fail |
| 336 | */ |
| 337 | int gsw_wifi_ap_channel_set(int channel); |
| 338 | |
| 339 | /** |
| 340 | * @brief get ap channel |
| 341 | * @param [out] channel channel |
| 342 | * @retval 0: success |
| 343 | * @retval other: fail |
| 344 | */ |
| 345 | int gsw_wifi_ap_channel_get(int *channel); |
| 346 | |
| 347 | /** |
| 348 | * @brief set ap authentication |
| 349 | * @param [in] auth authentication |
| 350 | * @retval 0: success |
| 351 | * @retval other: fail |
| 352 | */ |
| 353 | int gsw_wifi_ap_auth_set(gsw_wifi_auth_e auth); |
| 354 | |
| 355 | /** |
| 356 | * @brief get ap authentication |
| 357 | * @param [out] auth authentication |
| 358 | * @retval 0: success |
| 359 | * @retval other: fail |
| 360 | */ |
| 361 | int gsw_wifi_ap_auth_get(gsw_wifi_auth_e *auth); |
| 362 | |
| 363 | /** |
| 364 | * @brief set ap password |
| 365 | * @param [in] password password |
| 366 | * @retval 0: success |
| 367 | * @retval other: fail |
| 368 | */ |
| 369 | int gsw_wifi_ap_password_set(char *password); |
| 370 | |
| 371 | /** |
| 372 | * @brief get ap password |
| 373 | * @param [out] password password |
| 374 | * @retval 0: success |
| 375 | * @retval other: fail |
| 376 | */ |
| 377 | int gsw_wifi_ap_password_get(char *password); |
| 378 | |
| 379 | /** |
| 380 | * @brief get ap run state |
| 381 | * @param [out] ap_status ap run state |
| 382 | * @retval 0: success |
| 383 | * @retval other: fail |
| 384 | */ |
| 385 | int gsw_wifi_get_ap_status(gsw_wifi_ap_run_status_e *ap_status); |
| 386 | |
| 387 | /** |
| 388 | * @brief get sta run state |
| 389 | * @param [out] sta_status sta run state |
| 390 | * @retval 0: success |
| 391 | * @retval other: fail |
| 392 | */ |
| 393 | int gsw_wifi_get_sta_status(gsw_wifi_sta_run_status_e *sta_status); |
| 394 | |
| 395 | /** |
| 396 | * @brief start sta mode |
| 397 | * @retval 0: success |
| 398 | * @retval other: fail |
| 399 | */ |
| 400 | int gsw_wifi_sta_start(void); |
| 401 | |
| 402 | /** |
| 403 | * @brief stop sta mode |
| 404 | * @retval 0: success |
| 405 | * @retval other: fail |
| 406 | */ |
| 407 | int gsw_wifi_sta_stop(void); |
| 408 | |
| 409 | int gsw_wifi_stop_sta(wifi_mode_ability_e mode_ability); |
| 410 | |
| 411 | /** |
| 412 | * @brief obtain the ssid of the ap currently connected to the sta |
| 413 | * @param [out] sta_ssid ssid |
| 414 | * @retval 0: success |
| 415 | * @retval other: fail |
| 416 | */ |
| 417 | int gsw_wifi_get_sta_ssid(char *sta_ssid); |
| 418 | |
| 419 | /** |
| 420 | * @brief obtain the authentication of the ap currently connected to the sta |
| 421 | * @param [out] auth authentication |
| 422 | * @retval 0: success |
| 423 | * @retval other: fail |
| 424 | */ |
| 425 | int gsw_wifi_get_sta_auth(gsw_wifi_auth_e *auth); |
| 426 | |
| 427 | /** |
| 428 | * @brief connect to target ap |
| 429 | * @param [in] ssid the ssid of the target ap |
| 430 | * @param [in] auth the authentication of the target ap |
| 431 | * @param [in] password the password of the target ap |
| 432 | * @retval 0: success |
| 433 | * @retval other: fail |
| 434 | */ |
| 435 | int gsw_wifi_sta_connect(char *ssid, gsw_wifi_auth_e auth, char *password); |
| 436 | |
| 437 | /** |
| 438 | * @brief disconnect the currently connected ap |
| 439 | * @param [in] ssid the ssid of the target ap |
| 440 | * @retval 0: success |
| 441 | * @retval other: fail |
| 442 | */ |
| 443 | int gsw_wifi_sta_disconnect(char *ssid); |
| 444 | |
| 445 | /** |
| 446 | * @brief delete remembered ap |
| 447 | * @param [in] ssid the ssid of the target ap |
| 448 | * @param [in] auth the authentication of the target ap |
| 449 | * @retval 0: success |
| 450 | * @retval other: fail |
| 451 | */ |
| 452 | int gsw_wifi_sta_forget_ap(char *ssid, gsw_wifi_auth_e auth); |
| 453 | |
| 454 | /** |
| 455 | * @brief sta start scan |
| 456 | * @retval 0: success |
| 457 | * @retval other: fail |
| 458 | */ |
| 459 | int gsw_wifi_sta_start_scan(void); |
| 460 | |
| 461 | /** |
| 462 | * @brief get interface ip addr |
| 463 | * @param [in] idx interface idx |
| 464 | * @param [out] ip interface ip addr |
| 465 | * @retval 0: success |
| 466 | * @retval other: fail |
| 467 | */ |
| 468 | int gsw_wifi_get_interface_ip(gsw_wifi_index_e idx, char *ip); |
| 469 | |
| 470 | /** |
| 471 | * @brief get interface mac addr |
| 472 | * @param [in] idx interface idx |
| 473 | * @param [out] mac interface mac addr |
| 474 | * @retval 0: success |
| 475 | * @retval other: fail |
| 476 | */ |
| 477 | int gsw_wifi_get_interface_mac(gsw_wifi_index_e idx, char *mac); |
| 478 | |
| 479 | /** |
| 480 | * @brief obtain the mac of the ap currently connected to the sta |
| 481 | * @param [out] mac ap mac addr |
| 482 | * @retval 0: success |
| 483 | * @retval other: fail |
| 484 | */ |
| 485 | int gsw_wifi_get_connect_ap_mac(char *mac); |
| 486 | |
| 487 | /** |
| 488 | * @brief obtain the rssi of the ap currently connected to the sta |
| 489 | * @param [out] rssi ap rssi |
| 490 | * @retval 0: success |
| 491 | * @retval other: fail |
| 492 | */ |
| 493 | int gsw_wifi_get_connect_ap_rssi(int *rssi); |
| 494 | |
| 495 | /** |
| 496 | * @brief obtain the band of the ap currently connected to the sta |
| 497 | * @param [out] band the ap band |
| 498 | * @retval 0: success |
| 499 | * @retval other: fail |
| 500 | */ |
| 501 | int gsw_wifi_get_connect_ap_band(gsw_wifi_band_e *band); |
| 502 | |
| 503 | /** |
| 504 | * @brief obtain the ip of the ap currently connected to the sta |
| 505 | * @param [out] ip the ap ip |
| 506 | * @retval 0: success |
| 507 | * @retval other: fail |
| 508 | */ |
| 509 | int gsw_wifi_get_connect_ap_ip(char *ip); |
| 510 | |
| 511 | /** |
| 512 | * @brief get the currently connectable AP with the best signal strength |
| 513 | * @param [out] info the ap info |
| 514 | * @retval 0: success |
| 515 | * @retval other: fail |
| 516 | */ |
| 517 | int gsw_wifi_get_sta_available_ap(gsw_ap_detail_info_s *info); |
| 518 | |
| 519 | /** |
| 520 | * @brief get ap device list |
| 521 | * @param [in] len the size of the param[device_list] |
| 522 | * @param [out] ap_info the ap info |
| 523 | * @param [out] device_list the device list |
| 524 | * @param [out] dev_len the device num |
| 525 | * @retval 0: success |
| 526 | * @retval other: fail |
| 527 | */ |
| 528 | int gsw_wifi_get_ap_device_list(gsw_ap_info_s *ap_info, gsw_device_info_s *device_list, int len, int *dev_len); |
| 529 | |
| 530 | /** |
| 531 | * @brief get the saved ap list |
| 532 | * @param [in] len the size of the param[list] |
| 533 | * @param [out] list the saved ap list |
| 534 | * @param [out] list_len the list num |
| 535 | * @retval 0: success |
| 536 | * @retval other: fail |
| 537 | */ |
| 538 | int gsw_wifi_get_sta_saved_ap(gsw_saved_ap_info_s *list, int len, int *list_len); |
| 539 | |
| 540 | /** |
| 541 | * @brief get the sta scan list |
| 542 | * @param [in] len the size of the param[list] |
| 543 | * @param [out] list the scan list |
| 544 | * @param [out] list_len the list num |
| 545 | * @retval 0: success |
| 546 | * @retval other: fail |
| 547 | */ |
| 548 | int gsw_wifi_get_scan_list(gsw_scan_info_s *list, int len, int *list_len); |
| 549 | |
| 550 | |
| 551 | typedef void(*GSW_AP_CALLBACK_FUNC_PTR)(void *arg, gsw_wifi_ap_status_e status); |
| 552 | |
| 553 | /** |
| 554 | * @brief register ap event notification function |
| 555 | * @param [in] arg as gsw_cb function parameter, can be NULL |
| 556 | * @param [in] gsw_cb callback |
| 557 | * @retval 0: success |
| 558 | * @retval other: fail |
| 559 | */ |
| 560 | int gsw_wifi_reg_ap_event_callback(void *arg, GSW_AP_CALLBACK_FUNC_PTR gsw_cb); |
| 561 | |
| 562 | /** |
| 563 | * @brief unregister ap callback function |
| 564 | * @param [in] arg reserved parameter, can be NULL |
| 565 | * @retval 0: success |
| 566 | * @retval other: fail |
| 567 | */ |
| 568 | int gsw_wifi_unreg_ap_event_callback(void *arg); |
| 569 | |
| 570 | typedef void(*GSW_STA_CALLBACK_FUNC_PTR)(void *arg, gsw_wifi_sta_status_e status, error_number_e number, gsw_sta_dns_info_s* dns_info); |
| 571 | |
| 572 | /** |
| 573 | * @brief register sta event notification function |
| 574 | * @param [in] arg as gsw_cb function parameter, can be NULL |
| 575 | * @param [in] gsw_cb callback |
| 576 | * @retval 0: success |
| 577 | * @retval other: fail |
| 578 | */ |
| 579 | int gsw_wifi_reg_sta_event_callback(void *arg, GSW_STA_CALLBACK_FUNC_PTR gsw_cb); |
| 580 | |
| 581 | /** |
| 582 | * @brief unregister sta callback function |
| 583 | * @param [in] arg reserved parameters, can be NULL |
| 584 | * @retval 0: success |
| 585 | * @retval other: fail |
| 586 | */ |
| 587 | int gsw_wifi_unreg_sta_event_callback(void *arg); |
| 588 | |
| 589 | |
| 590 | #endif |