BeagleBone Black Wireless蓝牙AVRCP:向手机发音乐控制命令连接异常求助
Hey there, let’s tackle this frustrating Bluetooth connection issue you’re facing. I’ve run into similar pairing-then-disconnecting gremlins on Debian Jessie with embedded boards before, so let’s break this down step by step to get your music control commands flowing to your phone.
First, let’s make sure we’re targeting the right Bluetooth protocol: since you only need music control (not audio streaming), we’re dealing with AVRCP (Audio/Video Remote Control Profile). This is often the culprit when pairing works but control connections fail.
Step 1: Verify Essential Packages & Bluetooth Service
Debian Jessie’s default bluez setup might be missing some tools for AVRCP. Let’s install/refresh the necessary packages:
sudo apt-get update && sudo apt-get install bluez-utils bluez-tools
Next, check if the Bluetooth service is running properly (and set to start on boot):
sudo systemctl status bluetooth
If it’s inactive, start it and enable auto-start:
sudo systemctl start bluetooth sudo systemctl enable bluetooth
Step 2: Ensure Your Phone is Trusted (Not Just Paired)
Pairing doesn’t always equal trusted access, which is often why post-pairing connections fail. Use bluetoothctl to fix this:
- Launch the interactive tool:
bluetoothctl - List your paired devices to get your phone’s MAC address (looks like
AA:BB:CC:DD:EE:FF):paired-devices - Mark the phone as trusted:
trust AA:BB:CC:DD:EE:FF - Try connecting directly to the AVRCP service (use the MAC and AVRCP UUID):
connect AA:BB:CC:DD:EE:FF 0000110E-0000-1000-8000-00805F9B34FB
If this works, you’re halfway there. If not, note the error message—we’ll use logs next.
Step 3: Dig Into Bluetooth Logs for Root Cause
The most reliable way to diagnose connection failures is checking the Bluetooth system logs. Open a separate terminal window and run:
sudo journalctl -u bluetooth -f
This streams real-time logs. Now go back to bluetoothctl and try connecting again. Look for errors like:
Authentication failed: Indicates a trust or pairing key issue (re-pair withremove AA:BB:CC:DD:EE:FFthenpairagain)Service not found: Your phone might have AVRCP disabled, or bluez is missing AVRCP support (double-check the package install)Connection timeout: Could be a power-saving issue on the BBB’s Bluetooth adapter
Step 4: Tweak Bluetooth Adapter Settings
Debian Jessie sometimes enables power-saving modes that break post-pairing connections. Let’s disable those:
- Ensure the adapter is active:
sudo hciconfig hci0 up - Disable scanning (which can interfere with persistent connections) and enable secure simple pairing:
sudo hciconfig hci0 noscan sudo hciconfig hci0 sspmode 1 - Edit the main Bluetooth config to enforce classic Bluetooth mode (AVRCP uses classic, not BLE):
Find or add these lines:sudo nano /etc/bluetooth/main.conf
Save and exit, then restart the Bluetooth service:AutoEnable=true ControllerMode=bredrsudo systemctl restart bluetooth
Step 5: Upgrade Bluez (If All Else Fails)
Debian Jessie ships with an older bluez version (around 5.23) which has known post-pairing bugs. We can upgrade using Jessie backports:
- Add the backports repo to your sources:
Add this line:sudo nano /etc/apt/sources.listdeb http://deb.debian.org/debian jessie-backports main - Update and upgrade bluez:
sudo apt-get update sudo apt-get -t jessie-backports install bluez - Restart the Bluetooth service again.
Testing AVRCP Commands (Once Connected)
Once you’ve got a stable connection, test sending a control command using dbus-send (bluez uses D-Bus for control):
- Play:
dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0/dev_AA_BB_CC_DD_EE_FF/player0 org.bluez.MediaPlayer1.Play - Pause:
dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0/dev_AA_BB_CC_DD_EE_FF/player0 org.bluez.MediaPlayer1.Pause
Start with the trust step and log checking—those usually resolve 90% of these issues. Let me know what error messages you see in the logs if you’re still stuck!
内容的提问来源于stack exchange,提问作者DellanX

