toArguments method

Map<String, dynamic> toArguments()

Converts the characteristic to a map of arguments.

This method is useful for passing the characteristic as arguments to the Faketooth simulator.

Example usage:

FaketoothCharacteristic characteristic = FaketoothCharacteristic(
  uuid: '00002a37-0000-1000-8000-00805f9b34fb',
  properties: {
    FaketoothCharacteristicProperties.read,
    FaketoothCharacteristicProperties.write,
  },
  descriptors: [
    FaketoothDescriptor(
      uuid: '00002902-0000-1000-8000-00805f9b34fb',
      value: Uint8List.fromList([0x00, 0x00]),
    ),
  ],
);

Map<String, dynamic> arguments = characteristic.toArguments();
print(arguments);
// Output: {uuid: '00002a37-0000-1000-8000-00805f9b34fb', properties: ['read', 'write'], ...}

Implementation

Map<String, dynamic> toArguments() {
  return {
    'uuid'        : uuid,
    'properties'  : properties.map((e) => e.code).toList(),
    'descriptors' : descriptors?.map((e) => e.toArguments()).toList() ?? [],
    "initialValue": initialValue,
  };
}