Skip to content

Commit

Permalink
feat(vendor GATT command): add Send Multiple Notification command
Browse files Browse the repository at this point in the history
  • Loading branch information
OueslatiGhaith committed Jan 4, 2024
1 parent b8222b2 commit ee54737
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/vendor/command/gatt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,15 @@ pub trait GattCommands {
/// by default, the GATT database is saved per active connection at the time of disconnecting.
async fn store_database(&mut self);

// TODO: send_mult_notification
/// This commad sends a Multiple Handle Value Notification over the ATT bearer specified in
/// parameter. The handles provided as parameters must be the handles of the characteristic
/// declarations.
async fn send_multiple_notification(
&mut self,
conn_handle: ConnectionHandle,
handles: &[AttributeHandle],
);

// TODO: read_multiple_car_char_value
}

Expand Down Expand Up @@ -1239,6 +1247,21 @@ impl<T: Controller> GattCommands for T {
self.controller_write(crate::vendor::opcode::GATT_STORE_DB, &[])
.await;
}

async fn send_multiple_notification(
&mut self,
conn_handle: ConnectionHandle,
handles: &[AttributeHandle],
) {
let mut payload = [0; 255];
LittleEndian::write_u16(&mut payload[0..], conn_handle.0);
payload[1] = handles.len() as u8;
for (idx, handle) in handles.iter().enumerate() {
LittleEndian::write_u16(&mut payload[2 + (idx * 2)..], handle.0);
}
self.controller_write(crate::vendor::opcode::GATT_SEND_MULT_NOTIFICATION, &payload)
.await;
}
}

/// Potential errors from parameter validation.
Expand Down
1 change: 1 addition & 0 deletions src/vendor/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ vendor_opcodes! {
pub const GATT_DENY_READ = 0x2D;
pub const GATT_SET_ACCESS_PERMISSION = 0x2E;
pub const GATT_STORE_DB = 0x30;
pub const GATT_SEND_MULT_NOTIFICATION = 0x31;
}
L2Cap = 0x3;
{
Expand Down

0 comments on commit ee54737

Please sign in to comment.