/pps/services/cds/cnice/control

Cellular data service (CDS) control object for OS-level processes

Publishers
Cellular data service; clients of the cellular data service. Processes accessing this object must have OS-level privileges.
Subscribers
Cellular data service; clients of the cellular data service. Processes accessing this object must have OS-level privileges.
Note: This type of object is known as a server object, a special PPS object designed for point-to-point communication between a server and one or more clients. For details, see "Server objects" in the Persistent Publish/Subscribe Developer's Guide.

Overview

The cellular data services controller (CDSC) uses logical (symbolic) names to identify cellular data connections. This allows applications to reference a well known set of connections that's consistent across carriers. CDSC then performs the mapping to carrier-specific connection information based on the current runtime configuration (SIM, network, RAT, etc.).

The supported connections are listed in the following table:

Connection Logical Name Description
internet Represents the default cellular data connection to the internet. Usually becomes part of the default route.
mms Connection for Multimedia Messaging Services.
carrier_admin Represents an administrative connection. If available, it's typically a secured zero-cost connection available to specific applications and services.
carrier_apps Represents a special connection for use by specific applications (for example, certain carriers may provide this connection for their branded applications).
plan_admin Represents a connection used for administration of pre-paid and other related plan services.
a_gps Carrier may define a separate APN for assisted GPS server access.
carrier_800 Represents a connection where the carrier charges the destination for usage.
streaming Connection for alternate streaming channels.

Message/response format

Commands sent to the pps/services/cds/cnice/control objects are of the form:

msg::command_string\nid::msg_ID\ndat:json:{data}

Responses always reflect the command_string and msg_ID that were sent in the message. Depending on the command, the response may also include additional information (often JSON-encoded) in the dat attribute, along with an error code (err attribute), if applicable:

res::command_string
id::msg_ID
dat:json:additional_data
err:n:{error_code}

connect command

Request the activation of the specified logical connection.

The connect command has the following form:
msg::connect
id:msg_ID
dat:json:
{
    "name":"logical_name>", 
    "retries":"number_of_retries"
}
where name is the logical connection name and retries is an optional parameter that specifies the number of times CDSC will attempt to connect. If retries is not provided, CDSC will keep trying indefinitely.

The connect command sequence is asynchronous. If the response indicates success, this means only that the radio layer has accepted the request and has started the sequence of activating the connection. The actual result of the connection sequence is published to the logical connection's status attribute. Clients don't have to implement timeout logic for waiting for a result because the radio layer is guaranteed to return a result of some sort.

If retries is not provided, CDSC will keep retrying the connection. The service's active attribute in the status object is set to true; the connected attribute is false until a connection is established. If retries is provided and a connection can't be established within the specified number of retries, CDSC gives up trying connect and returns to the disconnected state. It's up to the applications to implement their own retry logic to handle connection failures.

What actually takes place during a specific connect request depends on the configuration of the connection and its current state:

  • If the connection is already active, then "already_connected":true is returned in the response dat field and no request is sent to the radio. No error code is returned; the request is considered successful. The status object isn't updated in this case.
  • If the connection isn't active, a connect request is sent to the radio layer. The response indicates the result of the request made to the radio layer.
  • If a connect request is already outstanding (due to another application making a connect request), CDSC doesn't make a new request to the radio (there can be only one outstanding connect request per connection at a time with the radio). CDSC returns a success indicator to the caller informing it that the request is being processed. The client should monitor the status object for results.

To allow CDSC to properly manage the life cycle of an "on demand" connection (not always on), an opaque connection ID value is returned to clients in the response. The client must track this ID and provide it when making the disconnect request. This allows CDSC to accurately track client references on the connection and close the connection when there are no applications using it. If a connection is closed for any reason, or a connect request fails, CDSC disards all existing connection references. Clients are expected to make a new connect request (if required) in these situations, resulting in a new connection ID for each request. If a client uses a "stale" connection ID in a disconnect request, the request is ignored.

It is highly recommended that client applications call connect and disconnect, even if a connection is currently active (as per the status object). If a client decides to bind to a connection's net interface without calling connect, there is a risk that CDSC will deem the connection unused and close it. By calling connect, clients ensure CDSC will keep the connection active at least until the client calls disconnect.

connect response

CDSC sends the connect response to the client in reply to the connect command. The response has the following form:
res::connect
id:msg_ID
dat:json:{"already_connected":true|false,"connect_id":"connect_id"}
err:n:error_code

The following parameters and attributes may be returned in the response:

already_connected
An optional boolean indicating whether the connection is already active. If true (connected), no interaction with the radio layer is required.
connect_id
An opaque ID value returned to the client for "on demand" connections. This is a unique ID for this connection request and must be supplied in the corresponding disconnect command. This ID allows CDSC to match disconnect and connect requests to keep track of client references to connections.
err
One of the following codes may be returned in the case of an error:
  • 312 (ESRVRFAULT)—General failure (STATUS_FAILURE from radio).
  • 16 (EBUSY)—The connection is in a transition state and currently cannot process the request. This is a transient error.
  • 22 (EINVAL)—Bad data was passed to the radio layer causing the request to fail immediately (for example, a spelling error in one of the command attributes).
  • 13 (EACCES)—The data connection isn't allowed (for example, the board isn't registered on the carrier network or data service mode is turned off for the board).
  • 48 (ENOTSUP)—The connection type isn't supported for the current carrier configuration or the connection type isn't enabled.

disconnect command

Request the deactivation of the specified logical connection.

The disconnect command has the following form:

msg::disconnect
id:msg_ID
dat:json:
{
    "name":"logical_name",
    "connect_id":"connect_id",
    "force":true|false
}
where
  • name is the logical connection name (required)
  • connect_id is the value returned in the original connect reponse. The connect_id value must be provided in the matching disconnect command to allow CDSC to match disconnect and connect requests to keep track of client references to connections.
  • force is an optional Boolean that indicates whether CDSC should request the radio layer to close the connection regardless of remaining references or "always on" state. If omitted, a value of false is assumed. A value of true should be used with caution because it forces the connection to be dropped even if other applications are using the connection.

disconnect response

CDSC sends the disconnect response to the client in reply to the disconnect command. The response has the following form:

res::disconnect
id::msg_ID
dat:json:
{
    "already_disconnected":true|false,
    "always_on":true|false,
    "ref_remaining":true|false
}
err:n:error_code

The following parameters and attributes may be returned in the response:

already_disconnected
An optional Boolean indicating whether the connection is already disconnected. If true, the connection is already disconnected and no interaction with the radio layer is required (if not true, the already_disconnected parameter doesn't appear in the response). The status object isn't updated in this case.
always_on
An optional Boolean that, when true, indicates that the connection wasn't actually closed because it's configured as "always on" and force was false in the request. If true, the connection remains active and no interaction with the radio layer is required. The status object isn't updated in this case.
ref_remaining
An optional Boolean indicating whether the connection has outstanding reference counts. If true, the reference associated with the connect_id is removed from the reference list for the connection, but the request to disconnect is not sent to the radio (because other applications still need the connection) and the status object is not updated. If force is true, the connection is closed regardless of other references, so ref_remaining is false.
err
One of the following codes may be returned in the case of an error:
  • 312 (ESRVRFAULT)—General failure (STATUS_FAILURE from radio).
  • 16 (EBUSY)—Indicates connection is in a transition state and currently cannot process the request. This is a transient error.
  • 22 (EINVAL)—Indicates bad data was passed to the radio layer causing the request to fail immediately.
  • 48 (ENOTSUP)—Indicates the connection type is not supported for the current carrier configuration or is not enabled.

get_service_stats command

Query the service statistics of the specified logical service.

The get_service_stats command has the following form:

msg::get_service_stats
id:msg_ID
dat:json:{
    "name":"logical_name",
    "timeUnit":"sec|msec|usec|nsec",
    "dataUnit":"Byte|KB|MB|GB"
}

where:

  • name is the logical connection name (required)
  • timeUnit (optional) is the time unit to be used in the response. If not specified, the response uses seconds.
  • dataUnit (optional) is the data unit to be used in the response. If not specified, the response uses kilobytes.

get_service_stats response

CDSC sends the get_service_stats response to the client in reply to the get_service_stats command. The response has the following form:

res::get_service_stats
id::msg_ID
dat:json:{ 
    "idleTime":value, 
    "bytesSent":value, 
    "bytesReceived":value
}
err:n:error_code>

The following attributes and parameters may be returned in the response:

idleTime
The service idle time in the specified unit. The default unit is seconds.
bytesSent
The amount of data the service has sent, in the specified unit. The default unit is kilobytes.
bytesReceived
The amount of data the service has received, in the specified unit. The default unit is kilobytes.
err
One of the following codes may be returned in the case of an error:
  • 22 (EINVAL)—Unknown logical name or otherwise bad parameters sent in the request.
  • 25 (ENOTTY)—Inappropriate I/O control operation. Service is not connected.
  • 79 (EOVERFLOW)—Value too large to be stored in data type.

set_data_service_mode command

Turn data services on or off. This value is persisted across device reboot.

The set_data_service_mode command has one of the following forms:

msg::set_data_service_mode
id::msg_ID
dat::ON|OFF

or

msg::set_data_service_mode
id::msg_ID
dat:json:
{
    "data_service_mode":"ON|OFF",
    "remember_user_enabled_data_roaming":true|false
}

where remember_user_enabled_data_roaming, if true, indicates that the setting of user_enabled_data_roaming is maintained. If false (default), the user_enabled_data_roaming state is cleared. In order for the user_enabled_data_roaming state to be maintained across a cycle of the data services mode, remember_user_enabled_data_roaming must be specified as true in both the ON and OFF messages.

set_data_service_mode response

CDSC sends the set_data_service_mode response to the client in reply to the set_data_service_mode command. The response has the following form:

res::set_data_service_mode
id::msg_ID
err:n:error_code

The following code may be returned in the err attribute in the case of an error:

  • 312 (ESRVRFAULT)—General failure (STATUS_FAILURE from radio)

set_data_roaming_mode command

Set the data services behaviour while roaming. This value is persisted across device reboot.

msg::set_data_roaming_mode
id::msg_ID
dat::ON|OFF|PROMPT

where the possible settings are as follows:

  • ON—turn data services on while data roaming.
  • OFF—turn data services off while data roaming.
  • PROMPT—turn data services off while roaming but will allow them to be re-enabled with the enable_data_roaming command.

set_data_roaming_mode response

CDSC sends the set_data_roaming_mode response to the client in reply to the set_data_roaming_mode command. The response has the following form:

res::set_data_roaming_mode
id::msg_ID
err:n:error_code

The following code may be returned in the case of an error:

  • 312 (ESRVRFAULT)—General failure (STATUS_FAILURE from radio).

enable_data_roaming command

Turn data services back on when they are currently turned off for roaming. The setting specified though this command is subsequently published in the user_enabled_data_roaming status attribute. This setting is maintained until data services are turned off or until the device ceases to be in a data roaming state.

The enable_data_roaming command has the following form:

msg::enable_data_roaming
id::msg_ID
dat::YES|NO
where YES indicates that data services will be enabled.
Note: An empty dat attribute is interpreted the same as YES. This case is deprecated and will be removed in a future version.

enable_data_roaming response

CDSC sends the enable_data_roaming response to the client in reply to the enable_data_roaming command. The response has the following form:

res::enable_data_roaming
id::msg_ID
err:n:error_code

One of the following codes may be returned in the case of an error:

  • 312 (ESRVRFAULT)—General failure (STATUS_FAILURE from radio).
  • 22 (EINVAL)—Indicates data services are not turned off for roaming; the request is invalid.

focus command

Assert that a critical connection request is prioritized over other active connections.

Some legacy cellular networks support a limited number of concurrent active logical connections. Even modern networks may become temporarily resource constrained. If an application can't afford to wait for the requested logical connection to be activated, it can use this command to prioritize its connection request.
Note: Prioritizing a connection may result in disconnecting one or more other active connections. This command should be used sparingly. The defocus command must be called on a focused connection as soon as the critical transmission has completed.

The focus command has the following form:

msg::focus
id::msg_ID
dat:json:{
    "name":"logical_name",
    "immediate":true|false
}

where:

  • name is the name of logical connection to prioritize (required).
  • immediate (required) is a boolean value indicating whether this focus request is to be applied immediately.

focus response

CDSC sends the focus response to the client in reply to the focus command. The response has the following form:

res::focus
id::msg_ID
err:n:error_code

The following error code (err) may be returned in the case of an error:

  • 22 (EINVAL)—An invalid argument was included.

defocus command

Remove the focus previously placed on the specified connection return to normal connection prioritization.

The defocus command has the following form:

msg::defocus
id::msg_ID
dat:json:{
    "name":"logical_name"
}

where name is the name of logical connection to remove the focus from (required).

defocus response

CDSC sends the defocus response to the client in reply to the defocus command. The response has the following form:

res::defocus
id::msg_ID
err:n:error_code

The following error code (err) may be returned in the case of an error:

  • 22 (EINVAL)—An invalid argument was included.

Examples

Request a connection for the mms, with 10 retries:
msg::connect
id:msg_ID
dat:json:
{
    "name":"mms", 
    "retries":"10"
}
If the connection is already active, the response is:
res::connect
id:msg_ID
dat:json:{"already_connected":"true","connect_id":"connect_id"}
If an error ocurred (the server is busy), the response is:
res::connect
id:msg_ID
err:n:16
Disconnect the plan_admin connection, but don't force the disconnection if other clients are connected:
msg::disconnect
id:msg_ID
dat:json:{"name":"plan_admin","connect_id":"connect_id"}
If another application is still using the plan_admin connection, the response is:
res::disconnect
id:msg_ID
dat:json:{"ref_remaining":true}