recover With
Attempts to recover from a failure using another BleResult.
If this is a Failure, returns the result of the recovery function. If this is a Success, returns the same Success unchanged.
val result = primaryConnection
.readCharacteristicResult(serviceUuid, charUuid)
.recoverWith { error ->
Log.w("BLE", "Primary failed, trying backup: ${error.message}")
backupConnection.readCharacteristicResult(serviceUuid, charUuid)
}Content copied to clipboard
Return
The original success or the recovery result.
Parameters
recovery
The function that provides the recovery BleResult.