1.5.3.13 SYS_WIFIPROV_Initialize Function

C

SYS_MODULE_OBJ SYS_WIFIPROV_Initialize
(
SYS_WIFIPROV_CONFIG *config,
SYS_WIFIPROV_CALLBACK callback,
void *cookie
)

Summary

Initializes the System Wi-Fi Provisioning module.

Description

Wi-Fi Provisioning service supports only single instance.

Parameters

ParamDescription
configWi-Fi Provisioning device configuration structure.
callbackThe client callback function pointer.
cookieThe pointer which will be passed to the client application when the client callback function is invoked.

Returns

If successful, returns a valid handle to an object. Otherwise, it returns SYS_MODULE_OBJ_INVALID.

Example

#define WIFI_DEV_SSID "DEMO_AP"
#define WIFI_DEV_PSK "password"

SYS_WIFIPROV_CONFIG wifiProvConfig;
SYS_MODULE_OBJ wifiProvServHandle;

// Set mode as STA
wifiProvConfig.mode = SYS_WIFI_STA;

// Disable saving wifi configuration
wifiProvConfig.saveConfig = false;

//Set the auth type to SYS_WIFI_WPA2
wifiProvConfig.staConfig.authType = SYS_WIFI_WPA2;

// Enable all the channels(0)
wifiProvConfig.staConfig.channel = 0;

// Device doesn't wait for user request.
wifiProvConfig.staConfig.autoConnect = 1;

// Set SSID
memcpy(wifiProvConfig.staConfig.ssid,WIFI_DEV_SSID,sizeof(WIFI_DEV_SSID));

// Set PSK
memcpy(wifiProvConfig.staConfig.psk,WIFI_DEV_PSK,sizeof(WIFI_DEV_PSK));

wifiProvServHandle = SYS_WIFIPROV_Initialize(&wifiProvConfig, WiFiProvServCallback, 0);
if (wifiProvServHandle == SYS_MODULE_OBJ_INVALID)
{
    // Handle error
}

Remarks

Client can auto enable the Provisioning service functionality by selecting MHC configuration option of Wi-Fi Service.