From df1256e89ca3a5da49954044b53f5225f9ca9d31 Mon Sep 17 00:00:00 2001 From: chrysn Date: Sun, 12 Mar 2023 01:43:20 +0100 Subject: [PATCH] WriteRequest: Add mtu field Contributes-To: https://github.com/dfrankland/bluster/issues/46 --- src/gatt/event.rs | 1 + src/peripheral/bluez/gatt/characteristic.rs | 2 ++ src/peripheral/bluez/gatt/descriptor.rs | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/gatt/event.rs b/src/gatt/event.rs index 61285cb..cf79ac9 100644 --- a/src/gatt/event.rs +++ b/src/gatt/event.rs @@ -26,6 +26,7 @@ pub struct WriteRequest { pub offset: u16, pub without_response: bool, pub response: ResponseSender, + pub mtu: u16, } #[derive(Debug, Clone)] diff --git a/src/peripheral/bluez/gatt/characteristic.rs b/src/peripheral/bluez/gatt/characteristic.rs index add80d8..875d272 100644 --- a/src/peripheral/bluez/gatt/characteristic.rs +++ b/src/peripheral/bluez/gatt/characteristic.rs @@ -116,6 +116,7 @@ impl Characteristic { ("value",), |mut ctx, cr, (data, options): (Vec, OptionsMap)| { let offset = options.get("offset").and_then(RefArg::as_u64).unwrap_or(0) as u16; + let mtu = options.get("mtu").and_then(RefArg::as_u64).unwrap_or(23) as u16; let characteristic = cr .data_mut::(ctx.path()) .unwrap() @@ -135,6 +136,7 @@ impl Characteristic { offset, without_response: false, response: sender, + mtu, }, )) .await diff --git a/src/peripheral/bluez/gatt/descriptor.rs b/src/peripheral/bluez/gatt/descriptor.rs index cf18e37..eddf4ff 100644 --- a/src/peripheral/bluez/gatt/descriptor.rs +++ b/src/peripheral/bluez/gatt/descriptor.rs @@ -76,6 +76,7 @@ impl Descriptor { ("value",), |mut ctx, cr, (data, options): (Vec, OptionsMap)| { let offset = options.get("offset").and_then(RefArg::as_u64).unwrap_or(0) as u16; + let mtu = options.get("mtu").and_then(RefArg::as_u64).unwrap_or(23) as u16; let descriptor = cr .data_mut::(ctx.path()) .unwrap() @@ -95,6 +96,7 @@ impl Descriptor { offset, without_response: false, response: sender, + mtu, }, )) .await