Kopīgot, izmantojot


WifiConfig_StoreWpa2Network Function

Header: #include <applibs/wificonfig.h>

Important

This function is obsolete. Use WifiConfig_AddNetwork instead.

Stores a WPA2 Wi-Fi network that uses a pre-shared key. This function is not thread safe.

Note

This function will fail if a network with the same SSID and pre-shared key is already stored. See the error section (EEXIST).

int WifiConfig_StoreWpa2Network(const uint8_t * ssid, size_t ssidLength, const char * psk, size_t pskLength);

Parameters

  • ssid A pointer to an SSID byte array with unspecified character encoding that identifies the Wi-Fi network.

  • ssidLength The number of bytes in the SSID of the Wi-Fi network.

  • psk A pointer to a buffer that contains the pre-shared key for the Wi-Fi network.

  • pskLength The length of the pre-shared key for the Wi-Fi network.

Errors

Returns -1 if an error is encountered and sets errno to the error value.

  • EACCES: the application manifest does not include the WifiConfig capability.

  • EEXIST: a stored Wi-Fi network already exists that has the same SSID and uses WPA2.

  • EFAULT: the ssid or psk is NULL.

  • ERANGE: the ssidLength or pskLength parameter is 0 or greater than WIFICONFIG_SSID_MAX_LENGTH and WIFICONFIG_WPA2_KEY_MAX_BUFFER_SIZE.

  • EAGAIN: the Wi-Fi device isn't ready yet.

  • ENETDOWN: the Wi-Fi network interface is unavailable.

  • ENOSPC: there are too many Wi-Fi networks for the configuration to persist; remove one and try again.

Any other errno may also be specified; such errors aren't deterministic and the same behavior might not be retained through system updates.

Return value

Returns 0 for success, or -1 for failure, in which case errno is set to the error value.

Application manifest requirements

The application manifest must include the WifiConfig capability.