[ English | 简体中文 ]
SIM Card Management API
SIM card status query and management.
Header file: #include <tapi_sim.h>
openvela Implementation Notes
- SIM management: All interfaces include
slot_idparameter for SIM card identification - PIN management: Provides
enter_pin/change_pin/reset_pin/lock_pin/unlock_pinfor complete PIN/PUK workflows - APDU channel: Use
open_logical_channel/close_logical_channel/transmit_apdu_*to send APDU commands directly to the SIM card - UICC switch: Control SIM card enablement state via
get_uicc_enablement/set_uicc_enablement - Event subscription:
tapi_sim_register/tapi_sim_unregisterto monitor SIM card state changes
SIM Status Query
tapi_sim_has_icc_card
int tapi_sim_has_icc_card(tapi_context context, int slot_id, bool* out);
Query whether a SIM card is inserted.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_get_sim_state
int tapi_sim_get_sim_state(tapi_context context, int slot_id, int* out);
Get the SIM card state.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_get_sim_operator
int tapi_sim_get_sim_operator(tapi_context context, int slot_id, int length, char* out);
Get the SIM card operator information.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).lengthData length.outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_get_sim_operator_name
int tapi_sim_get_sim_operator_name(tapi_context context, int slot_id, char** out);
Get the SIM card operator name.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_get_sim_iccid
int tapi_sim_get_sim_iccid(tapi_context context, int slot_id, char** out);
Get the SIM card ICCID.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_get_subscriber_id
int tapi_sim_get_subscriber_id(tapi_context context, int slot_id, char** out);
Get the subscriber identity (IMSI).
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
Event Subscription
tapi_sim_register
int tapi_sim_register(tapi_context context, int slot_id, tapi_indication_msg msg, void* user_obj, tapi_async_function p_handle);
Register a SIM event callback.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).msgMessage content.user_objUser object pointer.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_unregister
int tapi_sim_unregister(tapi_context context, int watch_id);
Unregister a SIM event callback.
Parameters:
contextTelephony context handle.watch_idWatch ID (used to cancel the subscription).
Returns:
Returns 0 on success, or a negative error code on failure.
PIN Management
tapi_sim_change_pin
int tapi_sim_change_pin(tapi_context context, int slot_id, int event_id, char* pin_type, char* old_pin, char* new_pin, tapi_async_function p_handle);
Change the SIM card PIN code.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.pin_typePIN code type.old_pinOld PIN code.new_pinNew PIN code.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_enter_pin
int tapi_sim_enter_pin(tapi_context context, int slot_id, int event_id, char* pin_type, char* pin, tapi_async_function p_handle);
Enter the SIM card PIN code.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.pin_typePIN code type.pinPIN code.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_reset_pin
int tapi_sim_reset_pin(tapi_context context, int slot_id, int event_id, char* puk_type, char* puk, char* new_pin, tapi_async_function p_handle);
Reset the SIM card PIN using PUK code.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.puk_typePUK code type.pukPUK code.new_pinNew PIN code.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_lock_pin
int tapi_sim_lock_pin(tapi_context context, int slot_id, int event_id, char* pin_type, char* pin, tapi_async_function p_handle);
Lock the SIM card PIN.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.pin_typePIN code type.pinPIN code.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_unlock_pin
int tapi_sim_unlock_pin(tapi_context context, int slot_id, int event_id, char* pin_type, char* pin, tapi_async_function p_handle);
Unlock the SIM card PIN.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.pin_typePIN code type.pinPIN code.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
APDU Logical Channel
tapi_sim_open_logical_channel
int tapi_sim_open_logical_channel(tapi_context context, int slot_id, int event_id, unsigned char aid[], int len, tapi_async_function p_handle);
Open a SIM card logical channel.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.aidApplication ID.lenLength.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_close_logical_channel
int tapi_sim_close_logical_channel(tapi_context context, int slot_id, int event_id, int session_id, tapi_async_function p_handle);
Close a SIM card logical channel.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.session_idSession ID.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_transmit_apdu_logical_channel
int tapi_sim_transmit_apdu_logical_channel(tapi_context context, int slot_id, int event_id, int session_id, unsigned char pdu[], int len, tapi_async_function p_handle);
Transmit an APDU command through the logical channel.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.session_idSession ID.pduPDU data.lenLength.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_transmit_apdu_basic_channel
int tapi_sim_transmit_apdu_basic_channel(tapi_context context, int slot_id, int event_id, unsigned char pdu[], int len, tapi_async_function p_handle);
Transmit an APDU command through the basic channel.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.pduPDU data.lenLength.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
UICC Switch
tapi_sim_get_uicc_enablement
int tapi_sim_get_uicc_enablement(tapi_context context, int slot_id, tapi_sim_uicc_app_state* out);
Get the UICC enablement state.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_set_uicc_enablement
int tapi_sim_set_uicc_enablement(tapi_context context, int slot_id, int event_id, int state, tapi_async_function p_handle);
Set the UICC enablement state.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.stateState.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sim_get_sim_invalid
int tapi_sim_get_sim_invalid(tapi_context context, int slot_id, int* out);
Get the SIM card invalid state.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.