WifiConfig_AddNetwork Function

Header: #include <applibs/wificonfig.h>

Adds a Wi-Fi network to the device and returns the ID of the network.

int WifiConfig_AddNetwork(void);

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.

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

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

  • ENOMEM: there is not enough memory to add a new network.

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 the ID of the new network, or -1 for failure, in which case errno is set to the error value. The network ID is zero or a positive value.

Remarks

The network ID is passed to WifiConfig_Set* functions, such as WifiConfig_SetSSID.

The new network isn't configured and can be configured with the WifiConfig_Set* functions. Changes to the network configuration are effective immediately but are lost when the device reboots unless the WifiConfig_PersistConfig function is called to save the configuration to nonvolatile storage.

The number of networks you can store on a device is not fixed, but depends on the available resources and the amount of storage required for each network configuration.

Application manifest requirements

The application manifest must include the WifiConfig capability.