BT Hands-Free HF Role Example
Source code path: example/bt/hfp
Supported Platforms
eh-lb52x
eh-lb56x
eh-lb58x
Overview
HFP_HF call status information acquisition demo:
Hands-free profile related AT command usage
Example Usage
The example enables Bluetooth by default on startup and is controlled through FINSH commands:
Search for Bluetooth devices Use the command hfp_cmd start_inquiry to search for mobile phone Bluetooth devices. Discovered devices will be printed in the form of logs “device [%s] searched” and “device COD is [%d], addr is xx:xx:xx:xx:xx:xx”.
Stop searching for Bluetooth devices Use the command hfp_cmd stop_inquiry to stop searching for mobile phone Bluetooth devices.
Connect to Bluetooth devices Use the command hfp_cmd hfp_connect [addr] to connect, where addr should be copied from the device address (xx:xx:xx:xx:xx:xx) found above. If you already know the mobile phone Bluetooth device address, you can connect directly without searching for Bluetooth devices. Connection result print: “HFP HF connected”
Disconnect from Bluetooth devices Use the command hfp_cmd hfp_disconnect [addr] to disconnect, where addr should be copied from the device address (xx:xx:xx:xx:xx:xx) found above. Disconnection result print: “HFP HF disconnected”
Query local phone number Use the command hfp_cmd local_phone_number to query the local phone number. When the local number is received, there will be a print “the remote phone local number + phone number”. Number acquisition completion print: “get remote local phone number complete”
Make a call Use the command hfp_cmd make_call [phone_number] to make a call. Call result print: “make a call complete “ + result
Call status notification After a successful call, call status changes will be received, with corresponding prints: “the remote phone call status type “ + type (callsetup) + status (2/3) outgoing call
Hang up call Use the command hfp_cmd handup_call to hang up a call. Hang up result print: “hangup a call complete “ + result, followed by call status notification
Answer call Use the command hfp_cmd answer_call to answer a call. Answer result print: “answer a call complete “ + result, followed by call status notification
Connect call audio Use the command hfp_cmd audio_connect to connect call audio. Successful call audio establishment print: “HFP HF audio_connected”
Disconnect call audio Use the command hfp_cmd audio_disconnect to disconnect call audio. Successful call audio disconnection print: “HFP HF audio_disconnected”
Adjust remote Bluetooth device volume Use the command hfp_cmd volume_control [val] to implement this, where val is valid between 0-15. Call volume adjustment completion print: “change volume value complete”
Hardware Requirements
Before running this example, you need to prepare:
One development board supported by this example (Supported Platforms).
Compilation and Flashing
Switch to the example project directory and run the scons command to compile:
> scons --board=eh-lb525 -j32
Switch to the example project/build_xx
directory and run uart_download.bat
, select the port as prompted to download:
$ ./uart_download.bat
Uart Download
please input the serial port num:5
For detailed compilation and download steps, please refer to the relevant introduction in Quick Start.
Expected Results
After the example starts: Mobile phone actively connects to device/device connects to mobile phone through commands. When mobile phone makes a call or device makes a call, mobile phone call status information can be obtained.
Exception Diagnosis
Reference Documentation
Update History
Version |
Date |
Release Notes |
---|---|---|
0.0.1 |
01/2025 |
Initial version |