Raspbian 上的低功耗蓝牙

2023-12-05

我从源代码安装了 bluez-5.15,配置如下:

$ ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc \
--localstatedir=/var --libexecdir=/lib --disable-systemd

然后我必须手动将 gatttool 复制到 /usr/local/bin 目录中

$ sudo cp attrib/gatttool /usr/local/bin/

我重新启动了 Raspberry Pi 并尝试以下方法连接到我的 BLE 设备:

$ sudo hciconfig hci0 up

$ sudo hcitool lescan
LE Scan ...  
EA:FB:B5:CE:B0:13 DfuTarg

$ sudo hcitool lewladd EA:FB:B5:CE:B0:13

$ sudo hcitool lecc EA:FB:B5:CE:B0:13
Could not create connection: Input/output error

然后我尝试使用 gatttool 连接:

$ gatttool -b EA:FB:B5:CE:B0:13 --interactive
[EA:FB:B5:CE:B0:13][LE]> connect
Attempting to connect to EA:FB:B5:CE:B0:13
Error: connect error: Device or resource busy (16)
[EA:FB:B5:CE:B0:13][LE]>

我在这里缺少什么 - 这是配置问题吗?这些错误是什么意思?


首先,我与一位同事讨论了我的配置,对于 Raspbian(或更具体地说,Debian),他推荐了以下配置设置:

./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-library --with-systemdsystemunitdir=/lib/systemd/system --with-systemduserunitdir=/usr/lib/systemd

后来,经过进一步检查,以下是我能够成功连接的方法。因此,我尝试连接的设备(基于 NRF 的 BLE 设备)需要将 LE 地址标志设置为“随机”。见下文:

gatttool -t random -b EA:FB:B5:CE:B0:13 -I

然后结果是:

[EA:FB:B5:CE:B0:13][LE]> connect
Attempting to connect to EA:FB:B5:CE:B0:13
Connection successful
[EA:FB:B5:CE:B0:13][LE]> characteristics
handle: 0x0002, char properties: 0x0a, char value handle: 0x0003, uuid: 00002a00
-0000-1000-8000-00805f9b34fb

哈扎!此外,可能需要将安全级别设置为低于高:

[EA:FB:B5:CE:B0:13][LE]> sec-level medium
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Raspbian 上的低功耗蓝牙 的相关文章

随机推荐