zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.89k stars 6.63k forks source link

Bluetooth: Host: bt_le_set_auto_conn() doesn't work #81230

Open ivaniushkov opened 6 days ago

ivaniushkov commented 6 days ago

Describe the bug Zephyr Host has a function called bt_le_set_auto_conn() which is supposed to auto-reconnect when the ACL connection disconnected. Unfortunately, the function doesn't work as expected. There are at least two issues with the current implementation of this function:

To Reproduce I modified samples/bluetooth/central sample to reproduce the issue. The changes include: removed disconnection, added bt_le_set_auto_conn() to device_found(), increased RSSI to -30dBm to connect only to the device located very close. Steps to reproduce the behavior:

  1. cd central_auto
  2. west build -bnrf52840dk_nrf52840
  3. west flash

It required additional device to be used as a Peripheral

I was using zephyr v3.7.99 but I think the bug is still presented on the v4.0

Expected behavior The following messages are expected in the sample output:

Device found: 52:84:E1:BC:96:03 (random) (RSSI -30)
Connected: 52:84:E1:BC:96:03 (random)
Disconnected: 52:84:E1:BC:96:03, reason 0x08
Connected: 52:84:E1:BC:96:03 (random)

Observed behavior

Disconnected: 52:84:E1:BC:96:03, reason 0x08

message is never printed when Peripheral is disconnected. It happens because notify_disconnected() is never called. Also, the second Connected: 52:84:E1:BC:96:03 (random) is not printed.

Suggested solution I would suggest to just remove this function because the use-cases are unclear. Also it looks like it didn't work as expected for a long time

central_auto.zip

ivaniushkov commented 6 days ago

bt_conn_le_create_auto() function is similar to bt_le_set_auto_conn() but uses BT_FILTER_ACCEPT_LIST feature. I guess it may have the same problems

jhedberg commented 3 days ago

Bluetooth WG meeting: decided that it should be fine to remove for 4.1, however the removal should follow the documented process for stable API breakage: https://docs.zephyrproject.org/latest/develop/api/api_lifecycle.html#introducing-breaking-api-changes