writeCharacteristic

suspend fun writeCharacteristic(serviceUuid: UUID, characteristicUuid: UUID, value: ByteArray): Boolean

Writes a value to a characteristic on the connected BLE device.

This is a suspend function that will complete when the characteristic write operation finishes. The device must be connected before calling this method. The write type used depends on the characteristic's properties and the underlying implementation.

Return

true if the write operation completed successfully (GATT_SUCCESS), false otherwise (e.g., characteristic not found, device disconnected, write not permitted, or GATT error).

Parameters

serviceUuid

The UUID of the GATT service containing the characteristic.

characteristicUuid

The UUID of the characteristic to write to.

value

The ByteArray value to write to the characteristic.

See also

Throws

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