Brikwerk / nxbt

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

Can't connect to switch, infinite connecting, got dbus.exceptions.DBusException #116

Open Fuyukiri opened 1 year ago

Fuyukiri commented 1 year ago

I can pass the demo but can't connect to switch anymore after 1s connection. In web UI, I can see that only in one second it shows connected, then it turns to yellow light and shows connecting.

System:

Linux Core 5.15.104-2-MANJARO #1 SMP PREEMPT Thu Mar 23 01:40:42 UTC 2023 x86_64 GNU/Linux

My gear:

❯ hwinfo --short
cpu:                                                            
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3580 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
keyboard:
  /dev/input/event3    Dell KB216 Wired Keyboard
mouse:
  /dev/input/mice      SteelSeries ApS SteelSeries Sensei 310 eSports Mouse
graphics card:
                       nVidia GP104 [GeForce GTX 1080]
sound:
                       Intel 200 Series PCH HD Audio
                       nVidia GP104 High Definition Audio Controller
storage:
                       Intel 200 Series PCH SATA controller [AHCI mode]
                       Kingston Technology Company U-SNS8154P3 NVMe SSD
                       Sandisk WD Black SN750 / PC SN730 NVMe SSD
network:
  enp0s31f6            Intel Ethernet Connection (2) I219-V
  wlp4s0               Realtek RTL8822BE 802.11a/b/g/n/ac WiFi adapter
network interface:
  lo                   Loopback network interface
  wlp4s0               Ethernet network interface
  enp0s31f6            Ethernet network interface
disk:
  /dev/nvme0n1         Kingston Technology Company U-SNS8154P3 NVMe SSD
  /dev/sdb             Hitachi HUA72302
  /dev/nvme1n1         Sandisk WD Black SN750 / PC SN730 NVMe SSD
  /dev/sda             ST1000LM024 HN-M
partition:
  /dev/nvme0n1p1       Partition
  /dev/nvme0n1p2       Partition
  /dev/nvme0n1p3       Partition
  /dev/nvme0n1p4       Partition
  /dev/nvme0n1p5       Partition
  /dev/nvme0n1p6       Partition
  /dev/sdb1            Partition
  /dev/sdb2            Partition
  /dev/sdb3            Partition
  /dev/nvme1n1p1       Partition
  /dev/nvme1n1p2       Partition
  /dev/nvme1n1p3       Partition
  /dev/sda1            Partition
usb controller:
                       ASMedia ASM2142 USB 3.1 Host Controller
                       ASMedia ASM2142 USB 3.1 Host Controller
                       Intel 200 Series/Z370 Chipset Family USB 3.0 xHCI Controller
bios:
                       BIOS
bridge:
                       Intel 200 Series PCH PCI Express Root Port #1
                       Intel Z370 Chipset LPC/eSPI Controller
                       Intel 6th-10th Gen Core Processor PCIe Controller (x16)
                       Intel 200 Series PCH PCI Express Root Port #17
                       ASUSTeK PRIME H310M-D
                       Intel 200 Series PCH PCI Express Root Port #9
                       Intel 200 Series PCH PCI Express Root Port #7
                       Intel 200 Series PCH PCI Express Root Port #5
                       Intel 200 Series PCH PCI Express Root Port #3
hub:
                       Linux Foundation 3.0 root hub
                       Linux Foundation 2.0 root hub
                       Linux Foundation 3.0 root hub
                       Linux Foundation 2.0 root hub
                       Linux Foundation 2.0 root hub
                       Linux Foundation 3.0 root hub
memory:
                       Main Memory
bluetooth:
                       ASUSTek Bluetooth Radio
unknown:
                       FPU
                       DMA controller
                       PIC
                       Keyboard controller
                       Intel 200 Series/Z370 Chipset Family Power Management Controller
                       Intel 200 Series PCH CSME HECI #1
                       Intel 200 Series/Z370 Chipset Family SMBus Controller
                       Serial controller
  /dev/input/event7    SteelSeries ApS SteelSeries Sensei 310 eSports Mouse
                       NZXT Smart Device
                       ASUSTek AURA LED Controller
  /dev/input/event5    Dell KB216 Wired Keyboard

Log:

Create Controller
Exception in thread Thread-1 (connection_reset_watchdog):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/nxbt/controller/server.py", line 331, in connection_reset_watchdog
    paths = self.bt.find_connected_devices(alias_filter="Nintendo Switch")
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/nxbt/bluez.py", line 908, in find_connected_devices
    devices = find_objects(
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/nxbt/bluez.py", line 84, in find_objects
    for path, ifaces in manager.GetManagedObjects().items():
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/dbus/proxies.py", line 72, in __call__
    return self._proxy_method(*args, **keywords)
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/dbus/proxies.py", line 141, in __call__
    return self._connection.call_blocking(self._named_service,
  File "/home/fuyu❯ hwinfo --short
cpu:                                                            
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3580 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
                       Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz, 3700 MHz
keyboard:
  /dev/input/event3    Dell KB216 Wired Keyboard
mouse:
  /dev/input/mice      SteelSeries ApS SteelSeries Sensei 310 eSports Mouse
graphics card:
                       nVidia GP104 [GeForce GTX 1080]
sound:
                       Intel 200 Series PCH HD Audio
                       nVidia GP104 High Definition Audio Controller
storage:
                       Intel 200 Series PCH SATA controller [AHCI mode]
                       Kingston Technology Company U-SNS8154P3 NVMe SSD
                       Sandisk WD Black SN750 / PC SN730 NVMe SSD
network:
  enp0s31f6            Intel Ethernet Connection (2) I219-V
  wlp4s0               Realtek RTL8822BE 802.11a/b/g/n/ac WiFi adapter
network interface:
  lo                   Loopback network interface
  wlp4s0               Ethernet network interface
  enp0s31f6            Ethernet network interface
disk:
  /dev/nvme0n1         Kingston Technology Company U-SNS8154P3 NVMe SSD
  /dev/sdb             Hitachi HUA72302
  /dev/nvme1n1         Sandisk WD Black SN750 / PC SN730 NVMe SSD
  /dev/sda             ST1000LM024 HN-M
partition:
  /dev/nvme0n1p1       Partition
  /dev/nvme0n1p2       Partition
  /dev/nvme0n1p3       Partition
  /dev/nvme0n1p4       Partition
  /dev/nvme0n1p5       Partition
  /dev/nvme0n1p6       Partition
  /dev/sdb1            Partition
  /dev/sdb2            Partition
  /dev/sdb3            Partition
  /dev/nvme1n1p1       Partition
  /dev/nvme1n1p2       Partition
  /dev/nvme1n1p3       Partition
  /dev/sda1            Partition
usb controller:
                       ASMedia ASM2142 USB 3.1 Host Controller
                       ASMedia ASM2142 USB 3.1 Host Controller
                       Intel 200 Series/Z370 Chipset Family USB 3.0 xHCI Controller
bios:
                       BIOS
bridge:
                       Intel 200 Series PCH PCI Express Root Port #1
                       Intel Z370 Chipset LPC/eSPI Controller
                       Intel 6th-10th Gen Core Processor PCIe Controller (x16)
                       Intel 200 Series PCH PCI Express Root Port #17
                       ASUSTeK PRIME H310M-D
                       Intel 200 Series PCH PCI Express Root Port #9
                       Intel 200 Series PCH PCI Express Root Port #7
                       Intel 200 Series PCH PCI Express Root Port #5
                       Intel 200 Series PCH PCI Express Root Port #3
hub:
                       Linux Foundation 3.0 root hub
                       Linux Foundation 2.0 root hub
                       Linux Foundation 3.0 root hub
                       Linux Foundation 2.0 root hub
                       Linux Foundation 2.0 root hub
                       Linux Foundation 3.0 root hub
memory:
                       Main Memory
bluetooth:
                       ASUSTek Bluetooth Radio
unknown:
                       FPU
                       DMA controller
                       PIC
                       Keyboard controller
                       Intel 200 Series/Z370 Chipset Family Power Management Controller
                       Intel 200 Series PCH CSME HECI #1
                       Intel 200 Series/Z370 Chipset Family SMBus Controller
                       Serial controller
  /dev/input/event7  

  SteelSeries ApS SteelSeries Sensei 310 eSports Mouse
                       NZXT Smart Device
                       ASUSTek AURA LED Controller
  /dev/input/event5    Dell KB216 Wired Keyboard
kiri/nxbt/nxbt/lib/python3.10/site-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
Exception in thread Thread-1 (connection_reset_watchdog):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/nxbt/controller/server.py", line 331, in connection_reset_watchdog
    paths = self.bt.find_connected_devices(alias_filter="Nintendo Switch")
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/nxbt/bluez.py", line 908, in find_connected_devices
    devices = find_objects(
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/nxbt/bluez.py", line 78, in find_objects
    bus.get_object(service_name, "/"),
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/dbus/bus.py", line 241, in get_object
    return self.ProxyObjectClass(self, bus_name, object_path,
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/dbus/proxies.py", line 250, in __init__
    self._named_service = conn.activate_name_owner(bus_name)
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/dbus/bus.py", line 177, in activate_name_owner
    return self.get_name_owner(bus_name)
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/dbus/bus.py", line 361, in get_name_owner
    return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
  File "/home/fuyukiri/nxbt/nxbt/lib/python3.10/site-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

I am guessing I need to use a usb bluetooth device instead of built-in bluetooth.

Also I am running nxbt in venv since the jinja dependency issue, not sure if this is related.

Dummydud3 commented 1 year ago

can i ask if you we're successful in fixing this problem? if not, what OS are you running? is this a virtual machine or a standard installation?

kotori2 commented 1 year ago

Same here. The configuration OP posted should be a standalone device but not virtual machine. I have issue with builtin BT as well. Here is my configuration:

$ hwinfo --short
cpu:                                                            
                       13th Gen Intel(R) Core(TM) i9-13900K, 1957 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 2033 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 1925 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 2030 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 2200 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 1937 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 1954 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 2094 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 2175 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 2058 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 1414 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 1039 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
                       13th Gen Intel(R) Core(TM) i9-13900K, 3000 MHz
keyboard:
  /dev/input/event5    SONiX USB DEVICE
  /dev/input/event11   IM Networks Virtual HID
mouse:
  /dev/input/event7    SONiX USB DEVICE
  /dev/input/mice      IM Networks Virtual HID
  /dev/input/mice      Logitech G502 SE HERO Gaming Mouse
monitor:
                       LG ELECTRONICS LG ULTRAGEAR+
                       ROG PG32UQX
graphics card:
                       nVidia VGA compatible controller
                       Intel Display controller
sound:
                       Intel Audio device
                       nVidia GA104 High Definition Audio Controller
storage:
                       Intel SATA controller
                       Samsung Electronics NVMe SSD Controller PM9A1/PM9A3/980PRO
                       Samsung Electronics NVMe SSD Controller SM981/PM981/PM983
                       ASMedia ASM1062 Serial ATA Controller
network:
  wlan0                Intel Wi-Fi 6 AX210 160MHz
  eth0                 Intel Ethernet Controller I225-V
network interface:
  eth0                 Ethernet network interface
  wlan0                WLAN network interface
  lo                   Loopback network interface
disk:
  /dev/nvme0n1         Samsung Electronics NVMe SSD Controller PM9A1/PM9A3/980PRO
  /dev/nvme1n1         Samsung Electronics NVMe SSD Controller SM981/PM981/PM983
partition:
  /dev/nvme0n1p1       Partition
  /dev/nvme0n1p2       Partition
  /dev/nvme0n1p3       Partition
usb controller:
                       Intel USB Controller
bios:
                       BIOS
bridge:
                       Intel PCI bridge
                       Intel ISA bridge
                       Intel PCI bridge
                       Intel PCI bridge
                       Intel Host bridge
                       Intel PCI bridge
                       Intel PCI bridge
                       Intel PCI bridge
                       Intel PCI bridge
hub:
                       Genesys Logic USB3.2 Hub
                       Genesys Logic Hub
                       Linux Foundation 2.0 root hub
                       Generic Virtual HUB
                       Genesys Logic Hub
                       Linux Foundation 3.0 root hub
                       Genesys Logic Hub
memory:
                       Main Memory
bluetooth:
                       Intel Bluetooth Device
unknown:
                       FPU
                       DMA controller
                       PIC
                       Keyboard controller
                       Intel System peripheral
                       Intel Communication controller
                       Intel Serial bus controller
                       Intel RAM memory
                       Intel SMBus
                       Serial controller
                       Micro Star International USB Audio
  /dev/input/event4    Micro Star International MYSTIC LIGHT
  /dev/input/event10   Logitech G502 SE HERO Gaming Mouse

My Usage:

$ sudo python3                          
Python 3.11.4 (main, Jun  7 2023, 10:13:09) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nxbt
>>> nx = nxbt.Nxbt()
>>> ci = nx.create_controller(nxbt.PRO_CONTROLLER)
>>> nx.wait_for_connection(ci)

(wait infinitely after last command) bluetoothctl:

$ sudo bluetoothctl              
Agent registered
[bluetooth]# list
Controller F4:A4:75:3F:0C:22 Pro Controller [default]
[CHG] Device 74:84:69:65:6C:64 Connected: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no
[CHG] Controller F4:A4:75:3F:0C:22 PairableTimeout: 0x00000000
[CHG] Controller F4:A4:75:3F:0C:22 DiscoverableTimeout: 0x000000b4
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00001104-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00001133-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00001106-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00005005-0000-1000-8000-0002ee000001
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Controller F4:A4:75:3F:0C:22 Class: 0x00002508
[CHG] Device 74:84:69:65:6C:64 Connected: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no
[CHG] Device 74:84:69:65:6C:64 Connected: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no
[DEL] Device 74:84:69:65:6C:64 Nintendo Switch
[NEW] Device 74:84:69:65:6C:64 Nintendo Switch
[CHG] Device 74:84:69:65:6C:64 Bonded: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no
[CHG] Device 74:84:69:65:6C:64 Paired: yes
[CHG] Device 74:84:69:65:6C:64 Connected: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no
[CHG] Device 74:84:69:65:6C:64 Connected: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no
[DEL] Device 74:84:69:65:6C:64 Nintendo Switch
[NEW] Device 74:84:69:65:6C:64 Nintendo Switch
[CHG] Device 74:84:69:65:6C:64 Bonded: yes
[CHG] Device 74:84:69:65:6C:64 UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device 74:84:69:65:6C:64 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device 74:84:69:65:6C:64 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device 74:84:69:65:6C:64 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device 74:84:69:65:6C:64 ServicesResolved: yes
[CHG] Device 74:84:69:65:6C:64 Paired: yes
[CHG] Device 74:84:69:65:6C:64 ServicesResolved: no
[CHG] Device 74:84:69:65:6C:64 Connected: no
[CHG] Device 74:84:69:65:6C:64 Connected: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no
[CHG] Device 74:84:69:65:6C:64 Connected: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no
[DEL] Device 74:84:69:65:6C:64 Nintendo Switch
[NEW] Device 74:84:69:65:6C:64 Nintendo Switch
[CHG] Device 74:84:69:65:6C:64 Bonded: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no
[CHG] Device 74:84:69:65:6C:64 Paired: yes
[CHG] Device 74:84:69:65:6C:64 Connected: yes
[CHG] Device 74:84:69:65:6C:64 Connected: no

It does shows "Connected" on my switch once or twice but the device never appear in the controller list.