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 the credentials
*/
//--------------------------------------------------------------------------------------------------
static void Testle_setCredentials
(
void
)
{
LE_ASSERT(LE_OK == le_wifiAp_SetPassPhrase ( TEST_PASSPHRASE ));
 
LE_ASSERT(LE_OK == le_wifiAp_SetSecurityProtocol ( TEST_SECU_PROTO ));
 
}

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_AddEventHandler() is to be called.

  • le_wifiAp_AddEventHandler()
//--------------------------------------------------------------------------------------------------
/**
* Handler for Wifi Client changes
*
* @param event
* Handles the wifi events
* @param contextPtr
*/
//--------------------------------------------------------------------------------------------------
static void myMsgHandler
(
void* contextPtr
)
{
LE_INFO( "Wifi Ap event received");
switch( event )
{
{
///< A client connect to AP
LE_INFO( "LE_WIFIAP_EVENT_CLIENT_CONNECTED");
}
break;
 
{
///< A client connect to 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();
 
if( LE_OK == le_wifiAp_Start() )
{
LE_INFO( "le_wifiAp_Start OK");
 
Testle_startDhcpServerAndbridgeConnection();
}
else
{
LE_ERROR( "le_wifiAp_Start ERROR");
}
 
LE_ASSERT(LE_OK == le_wifiAp_SetIpRange("192.168.10.1",
"192.168.10.10",
"192.168.10.100"));
}