protected open fun connectAsyncInternal(: Any, : CancellationToken?, : ((scanResult: SearchScanResult) -> Unit)?, : TimeSpan?, : ((foundDevice: Boolean) -> Unit)?): Task<NIMMSTADevice>
Connects a device by providing a ConnectionCode or DeviceAddress. Will search for the specific NIMMSTA Device until cancellation. Searches with the existing DeviceScanner
BluetoothNotInitializedException
- if bluetooth is disabled
LocationServicesNotEnabledException
- if location services are disabled
BluetoothPermissionException
- if location permissions are missing
ScanningDoesNotFindAnyDeviceException
- if we did not find any device for several seconds.
You should call this method again to restart scanning.
DeviceScanTimeoutException
- if scan-timeout specified in scanTimeout was reached
connectionInfo
- The ConnectionCode or DeviceAddress you want to connect to. For HS 50 use HS50ConnectionCode, for BLE BluetoothDeviceMacAddress
cancellationToken
- A CancellationToken if you want to be able to cancel the connect.
deviceFound
- you can register a callback here that is called once a device was found.
It means that it starts connecting to it at this point in time and
the task will be finished once the device is connected or connection failed.
scanTimeout
- defines how long the scanning should take place. This does not limit the time for a
connection attempt if a device was already found. By default is null and therefore no timeout.
Return
Task You can register for that to get the device that was connected or an exception that was thrown
Cancel task to cancel search.