[ English | 简体中文 ]
Bluetooth HFP API
openvela Bluetooth HFP (Hands-Free Profile) interface, supporting Bluetooth telephony functionality.
Header files: #include "bt_hfp.h", #include "bt_hfp_hf.h", #include "bt_hfp_ag.h"
openvela Implementation Notes
- Dual-role support: HF (Hands-Free unit) and AG (Audio Gateway)
- Features: Answer/hang up calls, volume control, voice recognition, phonebook access
Synchronous Interfaces
bt_hfp_hf_unregister_callbacks
bool bt_hfp_hf_unregister_callbacks(bt_instance_t* ins, void* cookie);
Unregister callback functions and stop receiving state change notifications.
Parameters:
cookieUser context.insBluetooth client instance.
Returns:
Returns true on success, or false on failure.
bt_hfp_hf_is_connected
bool bt_hfp_hf_is_connected(bt_instance_t* ins, bt_address_t* addr);
Check whether the HFP HF profile is connected to the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns true if connected, or false otherwise.
bt_hfp_hf_is_audio_connected
bool bt_hfp_hf_is_audio_connected(bt_instance_t* ins, bt_address_t* addr);
Check whether the SCO audio connection is established with the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns true if audio is connected, or false otherwise.
bt_hfp_hf_get_connection_state
profile_connection_state_t bt_hfp_hf_get_connection_state(bt_instance_t* ins, bt_address_t* addr);
Get the current HFP HF connection state with the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns the current profile connection state.
bt_hfp_hf_connect
bt_status_t bt_hfp_hf_connect(bt_instance_t* ins, bt_address_t* addr);
Initiate an HFP HF connection to a remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_disconnect
bt_status_t bt_hfp_hf_disconnect(bt_instance_t* ins, bt_address_t* addr);
Disconnect the HFP HF connection from a remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_set_connection_policy
bt_status_t bt_hfp_hf_set_connection_policy(bt_instance_t* ins, bt_address_t* addr, connection_policy_t policy);
Set the HFP HF connection policy for a remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.policyConnection policy value.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_connect_audio
bt_status_t bt_hfp_hf_connect_audio(bt_instance_t* ins, bt_address_t* addr);
Establish a SCO audio connection with a remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_disconnect_audio
bt_status_t bt_hfp_hf_disconnect_audio(bt_instance_t* ins, bt_address_t* addr);
Disconnect the SCO audio connection from a remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_start_voice_recognition
bt_status_t bt_hfp_hf_start_voice_recognition(bt_instance_t* ins, bt_address_t* addr);
Start voice recognition on the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_stop_voice_recognition
bt_status_t bt_hfp_hf_stop_voice_recognition(bt_instance_t* ins, bt_address_t* addr);
Stop voice recognition on the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_dial
bt_status_t bt_hfp_hf_dial(bt_instance_t* ins, bt_address_t* addr, const char* number);
Initiate a call via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.numberPhone number to dial.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_dial_memory
bt_status_t bt_hfp_hf_dial_memory(bt_instance_t* ins, bt_address_t* addr, uint32_t memory);
Dial a number stored in memory via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.memoryMemory location index.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_redial
bt_status_t bt_hfp_hf_redial(bt_instance_t* ins, bt_address_t* addr);
Redial the last dialed number via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_accept_call
bt_status_t bt_hfp_hf_accept_call(bt_instance_t* ins, bt_address_t* addr, hfp_call_accept_t flag);
Accept an incoming call via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.flagCall accept flag.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_reject_call
bt_status_t bt_hfp_hf_reject_call(bt_instance_t* ins, bt_address_t* addr);
Reject an incoming call via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_hold_call
bt_status_t bt_hfp_hf_hold_call(bt_instance_t* ins, bt_address_t* addr);
Hold the current call via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_terminate_call
bt_status_t bt_hfp_hf_terminate_call(bt_instance_t* ins, bt_address_t* addr);
Terminate the current call via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_control_call
bt_status_t bt_hfp_hf_control_call(bt_instance_t* ins, bt_address_t* addr, hfp_call_control_t chld, uint8_t index);
Control call state via HFP CHLD command.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.chldCHLD command type.indexCall index.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_query_current_calls
bt_status_t bt_hfp_hf_query_current_calls(bt_instance_t* ins, bt_address_t* addr, hfp_current_call_t** calls, int* num, bt_allocator_t allocator);
Query the status of all current calls (CLCC).
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.callsOutput parameter, stores the call information array.numOutput parameter, stores the number of calls.allocatorMemory allocator function.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_send_at_cmd
bt_status_t bt_hfp_hf_send_at_cmd(bt_instance_t* ins, bt_address_t* addr, const char* cmd);
Send a custom AT command to the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.cmdAT command string.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_update_battery_level
bt_status_t bt_hfp_hf_update_battery_level(bt_instance_t* ins, bt_address_t* addr, uint8_t level);
Update the local battery level information to the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.levelBattery level value.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_volume_control
bt_status_t bt_hfp_hf_volume_control(bt_instance_t* ins, bt_address_t* addr, hfp_volume_type_t type, uint8_t volume);
Control the volume on the remote device via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.typeVolume type (speaker or microphone).volumeVolume level.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_send_dtmf
bt_status_t bt_hfp_hf_send_dtmf(bt_instance_t* ins, bt_address_t* addr, char dtmf);
Send a DTMF tone via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.dtmfDTMF key character.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_hf_get_subscriber_number
bt_status_t bt_hfp_hf_get_subscriber_number(bt_instance_t* ins, bt_address_t* addr);
Get the subscriber number from the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
bt_hfp_hf_query_current_calls_with_callback
bt_status_t bt_hfp_hf_query_current_calls_with_callback(bt_instance_t* ins, bt_address_t* addr);
Query the status of all current calls (CLCC), with results returned via callback.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
bt_hfp_ag_unregister_callbacks
bool bt_hfp_ag_unregister_callbacks(bt_instance_t* ins, void* cookie);
Unregister callback functions and stop receiving state change notifications.
Parameters:
cookieUser context.insBluetooth client instance.
Returns:
Returns true on success, or false on failure.
bt_hfp_ag_is_connected
bool bt_hfp_ag_is_connected(bt_instance_t* ins, bt_address_t* addr);
Check whether the HFP AG profile is connected to the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns true if connected, or false otherwise.
bt_hfp_ag_is_audio_connected
bool bt_hfp_ag_is_audio_connected(bt_instance_t* ins, bt_address_t* addr);
Check whether the SCO audio connection is established with the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns true if audio is connected, or false otherwise.
bt_hfp_ag_get_connection_state
profile_connection_state_t bt_hfp_ag_get_connection_state(bt_instance_t* ins, bt_address_t* addr);
Get the current HFP AG connection state with the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns the current profile connection state.
bt_hfp_ag_connect
bt_status_t bt_hfp_ag_connect(bt_instance_t* ins, bt_address_t* addr);
Initiate an HFP AG connection to a remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_disconnect
bt_status_t bt_hfp_ag_disconnect(bt_instance_t* ins, bt_address_t* addr);
Disconnect the HFP AG connection from a remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_connect_audio
bt_status_t bt_hfp_ag_connect_audio(bt_instance_t* ins, bt_address_t* addr);
Establish a SCO audio connection with a remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_disconnect_audio
bt_status_t bt_hfp_ag_disconnect_audio(bt_instance_t* ins, bt_address_t* addr);
Disconnect the SCO audio connection from a remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_start_virtual_call
bt_status_t bt_hfp_ag_start_virtual_call(bt_instance_t* ins, bt_address_t* addr);
Start a virtual call on the AG side.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_stop_virtual_call
bt_status_t bt_hfp_ag_stop_virtual_call(bt_instance_t* ins, bt_address_t* addr);
Stop a virtual call on the AG side.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_start_voice_recognition
bt_status_t bt_hfp_ag_start_voice_recognition(bt_instance_t* ins, bt_address_t* addr);
Start voice recognition on the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_stop_voice_recognition
bt_status_t bt_hfp_ag_stop_voice_recognition(bt_instance_t* ins, bt_address_t* addr);
Stop voice recognition on the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_phone_state_change
bt_status_t bt_hfp_ag_phone_state_change(bt_instance_t* ins, bt_address_t* addr, uint8_t num_active, uint8_t num_held, hfp_ag_call_state_t call_state, hfp_call_addrtype_t type, const char* number, const char* name);
Notify the remote device of a phone state change (incoming call, active call, hang up, etc.).
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.num_activeNumber of active calls.num_heldNumber of held calls.call_stateCall state.typeAddress type.numberPhone number.nameCaller name.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_notify_device_status
bt_status_t bt_hfp_ag_notify_device_status(bt_instance_t* ins, bt_address_t* addr, hfp_network_state_t network, hfp_roaming_state_t roam, uint8_t signal, uint8_t battery);
Notify the remote device of the current device status.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.networkNetwork state.roamRoaming state.signalSignal strength.batteryBattery level.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_volume_control
bt_status_t bt_hfp_ag_volume_control(bt_instance_t* ins, bt_address_t* addr, hfp_volume_type_t type, uint8_t volume);
Control the volume on the remote device via HFP.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.typeVolume type (speaker or microphone).volumeVolume level.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_send_at_command
bt_status_t bt_hfp_ag_send_at_command(bt_instance_t* ins, bt_address_t* addr, const char* at_command);
Send an AT command to the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.at_commandAT command string.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_send_vendor_specific_at_command
bt_status_t bt_hfp_ag_send_vendor_specific_at_command(bt_instance_t* ins, bt_address_t* addr, const char* command, const char* value);
Send a vendor-specific AT command to the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.commandVendor-specific command.valueCommand value.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_send_clcc_response
bt_status_t bt_hfp_ag_send_clcc_response(bt_instance_t* ins, bt_address_t* addr, uint32_t index, hfp_call_direction_t dir, hfp_ag_call_state_t state, hfp_call_mode_t mode, hfp_call_mpty_type_t mpty, hfp_call_addrtype_t type, const char* number);
Send a CLCC response to the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.indexCall index.dirCall direction (incoming/outgoing).stateCall state.modeCall mode.mptyWhether the call is a multiparty call.typeAddress type.numberPhone number.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.
bt_hfp_ag_send_cind_response
bt_status_t bt_hfp_ag_send_cind_response(bt_instance_t* ins, bt_address_t* addr, hfp_network_state_t network, hfp_call_t call, hfp_callheld_t call_held, hfp_callsetup_t call_setup, uint8_t signal, hfp_roaming_state_t roam, uint8_t battery);
Send a CIND response to the remote device.
Parameters:
insBluetooth client instance.addrBluetooth address of the remote device.networkNetwork state.callCall information.call_heldNumber of held calls.call_setupCall setup state.signalSignal strength.roamRoaming state.batteryBattery level.
Returns:
Returns BT_STATUS_SUCCESS on success, or an error code on failure.