joycontrol icon indicating copy to clipboard operation
joycontrol copied to clipboard

KeyError: 'Name', BlueZ API yields invalid responses

Open JakkFish opened this issue 4 years ago • 19 comments

755C24A1-3F49-4704-A81A-E8F957429F01

JakkFish avatar May 14 '21 18:05 JakkFish

@JakkFish weird, will look into it. This is some convinience code to sanity check the given parameters. The hotfix: Go into joycontrol/joycontrol/device.py and change the get_paired_switches(self) definition to be the following:

    def get_paired_switches(self):
        return []

This will cause the pairing-detection to fail, meaning -r auto and unpairing sanity-check will no longer work.

A few more questions:

  • OS
  • BT-controller
  • bluez-version
  • If you want to, try using d-feet (might have to install) to look for some object with the org.bluez.Device1 interface inside the org.bluez service on the System-bus that has no Name Property.

Poohl avatar May 14 '21 20:05 Poohl

Okay i will try the code in a second also my OS is Ubuntu 20.04.2 LTS and im using Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) [8891] My bluez version 5.53 and i searched d-feet and im not sure what you mean but i have a picture im going to send of what i see

JakkFish avatar May 14 '21 21:05 JakkFish

A8459A26-CD86-4913-A2EA-54B6FA0951B3 0277C84F-82D5-4BB6-9172-32FF2F7D5638 09972660-6D0A-451C-9154-F3FDB37AFD58 also I changed def get_paired_switches(self): switches [ ] to

                      def get_paired_switches(self):
                             return [ ]

JakkFish avatar May 14 '21 21:05 JakkFish

Ok, that were the pictures I needed, thanks. The first two show some statisctics about the service I presume (I don't have them, maybe my dfeet is outdated). The last picture however is interesting. The default bluez interface is there (/org/bluez) and it's offering all the default interfaces, but there is no controller (/org/bluez/hciX). That would suggest you don't have bluetooth, but you stated you do (do the Bluetooth settings in ubuntu work?). Does bluetoothctl show show someting?

Poohl avatar May 14 '21 21:05 Poohl

My Bluetooth settings work I replugged my Bluetooth dongle and I see some other stuff in d-feet 9FEA57DF-FFE4-42CF-9CB8-8889113AC153 87960B34-639B-40C0-8972-6D1AA79C154A

Also I used Bluetoothctl in terminal and I see a really long code and it’s still going do you need a picture of that?

oh and also I replaced the code should I try to run the script again?

JakkFish avatar May 14 '21 21:05 JakkFish

yep, now the controller shows up. Try it (maybe even without the modification)

Poohl avatar May 14 '21 21:05 Poohl

Ok so I tried it and I got this 30631A43-94A4-412E-AB13-ECDCE3C9224B

then I removed the = and got this 10C7147D-89EE-4E5F-84E7-EA3C933E5E15 C3B3675F-3862-422E-A332-21D5323F780F

without modifications it’s same as the first picture I posted

JakkFish avatar May 14 '21 21:05 JakkFish

see #4 "how it should be"

Poohl avatar May 14 '21 21:05 Poohl

i tried running ExecStart=/usr/lib/bluetooth/bluetoothd -C -P sap,input,avrcp but it says "-C: command not found"

JakkFish avatar May 14 '21 22:05 JakkFish

/lib/systemd/system/bluetooth.service also permission denied and idk what to do from there

JakkFish avatar May 14 '21 22:05 JakkFish

Are you root? (Almost) nothing in this repo works as regular user. Use sudo su (not recommended) to permanently become root or prefix a command with sudo to run this command as root. To edit a file e.g. sudo nano /lib/systemd/system/bluetooth.service.

Poohl avatar May 14 '21 23:05 Poohl

I don’t think I’m root I’m using virtual box but did I do this right?

JakkFish avatar May 15 '21 00:05 JakkFish

0102DAE3-1FA2-48B2-8A76-5995A94076F4

JakkFish avatar May 15 '21 00:05 JakkFish

Good news I see this now using return [] or switches = [ ] E4574909-E57C-4AA1-95A8-28C9FBBB86C1 Which should I use though? The modify or regular? and sorry for commenting so much thank you for helping me!

JakkFish avatar May 15 '21 01:05 JakkFish

And also if you can answer one last question- How do i change the name? in /etc to Pro Controller

JakkFish avatar May 15 '21 02:05 JakkFish

No need to change name. Its done automatically And you forgot to reload and restart the service.

Poohl avatar May 15 '21 10:05 Poohl

The only problem is I have to restart ubuntu every time i run joycontrol because after i stop it or something errors i get this again 755C24A1-3F49-4704-A81A-E8F957429F01

JakkFish avatar May 15 '21 18:05 JakkFish

other then that everything is working nice!

JakkFish avatar May 15 '21 18:05 JakkFish

Ok, after some testing of my own i figured this is some issue with the BlueZ Dbus-API. Sometimes after restarting the daemon this occurs, and the effect is consintent across Applications. (E.g. d-Feet also just dies when trying to access the Name field) I'll try to come up with some workaround, but for now this only ever happened on ubuntu and even there is hard for me to reproduce. The main problem with fixing this is it's out of joycontrol's control. And ignoring might not be an option since when the dbus-api is broken there are a few more problems down the road. For more technical readers: The Name property that is expected inside the Device1 is just absent for some reason and GetAll or similar dictionary-lookups just forgo reporting it.

Poohl avatar May 17 '21 18:05 Poohl