ukBaz / BLE_GATT

Python package for using BlueZ D-Bus API to create a Client
MIT License
29 stars 5 forks source link

Running without sudo? / Characteristics don't appear #7

Closed hut closed 3 years ago

hut commented 3 years ago

Hi & thank you for this library.

The README says that it should be run without sudo. I can connect to a device, but whenever I try reading a characteristic, I get this error:

gi.repository.GLib.Error: g-io-error-quark: GDBus.Error:org.bluez.Error.NotPermitted: Read not permitted (36)

On a Linux Machine with Ubuntu 20.04.2 LTS.

I already tried:

No luck. How do you do this?

hut commented 3 years ago

Actually, this has nothing to do with root. The characteristic literally has no Read permissions, so nevermind that.

My actual problem is that most of the characteristics simply don't show up in central.chrcs. Not even my services appear in self.mngr.GetManagedObjects().I only see the "Generic Attribute/Service Changed" characteristic (the one I was trying to read originally, and which seems to be some maintenance thing that the ArduinoBLE library adds automatically.) Other programs like gatttool or the "BLE Tool" android app show all of the services and characteristics.

Do you perhaps know of any reason why characteristics wouldn't show up?

P.S. my device is a simple Arduino BLE 33 Sense running https://github.com/arduino-libraries/ArduinoBLE/blob/master/examples/Peripheral/BatteryMonitor/BatteryMonitor.ino

hut commented 3 years ago

The library https://github.com/getsenic/gatt-python doesn't show the services/characteristics either, so probably it's not a bug in your lib, and I just messed something up. Feel free to close.

ukBaz commented 3 years ago

When running your script have separate terminals open with the following running to get more debug information:

You might also want to check that your device is giving the correct information with a generic Bluetooth Low Energy scanning and exploration tool. The two I point people towards are:

Sounds like the issue is more generic than an issue with Bluezero so I'll close this issue, but if there is an issue with this library then please re-open

hut commented 3 years ago

For posterity, I think the characteristics didn't show up because I used reserved UUIDs. Generating random UUIDs solved the problem.

Thanks again @ukBaz for the elegant library and the helpful pointers for debugging BLE. :)