linux – Raspbian上的蓝牙LE
发布时间:2020-12-14 01:36:21 所属栏目:Linux 来源:网络整理
导读:我从源代码安装了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/gattt
我从源代码安装了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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |