-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BLE can't pair to new host after initial pairing #1817
Comments
Interesting observation, thanks for testing and giving a succinct explanation. What has me scratching my head is this:
The BLE pairing information is actually part of the application binary, so when you flash a new app it gets cleared out. So there are no shared keys available immediately after flashing. No comms would then be possible, I imagine. Maybe the PC is assuming the same BLE MAC already has the key and not negotiating a new one... |
This is a very good issue. Found several things already:
That was just looking during lunch. Let me implement some fixes for these two and see if that clears things up. The TLV alignment might explain why only the 1st connection works...the 2nd and subsequent ones would not be stored properly... |
If the BLE connection is severed, don't wait for the needToSend flag to clear in the HID::send routine since it may never actually clear unless the BLE connection is restored. Partial #1817
If the BLE connection is severed, don't wait for the needToSend flag to clear in the HID::send routine since it may never actually clear unless the BLE connection is restored. Partial #1817
Did some digging around and it looks like this is a BTstack internal thing, and only occurs in BLE mode. Ths following classic BT sketch pairs with multiple computers in a row without incident:
Only the BLE version has an issue:
Tracing the callbacks shows that BTStack is not calling us with a "new connection handle" event after negotiating with a new BLE host after the initial connection. arduino-pico/libraries/HID_Bluetooth/src/PicoBluetoothBLEHID.h Lines 179 to 186 in 39a2bbd
So the core here can't actually send or receive anything and isn't even aware things are connected. The infinite loop potential has been removed, and the TLV database is actually okay so those two things are not part of the issue here (TLV issues would affect classic BT too). |
After messing around with the auruino-pico I thought I was doing something weird, however I found that if you pair it everything will work as intended. But if you unpair it from the same device and try to pair with something else it completely stops outputting. You have to turn off the pico unpair then turn it on and pair to the new device. I figure this is not a intended function. I tried this on multiple versions. They basic code I was using to find that out is as follows:
Edit: It's almost like it needs to not be paired to anything when you turn it off if you are switching devices. It also happens if it is already connected to the pc and you update the firmware when it reboots it will auto reconnect to the what it was paired to and will not function until you unpair, then turn it off then back on and re-pair it.
The text was updated successfully, but these errors were encountered: