Get the App
SLTechnology News&Howtos  ›  Development  › 

How to configure bluetoothctl to connect Bluetooth and play music

Shulou Source: shulou.com Published: 2022-06-03 06:11:40 10月02日 Update

This article mainly introduces "how to configure bluetoothctl to achieve Bluetooth connection and play music". In daily operation, I believe many people have doubts about how to configure bluetoothctl to achieve Bluetooth connection and play music. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions of "how to configure bluetoothctl to achieve Bluetooth connection and play music". Next, please follow the editor to study!

1. Install bluetoothctlsudo apt-get install pi-bluetooth2. Configuration. If the configuration times out, you need to retry sudo hciattach / dev/ttyAMA0 bcm43xx 921600 noflow-

As shown in the following figure, the output Device setup complete indicates that the configuration is successful.

3. Enter bluetoothctlsudo bluetoothctl

As shown in the following figure, the output of Agent registered indicates that it is successful

4. Turn on Bluetooth power on

As shown in the following figure, the output of Changing power on succeeded indicates that it is successful

5. Can be found discoverable on

As shown in the following figure, the output of Changing discoverable on succeeded indicates that it is successful

6. Search for device scan on

As shown in the following figure, the output of Discovery started indicates that it is successful

At this point, you can continue to use settings to discover and connect Bluetooth.

7. Stop searching for device scan off8. Connect the equipment

Once you have found the MAC address of the device to which you want to connect, you can now continue to pair the Raspberry Pi with it.

① in order for Bluetooth to pair the device to the Raspberry Pi, you need to use the following command:

Pair [XX:XX:XX:XX:XX:XX]

Example: connect Xiaomi mobile phone

Pair F4:60:E2:D0:F8:B6

When ② paired the device for the first time, it immediately connected to the device. However, once you are out of the Bluetooth range of Raspberry Pi, you will need to reconnect the device using the following command.

Connect [XX:XX:XX:XX:XX:XX]

③ if you do not want to repair the device, you can use the rust command.

This command works like the other two commands and requires the MAC address of the Bluetooth device you want to trust.

Trust [XX:XX:XX:XX:XX:XX]

After the initial pairing, you can trust the Bluetooth device on the Raspberry Pi.

9. Give it a try.

Install the player:

Installing Sox [Sound eXchange) on Ubuntu is a Swiss Army knife that operates sound files. It can play and convert audio files and add effects. ]:

Sudo apt-get install sox libsox-fmt-all

Libsox-fmt-all contains decoders for mp3 and decoders for other formats.

Play music:

Play Hongyan. MP3 at this point, the study on "how to configure bluetoothctl to connect to Bluetooth and play music" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Device Bluetooth configuration music success command output learning address file more decoder help search utility next two saber sound instance Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux Shulou Technology Docker vpn