树莓派3B+连接蓝牙设备

参考:
http://shumeipai.nxez.com/2016/07/10/raspberry-pi-3-how-to-use-bluetooth.html
https://blog.csdn.net/guzhong10/article/details/78574577
一、连接蓝牙音箱

  1. 升级安装蓝牙相关软件包
    sudo apt-get update
    sudo apt-get upgrade -y
    sudo apt-get dist-upgrade -y
    sudo apt-get install pi-bluetooth bluez bluez-firmware blueman

  2. 添加pi用户到蓝牙组
    sudo usermod -G bluetooth -a pi

  3. 重启
    sudo reboot

  4. 使用命令打开蓝牙
    pi@raspberrypi:/ $ sudo bluetoothctl
    [bluetooth]#list
    Controller B8:27:EB:3D:15:E9 raspberrypi [default]
    [bluetooth]# scan on
    Discovery started
    [CHG] Device 5F:FC:4E:B0:EA:59 RSSI: -97
    [NEW] Device 42:29:9A:3B:75:E6 42-29-9A-3B-75-E6
    [bluetooth]# devices
    Device 30:21:4F:54:4D:8E Newmine
    Device 72:D7:02:62:CE:A0 72-D7-02-62-CE-A0
    Device 5F:FC:4E:B0:EA:59 5F-FC-4E-B0-EA-59
    Device E4:A7:C5:C8:55:F5 HUAWEI Mate 10 Pro
    Device 42:29:9A:3B:75:E6 42-29-9A-3B-75-E6
    [bluetooth]# pair 30:21:4F:54:4D:8E
    Attempting to pair with 30:21:4F:54:4D:8E
    Failed to pair: org.bluez.Error.AlreadyExists(已配对成功过,如果是初次配对是显示成功的信息)
    [bluetooth]# trust 30:21:4F:54:4D:8E
    Changing 30:21:4F:54:4D:8E trust succeeded
    [bluetooth]# connect 30:21:4F:54:4D:8E
    Attempting to connect to 30:21:4F:54:4D:8E
    [CHG] Device 30:21:4F:54:4D:8E Connected: yes
    Connection successful
    [CHG] Device 5F:FC:4E:B0:EA:59 RSSI: -86
    [CHG] Device 30:21:4F:54:4D:8E ServicesResolved: yes
    [Newmine]#quit

疑问:
与手机mate10 Pro可以配对成功,但是无法连接成功。在手机的蓝牙设置菜单中,显示raspberrypi为已配对的设备,但是点击连接无反应。
[bluetooth]# trust E4:A7:C5:C8:55:F5
Changing E4:A7:C5:C8:55:F5 trust succeeded
[CHG] Device 5F:FC:4E:B0:EA:59 RSSI: -96
[bluetooth]# connect E4:A7:C5:C8:55:F5
Attempting to connect to E4:A7:C5:C8:55:F5
Failed to connect: org.bluez.Error.Failed

你可能感兴趣的:(树莓派学习)