WiFi Access Point Service

API Reference


This WiFi Service API provides Wifi Access Point setup. Please note that if there is only one wifi hardware the WiFi Access Point cannot be used at the same time as the WiFi Client service.

IPC interfaces binding

Here's a code sample binding to WiFi service:

bindings:
{
   clientExe.clientComponent.le_wifiAp -> wifiService.le_wifiAp
}

Setting parameters for the Access Point

Note that these parameters must be set before the access point is started. See each function for its default value.

To set the SSID for the Access Point use the following function:

To set the pass phrase prior for the Access Point use the function: Also see le_wifiAp_SetPreSharedKey().

Instead of setting the pass phrase, the Pre Shared Key (PSK), can be set explicitly. To set the Pre Shared Key prior for the Access Point start use the function:

Sets the security protocol to use.

Sets is the Access Point should show up in network scans or not.

Sets which channel to use.

Sets what country code to use.

Sets which IEEE standard to use.

Gets which IEEE standard was set.

//--------------------------------------------------------------------------------------------------
/**
* Sets the credentials
*/
//--------------------------------------------------------------------------------------------------
static void Testle_setCredentials
(
void
)
{
LE_ASSERT(LE_OK == le_wifiAp_SetPassPhrase(TEST_PASSPHRASE));
 
 
}

Starting the WiFi Access Point

The WiFi Access Point is started with the function le_wifiAp_Start(). Unless values have been changed, default values will be used:

To subscribe to wifi events le_wifiAp_AddNewEventHandler() is to be called.

//--------------------------------------------------------------------------------------------------
/**
* Handler for WiFi client changes
*
*/
//--------------------------------------------------------------------------------------------------
static void myMsgHandler
(
le_wifiAp_Event_t event,
///< [IN]
///< WiFi event to process
void *contextPtr
///< [IN]
///< Associated event context
)
{
LE_INFO("WiFi access point event received");
switch(event)
{
case LE_WIFIAP_EVENT_CLIENT_CONNECTED:
{
// Client connected to AP
LE_INFO("LE_WIFIAP_EVENT_CLIENT_CONNECTED");
}
break;
 
case LE_WIFIAP_EVENT_CLIENT_DISCONNECTED:
{
// Client disconnected from AP
LE_INFO("LE_WIFICLIENT_EVENT_DISCONNECTED");
}
break;
 
 
default:
LE_ERROR("ERROR Unknown event %d", event);
break;
}
}
 
 
//--------------------------------------------------------------------------------------------------
/**
* Tests the WiFi access point.
*
*/
//--------------------------------------------------------------------------------------------------
void Testle_wifiApStart
(
void
)
{
LE_INFO("Start Test WiFi access point");
 
// Add an handler function to handle message reception
HdlrRef=le_wifiAp_AddNewEventHandler(myMsgHandler, NULL);
 
LE_ASSERT(HdlrRef != NULL);
 
LE_ASSERT(LE_OK == le_wifiAp_SetSsid(TEST_SSID, TEST_SSID_NBR_BYTES));
 
Testle_setCredentials();
 
{
LE_INFO("Start OK");
 
Testle_startDhcpServerAndbridgeConnection();
}
else
{
LE_ERROR("Start ERROR");
}
 
LE_ASSERT(LE_OK == le_wifiAp_SetIpRange(HOST_IP, IP_RANGE_START, IP_RANGE_END));
}