write method

Future<void> write(
  1. List<int> value, {
  2. bool allowLongWrite = false,
  3. bool withoutResponse = false,
  4. int timeout = 15,
})
override

Writes a characteristic.

  • withoutResponse: If true, the write is not guaranteed and always returns immediately with success. If false, the write returns error on failure.
  • allowLongWrite: if set, larger writes > MTU are allowed (up to 512 bytes). This should be used with caution. 1. it can only be used with response 2. the peripheral device must support the 'long write' ble protocol. 3. Interrupted transfers can leave the characteristic in a partially written state 4. If the mtu is small, it is very very slow.

Implementation

Future<void> write(List<int> value,
    {bool allowLongWrite = false,
    bool withoutResponse = false,
    int timeout = 15}) async {
  await WinBle.write(
    address: _address,
    service: serviceUuid.str128,
    characteristic: characteristicUuid.str128,
    data: Uint8List.fromList(value),
    writeWithResponse:
        !withoutResponse, // propertiesWinBle.writeWithoutResponse ?? false,
  );
  FlutterBluePlusWindows._charReadWriteStreamController.add((_key, value));
  FlutterBluePlusWindows._lastChrs[remoteId]?[_key] = value;
}