Jolle
Jolle

Reputation: 1426

Can connect to BLE device with hcitool but not gatttool?

I am trying to connect to a bluetooth low energy device from my PC and Raspberry Pi3 in a QT application, but I get this QT error when trying to connect:

qt.bluetooth.bluez: Unknown l2cp socket error:  QBluetoothSocket::UnknownSocketError "Transport endpoint is not connected"
qt.bluetooth.bluez: void QBluetoothSocketPrivate::_q_readNotify() 14 error: -1 "Resource temporarily unavailable"
qt.bluetooth.bluez: Unknown l2cp socket error:  QBluetoothSocket::UnknownSocketError "Resource temporarily unavailable"

I don't think its QT, I suspect bluez is the problem. I found out that Linux can find the device with:

sudo hcitool lescan

And it can connect through:

sudo hcitool lecc <address>

So that's good. Problem is that as soon as I try with gatttool (which must be the eqavelent of what QT is trying to do), I get the following:

pi@user:~$ sudo gatttool -I 
[                 ][LE]> connect <address>
Attempting to connect to <address>
Error: connect error: Transport endpoint is not connected (107)
[<address>][LE]> 

The results are the some on both PC and Raspberry. bluez version on PC is 5.37 and on raspberry 5.23.

Any ideas? :(

Upvotes: 5

Views: 9742

Answers (1)

Abhishek Dwivedi
Abhishek Dwivedi

Reputation: 7416

Using Gatttool:

Try with type random and most possibly it will work if there is no issue.

sudo gatttool -I -t random

You can bind to Bluetooth address in a single command itself.

sudo gatttool -I -t random -b <mac address>

Using Hcitool:

sudo hcitool lecc --random <mac address>

You can see the detailed HCI sniff log in another terminal while you are executing

sudo hcidump -X

Upvotes: 0

Related Questions