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

KeyError: 'Name', BlueZ API yields invalid responses #6

Open
JakkFish opened this issue May 14, 2021 · 19 comments
Open

KeyError: 'Name', BlueZ API yields invalid responses #6

JakkFish opened this issue May 14, 2021 · 19 comments

Comments

@JakkFish
Copy link

755C24A1-3F49-4704-A81A-E8F957429F01

@Poohl
Copy link
Owner

Poohl commented May 14, 2021

@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.

@JakkFish
Copy link
Author

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
Copy link
Author

JakkFish commented May 14, 2021

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 [ ]

@Poohl
Copy link
Owner

Poohl commented May 14, 2021

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?

@JakkFish
Copy link
Author

JakkFish commented May 14, 2021

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?

@Poohl
Copy link
Owner

Poohl commented May 14, 2021

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

@JakkFish
Copy link
Author

JakkFish commented May 14, 2021

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

@Poohl
Copy link
Owner

Poohl commented May 14, 2021

see #4 "how it should be"

@JakkFish
Copy link
Author

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

@JakkFish
Copy link
Author

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

@Poohl
Copy link
Owner

Poohl commented May 14, 2021

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.

@JakkFish
Copy link
Author

JakkFish commented May 15, 2021

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

@JakkFish
Copy link
Author

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

@JakkFish
Copy link
Author

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
Copy link
Author

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

@Poohl
Copy link
Owner

Poohl commented May 15, 2021

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

@JakkFish
Copy link
Author

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
Copy link
Author

other then that everything is working nice!

@Poohl Poohl changed the title I get this error whenever I run the startup code KeyError: 'Name', BlueZ API yields invalid responses May 17, 2021
@Poohl
Copy link
Owner

Poohl commented May 17, 2021

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.

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

No branches or pull requests

2 participants