connectDevice

fun connectDevice(lifecycleOwner: LifecycleOwner, device: BleDevice?, duration: Long = 5000, connectCallback: ConnectStateCallback)

Connects to a Bluetooth device

Parameters

lifecycleOwner

The LifecycleOwner used to manage the connection lifecycle

device

The Bluetooth device to connect to

duration

The connection timeout in milliseconds (default is 5000 milliseconds)

connectCallback

The callback for handling connection state changes