pygattlib icon indicating copy to clipboard operation
pygattlib copied to clipboard

Notifications have three extra bytes at start

Open vmedea opened this issue 4 years ago • 2 comments

It looks like notifications received through on_notification have three extra bytes prefixed compared to when using gattool, b'\x1b\x0e\x00'. I think this is the 3-byte header containing the opcode and originating handle

(I'm not sure that this is a problem, but it was unexpected to me, so it might make sense to at least document it)

vmedea avatar Dec 02 '20 15:12 vmedea

Yes, I noticed that too. Currently you just have to ignore the first 3 bytes.

Also, the various attribute reading functions return an array of bytestrings, even if they can only return one value and so returning the bytestring directly would make more sense.

I thought about submitting a patch to "correct" that, but that would involve changing the API on a module already out there that people may be relying on. I don't know how Oscar would feel about that but it seems potentially quite disruptive to me, even if the resulting API would be a lot cleaner.

(One possibility would be a constructor parameter to GATTRequester saying which calling convention to use...)

jsgh avatar Jan 24 '21 04:01 jsgh

Yes, I think that should be fixed as you comment. And I agree with you that changing the API would be cumbersome for some people (included me :D), but the idea of versioning the API (and enabling the user to continue using the legacy one) is a good approach.

If no one could do it sooner, I'll try to fix it when I have a free time-slot. ;)

oscaracena avatar Jan 28 '21 07:01 oscaracena