m2mb API docs  30.00.007
m2mb API sets documentation
m2mb_sim.h File Reference

Header file for m2mb_sim APIs. More...

Go to the source code of this file.

Data Structures

struct  M2MB_SIM_INCOMING_APDU_T
 
struct  M2MB_SIM_PERSO_DATA_T
 
struct  M2MB_SIMOS_REQ_T
 

Macros

#define MAX_APDU_SIZE   ( 300 )
 

Typedefs

typedef HANDLE M2MB_SIM_HANDLE
 
typedef void(* m2mb_sim_ind_callback) (M2MB_SIM_HANDLE h, M2MB_SIM_IND_E sim_event, UINT16 resp_size, void *resp_struct, void *userdata)
 

Enumerations

enum  M2MB_SIM_ERRNO_E { M2MB_SIM_SUCCESS, M2MB_SIM_GENERIC_FAILURE }
 
enum  M2MB_SIM_IND_E {
  M2MB_SIM_REMOTE_EVENT_RESP, M2MB_SIM_REMOTE_APDU_RESP, M2MB_SIM_REMOTE_CONNECT_IND, M2MB_SIM_REMOTE_APDU_IND,
  M2MB_SIM_REMOTE_INIT_IND, M2MB_SIM_PROF01_SET_IND, M2MB_SIM_PROF00_SET_IND, M2MB_SIM_EXECUTE_CRYPTO_IND
}
 
enum  M2MB_SIM_SELECTION_E { M2MB_SIM_LOCAL_SIM, M2MB_SIM_REMOTE_SIM }
 
enum  M2MB_SIMOS_MSGTYPE_E {
  M2MB_SIM_EUICC_EXECUTE_APDU_REQ = 0x01, M2MB_SIM_EUICC_EXECUTE_APDU_RESP = 0x02, M2MB_SIM_EUICC_INIT = 0x03, M2MB_SIM_EUICC_RESET = 0x04,
  M2MB_SIM_EUICC_EXECUTE_CRYPTO = 0x05
}
 

Functions

M2MB_RESULT_E m2mb_sim_init (M2MB_SIM_HANDLE *h, m2mb_sim_ind_callback callback, void *userdata)
 m2mb_sim_init initializes SIM service for current client. More...
 
M2MB_RESULT_E m2mb_sim_send_remote_apdu_req (M2MB_SIM_HANDLE h, UINT8 *apdu_command, UINT16 cmdApduLen)
 m2mb_sim_send_remote_apdu_req sends a PDU to remote SIM. More...
 
M2MB_RESULT_E m2mb_sim_select_sim (M2MB_SIM_HANDLE h, M2MB_SIM_SELECTION_E simSelection)
 m2mb_sim_select_sim switches between local (physical) and remote (virtual) SIM. More...
 
M2MB_RESULT_E m2mb_sim_send_remote_apdu_resp (M2MB_SIM_HANDLE h, UINT8 SW1, UINT8 SW2, UINT8 *apdu_response, UINT16 respLen, UINT8 SIMStatus)
 m2mb_sim_send_remote_apdu_resp sends a remote SIM response APDU to UIM. More...
 
M2MB_RESULT_E m2mb_sim_send_crypto_resp (M2MB_SIM_HANDLE h, UINT8 *pData, UINT16 datalen, M2MB_RESULT_E cryptoResult)
 Provide response after. More...
 
M2MB_RESULT_E m2mb_sim_send_remote_reset_req (M2MB_SIM_HANDLE h)
 Call reset of SIM service to the modem. More...
 
M2MB_RESULT_E m2mb_sim_send_remote_watchdog_kick_req (M2MB_SIM_HANDLE h, UINT32 wdTimeoutX)
 m2mb_sim_send_remote_watchdog_kick_req can both kick watchdog of uim task on modem and set r its timeout multiplie (something similar to clock divider). More...
 

Detailed Description

Header file for m2mb_sim APIs.

m2m/m2m_common/m2mb_inc/m2mb_sim.h

m2mb_sim APIs provide actions and events for remote SIM management.

@notes

Author
F. Sansa
Date
05/09/2017

Function Documentation

◆ m2mb_sim_init()

M2MB_RESULT_E m2mb_sim_init ( M2MB_SIM_HANDLE *  h,
m2mb_sim_ind_callback  callback,
void *  userdata 
)

m2mb_sim_init initializes SIM service for current client.

m2mb_sim_init initialize SIM service for current client returning the handle that must be passed as first parameter for all SIM actions. Calling the m2mb_sim_init is mandatory before using the SIM service.

Parameters
[in]*hfirst parameter is the handle to the SIM service, that will be initialized by the function.
[in]callbacksecond parameter is the callback that will be called if an event or a response happens.
[in]userdatathird parameter is a pointer to generic user data that will be returned as it is in the callback.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note

m2mb_sim_init(&h, myCallback, myUserdata);

void myCallback( M2MB_SIM_HANDLE h, M2MB_SIM_IND_E sim_event, UINT16 resp_size, void *resp_struct, void *userdata )
{
//my code
}
int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_SIM_HANDLE h;
struct myStruct myUserdata;
retVal = m2mb_sim_init(&h, myCallback, (void*)myUserdata);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_sim_init succeeded");
}

◆ m2mb_sim_select_sim()

M2MB_RESULT_E m2mb_sim_select_sim ( M2MB_SIM_HANDLE  h,
M2MB_SIM_SELECTION_E  simSelection 
)

m2mb_sim_select_sim switches between local (physical) and remote (virtual) SIM.

m2mb_sim_select_sim switches between local (physical) and remote (virtual) SIM.

Parameters
[in]hfirst parameter is the handle to the remote SIM service, previously initialized by the m2mb_sim_init function.
[in]simSelectionsecond parameter is an enum indicating which SIM should be selected.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note

m2mb_sim_select_sim(h, simSelection);

void myCallback( M2MB_SIM_HANDLE h, M2MB_SIM_IND_E sim_event, UINT16 resp_size, void *resp_struct, void *userdata )
{
//my code
}
int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_SIM_HANDLE h;
struct myStruct myUserdata;
retVal = m2mb_sim_init(&h, myCallback, (void*)myUserdata);
//...
retVal = m2mb_sim_select_sim(h, 1);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_sim_select_sim request succeeded");
}

◆ m2mb_sim_send_crypto_resp()

M2MB_RESULT_E m2mb_sim_send_crypto_resp ( M2MB_SIM_HANDLE  h,
UINT8 *  pData,
UINT16  datalen,
M2MB_RESULT_E  cryptoResult 
)

Provide response after.

Parameters
[in]hfirst parameter is the handle to the remote SIM service, previously initialized by the m2mb_sim_init function.
[in]pDatapointer to data provided as response
[in]datalenlenght of data
[in]cryptoResultresult from Crypto operation
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note

◆ m2mb_sim_send_remote_apdu_req()

M2MB_RESULT_E m2mb_sim_send_remote_apdu_req ( M2MB_SIM_HANDLE  h,
UINT8 *  apdu_command,
UINT16  cmdApduLen 
)

m2mb_sim_send_remote_apdu_req sends a PDU to remote SIM.

m2mb_sim_send_remote_apdu_req sends a PDU to the remote SIM. The function is TBD. The response of the request is received in the callback defined by the user, using the m2mb_sim_send_remote_apdu_resp template.

Parameters
[in]hfirst parameter is the handle to the remote SIM service, previously initialized by the m2mb_sim_init function.
[in]apdu_commandsecond parameter is an array containing the PDU to be sent.
[in]cmdApduLenthird parameter is PDU length in byte.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note

m2mb_sim_send_remote_apdu_req(h, apdu_command, cmdApduLen);

void myCallback( M2MB_SIM_HANDLE h, UINT8 *SW1, UINT8 *SW2, UINT8 *apdu_response, UINT16 respLen, UINT8 SIMStatus, void *userdata )
{
//my code
}
int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_SIM_HANDLE h;
struct myStruct myUserdata;
UINT8 apdu[] = {0x00, 0x11, 0x00, 0x0A, 0x91, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0xAA, 0x0C, 0xC8, 0xF7, 0x1D, 0x14, 0x96, 0x97, 0x41, 0xF9, 0x77, 0xFD, 0x07};
retVal = m2mb_sim_init(&h, myCallback, (void*)myUserdata);
//...
retVal = m2mb_sim_send_remote_apdu_req(h, pdu, 25);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_sim_send_remote_apdu_req request succeeded");
}

◆ m2mb_sim_send_remote_apdu_resp()

M2MB_RESULT_E m2mb_sim_send_remote_apdu_resp ( M2MB_SIM_HANDLE  h,
UINT8  SW1,
UINT8  SW2,
UINT8 *  apdu_response,
UINT16  respLen,
UINT8  SIMStatus 
)

m2mb_sim_send_remote_apdu_resp sends a remote SIM response APDU to UIM.

m2mb_sim_send_remote_apdu_resp sends a remote SIM response APDU to UIM task (UIM (local SIM) manager).

Parameters
[in]hfirst parameter is the handle to the remote SIM service, previously initialized by the m2mb_sim_init function.
[in]SW1second parameter is SW1 of remote SIM response APDU.
[in]SW2third parameter is SW2 of remote SIM response APDU.
[in]apdu_responsefourth parameter is remote SIM response APDU.
[in]respLenfifth parameter is remote SIM response APDU length.
[in]respLensixth parameter is remote SIM status.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note

m2mb_sim_send_remote_apdu_resp(h, SW1, SW2, apdu_response, respLen, SIMStatus);

void myCallback( M2MB_SIM_HANDLE h, M2MB_SIM_IND_E sim_event, UINT16 resp_size, void *resp_struct, void *userdata )
{
//my code
}
int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_SIM_HANDLE h;
struct myStruct myUserdata;
UINT8 apdu[] = {0x00, 0x11, 0x00, 0x0A, 0x91, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0xAA, 0x0C, 0xC8, 0xF7, 0x1D, 0x14, 0x96, 0x97, 0x41, 0xF9, 0x77, 0xFD, 0x07};
retVal = m2mb_sim_init(&h, myCallback, (void*)myUserdata);
//...
retVal = m2mb_sim_send_remote_apdu_resp(h, 0x90, 0x00, pdu, 25, 0);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_sim_send_remote_apdu_resp request succeeded");
}

◆ m2mb_sim_send_remote_reset_req()

M2MB_RESULT_E m2mb_sim_send_remote_reset_req ( M2MB_SIM_HANDLE  h)

Call reset of SIM service to the modem.

Parameters
[in]hfirst parameter is the handle to the remote SIM service, previously initialized by the m2mb_sim_init function.
Returns
Note

◆ m2mb_sim_send_remote_watchdog_kick_req()

M2MB_RESULT_E m2mb_sim_send_remote_watchdog_kick_req ( M2MB_SIM_HANDLE  h,
UINT32  wdTimeoutX 
)

m2mb_sim_send_remote_watchdog_kick_req can both kick watchdog of uim task on modem and set r its timeout multiplie (something similar to clock divider).

when heavy code is performed, using for example crypto libs or TrustZone, kicking of watchdog related to uim management in modem, can avoid crash for starvation

Parameters
[in]hfirst parameter is the handle to the remote SIM service, previously initialized by the m2mb_sim_init function.
[in]wdTimeoutXWatchdog timeout multiplier. If a value greater than 127 is set, WD will be disabled. If 0, 1 is set instead.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note

@code

m2mb_sim_send_remote_apdu_req
M2MB_RESULT_E m2mb_sim_send_remote_apdu_req(M2MB_SIM_HANDLE h, UINT8 *apdu_command, UINT16 cmdApduLen)
m2mb_sim_send_remote_apdu_req sends a PDU to remote SIM.
m2mb_sim_init
M2MB_RESULT_E m2mb_sim_init(M2MB_SIM_HANDLE *h, m2mb_sim_ind_callback callback, void *userdata)
m2mb_sim_init initializes SIM service for current client.
m2mb_sim_select_sim
M2MB_RESULT_E m2mb_sim_select_sim(M2MB_SIM_HANDLE h, M2MB_SIM_SELECTION_E simSelection)
m2mb_sim_select_sim switches between local (physical) and remote (virtual) SIM.
m2mb_sim_send_remote_apdu_resp
M2MB_RESULT_E m2mb_sim_send_remote_apdu_resp(M2MB_SIM_HANDLE h, UINT8 SW1, UINT8 SW2, UINT8 *apdu_response, UINT16 respLen, UINT8 SIMStatus)
m2mb_sim_send_remote_apdu_resp sends a remote SIM response APDU to UIM.