Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Header: #include <applibs/wificonfig.h>
Sets the pre-shared key (PSK) for a Wi-Fi network. The PSK is used for networks that are configured with the WifiConfig_Security_Wpa2_Psk security type.
The setting is effective immediately but won't persist across device reboots unless the WifiConfig_PersistConfig function is called after this function.
static int WifiConfig_SetPSK(int networkId, const char *psk, size_t pskLength);
Parameters
networkIdThe ID of the network to configure. WifiConfig_AddNetwork returns the network ID.pskA pointer to the buffer that contains the PSK for the network.pskLengthThe length of the PSK for the network. This parameter must be less than or equals toWIFICONFIG_WPA2_KEY_MAX_BUFFER_SIZE.
Errors
Returns -1 if an error is encountered and sets errno to the error value.
EACCES: the application manifest doesn't include the WifiConfig capability.
EFAULT: the
pskparameter is NULL.ERANGE: the
pskLengthparameter is greater thanWIFICONFIG_WPA2_KEY_MAX_BUFFER_SIZE.EAGAIN: the Wi-Fi device isn't ready.
ENETDOWN: the Wi-Fi network interface is unavailable.
EINVAL: the
networkIdparameter is invalid.ENODEV: the
networkIdparameter doesn't match any of the IDs of the stored networks.
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.