Snapdragon® Telematics Application Framework (TelAF) Interface Specification
SIM Access Profile

API Reference


The SIM Access Profile (SAP) is an interface to communicate between remote SIM (RSIM) service and applications. This service is based on the SIM Access Profile (SAP) specification and a bridge between RSIM and the host applications. This allows an application to convey APDU requests to the remote SIM and help APDU to get responses from the modem through the RSIM service. A SAP service is needed for applications that want to communicate through RSIM service related to SIM I/O e.g. APDU, ATR sends messages to the SIM which located at 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 SAP service.

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

Send message from app

A message can be sent to the service which then sends commands to the modem using taf_simSap_SendMessage() with the messagePtr and messageNumElements passed as parameters.

uint8_t buffer[TAF_SIMSAP_MAX_MSG_SIZE];
static bool daemonConnected = false;
int bytes;
le_result_t result = LE_FAULT;
memset(buffer, 0, sizeof(buffer));
if ((bytes = read(fd, buffer, TAF_SIMSAP_MAX_MSG_SIZE)) <= 0) {
    LE_ERROR("Connection closed or failed to read from daemon! %s\n", strerror(errno));
    daemonConnected = false;
} else {
    //Send message
    LE_INFO("Read %d bytes from daemon", bytes);
    result = taf_simSap_SendMessage(buffer, bytes);

}
LE_ASSERT(result == LE_OK);

Before an application starts to send message, the application needs to register a callback handler using taf_simSap_AddMessageHandler(). Once the message is sent, the handler will be called indicating the sending status of the message. If the message failed to send, the handler will be called with the error code.

taf_simSap_MessageHandlerRef_t msgHandlerRef = taf_simSap_AddMessageHandler(SAPMessageHandler, NULL);

Applications must use taf_simSap_RemoveMessageHandler() to release the taf_simSap_MessageHandlerRef_t message handler reference object when it is no longer used.