From 73ce069de154d36eae4455e1b7c6d14f66f6ee4b Mon Sep 17 00:00:00 2001 From: Alex Moon Date: Tue, 19 Mar 2024 13:40:16 -0400 Subject: [PATCH] Fix a couple of gatt_client macro bugs - The CCCD handle was not being checked for validity on discovery complete - The notifications event enum was not being given a visibility matching the client struct --- nrf-softdevice-macro/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nrf-softdevice-macro/src/lib.rs b/nrf-softdevice-macro/src/lib.rs index a07632d..43fdb0b 100644 --- a/nrf-softdevice-macro/src/lib.rs +++ b/nrf-softdevice-macro/src/lib.rs @@ -680,7 +680,7 @@ pub fn gatt_client(args: TokenStream, item: TokenStream) -> TokenStream { #cccd_handle: 0, )); code_disc_done.extend(quote_spanned!(ch.span=> - if self.#value_handle == 0 { + if self.#cccd_handle == 0 { return Err(#ble::gatt_client::DiscoverError::ServiceIncomplete); } )); @@ -746,6 +746,7 @@ pub fn gatt_client(args: TokenStream, item: TokenStream) -> TokenStream { let uuid = args.uuid; struct_fields.named = syn::punctuated::Punctuated::from_iter(fields); + let vis = struc.vis.clone(); let result = quote! { #struc @@ -789,7 +790,7 @@ pub fn gatt_client(args: TokenStream, item: TokenStream) -> TokenStream { } } - enum #event_enum_name { + #vis enum #event_enum_name { #code_event_enum } };