diff --git a/src/gatt/event.rs b/src/gatt/event.rs index bd09d94..353071c 100644 --- a/src/gatt/event.rs +++ b/src/gatt/event.rs @@ -12,9 +12,11 @@ pub enum Event { } #[derive(Debug)] +#[non_exhaustive] pub struct ReadRequest { pub offset: u16, pub response: ResponseSender, + pub mtu: u16, } #[derive(Debug)] diff --git a/src/peripheral/bluez/gatt/characteristic.rs b/src/peripheral/bluez/gatt/characteristic.rs index 03c4d3e..add80d8 100644 --- a/src/peripheral/bluez/gatt/characteristic.rs +++ b/src/peripheral/bluez/gatt/characteristic.rs @@ -77,6 +77,8 @@ impl Characteristic { ("value",), |mut ctx, cr, (options,): (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() @@ -93,6 +95,7 @@ impl Characteristic { .send(gatt::event::Event::ReadRequest(gatt::event::ReadRequest { offset, response: sender, + mtu, })) .await .map_err(|_| MethodErr::from((BLUEZ_ERROR_FAILED, "")))?; diff --git a/src/peripheral/bluez/gatt/descriptor.rs b/src/peripheral/bluez/gatt/descriptor.rs index 3fc6f4e..cf18e37 100644 --- a/src/peripheral/bluez/gatt/descriptor.rs +++ b/src/peripheral/bluez/gatt/descriptor.rs @@ -38,6 +38,7 @@ impl Descriptor { ("value",), |mut ctx, cr, (options,): (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() @@ -54,6 +55,7 @@ impl Descriptor { .send(gatt::event::Event::ReadRequest(gatt::event::ReadRequest { offset, response: sender, + mtu, })) .await .map_err(|_| MethodErr::from((BLUEZ_ERROR_FAILED, "")))?;