Brikwerk / nxbt

Control your Nintendo Switch through a website, terminal, or macro.
MIT License
806 stars 96 forks source link

Disconnects when exiting the grip order screen #39

Open WilsontheWolf opened 2 years ago

WilsontheWolf commented 2 years ago

It pairs successfully but the second I exit the grip order screen it instantly stops working. Using the pip version. Here is the logs from the last check in bluetoothctl

shorty@shorty-laptop:~/projects/iislander> bluetoothctl  
Agent registered
[CHG] Controller 80:2B:F9:D7:BD:F4 Class: 0x00300000
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001133-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001106-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001104-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00005005-0000-1000-8000-0002ee000001
[CHG] Controller 80:2B:F9:D7:BD:F4 Discoverable: no
[CHG] Controller 80:2B:F9:D7:BD:F4 Powered: no
[CHG] Controller 80:2B:F9:D7:BD:F4 Discovering: no
[CHG] Controller 80:2B:F9:D7:BD:F4 Class: 0x00000000
Agent unregistered
[DEL] Device B8:F6:53:21:1B:4D JBL TUNE115BT
[DEL] Device 4C:74:BF:E2:11:67 Shorty's iPhone
[DEL] Device E4:8B:7F:44:7D:F7 Shorty's iPad
[DEL] Controller 80:2B:F9:D7:BD:F4 Pro Controller [default]
Agent registered
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001133-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001106-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001104-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00005005-0000-1000-8000-0002ee000001
[CHG] Controller 80:2B:F9:D7:BD:F4 Class: 0x00300000
[CHG] Controller 80:2B:F9:D7:BD:F4 Powered: yes
[CHG] Controller 80:2B:F9:D7:BD:F4 PairableTimeout: 0x00000000
[CHG] Controller 80:2B:F9:D7:BD:F4 DiscoverableTimeout: 0x000000b4
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001133-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001106-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00001104-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
[CHG] Controller 80:2B:F9:D7:BD:F4 UUIDs: 00005005-0000-1000-8000-0002ee000001
[CHG] Controller 80:2B:F9:D7:BD:F4 Discoverable: yes
[CHG] Controller 80:2B:F9:D7:BD:F4 Class: 0x00002508
[NEW] Device B8:8A:EC:88:4A:45 Nintendo Switch
[CHG] Device B8:8A:EC:88:4A:45 UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device B8:8A:EC:88:4A:45 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device B8:8A:EC:88:4A:45 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device B8:8A:EC:88:4A:45 ServicesResolved: yes
[CHG] Device B8:8A:EC:88:4A:45 Paired: yes
[CHG] Device B8:8A:EC:88:4A:45 ServicesResolved: no
[CHG] Device B8:8A:EC:88:4A:45 Connected: no
[bluetooth]# 

Ubuntu 21.10

A not had to tell bluetoothctl to remove the switch for it to connect again.

Videos showing the issue https://youtu.be/VUe2xvHM-So https://youtu.be/P_nEkdsSc7w

Thanks

Brikwerk commented 2 years ago

Unfortunately, the issue you're experiencing is likely due to frequency problems I still haven't entirely solved yet. The Switch (as of SwitchOS v12 and onward) is far more sensitive to controller frequency when exiting the "Change Grip/Order" menu. NXBT attempts to keep a consistent frequency like a real controller, however, it can still vary a bit depending on external factors (OS scheduling, hardware, etc). At the moment, there are mitigations in place that work on some but not all hardware configurations.

Firstly, would you be able to list the specifications of the system you're using NXBT on? Eg: OS/version, CPU, etc.

Second, can you run sudo nxbt test and post the output here?

WilsontheWolf commented 2 years ago

Hey thanks for the help and sorry for the late reply. I just installed and tested on the latest version and its not working sadly. I'm currently running Ubuntu 21.10 x86_64 with an AMD Ryzen 3 2200U with Radeon Vega Mobile Gfx (4) @ 2.500GHz.

Here is the full neofetch

            .-/+oossssoo+/-.               shorty@shorty-laptop 
        `:+ssssssssssssssssss+:`           -------------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 21.10 x86_64 
    .ossssssssssssssssssdMMMNysssso.       Host: HP Laptop 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 5.13.0-21-generic 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 1 day, 22 hours, 11 mins 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 3497 (dpkg), 21 (snap) 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: zsh 5.8 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Resolution: 1366x768 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   DE: GNOME 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: Mutter 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   WM Theme: Adwaita 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Theme: Yaru-dark [GTK2/3] 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Icons: Yaru [GTK2/3] 
  +sssssssssdmydMMMMMMMMddddyssssssss+     Terminal: tilix 
   /ssssssssssshdmNNNNmyNMMMMhssssss/      CPU: AMD Ryzen 3 2200U with Radeon Vega Mobile Gfx (4) @ 2.500GHz 
    .ossssssssssssssssssdMMMNysssso.       GPU: AMD ATI Radeon Vega Series / Radeon Vega Mobile Series 
      -+sssssssssssssssssyyyssss+-         Memory: 5793MiB / 6848MiB 
        `:+ssssssssssssssssss+:`           Disk (/): 410G / 435G (99%) 
            .-/+oossssoo+/-.               Battery1: 100% [Full] 
                                           Local IP: 10.0.0.54 

The output is

[1] Attempting to initialize NXBT...
Successfully initialized NXBT.

[2] Checking for Bluetooth adapter availability...
1 Bluetooth adapter(s) available.
Adapters: ['/org/bluez/hci0'] 

[3] Please turn on your Switch and navigate to the 'Change Grip/Order menu.'
Press Enter to continue...
Creating a controller with the first Bluetooth adapter...
Successfully created a controller.

[4] Waiting for controller to connect with the Switch...
Connection timeout is 120 seconds for this test script.
Successfully connected.

[5] Attempting to exit the 'Change Grip/Order Menu'...
Controller disconnected after leaving the menu.
Exiting...

Although interestingly it didn't kill itself, and I manually had to ctrl + c it.

Brikwerk commented 2 years ago

Would you be able to explain what happened on the Switch while the test command was running? Did the emulated controller connect and was the "Change Grip/Order" menu exited successfully?

WilsontheWolf commented 2 years ago

Yep. The controller connected and and exited the grip menu, and then disconnected.