WiFi Client Service
This API provides WiFi Client setup. Please note that the WiFi Client cannot be used at the same time as the WiFi Access Points service, due to the sharing of same wifi hardware.
IPC interfaces binding
Here's a code sample binding to WiFi service:
bindings: { clientExe.clientComponent.le_wifiClient -> wifiService.le_wifiClient }
Starting the WiFi Client
First of all the function le_wifiClient_Start() must be called to start the WiFi Service.
- le_wifiClient_Start(): returns LE_OK if the call went ok. If WiFi Access Point is active, this will fail.
To subscribe to wifi events le_wifiClient_AddNewEventHandler() is to be called.
- le_wifiClient_AddNewEventHandler(): returns the handler reference if the call went ok.
static void EventHandler(le_wifiClient_Event_t clientEvent,void *contextPtr){switch( clientEvent ){{LE_INFO("WiFi Client Connected.");}break;{LE_INFO("WiFi Client Disconnected.");}break;{LE_INFO("WiFi Client Scan is done.");MyHandleScanResult();}break;}}le_wifiClient_NewEventHandler WiFiEventHandlerRef = NULL;static void MyInit(void){le_result_t result = le_wifiClient_start();if ( LE_OK == result ){LE_INFO("WiFi Client started.");WiFiEventHandlerRef = le_wifiClient_AddNewEventHandler( EventHandler, NULL );}{LE_INFO("ERROR: WiFi Client already started.");}else{LE_INFO("ERROR: WiFi Client not started.");}}
Scanning Access Points with WiFi Client
To start a scan for Access Points, the le_wifiClient_Scan() should be called.
- le_wifiClient_Scan(): returns the LE_OK if the call went ok.
Processing the WiFi scan results
Once the scan results are available, the event LE_WIFICLIENT_EVENT_SCAN_DONE is received. The found Access Points can then be gotten with
- le_wifiClient_GetFirstAccessPoint(): returns the Access Point if found. Else NULL.
- le_wifiClient_GetNextAccessPoint(): returns the next Access Point if found. Else NULL.
The Access Points SSID, Service Set Identifier, is not a string. It does however often contain human readable ASCII values. It can be read with the following function:
- le_wifiClient_GetSsid() : returns the LE_OK if the SSID was read ok.
The Access Points signal strength can be read with the following function:
- le_wifiClient_GetSignalStrength() : returns the signal strength in dBm of the AccessPoint
static void MyHandleScanResult(void){uint8 ssid[MAX_SSID_BYTES];le_wifiClient_AccessPointRef_t accessPointRef = le_wifiClient_GetFirstAccessPoint();while( NULL != accessPointRef ){result = le_wifiClient_GetSsid( accessPointRef, ssid, MAX_SSID_BYTES );{LE_INFO("WiFi Client found.");break;}accessPointRef = le_wifiClient_GetNextAccessPoint();}}
Connecting to Access Point
First of all, an Access Point reference should be created using the SSID of the target Access Point. Use the following function to create a reference:
- le_wifiClient_Create(): returns Access Point reference
To set the pass phrase prior for the Access Point use the function:
- le_wifiClient_SetPassphrase(): returns the function execution status.
WPA-Enterprise requires a username and password to authenticate. To set them use the function:
- le_wifiClient_SetUserCredentials(): returns the function execution status.
If an Access Point is hidden, it does not announce its presence and will not show up in scan. So, the SSID of this Access Point must be known in advance. Then, use the following function to allow connections to hidden Access Points: le_wifiClient_SetHiddenNetworkAttribute(): returns the function execution status.
Finally and when the Access Point parameters have been configured, use the following function to attempt a connection:
- le_wifiClient_Connect(): returns the function execution status.
static void MyConnectTo(le_wifiClient_AccessPointRef_t accessPointRef){le_result_t result;le_wifiClient_SetPassphrase ( accessPointRef, "Secret1" );result = le_wifiClient_Connect( accessPointRef );if (result == LE_OK){LE_INFO("Connecting to AP.");}}
Copyright (C) Sierra Wireless Inc.