bluetoothctl命令

原文链接:https://www.cnblogs.com/god-of-death/p/18297744

查看支持的命令

bluetoothctl -h

进入 bluetooth 环境后输命令不需再加bluetoothctl

img

查看是否有蓝牙设备

bluetoothctl list // 相当于 hciconfig -a

启动蓝牙设备

bluetoothctl power on // 相当于 hciconfig hci0 up

不启动直接调用 glib 接口会出现:

error(StartDiscovery): GDBus.Error:org.bluez.Error.NotReady: Resource Not Ready 

查看控制器信息

bluetoothctl show

可查看 MAC 地址、是否广播、广播的设备名、是否扫描设备等

img

扫描附近广播的蓝牙设备

bluetoothctl scan on

设置蓝牙可被发现

bluetoothctl discoverable on

设置蓝牙可被配对

bluetoothctl pairable on

查看bluetoothd守护进程打印的错误 log

cat /var/log/messages
tail -n 50 /var/log/messages

img

和设备配对(不知道什么时候需要发这个指令)

配对前需要先 scan

bluetoothctl pair A4:C1:38:10:09:2C

连接设备

配对前需要先 scan,确保要连接的设备出现在 devices 下,不需要 pair,直接 connect

连接成功可在目录 /var/lib/bluetooth/本机MAC/远端MAC 查看远端蓝牙设备提供的各种服务

img

设备连接前状态

img

设备连接后状态

img

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值