Skip to content

Commit

Permalink
WriteRequest: Add mtu field
Browse files Browse the repository at this point in the history
Contributes-To: dfrankland#46
  • Loading branch information
chrysn committed Jul 23, 2024
1 parent 5a4ecd0 commit df1256e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gatt/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct WriteRequest {
pub offset: u16,
pub without_response: bool,
pub response: ResponseSender,
pub mtu: u16,
}

#[derive(Debug, Clone)]
Expand Down
2 changes: 2 additions & 0 deletions src/peripheral/bluez/gatt/characteristic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl Characteristic {
("value",),
|mut ctx, cr, (data, options): (Vec<u8>, 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::<GattDataType>(ctx.path())
.unwrap()
Expand All @@ -135,6 +136,7 @@ impl Characteristic {
offset,
without_response: false,
response: sender,
mtu,
},
))
.await
Expand Down
2 changes: 2 additions & 0 deletions src/peripheral/bluez/gatt/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl Descriptor {
("value",),
|mut ctx, cr, (data, options): (Vec<u8>, 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::<GattDataType>(ctx.path())
.unwrap()
Expand All @@ -95,6 +96,7 @@ impl Descriptor {
offset,
without_response: false,
response: sender,
mtu,
},
))
.await
Expand Down

0 comments on commit df1256e

Please sign in to comment.