[ English | 简体中文 ]
Data Connection API
Cellular data connection management.
Header file: #include <tapi_data.h>
openvela Implementation Notes
- APN context: Manage APN configurations (add/remove/edit/query) via the
tapi_data_*_apn_contextseries of interfaces - On-demand connection:
tapi_data_request_network/tapi_data_release_networkcontrols data network establishment and release - Roaming control: Explicitly toggle data roaming via
tapi_data_enable_roaming - SIM identification: Operations involving a specific SIM use the
slot_idparameter; the default data SIM is set viatapi_data_set_default_slot - State subscription:
tapi_data_register/tapi_data_unregisterfor registering/unregistering state change events
APN Configuration Management
tapi_data_load_apn_contexts
int tapi_data_load_apn_contexts(tapi_context context, int slot_id, int event_id, tapi_async_function p_handle);
Load APN configurations.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_add_apn_context
int tapi_data_add_apn_context(tapi_context context, int slot_id, int event_id, tapi_data_context* apn, tapi_async_function p_handle);
Add an APN configuration.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.apnAccess Point Name (APN) configuration.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_remove_apn_context
int tapi_data_remove_apn_context(tapi_context context, int slot_id, int event_id, tapi_data_context* apn, tapi_async_function p_handle);
Remove an APN configuration.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.apnAccess Point Name (APN) configuration.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_edit_apn_context
int tapi_data_edit_apn_context(tapi_context context, int slot_id, int event_id, tapi_data_context* apn, tapi_async_function p_handle);
Edit an APN configuration.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.apnAccess Point Name (APN) configuration.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_reset_apn_contexts
int tapi_data_reset_apn_contexts(tapi_context context, int slot_id, int event_id, tapi_async_function p_handle);
Reset APN configurations to defaults.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
Data Network Status
tapi_data_is_registered
int tapi_data_is_registered(tapi_context context, int slot_id, bool* out);
Query whether the data network is registered.
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_data_is_data_emergency_only
int tapi_data_is_data_emergency_only(tapi_context context, int slot_id, bool* out);
Query whether the data connection is emergency-only.
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_data_get_network_type
int tapi_data_get_network_type(tapi_context context, int slot_id, tapi_network_type* out);
Get the current network type.
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_data_is_data_roaming
int tapi_data_is_data_roaming(tapi_context context, int slot_id, bool* out);
Query whether data roaming is active.
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.
Data Connection Control
tapi_data_request_network
int tapi_data_request_network(tapi_context context, int slot_id, const char* type);
Request to establish a data connection.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).typeType.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_release_network
int tapi_data_release_network(tapi_context context, int slot_id, const char* type);
Release a data connection.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).typeType.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_get_data_connection_list
int tapi_data_get_data_connection_list(tapi_context context, int slot_id, int event_id, tapi_async_function p_handle);
Get the data connection list.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
Preferred APN
tapi_data_set_preferred_apn
int tapi_data_set_preferred_apn(tapi_context context, int slot_id, tapi_data_context* apn);
Set the preferred APN.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).apnAccess Point Name (APN) configuration.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_get_preferred_apn
int tapi_data_get_preferred_apn(tapi_context context, int slot_id, char** out);
Get the preferred APN.
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.
Data Switch
tapi_data_enable_data
int tapi_data_enable_data(tapi_context context, bool enabled);
Enable or disable cellular data.
Parameters:
contextTelephony context handle.enabledWhether to enable.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_get_enabled
int tapi_data_get_enabled(tapi_context context, bool* out);
Query whether cellular data is enabled.
Parameters:
contextTelephony context handle.outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
Roaming Control
tapi_data_enable_roaming
int tapi_data_enable_roaming(tapi_context context, bool enabled);
Enable or disable data roaming.
Parameters:
contextTelephony context handle.enabledWhether to enable.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_get_roaming_enabled
int tapi_data_get_roaming_enabled(tapi_context context, bool* out);
Query whether data roaming is enabled.
Parameters:
contextTelephony context handle.outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
Default Slot and Authorization
tapi_data_set_default_slot
int tapi_data_set_default_slot(tapi_context context, int slot_id);
Set the default data SIM card slot.
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_data_get_default_slot
int tapi_data_get_default_slot(tapi_context context, int* out);
Get the default data SIM card slot.
Parameters:
contextTelephony context handle.outOutput parameter.
Returns:
Returns 0 on success, or a negative error code on failure.
tapi_data_set_data_allow
int tapi_data_set_data_allow(tapi_context context, int slot_id, int event_id, bool allowed, tapi_async_function p_handle);
Set data permission for the specified slot.
Parameters:
contextTelephony context handle.slot_idSIM card slot ID (0 or 1).event_idEvent ID for callback matching.allowedWhether to allow.p_handleAsynchronous callback function.
Returns:
Returns 0 on success, or a negative error code on failure.
Event Subscription
tapi_data_register
int tapi_data_register(tapi_context context, int slot_id, tapi_indication_msg msg, void* user_obj, tapi_async_function p_handle);
Register a data state change 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_data_unregister
int tapi_data_unregister(tapi_context context, int watch_id);
Unregister a data state change 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.