MCPcopy Create free account
hub / github.com/deviceplug/btleplug / start_scan

Method start_scan

src/winrtble/adapter.rs:89–109  ·  view source on GitHub ↗
(&self, filter: ScanFilter)

Source from the content-addressed store, hash-verified

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)?;

Callers

nothing calls this directly

Calls 5

startMethod · 0.80
peripheral_mutMethod · 0.80
update_propertiesMethod · 0.80
emitMethod · 0.80
add_peripheralMethod · 0.45

Tested by

no test coverage detected