crownstone / bluenet

Bluenet is the in-house firmware on Crownstone hardware. Functions: switching, dimming, energy monitoring, presence detection, indoor localization, switchcraft.
https://crownstone.rocks
91 stars 62 forks source link

Packet build-up #57

Closed mrquincle closed 5 years ago

mrquincle commented 6 years ago

A lot of packets at https://github.com/crownstone/bluenet/blob/master/docs/PROTOCOL.md seem to be nicely 4-byte aligned. A state packet starts for example with two uint8_t values and then a length of uint16_t.

However, this is not done consistently. A setup package has a lot of fields that cross 4-byte boundaries. This makes storing them much more cumbersome. In the worst case, it requires copying every field to the right alignment. A protocol redesign that takes into 4 bytes separation would be useful.

For now, I'll construct wrapper structs that prepend for example the setup package with a few bytes so that most of the large fields will be 4-byte aligned.

vliedel commented 5 years ago

This is only required for flash storage, and is handled in the storage class.