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

Dongle: "Bt security failed: right" #1019

Open
mondalaci opened this issue Nov 3, 2024 · 38 comments
Open

Dongle: "Bt security failed: right" #1019

mondalaci opened this issue Nov 3, 2024 · 38 comments
Assignees

Comments

@mondalaci
Copy link
Member

See the comments starting from UltimateHackingKeyboard/agent#2433

Dongle zephyr log:

uhk-dongle$ Filters matched: right (ea:5c:dd:bc:10:f4), connectable:1       
Scan connecting: right (ea:5c:dd:bc:10:f4)                                  
Filters matched: right (ea:5c:dd:bc:10:f4), connectable:0                   
Connecting failed: right (ea:5c:dd:bc:10:f4)                                
Bt connected to right (ea:5c:dd:bc:10:f4)                                   
Bt security failed: right (ea:5c:dd:bc:10:f4), level 1, err 2, disconnecting
@mhantsch
Copy link
Contributor

mhantsch commented Nov 4, 2024

Yeah, my UHK connects to the Dongle (at least it says so in the display shortly after I plug in the Dongle) but then it does not work anymore. No keystrokes, no mouse movements, and even when I disconnect the Dongle it won't work anymore over USB either. Have to reboot the right half to get it working again (over USB).

@pcooke9
Copy link

pcooke9 commented Nov 4, 2024

Yeah, my UHK connects to the Dongle (at least it says so in the display shortly after I plug in the Dongle) but then it does not work anymore. No keystrokes, no mouse movements, and even when I disconnect the Dongle it won't work anymore over USB either. Have to reboot the right half to get it working again (over USB).

Exactly the same for me. The dongle just never works anymore, even though it says it's connected on the UHK80 display.

I also tried connecting to an ASUS USB-BT500 adapter in Windows. Sometimes it will connect and work fine a few times. Sometimes it'll get stuck in an endless connect/disconnect loop. After the first successful connection, the most common behavior is that I need to remove the UHK80 from the Windows Bluetooth device list and reset the right half. Then it'll usually connect on the next attempt.

Connecting to my Samsung phone via BLE will usually only work once, and then I need to reset the UHK80 right half to get it to connect again.

@pcooke9
Copy link

pcooke9 commented Nov 4, 2024

I don't know if this is related or not, but I figured I'd go ahead and mention it now.
While trying to troubleshoot the dongle not working, I discovered another weird issue with the "Xbox 360 Wireless Receiver for Windows". If I disconnect and then reconnect either half of the UHK80 or the dongle, the next time I shutdown or restart the PC, it will hang with the error: "Please wait for the System Event Notification System" or "Please wait for the SENS". It hangs for over seven minutes!

If I disable all instances of "Xbox 360 Wireless Receiver for Windows" in the Windows Device Manager, and then reboot, all subsequent shutdown/restarts are fine.

This has actually been happening intermittently for a few weeks, but until now, I thought it was caused by a bad Windows update. I guess it still might just be a Windows issue, but I don't have any other PC to test it with. I don't have any other Xbox 360 Wireless devices either. I didn't realize that the UHK80 was recognized by Windows as an "Xbox 360 Wireless Receiver for Windows".

Weirdly enough, everything on the UHK80 still seems to work fine with it disabled. The left and right halves still communicate without the spiral cable, and the Bluetooth still connects (with the same issues as above). What's the Xbox 360 Wireless Receiver used for on the UHK80?

Anyone else experience this in Windows? If I need to create an issue, I guess I can later tonight or tomorrow. I've never actually started an issue before though, so I might need help with that. Anyway, sorry if this is out of place or whatever.

@mhantsch
Copy link
Contributor

mhantsch commented Nov 4, 2024

I'm running my Dongle experiments on Linux.

@kareltucek
Copy link
Collaborator

Old bonds were not secured. The master-paired increases bond security repaired, so after upgrading to pairing-enabled agent/firmware, the old bonds still exist but their security is not sufficient, so you need to re-pair both left-right link as well as dongles via Agent

@mhantsch
Copy link
Contributor

mhantsch commented Nov 8, 2024

you need to re-pair both left-right link as well as dongles via Agent

How exactly do I do that? I don't seem to find any option for that in Agent.

@kareltucek
Copy link
Collaborator

Dongle via host connections, left half via advanced settings

@mhantsch
Copy link
Contributor

mhantsch commented Nov 8, 2024

Dongle via host connections, left half via advanced settings

But how?

Both halves connected with spiral cable, right half connected to Laptop via USB. Agent shows this:

image

Dongle not visible.

If I plug in the Dongle, the keyboard stops working, and Agent just displays:

image

When I now unplug the Dongle, the keyboard does not recover. I have to reset the right half to get it to work again.

Where are "advanced settings"?

@kareltucek
Copy link
Collaborator

@ert78gb What is the state of unpairing and left half pairing Agent features? Are there any userfriendly scripts that Max could use in the meantime?

@ert78gb
Copy link
Member

ert78gb commented Nov 8, 2024

Dongle pairing implemented. Bluetooth pairing waiting to firmware to implement then new USB command that mentioned in #980

Laci and I waited for you because looks like when the keyboard uses Dongle or BLE to communicate with the computer then the keyboard stop exposing the USB interfaces.
I use my kinetic developer board as Dongle. I don't have real dongle.
When I use my prototype keyboard via the dev board and after I connect the right half via USB cable to the keyboard then my prototype disconnects from the dongle and switching to USB cable communication. This way Agent can communicate with the keyboard and the dongle too and can do the pairing process. It works on my mac.
But it does not work on Laci's linux computer. Laci's keyboard does not break the dongle communication until he not use the reset button on the keyboard if I remember well.

The BLE behaviour are same on Mac and Linux.
If the keyboard first connects to the computer via BLE and after the keyboard connect via USB cable then the keyboard does 't expose the USB communication interfaces. So Agent can't communicate with the keyboard. It is an other blocker of the BLE pairing implementation of Agent.

I hope I summarised correctly @mondalaci and my experiences.

@kareltucek
Copy link
Collaborator

That new command is already implemented and merged I believe.

As for rest of the logic, Laci accidentally closed it i UltimateHackingKeyboard/firmware80#342

@kareltucek
Copy link
Collaborator

kareltucek commented Nov 8, 2024

Anyways, the question wasnt about ble hid pairing, but about dongle unpairing.

@ert78gb
Copy link
Member

ert78gb commented Nov 8, 2024

Dongle unpairing works after dongle paired. The pairing does not work without UltimateHackingKeyboard/firmware80#342 if I understand well.

@kareltucek
Copy link
Collaborator

Well, Max should then be able to unpair his dongle when the dongle is not connected, shouldnt he?

@mhantsch
Copy link
Contributor

mhantsch commented Nov 8, 2024

Well, Max should then be able to unpair his dongle when the dongle is not connected, shouldnt he?

But I can't, because the Dongle is nowhere to be seen in Agent. There is no "unpair" button or anything similar.

@kareltucek
Copy link
Collaborator

kareltucek commented Nov 8, 2024

Ah, I see. Then please see https://github.com/UltimateHackingKeyboard/firmware-uhk80/blob/master/doc-dev%2Fother%2Fpairing%2Fpair.sh and send the delete all command to your right half. (Or run the entire script.)

@kareltucek
Copy link
Collaborator

Or flash a build of the mentioned UltimateHackingKeyboard/firmware80#342 and power ycle the board

@ert78gb
Copy link
Member

ert78gb commented Nov 8, 2024

I just checked the code of Agent and it currently expect the dongle is connected to the computer because it deletes bonds of the Dongle too. I could fix it.

But I can't, because the Dongle is nowhere to be seen in Agent. There is no "unpair" button or anything similar.

Because Agent detects/reads the paired devices from the host connections of the user config.
I think @mhantsch got the Dongle before this host connection feature has been implemented.
He is in a situation that should not exists

@mhantsch
Copy link
Contributor

mhantsch commented Nov 8, 2024

I think @mhantsch got the Dongle before this host connection feature has been implemented.

Yes.

He is in a situation that should not exists

Exactly.

@kareltucek
Copy link
Collaborator

kareltucek commented Nov 8, 2024

I just checked the code of Agent and it currently expect the dongle is connected to the computer because it deletes bonds of the Dongle too. I could fix it.

I think Agent should unpair even a dongle that is not connected - in that case, you should unpair just right half.

Because Agent detects/reads the paired devices from the host connections of the user config.
I think @mhantsch got the Dongle before this host connection feature has been implemented.

Indeed.

He is in a situation that should not exists

Well, I am not so sure about that - what if I just load another user config?

In any case UltimateHackingKeyboard/firmware80#342 should take care of that so we don't need to do anything except for merging that pr.

@mhantsch
Copy link
Contributor

mhantsch commented Nov 8, 2024

I think I better wait until the two of you agree what steps I should do now.

If you want me to install a specific build of Agent or firmware, can you please direct me to the exact action page that I should use? I am lost in half-merged branches and master-paired, bt-something etc. to know which would be the correct combination.

@ert78gb
Copy link
Member

ert78gb commented Nov 8, 2024

Well, I am not so sure about that - what if I just load another user config?

Agent offer the dongle pairing option when

  • the connected dongle is not in the host connections
  • the connected dongle is not paired for the keyboard

So Agent will offer the dongle pairing when you load another user config of which host connections don't contain the dongle

@mondalaci
Copy link
Member Author

@mhantsch
Copy link
Contributor

mhantsch commented Nov 9, 2024

@mhantsch Please try https://github.com/UltimateHackingKeyboard/firmware-uhk80/actions/runs/11742049901

I tried, but that didn't change anything. I plug in the Dongle and the UHK says "Dongle" and becomes unresponsive. Agent says "Can't find your UHK, please plug it in". When I unplug the Dongle, the UHK says "Disconnected" and never connects to USB anymore. It was still visible on Bluetooth. When I tried to connect/pair it on Bluetooth, the right half rebooted. After that it would connect to USB again and generally work again -- but only over USB.

@mhantsch
Copy link
Contributor

mhantsch commented Nov 9, 2024

Tried connecting via Bluetooth again, keyboard reboots.

At least that now gives me a convenient way of rebooting after failed Dongle tests 😉

@kareltucek
Copy link
Collaborator

You don't have access to right half logs, do you?

@mhantsch
Copy link
Contributor

mhantsch commented Nov 9, 2024

You don't have access to right half logs, do you?

How would I? I can't login to a shell via USB, can I? Maybe after running a secret macro command it should expose a USB file storage with all logs. 😊

@ert78gb
Copy link
Member

ert78gb commented Nov 9, 2024

@mhantsch Laci mentioned you need a script that delete the bonds of the Dongle.

The UltimateHackingKeyboard/agent80#134 PR contains ./packages/usb/delete-dongle-bonds.ts --log=all script.

To run the script:

  • checkout the branch
  • run npm ci
  • run npm run build
  • run ./packages/usb/delete-dongle-bonds.ts --log=all

@mondalaci
Copy link
Member Author

@mhantsch Please hold on. Based on my testing, the suggested fix doesn't work.

@kareltucek The first problem is that Agent expects the dongle to be connected upon deleting it from host connections, which shouldn't be required. UltimateHackingKeyboard/agent80#135 addresses this issue, but we should think deeply about the correct solution before merging it.

As for UltimateHackingKeyboard/agent80#134, after running this script, the UHK asks for the 6-digit pairing code when the dongle tries to connect. I assume that the /uh/addr/right settings key is still set. The UHK should reject such dongle connections that have been invalidated on either end. Do you have any ideas about how?

@mhantsch
Copy link
Contributor

mhantsch commented Nov 9, 2024

i don't have npm installed anyway, and I didn't necessarily want to run a bunch of complicated things. I think the user-level software must offer a way for an end user to get out of stuck situations such as mine.

I'll wait until the three of you have all agreed on how to continue.

@mondalaci
Copy link
Member Author

@mhantsch
Copy link
Contributor

OK, with this firmware at least there are no more crashes, and if I try the Dongle then at least the keyboard stays functional when I plug it back on USB.

I still can't pair it with my Laptop over BT, but I think that's a different issue. It doesn't crash or reboot anymore, though.

@mondalaci
Copy link
Member Author

@mhantsch Can you use your UHK via the dongle with the latest build I linked?

I still can't pair it with my Laptop over BT, but I think that's a different issue. It doesn't crash or reboot anymore, though.

Please elaborate on this.

@mhantsch
Copy link
Contributor

No, I can't use the Dongle, but at least it no longer crashes my UHK.

Ever since some changes were done to the pairing system several weeks ago, I could not use the Dongle anymore. Also, it doesn't show up in Agent on the Connections tab. And I have never seen any pairing button either.

BT doesn't work either with my Laptop because I can't initiate pairing. BT only works with my phone.

So the only connectivity that works with my UHK80 is USB.

@mondalaci
Copy link
Member Author

@kareltucek Agent does not support the dongle firmware update, only in a cumbersome way via recovery mode, which only flashes the firmware version bundled with Agent. Given this limitation, @mhantsch probably runs an old firmware version on his dongle. I think this causes his dongle issue. Agreed?

@mhantsch
Copy link
Contributor

So how is end user supposed to update dongle firmware?

@mondalaci
Copy link
Member Author

By pressing the dongle's reset button, Agent will offer firmware recovery, but the firmware bundled with Agent may be too old. We're discussing implementing a proper firmware update for the dongle other than the recovery mode.

@kareltucek
Copy link
Collaborator

@kareltucek Agent does not support the dongle firmware update, only in a cumbersome way via recovery mode, which only flashes the firmware version bundled with Agent. Given this limitation, @mhantsch probably runs an old firmware version on his dongle. I think this causes his dongle issue. Agreed?

It is possible.

Still not sure why Agent doesn't show it though. I would expect Agent to show it and then throw a bunch of errors about failed usb commands.

@mondalaci mondalaci transferred this issue from UltimateHackingKeyboard/firmware80 Dec 12, 2024
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

5 participants