Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ pub trait Central: Send + Sync + Clone {
/// Add a [`Peripheral`] from a MAC address without a scan result. Not supported on all Bluetooth systems.
async fn add_peripheral(&self, address: &PeripheralId) -> Result<Self::Peripheral>;

/// Clear the list of [`Peripheral`]s that have been discovered so far.
async fn clear_peripherals(&self) -> Result<()>;

/// Get information about the Bluetooth adapter being used, such as the model or type.
///
/// The details of this are platform-specific andyou should not attempt to parse it, but it may
Expand Down
6 changes: 6 additions & 0 deletions src/bluez/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ impl Central for Adapter {
))
}

async fn clear_peripherals(&self) -> Result<()> {
Err(Error::NotSupported(
"Can't clear peripheral list on this platform".to_string(),
))
}

async fn adapter_info(&self) -> Result<String> {
let adapter_info = self.session.get_adapter_info(&self.adapter).await?;
Ok(format!("{} ({})", adapter_info.id, adapter_info.modalias))
Expand Down
4 changes: 4 additions & 0 deletions src/common/adapter_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ where
self.peripherals.insert(peripheral.id(), peripheral);
}

pub fn clear_peripherals(&self) {
self.peripherals.clear();
}

pub fn peripherals(&self) -> Vec<PeripheralType> {
self.peripherals
.iter()
Expand Down
5 changes: 5 additions & 0 deletions src/corebluetooth/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ impl Central for Adapter {
))
}

async fn clear_peripherals(&self) -> Result<()> {
self.manager.clear_peripherals();
Ok(())
}

async fn adapter_info(&self) -> Result<String> {
// TODO: Get information about the adapter.
Ok("CoreBluetooth".to_string())
Expand Down
5 changes: 5 additions & 0 deletions src/droidplug/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ impl Central for Adapter {
async fn add_peripheral(&self, address: &PeripheralId) -> Result<Peripheral> {
self.add(address.0)
}

async fn clear_peripherals(&self) -> Result<()> {
self.manager.clear_peripherals();
Ok(())
}
}

pub(crate) fn adapter_report_scan_result_internal(
Expand Down
5 changes: 5 additions & 0 deletions src/winrtble/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ impl Central for Adapter {
))
}

async fn clear_peripherals(&self) -> Result<()> {
self.manager.clear_peripherals();
Ok(())
}

async fn adapter_info(&self) -> Result<String> {
// TODO: Get information about the adapter.
Ok("WinRT".to_string())
Expand Down