diff --git a/host/src/adapter.rs b/host/src/adapter.rs index 2d3bd5f..8eb7851 100644 --- a/host/src/adapter.rs +++ b/host/src/adapter.rs @@ -18,6 +18,7 @@ use bt_hci::cmd::le::{ LeSetScanEnable, LeSetScanParams, }; use bt_hci::cmd::link_control::{Disconnect, DisconnectParams}; +use bt_hci::cmd::status::ReadRssi; use bt_hci::cmd::{AsyncCmd, SyncCmd}; use bt_hci::controller::Controller; use bt_hci::controller::{ControllerCmdAsync, ControllerCmdSync}; @@ -135,6 +136,14 @@ where Ok(()) } + pub(crate) async fn read_rssi(&self, conn: ConnHandle) -> Result> + where + T: ControllerCmdSync, + { + let val = ReadRssi::new(conn).exec(&self.controller).await?; + Ok(val.rssi) + } + pub(crate) async fn connect(&self, config: &ConnectConfig<'_>) -> Result, AdapterError> where T: ControllerCmdSync diff --git a/host/src/connection.rs b/host/src/connection.rs index 50b73d4..0222251 100644 --- a/host/src/connection.rs +++ b/host/src/connection.rs @@ -5,6 +5,7 @@ use bt_hci::{ LeSetExtScanParams, LeSetScanEnable, LeSetScanParams, }, link_control::DisconnectParams, + status::ReadRssi, }, controller::{ControllerCmdAsync, ControllerCmdSync}, param::{BdAddr, ConnHandle, DisconnectReason, LeConnRole}, @@ -86,6 +87,23 @@ impl<'d> Connection<'d> { self.info.peer_address } + pub async fn rssi< + M: RawMutex, + T, + const CONNS: usize, + const CHANNELS: usize, + const L2CAP_TXQ: usize, + const L2CAP_RXQ: usize, + >( + &self, + adapter: &'d Adapter<'_, M, T, CONNS, CHANNELS, L2CAP_TXQ, L2CAP_RXQ>, + ) -> Result> + where + T: ControllerCmdSync, + { + adapter.read_rssi(self.info.handle).await + } + pub async fn connect< M: RawMutex, T,