embassy-rs / trouble

A Rust Host BLE stack with a future goal of qualification.
Apache License 2.0
121 stars 24 forks source link

Allow values different from `[u8]` in `AttributeTable` #153

Open Erik1000 opened 1 month ago

Erik1000 commented 1 month ago

I find it quite counter-intuitive that one defines a characteristic with the characteristic macro and some type but this type is never actually used as a value since it is only used in the macro to initialize the storage capacity of the array in the StaticCell using [0; size_of::<T>()].

I would find it much more intuitive if one could use an array that has the same type as in the characteristic macro and enforce some kind of (de)serialization trait to convert it to its bytes representation as it would be used by the bluetooth stack. It would also allow for more type safety, because one would not work with raw bytes.

petekubiak commented 1 month ago

We're in the process of implementing this as part of #151. The idea is that get, set and notify will require the expected type for that characteristic rather than &[u8]