(&self, filter: ScanFilter)
| 87 | } |
| 88 | |
| 89 | async fn start_scan(&self, filter: ScanFilter) -> Result<()> { |
| 90 | let watcher = self.watcher.lock().map_err(Into::<Error>::into)?; |
| 91 | let manager = self.manager.clone(); |
| 92 | watcher.start( |
| 93 | filter, |
| 94 | Box::new(move |args| { |
| 95 | let bluetooth_address = args.BluetoothAddress()?; |
| 96 | let address: BDAddr = bluetooth_address.try_into().unwrap(); |
| 97 | if let Some(mut entry) = manager.peripheral_mut(&address.into()) { |
| 98 | entry.value_mut().update_properties(args); |
| 99 | manager.emit(CentralEvent::DeviceUpdated(address.into())); |
| 100 | } else { |
| 101 | let peripheral = Peripheral::new(Arc::downgrade(&manager), address); |
| 102 | peripheral.update_properties(args); |
| 103 | manager.add_peripheral(peripheral); |
| 104 | manager.emit(CentralEvent::DeviceDiscovered(address.into())); |
| 105 | } |
| 106 | Ok(()) |
| 107 | }), |
| 108 | ) |
| 109 | } |
| 110 | |
| 111 | async fn stop_scan(&self) -> Result<()> { |
| 112 | let watcher = self.watcher.lock().map_err(Into::<Error>::into)?; |
nothing calls this directly
no test coverage detected