Skip to content

Commit e9cc958

Browse files
author
Łukasz Rejman
authored
Fix capitalization style for UUID and constant names (#437)
* Fix capitalization of UUID in Service * Fix capitalization of UUID in ScanResult * Fix capitalization of UUID in Peripheral * Rename bytes to value * Fix capitalization of UUID in metadata strings in ScanResult * Fix constants capitalization in BleError * Revert "Fix capitalization of UUID in metadata strings in ScanResult" This reverts commit 08516ec. * Fix capitalization of UUID in managers for classes * Fix capitalization of UUID for InternalBleManager * Fix capitalization of UUID in CharacteristicsMixin * Fix capitalization of UUID in DevicesMixin * Rename bytes to value in internal classes
1 parent 76e6fcf commit e9cc958

10 files changed

+162
-160
lines changed

lib/ble_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class BleManager {
4242
}
4343

4444
/// Cancels transaction's return, resulting in [BleError] with
45-
/// [BleError.errorCode] set to [BleErrorCode.OperationCancelled] being returned
45+
/// [BleError.errorCode] set to [BleErrorCode.operationCancelled] being returned
4646
/// from transaction's Future.
4747
///
4848
/// The operation might be cancelled if it hadn't yet started or be run

lib/characteristic.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Characteristic extends InternalCharacteristic {
3636

3737
/// True if this characteristic can be monitored via notifications.
3838
bool isNotifiable;
39+
3940
/// True if this characteristic can be monitored via indications.
4041
bool isIndicatable;
4142

@@ -70,14 +71,14 @@ class Characteristic extends InternalCharacteristic {
7071
/// [isWritableWithoutResponse] is `true` and argument [withResponse] is
7172
/// set accordingly.
7273
Future<void> write(
73-
Uint8List bytes,
74+
Uint8List value,
7475
bool withResponse, {
7576
String transactionId,
7677
}) =>
7778
_manager.writeCharacteristicForIdentifier(
7879
service.peripheral,
7980
this,
80-
bytes,
81+
value,
8182
withResponse,
8283
transactionId ?? TransactionIdGenerator.getNextId(),
8384
);

lib/error/ble_error.dart

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
part of flutter_ble_lib;
22

33
abstract class _BleErrorMetadata {
4-
static const String ERROR_CODE = "errorCode";
5-
static const String ATT_ERROR_CODE = "attErrorCode";
6-
static const String ANDROID_ERROR_CODE = "androidErrorCode";
7-
static const String REASON = "reason";
8-
static const String DEVICE_ID = "deviceID";
9-
static const String SERVICE_UUID = "serviceUUID";
10-
static const String CHARACTERISTIC_UUID = "characteristicUUID";
11-
static const String DESCRIPTOR_UUID = "descriptorUUID";
12-
static const String INTERNAL_MESSAGE = "internalMessage";
4+
static const String errorCode = "errorCode";
5+
static const String attErrorCode = "attErrorCode";
6+
static const String androidErrorCode = "androidErrorCode";
7+
static const String reason = "reason";
8+
static const String deviceId = "deviceID";
9+
static const String serviceUuid = "serviceUUID";
10+
static const String characteristicUuid = "characteristicUUID";
11+
static const String descriptorUuid = "descriptorUUID";
12+
static const String internalMessage = "internalMessage";
1313
}
1414

1515
class BleError {
@@ -20,21 +20,21 @@ class BleError {
2020
String reason;
2121

2222
String deviceID;
23-
String serviceUUID;
24-
String characteristicUUID;
25-
String descriptorUUID;
23+
String serviceUuid;
24+
String characteristicUuid;
25+
String descriptorUuid;
2626
String internalMessage;
2727

2828
BleError.fromJson(Map<String, dynamic> json)
29-
: errorCode = BleErrorCode(json[_BleErrorMetadata.ERROR_CODE]),
30-
attErrorCode = json[_BleErrorMetadata.ATT_ERROR_CODE],
31-
androidErrorCode = json[_BleErrorMetadata.ANDROID_ERROR_CODE],
32-
reason = json[_BleErrorMetadata.REASON],
33-
deviceID = json[_BleErrorMetadata.DEVICE_ID],
34-
serviceUUID = json[_BleErrorMetadata.SERVICE_UUID],
35-
characteristicUUID = json[_BleErrorMetadata.CHARACTERISTIC_UUID],
36-
descriptorUUID = json[_BleErrorMetadata.DESCRIPTOR_UUID],
37-
internalMessage = json[_BleErrorMetadata.INTERNAL_MESSAGE];
29+
: errorCode = BleErrorCode(json[_BleErrorMetadata.errorCode]),
30+
attErrorCode = json[_BleErrorMetadata.attErrorCode],
31+
androidErrorCode = json[_BleErrorMetadata.androidErrorCode],
32+
reason = json[_BleErrorMetadata.reason],
33+
deviceID = json[_BleErrorMetadata.deviceId],
34+
serviceUuid = json[_BleErrorMetadata.serviceUuid],
35+
characteristicUuid = json[_BleErrorMetadata.characteristicUuid],
36+
descriptorUuid = json[_BleErrorMetadata.descriptorUuid],
37+
internalMessage = json[_BleErrorMetadata.internalMessage];
3838

3939
@override
4040
String toString() => "BleError ("
@@ -45,57 +45,57 @@ class BleError {
4545
"reason: $reason, "
4646
"internal message: $internalMessage, "
4747
"device ID: $deviceID, "
48-
"service UUID: $serviceUUID, "
49-
"characteristic UUID: $characteristicUUID, "
50-
"descriptor UUID: $descriptorUUID)";
48+
"service UUID: $serviceUuid, "
49+
"characteristic UUID: $characteristicUuid, "
50+
"descriptor UUID: $descriptorUuid)";
5151
}
5252

5353
class BleErrorCode {
54-
static const int UnknownError = 0;
55-
static const int BluetoothManagerDestroyed = 1;
56-
static const int OperationCancelled = 2;
57-
static const int OperationTimedOut = 3;
58-
static const int OperationStartFailed = 4;
59-
static const int InvalidIdentifiers = 5;
54+
static const int unknownError = 0;
55+
static const int bluetoothManagerDestroyed = 1;
56+
static const int operationCancelled = 2;
57+
static const int operationTimedOut = 3;
58+
static const int operationStartFailed = 4;
59+
static const int invalidIdentifiers = 5;
6060

61-
static const int BluetoothUnsupported = 100;
62-
static const int BluetoothUnauthorized = 101;
63-
static const int BluetoothPoweredOff = 102;
64-
static const int BluetoothInUnknownState = 103;
65-
static const int BluetoothResetting = 104;
66-
static const int BluetoothStateChangeFailed = 105;
61+
static const int bluetoothUnsupported = 100;
62+
static const int bluetoothUnauthorized = 101;
63+
static const int bluetoothPoweredOff = 102;
64+
static const int bluetoothInUnknownState = 103;
65+
static const int bluetoothResetting = 104;
66+
static const int bluetoothStateChangeFailed = 105;
6767

68-
static const int DeviceConnectionFailed = 200;
69-
static const int DeviceDisconnected = 201;
70-
static const int DeviceRSSIReadFailed = 202;
71-
static const int DeviceAlreadyConnected = 203;
72-
static const int DeviceNotFound = 204;
73-
static const int DeviceNotConnected = 205;
74-
static const int DeviceMTUChangeFailed = 206;
68+
static const int deviceConnectionFailed = 200;
69+
static const int deviceDisconnected = 201;
70+
static const int deviceRSSIReadFailed = 202;
71+
static const int deviceAlreadyConnected = 203;
72+
static const int deviceNotFound = 204;
73+
static const int deviceNotConnected = 205;
74+
static const int deviceMTUChangeFailed = 206;
7575

76-
static const int ServicesDiscoveryFailed = 300;
77-
static const int IncludedServicesDiscoveryFailed = 301;
78-
static const int ServiceNotFound = 302;
79-
static const int ServicesNotDiscovered = 303;
76+
static const int servicesDiscoveryFailed = 300;
77+
static const int includedServicesDiscoveryFailed = 301;
78+
static const int serviceNotFound = 302;
79+
static const int servicesNotDiscovered = 303;
8080

81-
static const int CharacteristicsDiscoveryFailed = 400;
82-
static const int CharacteristicWriteFailed = 401;
83-
static const int CharacteristicReadFailed = 402;
84-
static const int CharacteristicNotifyChangeFailed = 403;
85-
static const int CharacteristicNotFound = 404;
86-
static const int CharacteristicsNotDiscovered = 405;
87-
static const int CharacteristicInvalidDataFormat = 406;
81+
static const int characteristicsDiscoveryFailed = 400;
82+
static const int characteristicWriteFailed = 401;
83+
static const int characteristicReadFailed = 402;
84+
static const int characteristicNotifyChangeFailed = 403;
85+
static const int characteristicNotFound = 404;
86+
static const int characteristicsNotDiscovered = 405;
87+
static const int characteristicInvalidDataFormat = 406;
8888

89-
static const int DescriptorsDiscoveryFailed = 500;
90-
static const int DescriptorWriteFailed = 501;
91-
static const int DescriptorReadFailed = 502;
92-
static const int DescriptorNotFound = 503;
93-
static const int DescriptorsNotDiscovered = 504;
94-
static const int DescriptorInvalidDataFormat = 505;
95-
static const int DescriptorWriteNotAllowed = 506;
89+
static const int descriptorsDiscoveryFailed = 500;
90+
static const int descriptorWriteFailed = 501;
91+
static const int descriptorReadFailed = 502;
92+
static const int descriptorNotFound = 503;
93+
static const int descriptorsNotDiscovered = 504;
94+
static const int descriptorInvalidDataFormat = 505;
95+
static const int descriptorWriteNotAllowed = 506;
9696

97-
static const int ScanStartFailed = 600;
98-
static const int LocationServicesDisabled = 601;
97+
static const int scanStartFailed = 600;
98+
static const int locationServicesDisabled = 601;
9999

100100
int value;
101101

lib/peripheral.dart

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,39 +122,39 @@ class Peripheral {
122122

123123
/// Reads value of [Characteristic] matching specified UUIDs.
124124
///
125-
/// Returns value of characteristic with [characteristicUUID] for service with
126-
/// [serviceUUID]. Optional [transactionId] could be used to cancel operation.
125+
/// Returns value of characteristic with [characteristicUuid] for service with
126+
/// [serviceUuid]. Optional [transactionId] could be used to cancel operation.
127127
///
128128
/// Will result in error if discovery was not done during this connection.
129129
Future<CharacteristicWithValue> readCharacteristic(
130-
String serviceUUID,
131-
String characteristicUUID, {
130+
String serviceUuid,
131+
String characteristicUuid, {
132132
String transactionId,
133133
}) =>
134134
_manager.readCharacteristicForDevice(
135135
this,
136-
serviceUUID,
137-
characteristicUUID,
136+
serviceUuid,
137+
characteristicUuid,
138138
transactionId ?? TransactionIdGenerator.getNextId(),
139139
);
140140

141141
/// Writes value of [Characteristic] matching specified UUIDs.
142142
///
143-
/// Writes [value] to characteristic with [characteristicUUID] for service with
144-
/// [serviceUUID]. Optional [transactionId] could be used to cancel operation.
143+
/// Writes [value] to characteristic with [characteristicUuid] for service with
144+
/// [serviceUuid]. Optional [transactionId] could be used to cancel operation.
145145
///
146146
/// Will result in error if discovery was not done during this connection.
147147
Future<Characteristic> writeCharacteristic(
148-
String serviceUUID,
149-
String characteristicUUID,
148+
String serviceUuid,
149+
String characteristicUuid,
150150
Uint8List value,
151151
bool withResponse, {
152152
String transactionId,
153153
}) =>
154154
_manager.writeCharacteristicForDevice(
155155
this,
156-
serviceUUID,
157-
characteristicUUID,
156+
serviceUuid,
157+
characteristicUuid,
158158
value,
159159
withResponse,
160160
transactionId ?? TransactionIdGenerator.getNextId(),
@@ -221,21 +221,21 @@ class Peripheral {
221221
/// matching specified UUIDs.
222222
///
223223
/// Emits [CharacteristicWithValue] for every observed change of the
224-
/// characteristic specified by [serviceUUID] and [characteristicUUID]
224+
/// characteristic specified by [serviceUuid] and [characteristicUuid]
225225
/// If notifications are enabled they will be used in favour of indications.
226226
/// Optional [transactionId] could be used to cancel operation. Unsubscribing
227227
/// from the stream cancels monitoring.
228228
///
229229
/// Will result in error if discovery was not done during this connection.
230230
Stream<CharacteristicWithValue> monitorCharacteristic(
231-
String serviceUUID,
232-
String characteristicUUID, {
231+
String serviceUuid,
232+
String characteristicUuid, {
233233
String transactionId,
234234
}) =>
235235
_manager.monitorCharacteristicForDevice(
236236
this,
237-
serviceUUID,
238-
characteristicUUID,
237+
serviceUuid,
238+
characteristicUuid,
239239
transactionId ?? TransactionIdGenerator.getNextId(),
240240
);
241241

lib/scan_result.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ class ScanResult {
2020

2121
/// Signal strength of the peripheral in dBm.
2222
int rssi;
23+
2324
/// An indicator whether the peripheral is connectable (iOS only).
2425
bool isConnectable;
2526

2627
/// A list of UUIDs found in the overflow area of the advertisement data (iOS only).
27-
List<String> overflowServiceUUIDs;
28+
List<String> overflowServiceUuids;
2829

2930
/// A packet of data advertised by the peripheral.
3031
AdvertisementData advertisementData;
@@ -33,7 +34,7 @@ class ScanResult {
3334
: peripheral = Peripheral.fromJson(json, manager),
3435
rssi = json[_ScanResultMetadata.rssi],
3536
isConnectable = json[_ScanResultMetadata.isConnectable],
36-
overflowServiceUUIDs = json[_ScanResultMetadata.overflowServiceUuids],
37+
overflowServiceUuids = json[_ScanResultMetadata.overflowServiceUuids],
3738
advertisementData = AdvertisementData._fromJson(json);
3839
}
3940

@@ -47,7 +48,7 @@ class AdvertisementData {
4748
Map<String, Uint8List> serviceData;
4849

4950
/// A list of service UUIDs.
50-
List<String> serviceUUIDs;
51+
List<String> serviceUuids;
5152

5253
/// The local name of the [Peripheral]. Might be different than
5354
/// [Peripheral.name].
@@ -57,18 +58,18 @@ class AdvertisementData {
5758
int txPowerLevel;
5859

5960
/// A list of solicited service UUIDs.
60-
List<String> solicitedServiceUUIDs;
61+
List<String> solicitedServiceUuids;
6162

6263
AdvertisementData._fromJson(Map<String, dynamic> json)
6364
: manufacturerData =
6465
_decodeBase64OrNull(json[_ScanResultMetadata.manufacturerData]),
6566
serviceData =
6667
_getServiceDataOrNull(json[_ScanResultMetadata.serviceData]),
67-
serviceUUIDs =
68+
serviceUuids =
6869
_mapToListOfStringsOrNull(json[_ScanResultMetadata.serviceUuids]),
6970
localName = json[_ScanResultMetadata.localName],
7071
txPowerLevel = json[_ScanResultMetadata.txPowerLevel],
71-
solicitedServiceUUIDs = _mapToListOfStringsOrNull(
72+
solicitedServiceUuids = _mapToListOfStringsOrNull(
7273
json[_ScanResultMetadata.solicitedServiceUuids]);
7374

7475
static Map<String, Uint8List> _getServiceDataOrNull(

lib/service.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Service extends InternalService {
3030
_manager.characteristicsForService(this);
3131

3232
/// Writes the [value] to the [Characteristic] identified by
33-
/// [characteristicUUID].
33+
/// [characteristicUuid].
3434
///
3535
/// It returns a [Future] that completes with the [Characteristic] for the
3636
/// convenience of chaining operations.
@@ -40,52 +40,52 @@ class Service extends InternalService {
4040
/// [Characteristic.isWritableWithoutResponse] is `true` and
4141
/// [withResponse] is specified accordingly can be written to.
4242
Future<Characteristic> writeCharacteristic(
43-
String characteristicUUID,
43+
String characteristicUuid,
4444
Uint8List value,
4545
bool withResponse, {
4646
String transactionId,
4747
}) =>
4848
_manager.writeCharacteristicForService(
4949
peripheral,
5050
this,
51-
characteristicUUID,
51+
characteristicUuid,
5252
value,
5353
withResponse,
5454
transactionId ?? TransactionIdGenerator.getNextId());
5555

56-
/// Reads the value of a [Characteristic] identified by [characteristicUUID].
56+
/// Reads the value of a [Characteristic] identified by [characteristicUuid].
5757
///
5858
/// It returns a [Future] that completes with [CharacteristicWithValue],
5959
/// which is just a [Characteristic] but with an additonal `value`
6060
/// property of type [Uint8List]. Only [Characteristic] where
6161
/// [Characteristic.isReadable] is `true` can be read.
6262
Future<CharacteristicWithValue> readCharacteristic(
63-
String characteristicUUID, {
63+
String characteristicUuid, {
6464
String transactionId,
6565
}) =>
6666
_manager.readCharacteristicForService(
6767
peripheral,
6868
this,
69-
characteristicUUID,
69+
characteristicUuid,
7070
transactionId ?? TransactionIdGenerator.getNextId(),
7171
);
7272

7373
/// Returns a [Stream] of values emitted by a [Characteristic] identified by
74-
/// [characteristicUUID].
74+
/// [characteristicUuid].
7575
///
7676
/// Just like [readCharacteristic()] method, values are emitted as
7777
/// [CharacteristicWithValue] objects, which are the same as [Characteristic]
7878
/// but with an additonal `value` property of type [Uint8List]. Only
7979
/// [Characteristic] where [Characteristic.isNotifiable] is `true` can be
8080
/// monitored.
8181
Stream<CharacteristicWithValue> monitorCharacteristic(
82-
String characteristicUUID, {
82+
String characteristicUuid, {
8383
String transactionId,
8484
}) =>
8585
_manager.monitorCharacteristicForService(
8686
peripheral,
8787
this,
88-
characteristicUUID,
88+
characteristicUuid,
8989
transactionId ?? TransactionIdGenerator.getNextId(),
9090
);
9191

0 commit comments

Comments
 (0)