writeValueWithResponse method
Will write a new value to the characteristic.
This will not update the WebBluetoothRemoteGATTCharacteristic.value property.
Write a value and wait for the response of the device before continuing.
This method may not be implemented in the current browser version. Check this by calling hasWriteValueWithResponse. ignore: deprecated_member_use_from_same_package Otherwise use writeValue.
-
May throw NativeAPINotImplementedError if the method does not exist.
-
May throw NotSupportedError if the operation is not allowed. Check properties to see if it is supported.
-
May throw SecurityError if the characteristic is blocked form writing using a blocklist.
-
May throw NetworkError if the GATT server is not connected.
-
May throw InvalidStateError if characteristic is null
See:
ignore: deprecated_member_use_from_same_package
Implementation
Future<void> writeValueWithResponse(final Uint8List value) async {
if (!hasWriteValueWithResponse()) {
throw NativeAPINotImplementedError("writeValueWithResponse");
}
final data = WebBluetoothConverters.convertUint8ListToJSArrayBuffer(value);
final promise =
_JSUtil.callMethod(_jsObject, "writeValueWithResponse", [data]);
await _JSUtil.promiseToFuture(promise);
}