[ English | 简体中文 ]
SMS Management API
SMS sending and receiving.
Header: #include <tapi_sms.h>
openvela Implementation Notes
- Text and Data SMS:
send_messagesends text SMS,send_data_messagesends binary PDU - Service Center Address: Configure the carrier SMS gateway via
set_service_center_address/get_service_center_address - Delivery Report: Toggle delivery reports with
enable_delivery_report - SIM Card Storage: Provides
get_all_messages_from_sim/copy_message_to_sim/delete_message_from_simto operate on SMS stored on the SIM card - Event Subscription:
tapi_sms_registerlistens for incoming/outgoing message events
Sending SMS
tapi_sms_send_message
int tapi_sms_send_message(tapi_context context, int slot_id, int sms_id, char* number, char* text, int event_id, tapi_async_function p_handle);
Sends a text SMS message.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).sms_idSMS message ID.numberPhone number.textText content.event_idEvent ID for callback matching.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sms_send_data_message
int tapi_sms_send_data_message(tapi_context context, int slot_id, int sms_id, char* dest_addr, unsigned int port, char* text, int event_id, tapi_async_function p_handle);
Sends a data SMS message.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).sms_idSMS message ID.dest_addrDestination number.portPort number.textText content.event_idEvent ID for callback matching.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
Service Center and Delivery Report
tapi_sms_set_service_center_address
bool tapi_sms_set_service_center_address(tapi_context context, int slot_id, char* number);
Sets the SMSC (Short Message Service Center) address.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).numberSMSC phone number.
Returns:
Returns true on success, false on failure.
tapi_sms_get_service_center_address
int tapi_sms_get_service_center_address(tapi_context context, int slot_id, char** number);
Gets the SMSC (Short Message Service Center) address.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).numberPointer to receive the SMSC phone number.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sms_enable_delivery_report
int tapi_sms_enable_delivery_report(tapi_context context, int slot_id, bool enable);
Enables or disables SMS delivery reports.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).enableWhether to enable delivery reports.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sms_get_delivery_report_status
int tapi_sms_get_delivery_report_status(tapi_context context, int slot_id, bool* out);
Gets the current delivery report status.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).outOutput parameter to receive the status.
Returns:
Returns 0 on success, or a negative error code on failure.
SIM Card SMS Storage
tapi_sms_get_all_messages_from_sim
int tapi_sms_get_all_messages_from_sim(tapi_context context, int slot_id, tapi_message_list* list, tapi_async_function p_handle);
Retrieves all SMS messages stored on the SIM card.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).listMessage list to populate.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sms_copy_message_to_sim
int tapi_sms_copy_message_to_sim(tapi_context context, int slot_id, char* number, char* text, char* send_time, int type);
Copies an SMS message to the SIM card.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).numberPhone number.textText content.send_timeSend time.typeMessage type.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sms_delete_message_from_sim
int tapi_sms_delete_message_from_sim(tapi_context context, int slot_id, int index);
Deletes an SMS message from the SIM card.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).indexMessage index on the SIM card.
Returns:
Returns 0 on success, or a negative error code on failure.
Event Subscription and Default Slot
tapi_sms_register
int tapi_sms_register(tapi_context context, int slot_id, tapi_indication_msg msg, void* user_obj, tapi_async_function p_handle);
Registers for SMS event notifications.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).msgIndication message type.user_objUser object pointer.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sms_unregister
int tapi_sms_unregister(tapi_context context, int watch_id);
Unregisters from SMS event notifications.
Parameters:
contextTelephony context handle.watch_idWatch ID (used to cancel the subscription).
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sms_set_default_slot
int tapi_sms_set_default_slot(tapi_context context, int slot_id);
Sets the default SIM slot for SMS.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_sms_get_default_slot
int tapi_sms_get_default_slot(tapi_context context, int* out);
Gets the default SIM slot for SMS.
Parameters:
contextTelephony context handle.outOutput parameter to receive the default slot ID.
Returns:
Returns 0 on success, or a negative error code on failure.