Bluez BLE Connection Linux
I'm very new to Linux and Bluetooth development and I'm not sure about the difference between sudo hcitool lecc <bdaddr>
and sudo gatttool -b <dbaddr> -I
? I do not request any GATT services; I just want a connection between two devices.
I vaguely follow this widely mentioned in the tutorial and I am considering adapting a method cmd_lecc
in Bluez / tools / hcitool.c, but I cannot connect to my BLE device with hcitool lecc
.
When I connect using gatttool
, I can connect successfully, but when using, it hcitool lecc
returns the error "Connection failed: connection timed out" and no connection to BLE device occurs. However, running sudo hcitool con
to display active connections shows that there is one: "Unknown handle 0 state 2 lm SLAVE". If it was unable to establish a connection, why is it registering the connection as active at hcitool
?
So my question is three times:
- What is the difference between the two teams?
- Could it
gatttool
be suitable for my purpose, or should I decide what doesn't work withhcitool
(after something like this ? - Why
sudo hcitool lecc <bdaddr>
does it partially connect even when it disconnects?
Many thanks.
source to share
hcitool lecc <bdaddr>
creates a connection and returns a handle, but gatttool -b <bdaddr> -I
only opens an interactive terminal with an interface associated with an address but not yet connected. To connect using a command gatttool
, you have to enter connect
which will most likely fail as well.
I would suggest looking at how hcitool
connects to write your own code, since everything is gatttool
just a wrapper around the same process that it uses hcitool
, but its wrapper is not available unless you copy its code.
Finally, descriptor 0, which reports hcitool
, is an invalid descriptor that does not try to connect as, as far as I have seen, all valid descriptors are greater than 0.
source to share