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

changed order of device class setting #21

Merged
merged 1 commit into from
Dec 19, 2020
Merged

changed order of device class setting #21

merged 1 commit into from
Dec 19, 2020

Conversation

mart1nro
Copy link
Owner

Pull request to fix #20

Registering the Bluetooth SDP record seems to cause the device class to be reset to 0x000c010c.
Should further investigate why that happens...

Hotfix: Changed the order of setting the device class to after registering the SDP record.

@JuanPotato
Copy link
Contributor

My class still does not change with this patch

@mart1nro
Copy link
Owner Author

@JuanPotato Can you open bluetoothctl, run the joycontrol script and send me the output of bluetoothctl?
While you at it, please send me the output of the joycontrol script as well.

@JuanPotato
Copy link
Contributor

Oh I've just noticed something, I had bluetoothctl open when I had the switch connect successfully. In both master and this branch, the class is not reflected as changed when I run hciconfig to check it. In both branches, no connection is made regardless if I change the class manually, until I open bluetoothctl. This is really weird.

bluetoothctl
Agent registered
[CHG] Controller 9C:B6:D0:8F:03:08 Pairable: yes
[CHG] Controller 9C:B6:D0:8F:03:08 Powered: no
[CHG] Controller 9C:B6:D0:8F:03:08 Discovering: no
[CHG] Controller 9C:B6:D0:8F:03:08 Class: 0x00000000
Agent unregistered
[DEL] Device 58:2F:40:73:25:97 Nintendo Switch
[DEL] Device E8:07:BF:69:E8:D1 SoundBuds Slim+
[DEL] Controller 9C:B6:D0:8F:03:08 Pro Controller [default]
Agent registered
[CHG] Controller 9C:B6:D0:8F:03:08 Class: 0x0000010c
[CHG] Controller 9C:B6:D0:8F:03:08 Powered: yes
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 Name: XtremePotatoShip
[CHG] Controller 9C:B6:D0:8F:03:08 Class: 0x00002508
[CHG] Controller 9C:B6:D0:8F:03:08 Class: 0x0000010c
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Controller 9C:B6:D0:8F:03:08 Discoverable: yes
[CHG] Device 58:2F:40:73:25:97 Connected: yes
[CHG] Controller 9C:B6:D0:8F:03:08 Discoverable: no
joycontrol when I have bluetoothctl running
[15:06:34] joycontrol.server create_hid_server::58 WARNING - [Errno 98] Address already in use
[15:06:34] joycontrol.server create_hid_server::60 WARNING - Fallback: Restarting bluetooth due to incompatibilities with the bluez "input" plugin. Disable the plugin to avoid issues. See https://github.com/mart1nro/joycontrol/issues/8.
[15:06:34] joycontrol.server create_hid_server::65 INFO - Restarting bluetooth service...
[15:06:34] joycontrol.utils run_system_command::75 DEBUG - ['systemctl restart bluetooth.service' exited with 0]
[15:06:35] joycontrol.device set_name::63 INFO - setting device name to Pro Controller...
[15:06:35] joycontrol.device set_class::55 INFO - setting device class to 0x002508...
[15:06:36] joycontrol.utils run_system_command::75 DEBUG - ['hciconfig hci0 class 0x002508' exited with 0]
[15:06:36] joycontrol.server create_hid_server::82 INFO - Advertising the Bluetooth SDP record...
[15:06:36] joycontrol.server create_hid_server::92 INFO - Waiting for Switch to connect... Please open the "Change Grip/Order" menu.
[15:06:40] joycontrol.server create_hid_server::96 INFO - Accepted connection at psm 17 from ('58:2F:40:73:25:97', 17)
[15:06:40] joycontrol.server create_hid_server::98 INFO - Accepted connection at psm 19 from ('58:2F:40:73:25:97', 19)
[15:06:40] joycontrol.protocol connection_made::107 DEBUG - Connection established.
[15:06:41] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.REQUEST_DEVICE_INFO
cmd >> [15:06:41] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SET_SHIPMENT_STATE
[15:06:41] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SPI_FLASH_READ
[15:06:42] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SPI_FLASH_READ
[15:06:42] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SET_INPUT_REPORT_MODE
[15:06:42] joycontrol.protocol _command_set_input_report_mode::320 INFO - Setting input report mode to 0x30...
[15:06:42] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.TRIGGER_BUTTONS_ELAPSED_TIME
[15:06:42] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SPI_FLASH_READ
[15:06:42] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SPI_FLASH_READ
[15:06:43] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SPI_FLASH_READ
[15:06:43] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SPI_FLASH_READ
[15:06:43] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SPI_FLASH_READ
[15:06:44] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.ENABLE_6AXIS_SENSOR
[15:06:44] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.ENABLE_VIBRATION
[15:06:44] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SET_NFC_IR_MCU_CONFIG
[15:06:45] root _reply_to_sub_command::221 INFO - received output report - Sub command SubCommand.SET_PLAYER_LIGHTS

joycontrol when I dont have bluetoothctl running
[15:12:33] joycontrol.server create_hid_server::58 WARNING - [Errno 98] Address already in use
[15:12:33] joycontrol.server create_hid_server::60 WARNING - Fallback: Restarting bluetooth due to incompatibilities with the bluez "input" plugin. Disable the plugin to avoid issues. See https://github.com/mart1nro/joycontrol/issues/8.
[15:12:33] joycontrol.server create_hid_server::65 INFO - Restarting bluetooth service...
[15:12:33] joycontrol.utils run_system_command::75 DEBUG - ['systemctl restart bluetooth.service' exited with 0]
[15:12:34] joycontrol.device set_name::63 INFO - setting device name to Pro Controller...
[15:12:34] joycontrol.device set_class::55 INFO - setting device class to 0x002508...
[15:12:34] joycontrol.utils run_system_command::75 DEBUG - ['hciconfig hci0 class 0x002508' exited with 0]
[15:12:34] joycontrol.server create_hid_server::82 INFO - Advertising the Bluetooth SDP record...
[15:12:34] joycontrol.server create_hid_server::92 INFO - Waiting for Switch to connect... Please open the "Change Grip/Order" menu.

This may be an issue just because of the way I have things set up on my laptop. I don't use bluetooth that much and am running i3 as my window manager. I'll check if this works while I'm running in gnome.

@JuanPotato
Copy link
Contributor

Same issue happens in gnome, switch refuses to recognize me until I open bluetoothctl or gnome bluetooth settings. If I run joycontrol without bluetoothctl, wait, and then open bluetoothctl, it connects and this is blueoothctl's output

Agent registered
[CHG] Controller 9C:B6:D0:8F:03:08 Pairable: yes
[CHG] Device 58:2F:40:73:25:97 Connected: yes
[CHG] Controller 9C:B6:D0:8F:03:08 Discoverable: no

which makes me think joycontrol isn't making the device pairable?

@mart1nro
Copy link
Owner Author

This is indeed strange... I don't see why it would make a difference to have bluetoothctl running.

I think I have to check back at a later date. It's getting pretty late here. Sorry I couldn't be of any help as of now.

@mart1nro
Copy link
Owner Author

Since you paired initially paired with the Switch you can use the reconnect option.
Pass -r <bluetooth_mac_address> to the script (In your case -r 58:2F:40:73:25:97).

Maybe you can at least avoid the issue this way for now.

@JuanPotato
Copy link
Contributor

Check out my patch, I'm not sure if disabling Pairable is needed but it works for me.

@mart1nro mart1nro merged commit 6e1d625 into master Dec 19, 2020
@mart1nro mart1nro deleted the fix_device_class branch December 19, 2020 21:29
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

Successfully merging this pull request may close these issues.

Bluetooth class isn't changed properly
2 participants