embassy-rs / trouble

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

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

Open Erik1000 opened 1 week ago

Erik1000 commented 1 week 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 week 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]