Skip to content
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 reconnect loop #1056

Open
mondalaci opened this issue Dec 23, 2024 · 6 comments
Open

BLE reconnect loop #1056

mondalaci opened this issue Dec 23, 2024 · 6 comments

Comments

@mondalaci
Copy link
Member

I seldom test BLE, but I paired my UHK 80 to my Linux PC yesterday, disconnected the BLE connection, and kept using USB. I think I didn't delete the bond. Before going to bed, I put my PC to sleep, and when I woke it up today, my UHK 80 seemingly didn't work and was disconnected according to the OLED display.

I looked into the Zephyr log and saw the following repeating:

W: opcode 0x200a status 0x0d 
Bt connected to unknown (e8:9c:25:57:11:5f)
Bt disconnected from unknown (e8:9c:25:57:11:5f), reason 5
NUS and HID advertising successfully started
USB config changing to Hid_Full
USB config changing to Hid_Full
W: opcode 0x200a status 0x0d 
Bt connected to unknown (e8:9c:25:57:11:5f)
Bt disconnected from unknown (e8:9c:25:57:11:5f), reason 5
NUS and HID advertising successfully started
USB config changing to Hid_Full
USB config changing to Hid_Full
W: opcode 0x200a status 0x0d 
Bt connected to unknown (e8:9c:25:57:11:5f)
Bt disconnected from unknown (e8:9c:25:57:11:5f), reason 5
NUS and HID advertising successfully started
USB config changing to Hid_Full
USB config changing to Hid_Full

I'm unsure about the best solution but feel free to make suggestions. Maybe the firmware should simply stop trying to connect after a certain number of failures within a timeframe per host connection. I'm on master.

@mhantsch
Copy link
Contributor

mhantsch commented Dec 23, 2024

Oh, that confirms that I'm not alone seeing this. When I tried playing with Bluetooth on my UHK 80 and Linux systems, I often end up in a state where Linux desktop notifications pop up: "UHK 80 connected", "UHK 80 disconnected", "UHK 80 connected", "UHK 80 disconnected" etc. and it never ends until I plug in the UHK via USB, or sometimes I need to "forget" the pairing on the Linux system. I haven't figured out a reproducible sequence, but I have real difficulty pairing the UHK. I need to use commandline and issue a few times a random sequence of these commands:

  • bluetoothctl connect <uhk80-mac-address>
  • bluetoothctl pair <uhk80-mac-address>
  • bluetoothctl trust <uhk80-mac-address>

Sometimes along this process, finally the pop-up appears prompting me to enter the six-digit pairing code. Often this does not pop up and the UHK pairing starts but then fails. It seems very random. Sometimes after having done the "trust" command, it pairs. But then later after turning something off and on again, it enters the connect/disconnect loop with the neverending recurring notification pop-ups.

That's the best description I currently have.

@mondalaci
Copy link
Member Author

Yes, I forgot about the incessant "UHK 80 connected" notifications I've also experienced.

@kareltucek
Copy link
Collaborator

kareltucek commented Dec 23, 2024

GPT says 5 means authentication failure.

UHK acts as a peripheral in this interaction, so it should be the PC that stops obsessively trying to connect when it knows it cannot authenticate, shouldn't it?

(UHK isn't trying anything. It just advertises its features and responds to whoever tries to connect to it.)

The only thing I see that should be done about that is that UHK should not switch from USB HID to BLE HID until a connection is fully formed and secured.

@mondalaci
Copy link
Member Author

The only thing I see that should be done about that is that UHK should not switch from USB HID to BLE HID until a connection is fully formed and secured.

Would this stop the incessant notifications on Linux?

UHK acts as a peripheral in this interaction, so it should be the PC that stops obsessively trying to connect when it knows it cannot authenticate, shouldn't it?

It probably should, but the world is a mess, and the UHK must handle these situations gracefully, even if the root cause is not our fault.

@kareltucek
Copy link
Collaborator

Would this stop the incessant notifications on Linux?

Maybe.


Also another story is why the authentication fails. Let's wait until the connection manager is merged. It fixes a couple of bluetooth bugs that may easily by the culprit...

@mhantsch
Copy link
Contributor

another story is why the authentication fails

That is indeed the main culprit. It is super hard for me to get the UHK 80 to consistently pair. Once it is really paired, it works. But recent firmware upgrade blew it again, and I ended up in the reconnect loop. I suspect that somehow the keys of UHK and Host don't match anymore, and host is trying to keep connecting to a connection that doesn't match up on the UHK. But I may be wrong.

I had something similar with my ZMK keyboard, but after deleting BLE keys on the keyboard (on ZMK you can just configure a key to delete all BLE keys), they keyboard would pair again. Couldn't get that done on the UHK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants