Closed StevenLooman closed 7 years ago
Another note on the changes. No longer are handles used (directly.) It seems that the handles to read from/write to are static but do appear to change with bulb versions. A UUID is used to access the characteristics (0xFFE4 for notifications/reading, 0xFFE9 for writing commands) to retrieve the necessary handles from the bulb.
Please wait before merging. I am having some troubles due to sudo
being used from pygatt
.
I will explain later.
Lot of good changes in here ! I like what you've done with the @connection_required
decorator.
I'll start testing this during the week to assist you with this task :+1:
The fact we have to be root to access the bluetooth device is very inconvenient. Haven't tried this yet but maybe I could also add a section in README to explain how to make BLE device accessible for non root (as with this link)
And I've moved back to bluepy
again... when I was testing the homeassistant-magicblue component I got several password-entry request from sudo
.
This can be worked around by creating 5 entries in /etc/sudoers
giving a specific user the ability to run 5 commands passwordless. But this feels like a hurdle compared to running a single command to set capabilities for hcitool
.
Also, if hcitool
has the capabilities, there is no need to run the shell as root
/using sudo
. I tried to find a library to check capabilities, but couldn't find one. I'll create an issue for this.
Please test this version. I was able to get notifications using bluepy
. Turns out pygatt
simply sends a special message to subscribe.
After this is merged, I'll create a pull request for homeassistant-magicblue to incorporate the new abilities of this library.
Everything run fine with my v7 bulb, thank for this PR :wink:
I'll release a new version with these changes
Thanks!
Following up on #17. Here is a pull request which moves
magicblue
topygatt
frombluepy
, and further implements the protocol.Unfortunately, I have (yet) seen no way to dynamically figure out the address type to use. The software does try to guess if no version is given, but your mileage may vary. Maybe we can detect it from the bulb-address? Please, let me know the versions and mac addresses of your bulb(s).
Also, scanning for bulbs is now slightly altered.
pygatt
reports all found devices at once after scanning.bluepy
uses a callback which is called during scanning. In the new method of scanning, it might look scanning has stalled. Therefore, I have shortened the scanning-time to 10 seconds.Please, feel free to provide any feedback. And, of course, do test this on your own bulb(s)! For my V10 bulbs all implemented functions work.