Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 407
leisurelarry Avatar asked Oct 23 '25 14:10

leisurelarry


1 Answers

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
like image 51
flarno11 Avatar answered Oct 27 '25 00:10

flarno11