1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 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 * @addtogroup wifiservice 18 * @{ 19 * 20 * @brief Provides functions for the Wi-Fi station and hotspot modes. 21 * 22 * You can use this module to enable and disable the Wi-Fi station or hotspot mode, connect to and disconnect from a 23 * station or hotspot, query the station or hotspot status, and listen for events. \n 24 * 25 * @since 7 26 */ 27 28 /** 29 * @file wifi_device_config.h 30 * 31 * @brief Defines the Wi-Fi station configuration. 32 * 33 * The Wi-Fi station configuration includes the security type and data length. \n 34 * 35 * @since 7 36 */ 37 38 #ifndef WIFI_LITE_WIFI_DEVICE_CONFIG_H 39 #define WIFI_LITE_WIFI_DEVICE_CONFIG_H 40 41 /** 42 * @brief Indicates the maximum number of Wi-Fi station configurations that can be added using {@link AddDeviceConfig}. 43 * 44 * If the maximum number is reached, an error will be returned. In this case, you must delete at least one 45 * configuration before you can add new ones. \n 46 */ 47 #define WIFI_MAX_CONFIG_SIZE 10 48 /** 49 * @brief Indicates the value of <b>networkId</b> when the configuration file is unavailable. 50 * 51 * Generally, the configuration file is unavailable because the configuration matching the <b>networkId</b> is 52 * uninitialized. \n 53 */ 54 #define WIFI_CONFIG_INVALID (-1) 55 /** 56 * @brief Indicates the maximum length of a Wi-Fi SSID. 57 * 58 * The maximum length is 32, and the last bit is reserved and set to <b>\0</b>. \n 59 */ 60 #define WIFI_MAX_SSID_LEN 33 // 32 + \0 61 /** 62 * @brief Indicates the maximum length of a Wi-Fi key. 63 * 64 * The maximum length is 64, and the last bit is reserved and set to <b>\0</b>. \n 65 */ 66 #define WIFI_MAX_KEY_LEN 65 // 64 + \0 67 /** 68 * @brief Indicates the maximum length of a Wi-Fi MAC address or a Wi-Fi BSSID. 69 * 70 */ 71 #define WIFI_MAC_LEN 6 72 73 /** 74 * @brief Indicates the maximum length of a Wi-Fi PSK. 75 * 76 */ 77 #define WIFI_PSK_LEN 32 78 79 /** 80 * @brief Indicates the maximum number of DNS servers. 81 * 82 * A maximum of two DNS servers are allowed. \n 83 */ 84 #define WIFI_MAX_DNS_NUM 2 85 86 /** 87 * @brief Indicates the maximum length of a device name. 88 * 89 */ 90 #define DEVICE_NAME_LEN 128 91 92 /** 93 * @brief Indicates the maximum length of a ipv4 address. 94 * 95 */ 96 #define WIFI_MAX_IPV4_LEN 16 97 98 /** 99 * @brief Indicates the maximum length of IPV ADDRESS. 100 * 101 */ 102 #define DEVICE_IPV6_MAX_LEN 128 103 104 /** 105 * @brief Indicates the maximum length of ifName. 106 * 107 */ 108 #define WIFI_IF_NAME_MAX_LEN 16 109 110 /** 111 * @brief Indicates the maximum length of peer mac address. 112 * 113 */ 114 #define WIFI_PEER_MAC_ADDR_MAX_LEN 18 115 116 /** 117 * @brief Indicates the maximum length of low tx power param. 118 * 119 */ 120 #define WIFI_LOW_TX_POWER_PARAM_MAX_LEN 40 121 122 /** 123 * @brief Enumerates Wi-Fi security types. 124 * 125 * @since 7 126 */ 127 typedef enum { 128 /** Invalid security type */ 129 WIFI_SEC_TYPE_INVALID = -1, 130 /** Open */ 131 WIFI_SEC_TYPE_OPEN = 0, 132 /** Wired Equivalent Privacy (WEP) */ 133 WIFI_SEC_TYPE_WEP = 1, 134 /** Pre-shared key (PSK) */ 135 WIFI_SEC_TYPE_PSK = 2, 136 /** Ethernet Automatic Protection (EAP) */ 137 WIFI_SEC_TYPE_EAP = 3, 138 /** Simultaneous Authentication of Equals (SAE) */ 139 WIFI_SEC_TYPE_SAE = 4, 140 /** EAP suite B */ 141 WIFI_SEC_TYPE_EAP_SUITE_B = 5, 142 /** Opportunistic Wireless Encryption (OWE) */ 143 WIFI_SEC_TYPE_OWE = 6, 144 /** WAPI cert */ 145 WIFI_SEC_TYPE_WAPI_CERT = 7, 146 /** WAPI PSK */ 147 WIFI_SEC_TYPE_WAPI_PSK = 8, 148 } WifiSecurityType; 149 150 /** 151 * @brief Enumerates psk encryption types. 152 * 153 * @since 7 154 */ 155 typedef enum { 156 /** Indicates that the ascii type of psk encryption type */ 157 WIFI_PSK_TYPE_ASCII = 0, 158 /** Indicates that the hex type of psk encryption type */ 159 WIFI_PSK_TYPE_HEX, 160 } WifiPskType; 161 162 /** 163 * @brief Defines the IP configuration of the Wi-Fi device. 164 * 165 * The IP configuration is mainly used for connecting to the device. \n 166 * 167 * @since 3 168 */ 169 typedef struct { 170 /** IP address of the Wi-Fi device */ 171 unsigned int ipAddress; 172 /** Gateway of the Wi-Fi device */ 173 unsigned int gateway; 174 /** DNS server addresses for the Wi-Fi device */ 175 unsigned int dnsServers[WIFI_MAX_DNS_NUM]; 176 /** Subnet mask of the Wi-Fi device */ 177 unsigned int netmask; 178 } IpConfig; 179 180 /** 181 * @brief Enumerates IP address types for the Wi-Fi device. 182 * 183 * @since 3 184 */ 185 typedef enum { 186 /** Static IP address */ 187 STATIC_IP, 188 /** IP address dynamically assigned by DHCP */ 189 DHCP, 190 /** Unknown IP address type */ 191 UNKNOWN 192 } IpType; 193 194 /** 195 * @brief Represents the Wi-Fi station configuration used to connect to a specified Wi-Fi device. 196 * 197 * @since 7 198 */ 199 typedef struct WifiDeviceConfig { 200 /** Service set ID (SSID). For its length, see {@link WIFI_MAX_SSID_LEN}. */ 201 char ssid[WIFI_MAX_SSID_LEN]; 202 /** Basic service set ID (BSSID). For its length, see {@link WIFI_MAC_LEN}. */ 203 unsigned char bssid[WIFI_MAC_LEN]; 204 /* bssid type. */ 205 int bssidType; 206 /** Key. For its length, see {@link WIFI_MAX_KEY_LEN}. */ 207 char preSharedKey[WIFI_MAX_KEY_LEN]; 208 /** Security type. It is defined in {@link WifiSecurityType}. */ 209 int securityType; 210 /** Allocated <b>networkId</b> */ 211 int netId; 212 /** Frequency */ 213 unsigned int freq; 214 /** PSK type, see {@link WifiPskType}. */ 215 int wapiPskType; 216 /** IP address type */ 217 IpType ipType; 218 /** Static IP address */ 219 IpConfig staticIp; 220 /* 1 for hidden config */ 221 int isHiddenSsid; 222 /* randomMacType */ 223 int randomMacType; 224 } WifiDeviceConfig; 225 226 /** 227 * @brief Enumerates Wi-Fi scan types. 228 * 229 * @since 7 230 */ 231 typedef enum { 232 /** A scan based on a specified frequency. */ 233 WIFI_FREQ_SCAN, 234 /** A scan based on a specified SSID. */ 235 WIFI_SSID_SCAN, 236 /** A scan based on a specified BSSID. */ 237 WIFI_BSSID_SCAN, 238 /** A scan based on a specified frequency band. */ 239 WIFI_BAND_SCAN 240 } WifiScanType; 241 242 /** 243 * @brief Represents the Wi-Fi station configuration used to connect to a specified Wi-Fi device. 244 * 245 * @since 7 246 */ 247 typedef struct { 248 /** Service set ID (SSID). Its maximum length is defined by {@link WIFI_MAX_SSID_LEN}. */ 249 char ssid[WIFI_MAX_SSID_LEN]; 250 /** Length of the SSID. */ 251 char ssidLen; 252 /** Basic service set ID (BSSID). Its length is defined by {@link WIFI_MAC_LEN}. */ 253 unsigned char bssid[WIFI_MAC_LEN]; 254 /** Frequency. */ 255 int freqs; 256 /** Frequency band. */ 257 int band; 258 /** Wi-Fi scan type, which is defined by {@link WifiScanType}. */ 259 WifiScanType scanType; 260 } WifiScanParams; 261 262 /** 263 * @brief IP info 264 * 265 * @since 7 266 */ 267 typedef struct { 268 unsigned int ipAddress; 269 unsigned int netMask; 270 unsigned int netGate; 271 unsigned int dns1; 272 unsigned int dns2; 273 unsigned int serverAddress; 274 int leaseDuration; 275 } IpInfo; 276 277 /* DHCP IpV6Info */ 278 typedef struct { 279 char linkIpV6Address[DEVICE_IPV6_MAX_LEN]; 280 char globalIpV6Address[DEVICE_IPV6_MAX_LEN]; 281 char randGlobalIpV6Address[DEVICE_IPV6_MAX_LEN]; 282 char uniqueIpv6Address[DEVICE_IPV6_MAX_LEN]; 283 char randUniqueIpv6Address[DEVICE_IPV6_MAX_LEN]; 284 char gateway[DEVICE_IPV6_MAX_LEN]; 285 char netmask[DEVICE_IPV6_MAX_LEN]; 286 char primaryDns[DEVICE_IPV6_MAX_LEN]; 287 char secondDns[DEVICE_IPV6_MAX_LEN]; 288 } IpV6Info; 289 290 /* Wifi Low Tx Power Param */ 291 typedef struct { 292 char ifName[WIFI_IF_NAME_MAX_LEN]; 293 int scene; 294 int rssiThreshold; 295 char peerMacaddr[WIFI_PEER_MAC_ADDR_MAX_LEN]; 296 char powerParam[WIFI_LOW_TX_POWER_PARAM_MAX_LEN]; 297 int powerParamLen; 298 } WifiLowPowerParam; 299 300 #endif // WIFI_LITE_WIFI_DEVICE_CONFIG_H 301 /** @} */ 302