Skip to content

Commit

Permalink
add support for reading rssi
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Apr 8, 2024
1 parent 369f5d5 commit fcbdf2b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions host/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -135,6 +136,14 @@ where
Ok(())
}

pub(crate) async fn read_rssi(&self, conn: ConnHandle) -> Result<i8, AdapterError<T::Error>>
where
T: ControllerCmdSync<ReadRssi>,
{
let val = ReadRssi::new(conn).exec(&self.controller).await?;
Ok(val.rssi)
}

pub(crate) async fn connect(&self, config: &ConnectConfig<'_>) -> Result<Connection<'_>, AdapterError<T::Error>>
where
T: ControllerCmdSync<LeClearFilterAcceptList>
Expand Down
18 changes: 18 additions & 0 deletions host/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use bt_hci::{
LeSetExtScanParams, LeSetScanEnable, LeSetScanParams,
},
link_control::DisconnectParams,
status::ReadRssi,
},
controller::{ControllerCmdAsync, ControllerCmdSync},
param::{BdAddr, ConnHandle, DisconnectReason, LeConnRole},
Expand Down Expand Up @@ -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<i8, AdapterError<T::Error>>
where
T: ControllerCmdSync<ReadRssi>,
{
adapter.read_rssi(self.info.handle).await
}

pub async fn connect<
M: RawMutex,
T,
Expand Down

0 comments on commit fcbdf2b

Please sign in to comment.