RFC: Service discovery and characteristic permissions #278
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
Disclaimer: I open this PR to see if we can discuss a bit on this, indeed I don't expect it to be ready for merge yet..
Context: I'm working on a demo application written with Kivy (that should work on both Linux PCs and android devices) that scans and explores BLE devices (similar to those APPs you can find on google play market); on Linux PC platform I use pygatt for communicating with BLE.
While I found easy to get tree view of services and characteristics with android APIs, I couldn't do this with pygatt: I could only get a flat list of characteristics, but I didn't found a way to get a clue about primary services.. So my first commit in this PR adds a method to enumerate primary services. I match them with child characteristics by checking for handles numeric order outside pygatt, but maybe there is some better way to do this..
The other thing that I didn't find a way to achieve with pygatt is to detect the characteristics permissions (i.e. which could be read, which could be written, which can be subscribed for notifications, etc..). My second patch in this PR tries to add this information to the characteristics objects; it reads the characteristic declarations attributes from BLE after discovering the characteristics.
One of the problem I faced doing this, is that, while inquiring for the characteristic declarations, I got the same events flavour used also for regular characteristic reads, so I tried to workaround on this in my 3rd patch, but, again there might be better way for achieving my goal..
Indeed even if I have had already putted my hand a bit in pygatt code, I'm not very familiar with its design (and I'm mostly an embedded, low-level, C software guy), so any comment would be extremely appreciated..
Oh, I'm working on bluegiga dongles, but I would like to expand this also to the gatttool wrapper in future...
Thanks,
Andrea