readCharacteristic

suspend fun readCharacteristic(serviceUuid: UUID, characteristicUuid: UUID): ByteArray?

Reads the value of a characteristic from the connected BLE device.

This is a suspend function that will complete when the characteristic read operation finishes. The device must be connected before calling this method.

For more detailed error information, consider using readCharacteristicResult instead, which returns a BleResult with specific error types.

Return

The characteristic value as a ByteArray if the read was successful, or null if the read operation failed (e.g., characteristic not found, device disconnected, or GATT error).

Parameters

serviceUuid

The UUID of the GATT service containing the characteristic.

characteristicUuid

The UUID of the characteristic to read.

See also

Throws

If called when the device is not connected (depending on implementation).