scan And Connect To Peripheral
Connects to a BleTerminal device.
This function initiates the connection process by first validating the provided authKey
and then scanning for available BLE devices. Upon finding a matching device, it establishes a connection and performs authentication.
Error Handling: The function returns a BleError
in the following scenarios:
BleError.KeyNotFound
: TheauthKey
is not found.BleError.KeyInvalid
: TheauthKey
has an invalid length (expected 64 characters).BleError.BluetoothUnsupported
: The device does not support Bluetooth.BleError.BluetoothUnauthorized
: Bluetooth permissions are not granted.BleError.LocationUnauthorized
: Location permissions are not granted (required for BLE scanning).BleError.TerminalNotFound
: Unable to find the target BleTerminal device.
Successful Connection: Upon successful connection and authentication, the BleListener.onTerminalConnected
callback is invoked.
See also
Parameters
The duration to wait for a connection to be established.