Raspbian上的Bluetooth LE [英] Bluetooth LE on Raspbian
问题描述
我通过以下配置从源代码安装了bluez-5.15:
I installed bluez-5.15 from source with the following configuration:
$ ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc \
--localstatedir=/var --libexecdir=/lib --disable-systemd
然后我必须手动将gatttool复制到/usr/local/bin目录中
Then I had to copy gatttool manually into the /usr/local/bin dir
$ sudo cp attrib/gatttool /usr/local/bin/
我重新启动了Raspberry Pi,并尝试了以下操作以连接到我的BLE设备:
I rebooted the Raspberry Pi and tried the following to connect to my BLE device:
$ 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连接:
So then I tried to connect with 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]>
我在这里缺少什么-这是配置问题吗?错误是什么意思?
What am I missing here - is this a configuration issue? What do the errors mean?
推荐答案
首先,我与一位同事讨论了我的配置,并为Raspbian(或更具体地说,是Debian)推荐了以下配置设置:
First off, I spoke with a colleague about my configuration and for Raspbian (or more specifically, Debian) he recommended the following configuration settings:
./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地址标志设置为随机".见下文:
Afterward, upon further inspection, here is how I was able to successfully connect. So what was happening was that the device I was trying to connect to (an NRF-based BLE device) required the LE address flag to be set to 'random'. See below:
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
Huzzah!另外,可能需要将安全级别设置为低于高级别:
Huzzah! Also, there may be a need to set the security level to something lower than high:
[EA:FB:B5:CE:B0:13][LE]> sec-level medium
这篇关于Raspbian上的Bluetooth LE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!