[英]Bluez BLE Connection Linux
I'm very new to Linux and Bluetooth development, and I'm unsure of the difference between sudo hcitool lecc <bdaddr>
and sudo gatttool -b <dbaddr> -I
? 我是Linux和蓝牙开发的新手,我不确定
sudo hcitool lecc <bdaddr>
和sudo gatttool -b <dbaddr> -I
之间的区别? I don't require any of the GATT services; 我不要求任何关贸总协定的服务; I just want a connection between the two devices.
我只想要两个设备之间的连接。
I'm looking at vaguely following this widely referred to tutorial , and am looking at adapting the cmd_lecc
method in Bluez /tools/hcitool.c, but I am unable to connect to my BLE device using hcitool lecc
. 我正在模糊地关注这个广泛引用的教程 ,我正在考虑在Bluez /tools/hcitool.c中调整
cmd_lecc
方法,但是我无法使用hcitool lecc
连接到我的BLE设备。
When I connect using gatttool
, I am able to connect successfully, however using hcitool lecc
returns the error 'Could not create connection: Connection timed out', and no connection is made to the BLE device. 当我使用
gatttool
连接时,我能够成功连接,但是使用hcitool lecc
返回错误'无法创建连接:连接超时',并且没有连接到BLE设备。 However, running sudo hcitool con
to show active connections shows that there is one: 'Unknown handle 0 state 2 lm SLAVE'. 但是,运行
sudo hcitool con
来显示活动连接会显示有一个:'Unknown handle 0 state 2 lm SLAVE'。 If it's failing to make the connection, why is it then registering the connection as active in hcitool
? 如果它没有建立连接,为什么它会在
hcitool
中将连接注册为活动状态?
My question therefore is threefold: 因此,我的问题有三个:
gatttool
be suitable for my purpose, or should I work out what's not working with hcitool
(following something like this ? gatttool
适合我的目的,或者我应该制定出什么不与工作hcitool
(以下像这样 ? sudo hcitool lecc <bdaddr>
partially connect, even when it times out? sudo hcitool lecc <bdaddr>
部分连接,即使它超时? Many thanks. 非常感谢。
hcitool lecc <bdaddr>
creates a connection and returns a handle, while gatttool -b <bdaddr> -I
only opens an interactive terminal with an interface bound to the address but not yet connected. hcitool lecc <bdaddr>
创建一个连接并返回一个句柄,而gatttool -b <bdaddr> -I
只打开一个交互式终端,其接口绑定到该地址但尚未连接。 To connect using the gatttool
command you must then enter connect
, which will most likely also fail. 要使用
gatttool
命令进行connect
,必须输入connect
,这很可能也会失败。
I would suggest looking at how hcitool
connects for writing your own code as all of gatttool
simply is a wrapper around the same process that hcitool
uses, but its wrapper is not available unless you copy its code. 我建议看看
hcitool
如何连接编写自己的代码,因为所有gatttool
只是围绕hcitool
使用的相同进程的包装器,但除非你复制其代码,否则它的包装器不可用。
lastly, the handle 0 that hcitool
is reporting is an invalid handle left from trying to connect, because as far as I've seen all valid handles are greater than 0. 最后,
hcitool
报告的句柄0是尝试连接时留下的无效句柄,因为据我所见,所有有效句柄都大于0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.