Snapdragon® Telematics Application Framework (TelAF) Interface Specification
Remote SIM

API Reference


The Remote SIM (RSIM) service allows apps to manage a remote SIM instead of the internal SIM card. This service allows a user application to convey APDU requests to the remote SIM and APDU responses to the modem through the RSIM service. The link between the application and the RSIM service is based on the SIM Access Profile (SAP) specification. A remote SIM service is needed for applications that want to communicate related to SIM I/O, e.g., APDU, ATR sends a message to the SIM located at the remote side.

IPC interfaces binding

The functions of this API are provided by the tafRemoteSimSvc application service.

The following example illustrates how to bind to the remote SIM service.

bindings:
{
    clientExe.clientComponent.taf_simRsim -> tafRemoteSimSvc.taf_simRsim
}

Communication

The communication between the application and the remote SIM service uses the SIM Access Profile (SAP) protocol.

The latest V11r00 SAP specification is supported by the remote SIM service. All client-mandatory features and some optional features are supported. The table below summarizes all SAP messages supported by the remote SIM service.

Feature Associated SAP messages Support in SAP client RSIM support
Connection management MSGID_CONNECT_REQ Mandatory Supported
MSGID_CONNECT_RESP Supported
MSGID_DISCONNECT_REQ Supported
MSGID_DISCONNECT_RESP Supported
MSGID_DISCONNECT_IND Supported
Transfer APDU MSGID_TRANSFER_APDU_REQ Mandatory Supported
MSGID_TRANSFER_APDU_RESP Supported
Transfer ATR MSGID_TRANSFER_ATR_REQ Mandatory Supported
MSGID_TRANSFER_ATR_RESP Supported
Power SIM off MSGID_POWER_SIM_OFF_REQ Optional Supported
MSGID_POWER_SIM_OFF_RESP Supported
Power SIM on MSGID_POWER_SIM_ON_REQ Mandatory Supported
MSGID_POWER_SIM_ON_RESP Supported
Reset SIM MSGID_RESET_SIM_REQ Optional Supported
MSGID_RESET_SIM_RESP Supported
Report Status MSGID_STATUS_IND Mandatory Supported
Transfer Card Reader Status MSGID_TRANSFER_CARD_READER_STATUS_REQ Optional Supported
MSGID_TRANSFER_CARD_READER_STATUS_RESP Supported
Error handling MSGID_ERROR_RESP Mandatory Supported
Set Transport Protocol MSGID_SET_TRANSPORT_PROTOCOL_REQ Optional Not supported
MSGID_SET_TRANSPORT_PROTOCOL_RESP Not supported

A message can be sent to the service which the sends commands to the modem using taf_simRsim_SendMessage() with the messagePtr, messageNumElements, callbackPtr and contextPtr passed as parameters. This message sending is an asynchronous process. A callback pointer can therefore be passed to taf_simRsim_SendMessage() in order to receive the sending result for the message.

static le_mem_PoolRef_t RsimMsgsPool;
static uint8_t APDUResp[60] = { 0x06, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
                           0x04, 0x00, 0x00, 0x29, 0x62, 0x25, 0x82, 0x02, 0x78, 0x21, 0x83, 0x02,
                           0x3F, 0x00, 0xA5, 0x0B, 0x80, 0x01, 0x71, 0x83, 0x03, 0x07, 0x93, 0x81,
                           0x87, 0x01, 0x01, 0x8A, 0x01, 0x05, 0x8B, 0x03, 0x2F, 0x06, 0x02, 0xC6,
                           0x06, 0x90, 0x01, 0x00, 0x83, 0x01, 0x01, 0x90, 0x00, 0x00, 0x00, 0x00 };
static uint8_t APDURespLength = 60;
RsimMsg_t* rsimPtr1 = le_mem_ForceAlloc(RsimMsgsPool);
memcpy(rsimPtr1->msg, APDUResp, APDURespLength);
rsimPtr1->msgLength = APDURespLength;
rsimPtr1->callback = CallbackHandler;
rsimPtr1->contextPtr = NULL;
le_result_t result = taf_simRsim_SendMessage(rsimPtr1->msg, rsimPtr1->msgLength, rsimPtr1->callback, rsimPtr1->contextPtr);
LE_ASSERT(res == LE_OK);

Before the tafsimRsim message sending is started, an application registers a callback handler using taf_simRsim_AddMessageHandler(). Once the message is sent, the handler will be called indicating the sending status of the message. If sending the message failed, the handler will be called with the error code.

taf_simRsim_MessageHandlerRef_t msgHandlerRef = @ref taf_simRsim_AddMessageHandler(SAPMessageHandler, NULL);

Applications must use taf_simRsim_RemoveMessageHandler() to release taf_simRsim_MessageHandlerRef_t message handler reference object when it is no longer used.

Warning
The remote SIM service supports only one remote SIM card and can therefore be connected with only one application.
Note
  • The remote SIM service has to be supported by the modem to be used: check your platform documentation.
  • The remote SIM card should be selected in order to use the remote SIM service.
  • As runtime switch is not currently supported, the switch between local and remote SIM card requires a platform reset to take effect.