Data Connection

API Reference


A data connection is needed for applications that exchange data with devices where SMS messages are insufficient or not possible. The data connection can be over a mobile network, over Wi-Fi, or over a fixed link (e.g., Ethernet).

The data connection service provides a basic API for requesting and releasing a data connection.

Note
This interface does not support yet data connection over a fixed link.

IPC interfaces binding

All the functions of this API are provided by the dataConnectionService application service.

Here's a code sample binding to Data Connection services:

bindings:
{
   clientExe.clientComponent.le_data -> dataConnectionService.le_data
}

Default Data Connection

Default data connection is obtained using le_data_Request(). Before the data connection is requested, an application registers a connection state handler using le_data_AddConnectionStateHandler(). Once the data connection is established, the handler will be called indicating it's now connected. If the state of the data connection changes, then the handler will be called with the new state. To release a data connection, an application can use le_data_Release().

The technology of the established connection can be retrieved with le_data_GetTechnology().

If the default data connection is not currently available when le_data_Request() is called, the data connection service first ensures all pre-conditions are satisfied (e.g., modem is registered on the network), before trying to start the data connection.

If the default data connection is already available when le_data_Request() is called, a new connection will not be started. Instead, the existing data connection will be used. This happens if another application also requested the default data connection. This is how multiple applications can share the same data connection.

Once an application makes a data connection request, it should monitor the connection state reported to the registered connection state handler. The application should only try transmitting data when the state is connected, and should stop transmitting data when the state is not connected. If the state is not connected, the data connection service will try to re-establish the connection. There's no need for an application to issue a new connection request.

The default data connection will not necessarily be released when an application calls le_data_Release(). The data connection will be released only after le_data_Release() is called by all applications that previously called le_data_Request().

Technology rank

The technology to use for the default data connection can be chosen by the applications with an ordered list. If the connection becomes unavailable through a technology, the next one in the list is used for the default data connection. If the connection is also unavailable through the last technology of the list, the first technology will be used again. The default sequence is LE_DATA_WIFI at rank #1 and LE_DATA_CELLULAR at rank #2.

Note
  • Only one list is available and therefore only one application should set the technology preferences for the default data connection.
  • The list should not be modified while the default data connection is established.
  • le_data_SetTechnologyRank() sets the rank of the technology to use for the data connection service. le_data_SetTechnologyRank() inserts a technology into a list, so all the technologies previously set with ranks r and r+n are automatically shifted to ranks r+1 and r+n+1. Technologies with ranks under r are not impacted. If the technology is already in the list, it is removed from its current rank and added to the new rank.
  • le_data_GetFirstUsedTechnology() and le_data_GetNextUsedTechnology() let you retrieve the different technologies of the ordered list to use for the default connection data.

Configuration tree

The configuration of the Wi-Fi access point is stored in the configuration database of the dataConnectionService under the following path:

 dataConnectionService:/
     wifi/
         SSID<string> == TestSsid
         secProtocol<int> == 3
         passphrase<string> == Passw0rd
Note
The security protocol is one of the supported protocols defined in the le_wifiClient_SecurityProtocol_t enumerator.