bluekitchen / btstack

Dual-mode Bluetooth stack, with small memory footprint.
http://bluekitchen-gmbh.com
Other
1.7k stars 607 forks source link

Bluetooth classic pairing from Pico W HID host to any Android BluetoothHidDevice fails #612

Open Slion opened 3 months ago

Slion commented 3 months ago

Pico W SDK 1.5.1

Bluetooth classic pairing from Pico W HID host to any Android BluetoothHidDevice fails. It works fine when connection is initiated from the Android device. Other HID host such as PCs are known to be able to initiate pairing fine.

Here are the logs when the tablet is not discoverable: pair-fail-pico-to-tab-s8.zip

Here are the logs when the tablet is discoverable: pair-fail-pico-to-tab-s8-visible.zip

Somehow they are quite different.

mringwal commented 3 months ago

Logs are good now, but please post complete logs from start.

pair-fail-pico-tab-s8: looks like remote hast lost the link key - see Authentication Complete Event with "PIN or Key Missing". Please delete local bonding(e.g. with gap_delete_all_link_keys)

pair-fail-pico-tab-s8-visible: authentication works - you get Authentication Complete Event with status 0x00 and Encryption Changed event. There's an unexpected ACL packet which gets dropped by the stack. Then the log stops in the middle of a Information Request. BTstack is supposed to send an L2CAP Information Response... not sure if the Pico crashed here or what happened.

Slion commented 3 months ago

BTstack is supposed to send an L2CAP Information Response... not sure if the Pico crashed here or what happened.

I noticed that when calling hid_host_connect the timer callback I use to perform tasks including blinking the LED is not called anymore until hid_host_disconnect is called. It sounds like your observation could match that behaviour. Something is preventing the event loop to run somehow.

Slion commented 3 months ago

Those are logs of the Pico W trying to connect to Interface on HONOR Magic V2 using hid_host_connect. It hangs until the Android app is sent to the background. Meaning my btstack timer callback that blinks the LED is not called anymore until the Android app is sent to the background. Both devices have bonded already and the connection works when initiated from the Android device.

The weird thing is that as the Pico tries to connect it would cause the phone to connect to the PC. So I unpaired the PC and it would trigger pairing request with the PC. So I unplugged the PC Bluetooth dongle but it would not work any better.

host-connection-fail.zip