write

suspend fun write(newValue: ByteArray, writeType: WriteType): GattResponse.WriteResponse

Requests a write of newValue to the characteristic using the given writeType and suspends until the result is received. The characteristic must support the property corresponding to writeType, otherwise GattResponse.WriteNotPermitted is returned.

Return

the GattResponse.WriteResponse received from the device

Parameters

newValue

the ByteArray to write

writeType

the WriteType to use


suspend fun <T> write(serializationStrategy: SerializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat, newValue: T, writeType: WriteType): GattResponse.WriteResponse

Attempts to write a value of T to the characteristic using the given writeType and suspends until the write completes.

Return

the GattResponse.WriteResponse received from the remote device.

Parameters

serializationStrategy

the SerializationStrategy to use to serialize the value.

bluetoothFormat

the BluetoothFormat to use to serialize the value.

newValue

the T to write.

writeType

the WriteType to use

Type Parameters

T

the type of the data object to write.


inline suspend fun <T> write(bluetoothFormat: BluetoothFormat = BluetoothFormat, newValue: T, writeType: WriteType): GattResponse.WriteResponse

Attempts to write a value of T to the characteristic using the given writeType and suspends until the write completes.

Return

the GattResponse.WriteResponse received from the remote device.

Parameters

bluetoothFormat

the BluetoothFormat to use to serialize the value.

newValue

the T to write.

writeType

the WriteType to use

Type Parameters

T

the type of the data object to write.