write Long Characteristic Result
Writes a large value to a characteristic using sequential chunked writes, returning a BleResult.
This is a type-safe alternative to writeLongCharacteristic that returns detailed error information instead of a boolean. Use this method when you need to distinguish between different failure causes.
The method automatically splits the data into chunks that fit within the current MTU size and writes them sequentially. If the value is small enough to fit in a single write (within MTU - 3 bytes for ATT header), it delegates to regular write.
Usage Example
val firmwareData = readFirmwareFile()
connection.writeLongCharacteristicResult(serviceUuid, charUuid, firmwareData)
.onSuccess {
Log.i("BLE", "Firmware upload complete")
}
.onFailure { error ->
when (error) {
is BleCharacteristicException -> {
Log.e("BLE", "Write failed with GATT status: ${error.gattStatus}")
}
else -> Log.e("BLE", "Error: ${error.message}")
}
}Return
A BleResult containing either: - BleResult.Success with Unit indicating all chunks were written successfully - BleResult.Failure with a BleCharacteristicException
Parameters
The UUID of the GATT service containing the characteristic.
The UUID of the characteristic to write to.
The ByteArray value to write. Can be larger than MTU.