树莓派端的蓝牙操作
首先利用ssh登录树莓派(假设用户名为pi)
ssh pi@xxx.xxx.xxx.xxx
更新软件源、软件包等相关操作:
sudo apt-get update
sudo apt-get upgrade
查看蓝牙信息
sudo bluetoothctl
显示如下信息,其中B8:27:EB:19:55:E7就是树莓派的蓝牙地址
[NEW] Controller B8:27:EB:19:55:E7 raspberrypi [default]
输入scan on命令进行扫描
找到和手机相关的设备信息,如下:
[NEW] Device C0:9F:05:49:99:2C OPPO R9m
C0:9F:05:49:99:2C就是手机的蓝牙地址 接下来即可进行配对
蓝牙配对
power on
agent on
pair C0:9F:05:49:99:2C
但是返回信息里边显示失败:
Attempting to pair with C0:9F:05:49:99:2C
[CHG] Device C0:9F:05:49:99:2C Connected: yes
Request confirmation
[agent] Confirm passkey 439499 (yes/no): yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device C0:9F:05:49:99:2C Connected: no
返回手机的蓝牙设置界面,再次执行配对,出现是否允许配对时选择确定即可
Attempting to pair with C0:9F:05: