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

Method connect

src/corebluetooth/peripheral.rs:279–299  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

277 }
278
279 async fn connect(&self) -> Result<()> {
280 let fut = CoreBluetoothReplyFuture::default();
281 self.shared
282 .message_sender
283 .to_owned()
284 .send(CoreBluetoothMessage::ConnectDevice {
285 peripheral_uuid: self.shared.uuid,
286 future: fut.get_state_clone(),
287 })
288 .await?;
289 match fut.await {
290 CoreBluetoothReply::Connected => {
291 self.shared
292 .emit_event(CentralEvent::DeviceConnected(self.shared.uuid.into()));
293 }
294 CoreBluetoothReply::Err(msg) => return Err(Error::RuntimeError(msg)),
295 _ => panic!("Shouldn't get anything but connected or err!"),
296 }
297 trace!("Device connected!");
298 Ok(())
299 }
300
301 async fn disconnect(&self) -> Result<()> {
302 let fut = CoreBluetoothReplyFuture::default();

Callers

nothing calls this directly

Calls 2

get_state_cloneMethod · 0.80
emit_eventMethod · 0.45

Tested by

no test coverage detected