-
Notifications
You must be signed in to change notification settings - Fork 310
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
Format Characteristics Value following Bluetooth SIG specification #237
Comments
I like the idea, but I am not sure about adding it as default behaviour for the read method. It you would implement something like def get_char_value(value: Union[bytes, bytestring], characteristic: BleakGATTCharacteristic) -> dict:
... and add that to |
Yes, this is not intended to replace the read method, it is just a utility to unpack/decode those bytes into the right variables.
Yes this is in fact trivial with characteristics that encode a single value, like So this feature may save some work time when trying to read more complex characteristics.
The only "downside" I see is that it needs the xml file of each characteristic, then they should be included in the installation (about 3.5 MB). I will fork and implement this into the develop branch, then I will make a proper PR explaining everything in detail so you can decide and cherry-pick what is worthy. 👍 |
@hbldh I've just merged this feature into the develop branch of my fork, see Carglglz#1 so you can test this with the phone (nRF Connect) or another device (microbit, esp32, sensor tag, etc.) |
This is interesting indeed. Is it possible to trim down the xmls to what you actually need instead of including the entire files? This will grow the size of the bleak installation by many order of magnitudes, and I am reluctant to do so. I think it would be better to extract this into a separate package ( |
I'm afraid it is not possible, I would say that almost 90% of the xml file is relevant , but this:
I think it is a nice solution, I could make a test repo and maybe add some documentation about how it is done and the limitations or future enhancements that it could have. I will let you know when it is ready to test. 👍 |
@hbldh |
Nice! Regarding the fixes and addons, please make a pull request of it towards the Feel free to include documentation changes referring people to your package in the documentation! It is enough relevant to also merit reference in the README, imo. |
I will try to get this done by the end of this week, since I would like to double check everything and update the documentation accordingly. I will make a PR when it's done and I will let you know. 👍 |
Sounds fine! I will not be available to do any work with the PR until middle of next week anyway I am afraid... |
Great Idea! Tried to use |
Hi @polskafan I'm still working on this. About b) The good news is that I think is doable. The bad news is I that I will need to introduce some changes to check for this specific characteristic and use its own method. I can't do this right now but I will point you in the right direction: Since this characteristic has a
So that's it, just check |
Well It took me longer than expected, but I think this is almost done, now I have to write the documentation #266.
This should add compatibility with any characteristic with a proper xml file and a compatible encoding format. |
This looks very interesting, but I just want to request some modifications on how this is brought into Bleak:
These two I would like to have added as a separate PR, related to uuids. The
The two fixes and the added RSSI could be one PR, addressing macOS issues.
These two I had planned to present in the |
I agree, this in fact would make things easier, so here are the PRs:
I've already moved the xml parser and characteristics formatter to |
Fixed #273 and PR is ready. |
It looks good! I regard this as done and will make sure reference to |
I just want to mention that the documentation is now done and the package is already on PYPI. https://pypi.org/project/bleak-sigspec/ Also if help is needed with #266 , I'm in. And finally I'm very pleased with |
Very nice. I will get the 0.8.0 release out first and focus on 266 after that. There is a |
Hi, this is an enhancement proposal.
The feature I'm proposing is to automatically format a characteristic value following Bluetooth SIG specification.
This would work the same way as nRF Connect android app, e.g. in
service_explorer.py
example instead of:where
value
is a bytearray, implementing a function likeget_char_value
:This function will format the bytearray according to the characteristic.
For example reading the
Temperature
characteristic, thevalue
in this case could beb'\xc4\t'
, thenformatted_value
wil be:{'Temperature':{'Value':25.00, 'Symbol': 'ºC'}}
I've already got this working, although I haven't test all the characteristic (there are around 283...) I think this looks promising, so If there is any interest in this feature I could make a PR this or the next week. 👍
The text was updated successfully, but these errors were encountered: