Skip to content

Commit cc65e15

Browse files
committed
Add toString for all classes.
1 parent 1403ecb commit cc65e15

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

lib/src/bluetooth_characteristic.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ class BluetoothCharacteristic {
172172
return (c.isNotifying == notify);
173173
});
174174
}
175+
176+
@override
177+
String toString() {
178+
return 'BluetoothCharacteristic{uuid: $uuid, deviceId: $deviceId, serviceUuid: $serviceUuid, secondaryServiceUuid: $secondaryServiceUuid, properties: $properties, descriptors: $descriptors, value: ${_value?.value}';
179+
}
175180
}
176181

177182
enum CharacteristicWriteType { withResponse, withoutResponse }
@@ -212,4 +217,9 @@ class CharacteristicProperties {
212217
extendedProperties = p.extendedProperties,
213218
notifyEncryptionRequired = p.notifyEncryptionRequired,
214219
indicateEncryptionRequired = p.indicateEncryptionRequired;
220+
221+
@override
222+
String toString() {
223+
return 'CharacteristicProperties{broadcast: $broadcast, read: $read, writeWithoutResponse: $writeWithoutResponse, write: $write, notify: $notify, indicate: $indicate, authenticatedSignedWrites: $authenticatedSignedWrites, extendedProperties: $extendedProperties, notifyEncryptionRequired: $notifyEncryptionRequired, indicateEncryptionRequired: $indicateEncryptionRequired}';
224+
}
215225
}

lib/src/bluetooth_descriptor.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,9 @@ class BluetoothDescriptor {
8181
.then((_) => _value.add(value))
8282
.then((_) => null);
8383
}
84+
85+
@override
86+
String toString() {
87+
return 'BluetoothDescriptor{uuid: $uuid, deviceId: $deviceId, serviceUuid: $serviceUuid, characteristicUuid: $characteristicUuid, value: ${_value?.value}}';
88+
}
8489
}

lib/src/bluetooth_device.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ class BluetoothDevice {
140140

141141
@override
142142
int get hashCode => id.hashCode;
143+
144+
@override
145+
String toString() {
146+
return 'BluetoothDevice{id: $id, name: $name, type: $type, isDiscoveringServices: ${_isDiscoveringServices?.value}, _services: ${_services?.value}';
147+
}
143148
}
144149

145150
enum BluetoothDeviceType { unknown, classic, le, dual }

lib/src/bluetooth_service.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ class BluetoothService {
2121
includedServices = p.includedServices
2222
.map((s) => new BluetoothService.fromProto(s))
2323
.toList();
24+
25+
@override
26+
String toString() {
27+
return 'BluetoothService{uuid: $uuid, deviceId: $deviceId, isPrimary: $isPrimary, characteristics: $characteristics, includedServices: $includedServices}';
28+
}
2429
}

lib/src/flutter_blue.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ class ScanResult {
237237

238238
@override
239239
int get hashCode => device.hashCode;
240+
241+
@override
242+
String toString() {
243+
return 'ScanResult{device: $device, advertisementData: $advertisementData, rssi: $rssi}';
244+
}
240245
}
241246

242247
class AdvertisementData {
@@ -263,4 +268,9 @@ class AdvertisementData {
263268
manufacturerData = p.manufacturerData,
264269
serviceData = p.serviceData,
265270
serviceUuids = p.serviceUuids;
271+
272+
@override
273+
String toString() {
274+
return 'AdvertisementData{localName: $localName, txPowerLevel: $txPowerLevel, connectable: $connectable, manufacturerData: $manufacturerData, serviceData: $serviceData, serviceUuids: $serviceUuids}';
275+
}
266276
}

0 commit comments

Comments
 (0)