Jakeler / ble-serial

"RFCOMM for BLE" a UART over Bluetooth low energy (4+) bridge for Linux, Mac and Windows
https://blog.ja-ke.tech/tags/#bluetooth
MIT License
251 stars 37 forks source link

Bluetooth Connection Timeout. #73

Open chrisjaxy opened 1 year ago

chrisjaxy commented 1 year ago

Additional Context I refer to the instructions to connect to BLE Bluetooth, such as ESP32, WLT8016, but I find that the Bluetooth connection is always disconnected. I grab the logs with hcidump and btmon, and it shows Connection Timeout. This rarely happens when I use bluetoothctl to connect to a Bluetooth device. I wonder if there is any difference between these two connections?

Jakeler commented 1 year ago

It really should not make a difference, both bluetoothctl and ble-serial/bleak utilize the bluez dbus API. They should send practically the same commands. Is there is specific time when the connection breaks? did you also try enabling notifications/indications via bluetoothctl, maybe that causes issues? Otherwise you could check with the super verbose mode -vv or what happens on the bus dbus-monitor --system "destination=org.bluez".

chrisjaxy commented 1 year ago

According to your method, I found these in the ble-serial log

DEBUG | manager.py: received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_01_00_0A_DA_67_25): ['org.bluez.Device1', {'ServicesResolved': <dbus_fast.signature .Variant ('b', False)>, 'Connected': <dbus_fast.signature.Variant ('b', False)>}, []]’

In dbus-monitor, there is no special log for disconnection.

method return time=1669600087.902222 sender=org.freedesktop.DBus -> destination=:1.526 serial=344 reply_serial=22785