Open
Description
Hello you all were able to help me earlier with #272 . I'm finally looking to pick that project back up and it seems that the gatt_service
macro can't handle &'static str
values. I get the following error:
error[E0599]: no associated item named `Value` found for struct `DeviceInfoService` in the current scope
--> rp_firmware/src/bluetooth.rs:110:63
|
25 | #[gatt_service(uuid = "0000180a-0000-1000-8000-00805f9b34fb")]
| -------------------------------------------------------------- associated item `Value` not found for this struct
...
110 | AdStructure::ServiceUuids128(&[DeviceInfoService::Value]),
| ^^^^^ associated item not found in `DeviceInfoService`
error[E0080]: could not evaluate static initializer
--> rp_firmware/src/bluetooth.rs:38:20
|
38 | serial_number: &'static str,
| ^ values of the type `[u8; usize::MAX]` are too big for the target architecture
Some errors have detailed explanations: E0080, E0599.
For more information about an error, try `rustc --explain E0080`.
Poking around a bit it looks like the result of the AsGatt
implmentation of &str
setting MAX_SIZE = usize::MAX
:
impl AsGatt for &'static str {
const MIN_SIZE: usize = 0;
const MAX_SIZE: usize = usize::MAX;
fn as_gatt(&self) -> &[u8] {
self.as_bytes()
}
}
and the macro having the following instantiation of StaticCell
:
static #name_screaming: static_cell::StaticCell<[u8; <#ty as trouble_host::types::gatt_traits::AsGatt>::MAX_SIZE]> = static_cell::StaticCell::new();
It looks like this would also impact the impl for &[u8]
since that sets MAX_SIZE
the same way