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.

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().

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().

All configuration data required for the default data connection, like the Access Point Name (APN), will be stored in the Config database.

Configuration tree

The configuration database path for the Data Connection Service is:

 /
     dataConnectionService/
         prefTech<string> == <technology>

'prefTech' is the preferred technology used for the data connection service. It can be set with the following choices (string type):

  • "wifi"
  • "ethernet"
  • "cellular"

For example, with "cellular", the DCS will load a profile regarding a policy. If the APN is empty the DCS will read a configuration file (Containing all APN for MCC/MNC) to fill the APN regarding the MCC,MNC (provided by the IMSI code).

Note
Only "cellular" choice is available in the present version.
Profile selection policy is not yet implemented. The first found profile of the selected technology is loaded in the present version.

Data Connection Options

Note
Functionality described in this section is not currently implemented; this description is provided to outline future functionality.

Some applications may have data connection requirements that are not met by the default data connection (e.g., use a least cost data link or disable roaming on mobile networks). You can do this by:

  • creating a request object using le_data_CreateRequest(),
  • setting optional values on that request object using le_data_SelectLeastCost() or le_data_DisableRoaming(),
  • and then submitting that object to a data connection request using le_data_SubmitRequest

le_data_AddConnectionStateHandler() and le_data_Release() APIs can continue to be used, as described above.