combustion-inc / combustion-documentation

Probe BLE specification and other public documentation.
22 stars 2 forks source link

Clarify bit numbering #23

Closed simonft closed 10 months ago

simonft commented 10 months ago

This could just me not being used to dealing directly with bits, but it would have been helpful for me if the bit ordering scheme used was stated somewhere. It looks like the docs are using LSb 0 (or I guess LSb 1 since they go from 1-8?). I eventually figured this out, but the parsing libraries I was attempting to use were MSb 0 by default.

In the UART headers section it also talks about the "leftmost bit" being 1 or 0, which I would have expected to mean bit 1, but I think actually means bit 8 (the most significant bit).

jmaha commented 10 months ago

Thanks for reaching out. Decoding those fields is a bit confusing. I should add some notes explaining that the struct definitions are from the perspective of our ARM C++ compiler's handling of packed structs with bit-fields. Depending on how you're decoding them, you might need to jump through some hoops to decode the data.

When we have some time, I'll clean up some Python libraries we've written for interfacing with the Combustion products and publish them in this repository. Those provide a helpful reference for figuring out how to retrieve the data. In the meantime, I posted a hopefully helpful code snippet showing how to decode these fields in Python here: https://github.com/combustion-inc/combustion-documentation/issues/24