From 18688ae733d2e204bb0c5a810751fda07b94d443 Mon Sep 17 00:00:00 2001 From: Bob McWhirter Date: Mon, 16 May 2022 13:26:11 -0400 Subject: Add support for `write_without_response` on server characteristics. Sets the appropriate flag in the Softdevice database. --- nrf-softdevice-macro/src/lib.rs | 6 +++++- nrf-softdevice/src/ble/gatt_server.rs | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nrf-softdevice-macro/src/lib.rs b/nrf-softdevice-macro/src/lib.rs index 3a73263..b0382d6 100644 --- a/nrf-softdevice-macro/src/lib.rs +++ b/nrf-softdevice-macro/src/lib.rs @@ -25,6 +25,8 @@ struct CharacteristicArgs { #[darling(default)] write: bool, #[darling(default)] + write_without_response: bool, + #[darling(default)] notify: bool, #[darling(default)] indicate: bool, @@ -221,6 +223,7 @@ pub fn gatt_service(args: TokenStream, item: TokenStream) -> TokenStream { let uuid = ch.args.uuid; let read = ch.args.read; let write = ch.args.write; + let write_without_response = ch.args.write_without_response; let notify = ch.args.notify; let indicate = ch.args.indicate; let ty = &ch.ty; @@ -240,6 +243,7 @@ pub fn gatt_service(args: TokenStream, item: TokenStream) -> TokenStream { uuid: #uuid, can_read: #read, can_write: #write, + can_write_without_response: #write_without_response, can_notify: #notify, can_indicate: #indicate, max_len: #ty_as_val::MAX_SIZE as _, @@ -281,7 +285,7 @@ pub fn gatt_service(args: TokenStream, item: TokenStream) -> TokenStream { )); } - if write { + if write || write_without_response { let case_write = format_ident!("{}Write", name_pascal); code_event_enum.extend(quote_spanned!(ch.span=> #case_write(#ty), diff --git a/nrf-softdevice/src/ble/gatt_server.rs b/nrf-softdevice/src/ble/gatt_server.rs index 6c7eb8c..398f88d 100644 --- a/nrf-softdevice/src/ble/gatt_server.rs +++ b/nrf-softdevice/src/ble/gatt_server.rs @@ -15,6 +15,7 @@ pub struct Characteristic { pub uuid: Uuid, pub can_read: bool, pub can_write: bool, + pub can_write_without_response: bool, pub can_notify: bool, pub can_indicate: bool, pub max_len: usize, @@ -107,6 +108,9 @@ pub fn register_service(_sd: &Softdevice) -> Result