user1381
user1381

Reputation: 526

Cannot disconnect BLE connection

From time to time, I end up with a Bluetooth Low Energy connection in a strange state from which I cannot disconnect:

$ sudo hcitool con
Connections:
    < LE F1:11:52:84:77:25 handle 70 state 1 lm MASTER

$ sudo hcitool ledc F1:11:52:84:77:25
Could not disconnect: Input/output error

I can't get any information on the connection either:

$ sudo hcitool leinfo F1:11:52:84:77:25
Requesting information ...
Could not create connection: Input/output error

I can't re-connect either (checked the code: the error comes down from l2cap_connect() where it tries to open a socket to this remote address and fails to).

$ sudo gatttool -t random -b F1:11:52:84:77:25 -I
[F1:11:52:84:77:25][LE]> connect
Attempting to connect to F1:11:52:84:77:25
Error: connect: Device or resource busy (16)

The only solution I have so far is to unplug and replug my BLE dongle ;( but that's not very satisfactory...

Is there a command or something to erase that buggy connection?

This is on Linux (Mint 18), and using bluez 5.37.

Upvotes: 2

Views: 3025

Answers (2)

Ahmed_Saeed
Ahmed_Saeed

Reputation: 31

sudo hcitool ledc <handle>

ledc takes handle as argument not the mac.

type sudo hcitool con to find out the handle of the connection you want to disconnect. Then use that handle as argument of ledc.

Example:

sudo hcitool con

Output:

connections:
<LE XX:XX:XX:XX:XX:XX handle 64 state 1 lm MASTER

To disconnect this connection type:

sudo hcitool ledc 64

Upvotes: 3

lairkers
lairkers

Reputation: 26

I can confirm this problem on Ubuntu 14.04 with BlueZ 5.40 and 5.43.

Workaround 1: Disconnect from the other side.

Workaround 2: Use

sudo hciconfig hciX down
sudo hciconfig hciX up

where hciX is your controller (e.g. hci0). Unfortunately, this will remove all connections.

Upvotes: 1

Related Questions