diff --git a/src/corebluetooth/adapter.rs b/src/corebluetooth/adapter.rs index 0c489a28..f1c5170c 100644 --- a/src/corebluetooth/adapter.rs +++ b/src/corebluetooth/adapter.rs @@ -140,6 +140,11 @@ impl Central for Adapter { async fn clear_peripherals(&self) -> Result<()> { self.manager.clear_peripherals(); + self.sender + .to_owned() + .send(CoreBluetoothMessage::ClearPeripherals) + .await + .map_err(|e| Error::Other(Box::new(e)))?; Ok(()) } diff --git a/src/corebluetooth/internal.rs b/src/corebluetooth/internal.rs index c0f42aa6..59ac0b77 100644 --- a/src/corebluetooth/internal.rs +++ b/src/corebluetooth/internal.rs @@ -499,6 +499,7 @@ pub enum CoreBluetoothMessage { peripheral_uuid: Uuid, future: CoreBluetoothReplyStateShared, }, + ClearPeripherals, } #[derive(Debug)] @@ -1438,6 +1439,9 @@ impl CoreBluetoothInternal { CoreBluetoothMessage::ReadRssi{peripheral_uuid, future} => { self.read_rssi(peripheral_uuid, future) } + CoreBluetoothMessage::ClearPeripherals => { + self.peripherals.clear(); + } }; } }