4

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? :(

Jolle
  • 1,336
  • 5
  • 24
  • 36
  • This link will help you: http://stackoverflow.com/questions/15657007/bluetooth-low-energy-listening-for-notifications-indications-in-linux . As per the post, you need to use gatttool -b
    -I
    – aksonlyaks Oct 26 '16 at 12:23
  • a bit late for a reply...Every time they update bluez/bluetooth kernel they break something else. I believe when you use gatttool the kernel gets involved in the connection and does a lot of other stuff, but when you use hcitool it does a hci command. – mw. Aug 11 '17 at 15:14

1 Answers1

0

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
Abhishek Dwivedi
  • 6,557
  • 3
  • 15
  • 20
  • Thanks for advice. But Do you have ideal step for hcitool for connecting the ble device. So I can simply follow that steps and if I get problem I need to debug but the steps are ideal so should not confuse in steps. – chaitanya sonagara Jul 15 '20 at 05:08