connect

suspend fun connect(address: String?): Result<String>(source)

Find the device with address, or the one the user picks in the scanner's own chooser, and connect to it.

A scanner that lists devices itself needs an address: choosing among advertisers is the caller's job, which then calls connect with the BleDevice picked.

Return

The device's advertised name on success; a NoDevicePickedException failure when the scanner is a device chooser the user dismissed; a DeviceNotFoundException failure when the device does not advertise within SCAN_TIMEOUT. Cancelling the caller still cancels: only the timeout is converted to a failure.

Parameters

address

The MAC address to connect to, or null where BleScanner.picksDevice is true.


suspend fun connect(device: BleDevice): Result<String>(source)

Connect to device, which the caller already chose from a scan, and return its advertised name.