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
New Bluetooth pairing script doesn't allow input, doesn't pair any devices #254
Comments
If some BT device requires to enter something from MiSTer side, then you can't pair it from OSD and it doesn't provide any inputs. |
The previous version of the script successfully paired to my controller without using SSH, as long as it was the only device in the area. The update was supposed to gracefully handle multiple devices, but now breaks pairing. For reference, this is a PS4 dual shock controller. |
I've just tried to re-pair my DualShock 4 and didn't find any problem. But it's the only BT device around in pairing mode. |
I turned off my other BT devices and ran the script with only the DS4 nearby. It only found the controller, but still displayed the same output: "Enter PIN" followed immediately by "Authentication Failed." Does your DS4 require you to enter 0000 when you connect via SSH? Mine does, but the previous version of the script apparently handled that step automatically. So, I'd suggest that the updated version maintain that functionality. |
my DS4 doesn't require any pin. Neither in OSD nor in USB console (terminal). And it never required before. |
in SSH:
|
Interesting. It seems like maybe there are two versions of the DS4 out there, and the updated script doesn't properly handle my type anymore. Here's what I get via SSH if I don't provide a PIN:
And here's what I get if I do provide a PIN:
|
I just tried a second DS4 controller and got the same results as my first controller. |
how is the previous linux release? you can simply replace linux.img |
I tried the 6/18 Linux release with both the 6/18 and 6/22 Main releases and got the same behavior as described above. I then tried the 4/29 Linux release with the 6/22 Main release and the controller pairs successfully through both the OSD and SSH, with no interaction on my part (as long as it is the only device in the vicinity, per #215):
|
i don't call it really success as it still displays |
besides fake DS4 i think MiSTer should try well known basic pins 0000 and 1234 before give up. Script needs to be updated. |
Highly unlikely that it's a fake controller, as it's the one that came with my boxed retail PS4. Seems more likely that there are different revisions of the controller that behave differently. Regardless, I agree - an updated script that handles basic PINs would be a good resolution. |
The old version of the script had a bug: when it was supposed to prompt the user to enter a PIN supplied by the device, it instead printed "Enter PIN 0000 on device", didn't prompt the user for input, and immediately returned a hard-coded 0000 as if that was what the user had typed. That buggy behavior just happened to work out nicely for timherr's DS4 controllers.
I have two genuine SONY DS4 controllers (each one was included with a sealed new-in-box PS4 console I bought at retail, so they are definitely genuine), and when I try pairing either one with my MiSTer using the new I wouldn't assume timherr's DS4 controllers are fakes. It's just as likely that they have a buggy firmware version or have somehow gotten into a bad state and just need to be reset (using the little pinhole reset button on the back side). |
the issue is not in buggy/fake DS4.
what you call buggy actually in not buggy. It's intended behavior for pairing when you can't enter. "Enter PIN 0000" is actually for user to enter this pin on his BT keyboard to finish pairing. This is how BT keyboards are paired. It used only hardcoded 0000 pin which should be extended to 2 tries with 0000 and 1234 (for non-keyboard devices with hardcoded PINs) - these 2 PINs cover 99.9% devices using PIN to pair. I've thought your change included such behavior, but unfortunately now it's broken and such devices cannot be paired in OSD. |
I see. I think it's possible for the Python code to detect if stdin is connected to the process or not, and take different actions in each case. That way it could automatically attempt 0000 (and maybe also 1234? not sure if the bluez API allows a second attempt) when run from the OSD, but prompt the user for a PIN when stdin is available. |
I can try coding this up tomorrow after work, unless you get some other fix done before me. |
Yes, Python has a built-in |
i'll leave it to you. I'm not good at python. |
Good idea. I’ll see what I can come up with tomorrow.
|
Just FYI, I'm working on this, but hitting some challenges with self-testing it. My BT keyboard doesn't require a PIN to pair, but bluez keeps calling back into |
Looks like it's some kind of real problem with my keyboard, because now whenever I try to pair it with my Windows PCs they also ask me to type in the PIN for the device. It doesn't have a PIN and has never required one before. 🤦♂️ |
Updated the keyboard's firmware, and now it's behaving sanely again. Glad I'm not actually losing my mind :) |
I have three different Bluetooth keyboards, and two of them behave differently from the third one in terms of the pairing process. It seems that some BT keyboards don't require a PIN to pair, while others require you type type a PIN on the keyboard itself that should match the one that the MiSTer user is supposed to type into the MiSTer. Gotta love inconsistency! 🤦♂️ I'm revising the script and the messaging it gives to the user to handle both types. |
Alright, here's the new version. It's two scripts that needed changing. timherr, can you please give these a try and report back? Unfortunately, there's just such a wide range of Bluetooth devices out there, and some of them don't seem to adhere to the intent of the spec/API, that the best we can do to avoid regressing things is do a bunch of manual testing with as many different Bluetooth devices as possible. (EDITED: to remove lengthy now-pointless early revisions of the scripts) |
Specifically, I have no BT devices that have a hard-coded PIN that must be entered on the MiSTer in order to pair, nor do I have any devices that need a simple yes/no confirmation/authorization, so there are some cases and codepaths in here I can't exercise completely. |
Figured out I can make my laptop discoverable in such a way that MiSTer goes through the confirmation codepath. Looks like the new |
Fixed it; edited my earlier post to contain the fix. Please try now. |
Awesome! I'll test tomorrow night and report back here. |
Running the latest version of the Linux/Main/Menu releases, then updated btpair and pair-agent to the above code. Using the OSD, it finds my controller and gets to the "Trusting..." line and never completes. Via SSH, here's what I get:
|
Thanks. That means the |
Also, I realized that your strange DS4 pairing behavior probably meant you'd get the messaging about "Your keyboard", which obviously doesn't apply correctly to your case, so I'll revise that messaging more as well. |
timherr, if you're willing to connect via a chat app like Facebook Messenger or Google Hangouts, I think that would enable more efficient back-and-forth while we iteratively work through this. If you're up for that, email me at [EDITED for privacy] and I'll send you contact info. |
I lurk on the (heavily MiSTer focused) Classic Gaming Discord server here: https://discord.gg/UDu5ztY Feel free to message me, I'll be around most of the evening (username: therr) |
That works. |
Update: timherr and I made some good progress on this tonight. I think it's finally done, but I'd like him to verify one last time tomorrow before I post the new scripts here. |
Two great pieces of news:
Summary of changes
Download: issue-254-fix.zip |
Thanks for constant improving the BT pairing. |
Happy to help!
I think I forgot to properly escape the backslash characters in the new messaging about the “Operation not permitted” error. I’ll check it and send one more tiny revision to fix it if I need to.
|
i'll leave the changes to you. |
Posting revised ZIP file which refines the messaging and avoids the backslash-escaping problem. Download: issue-254-fix.zip |
One more quick thing I noticed: you know that "wonky" BT adapter state I mentioned in the |
Official USB hub v2.x cuts off the power from all USB devices upon reset. |
Okay, then I will forget about this extra idea. |
While i have BT dongle in my MiSTer, i use RF keyboard (Logitech K400r) and RF gamepad (Logitech F710).. Guess why ;) |
Were the latest changes included in the most recent MiSTer main release? If so, it should be safe to close this now. |
I can confirm the latest version from here works far far better for me, so I support it being officially released: #254 (comment) I still have to re-pair every time I boot the MiSTer because my adapter randomizes its MAC, but pairing works like a charm now, so that's trivially easy. @c0d3h4x0r I sent you a DM on Discord last week with a possible edge case, but it's not too urgent. |
This belongs to Linux. So it will be released with Linux. I plan to release soon |
should be done already |
Following up on closed issue #215, the updated script does not work properly for me when running from the MiSTer UI. When running the script, it identifies three devices in my vicinity. For each device, it displays the "Enter device PIN or ENTER to skip:" prompt, but continues on to the next device with the message "ERROR: Authentication Failed" before I can enter anything. Therefore, it skips all devices and nothing connects.
When I run the btpair script from an SSH connection, it works as expected and allows time for me to input a value. I'm able to successfully connect to my wireless controller while skipping other devices.
This is running the 6/22 release.
@c0d3h4x0r
The text was updated successfully, but these errors were encountered: