Skip to content

Commit 07fa452

Browse files
authored
Merge pull request #216 from pperanich/fix-variable-fields
fix: initialize storage arrays manually instead of `Default::default()`
2 parents f7c7732 + 60f6460 commit 07fa452

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

host-macros/src/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl ServiceBuilder {
150150
static #name_screaming: static_cell::StaticCell<[u8; <#ty as GattValue>::MAX_SIZE]> = static_cell::StaticCell::new();
151151
let mut val = <#ty>::default(); // constrain the type of the value here
152152
val = #default_value; // update the temporary value with our new default
153-
let store = #name_screaming.init(Default::default());
153+
let store = #name_screaming.init([0; <#ty as GattValue>::MAX_SIZE]);
154154
let mut builder = service
155155
.add_characteristic(#uuid, &[#(#properties),*], val, store);
156156
#descriptors

host/tests/gatt_derive.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const VALUE_UUID: Uuid = Uuid::new_long([
1616
0x00, 0x00, 0x10, 0x01, 0xb0, 0xcd, 0x11, 0xec, 0x87, 0x1f, 0xd4, 0x5d, 0xdf, 0x13, 0x88, 0x40,
1717
]);
1818

19-
#[gatt_server(mutex_type = NoopRawMutex, attribute_table_size = 22)]
19+
#[gatt_server(mutex_type = NoopRawMutex, attribute_table_size = 25)]
2020
struct Server {
2121
service: CustomService,
2222
}
@@ -40,6 +40,8 @@ struct CustomService {
4040
pub third: [u8; 2],
4141
#[characteristic(uuid = "408816df-5dd4-1f87-ec11-cdb001100000", read, write, notify)]
4242
pub fourth: heapless::Vec<u8, 3>,
43+
#[characteristic(uuid = "408817df-5dd4-1f87-ec11-cdb001100000", read, write, notify)]
44+
pub fifth: heapless::Vec<u8, 33>,
4345
}
4446

4547
#[tokio::test]

0 commit comments

Comments
 (0)