diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2020-12-03 00:46:53 +0100 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2020-12-03 00:46:53 +0100 |
commit | 25280ed723bea3ff0afd843d8d4fc18ffd9e0153 (patch) | |
tree | 86ea18375e7aabb62150f159df8ba8c46d3db114 /nrf-softdevice-macro | |
parent | b84ee960edbcdd035ee8c95a0e2d64fdbce9f300 (diff) | |
download | nrf-softdevice-25280ed723bea3ff0afd843d8d4fc18ffd9e0153.zip |
Add write_without_response to gatt client macros
Diffstat (limited to 'nrf-softdevice-macro')
-rw-r--r-- | nrf-softdevice-macro/src/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/nrf-softdevice-macro/src/lib.rs b/nrf-softdevice-macro/src/lib.rs index 8ac6a7e..53d50f3 100644 --- a/nrf-softdevice-macro/src/lib.rs +++ b/nrf-softdevice-macro/src/lib.rs @@ -360,6 +360,8 @@ pub fn gatt_client(args: TokenStream, item: TokenStream) -> TokenStream { let cccd_handle = format_ident!("{}_cccd_handle", ch.name); let read_fn = format_ident!("{}_read", ch.name); let write_fn = format_ident!("{}_write", ch.name); + let write_wor_fn = format_ident!("{}_write_without_response", ch.name); + let write_try_wor_fn = format_ident!("{}_try_write_without_response", ch.name); let uuid = ch.args.uuid; let read = ch.args.read; @@ -435,6 +437,14 @@ pub fn gatt_client(args: TokenStream, item: TokenStream) -> TokenStream { let buf = #ty_as_val::to_gatt(&val); #ble::gatt_client::write(&self.conn, self.#value_handle, buf).await } + async fn #write_wor_fn(&self, val: #ty) -> Result<(), #ble::gatt_client::WriteError> { + let buf = #ty_as_val::to_gatt(&val); + #ble::gatt_client::write_without_response(&self.conn, self.#value_handle, buf).await + } + fn #write_try_wor_fn(&self, val: #ty) -> Result<(), #ble::gatt_client::TryWriteError> { + let buf = #ty_as_val::to_gatt(&val); + #ble::gatt_client::try_write_without_response(&self.conn, self.#value_handle, buf) + } )); } |