writeValue method

Future<void> writeValue(
  1. Iterable<int> data, {
  2. int? offset,
  3. BlueZGattCharacteristicWriteType? type,
  4. bool? prepareAuthorize,
})

Writes data to the characteristic.

Implementation

Future<void> writeValue(Iterable<int> data,
    {int? offset,
    BlueZGattCharacteristicWriteType? type,
    bool? prepareAuthorize}) async {
  var options = <String, DBusValue>{};
  if (offset != null) {
    options['offset'] = DBusUint16(offset);
  }
  if (type != null) {
    String typeName;
    switch (type) {
      case BlueZGattCharacteristicWriteType.command:
        typeName = 'command';
        break;
      case BlueZGattCharacteristicWriteType.request:
        typeName = 'request';
        break;
      case BlueZGattCharacteristicWriteType.reliable:
        typeName = 'reliable';
        break;
    }
    options['type'] = DBusString(typeName);
  }
  if (prepareAuthorize != null) {
    options['prepare-authorize'] = DBusBoolean(prepareAuthorize);
  }
  await _object.callMethod(_gattCharacteristicInterfaceName, 'WriteValue',
      [DBusArray.byte(data), DBusDict.stringVariant(options)],
      replySignature: DBusSignature(''));
}