Wi-Fi Manager service

This example covers the use case where the client connects to an available (scanned) access point.

// Return Code for QWF Wi-Fi API calls
qwf_wifi_Results_e rc;
// ID of the created Saved Network
uint16_t savedNetworkId, wait;
qwf_wifi_Ssid_t ssid;
qwf_wifi_StationModeStatusData_t status;

// API calls assume QWF Wi-Fi initialized and QWF Context stored in
// variable pCtx. Also assumes user knows SSID and Authentication used
// by access point. This information can be obtained from the
// qwf_wifi_GetScanResults() interface.

// Create a "saved network", if not already existing, for this access
// point, by first setting the required authentication parameters, WPA2
// PSK for example, requires a passphrase. For this example the access
// point has SSID name of "SampleWifi" and passphrase is "Testing123".

rc = qwf_wifi_SetPassphrase(pCtx, "Testing123");

// Second, create the Saved Network.
strlcpy(ssid.name, "SampleWifi", sizeof(ssid.name));
rc = qwf_wifi_CreateSavedNetwork(pCtx, &ssid, WIFI_SEC_PROT_WPA2_PSK,
                                 WIFI_BAND_2_4_GHZ, &savedNetworkId);

if (WIFI_OK == rc) {
    printf("Created Saved Network for %s!! Now Enable ID=%d\n",
           ssid.name, savedNetworkId);

    // Created OK, so "Enable" the Saved Network if want to connect when
    // not currently connected to the access point if available
    rc = qwf_wifi_EnableSavedNetwork(pCtx, savedNetworkId);

// Query the Wi-Fi status to see what status of connection is
// and what SSID the device is connected to if any.
// Using a simple loop to wait for connected, but should use the event
// WIFI_EVENT_CLIENT_CONNECTION_STATUS to track connection status.
for (wait=0;wait<20;wait++) {
    rc = qwf_wifi_GetClientStatus(pCtx, &status);
    if (WIFI_OK == rc) {
        if (status.connected) {
            printf("WiFi is CONNECTED to Saved Network ID: %d, Access
                   Point: %s\n", status.connectedSavedNetworkId,
                   status.connectedSsid.name); break;
        else {
            printf("WiFi is NOT Connected!\n");
    delay(1000); //sleep 1 sec