leisurelarry
leisurelarry

Reputation: 353

bluez5 ble advertise stops after first connect

We are unclear about the functionality of the leadv command in bluez5. After connecting to a device and disconnecting again it is impossible to reconnect to the same device. Only after calling leadv again it is possible to reconnect.

We have reproduced this behaviour with various platforms (raspberrypi, x86) and various versions of bluez5 (5.15, 5.16, 5.18, 5.21) and bt dongles from broadcom and csr.

Is it possible to reconnect multiple times without readvertising?

bluetoothd with gatt server is running

We issued the following commands

hciconfig hci0 up
hciconfig hci0 noscan
hciconfig hci0 name foo
hciconfig hci0 leadv 0

Upvotes: 4

Views: 1298

Answers (2)

leisurelarry
leisurelarry

Reputation: 353

It turned out that it is actually possible to reenable advertising automatically, but it only seems to work with selected bluez/kernel combinations. We finally had it working with bluez 5.21 and a raspberry pi kernel 3.16 for both broadcom and csr dongles. We haven't tried since with other combinations because we switched to custom hardware (TI CC2451) shortly afterwards.

Upvotes: 0

flarno11
flarno11

Reputation: 143

I am having the exact same issue.

Interesting is that during a disconnect 'hcidump' doesn't show any commands issued by bluez to the bluetooth controller which would indicate that it turned off the advertising.

I am using this workaround to re-enable advertising as soon as a device disconnected:

sudo dbus-monitor --system --profile | grep --line-buffered --only-matching InterfacesRemoved | xargs -n1 -I % sudo /home/pi/bluez/bluez-5.25/tools/hciconfig hci0 leadv 0

Explanations:

  • '--line-buffered' is needed as dbus-monitor does not flush its output
  • '-I %' makes xargs not appending the grep'd "InterfaceRemoved" to the executed command

Upvotes: 3

Related Questions