run Catching Ble
Wraps the execution of block in a BleResult.
If block completes successfully, returns BleResult.Success with the result. If block throws a BleException, returns BleResult.Failure with that exception. Other exceptions are not caught and will propagate.
val result: BleResult<ByteArray> = runCatchingBle {
connection.readCharacteristic(serviceUuid, charUuid)
?: throw BleCharacteristicException("Read returned null")
}Content copied to clipboard
Return
A BleResult containing either the success value or the caught BleException.
Parameters
block
The block of code to execute.