Skip to content

Fix capitalization style for UUID and constant names #437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ble_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class BleManager {
}

/// Cancels transaction's return, resulting in [BleError] with
/// [BleError.errorCode] set to [BleErrorCode.OperationCancelled] being returned
/// [BleError.errorCode] set to [BleErrorCode.operationCancelled] being returned
/// from transaction's Future.
///
/// The operation might be cancelled if it hadn't yet started or be run
Expand Down
5 changes: 3 additions & 2 deletions lib/characteristic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Characteristic extends InternalCharacteristic {

/// True if this characteristic can be monitored via notifications.
bool isNotifiable;

/// True if this characteristic can be monitored via indications.
bool isIndicatable;

Expand Down Expand Up @@ -70,14 +71,14 @@ class Characteristic extends InternalCharacteristic {
/// [isWritableWithoutResponse] is `true` and argument [withResponse] is
/// set accordingly.
Future<void> write(
Uint8List bytes,
Uint8List value,
bool withResponse, {
String transactionId,
}) =>
_manager.writeCharacteristicForIdentifier(
service.peripheral,
this,
bytes,
value,
withResponse,
transactionId ?? TransactionIdGenerator.getNextId(),
);
Expand Down
126 changes: 63 additions & 63 deletions lib/error/ble_error.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
part of flutter_ble_lib;

abstract class _BleErrorMetadata {
static const String ERROR_CODE = "errorCode";
static const String ATT_ERROR_CODE = "attErrorCode";
static const String ANDROID_ERROR_CODE = "androidErrorCode";
static const String REASON = "reason";
static const String DEVICE_ID = "deviceID";
static const String SERVICE_UUID = "serviceUUID";
static const String CHARACTERISTIC_UUID = "characteristicUUID";
static const String DESCRIPTOR_UUID = "descriptorUUID";
static const String INTERNAL_MESSAGE = "internalMessage";
static const String errorCode = "errorCode";
static const String attErrorCode = "attErrorCode";
static const String androidErrorCode = "androidErrorCode";
static const String reason = "reason";
static const String deviceId = "deviceID";
static const String serviceUuid = "serviceUUID";
static const String characteristicUuid = "characteristicUUID";
static const String descriptorUuid = "descriptorUUID";
static const String internalMessage = "internalMessage";
}

class BleError {
Expand All @@ -20,21 +20,21 @@ class BleError {
String reason;

String deviceID;
String serviceUUID;
String characteristicUUID;
String descriptorUUID;
String serviceUuid;
String characteristicUuid;
String descriptorUuid;
String internalMessage;

BleError.fromJson(Map<String, dynamic> json)
: errorCode = BleErrorCode(json[_BleErrorMetadata.ERROR_CODE]),
attErrorCode = json[_BleErrorMetadata.ATT_ERROR_CODE],
androidErrorCode = json[_BleErrorMetadata.ANDROID_ERROR_CODE],
reason = json[_BleErrorMetadata.REASON],
deviceID = json[_BleErrorMetadata.DEVICE_ID],
serviceUUID = json[_BleErrorMetadata.SERVICE_UUID],
characteristicUUID = json[_BleErrorMetadata.CHARACTERISTIC_UUID],
descriptorUUID = json[_BleErrorMetadata.DESCRIPTOR_UUID],
internalMessage = json[_BleErrorMetadata.INTERNAL_MESSAGE];
: errorCode = BleErrorCode(json[_BleErrorMetadata.errorCode]),
attErrorCode = json[_BleErrorMetadata.attErrorCode],
androidErrorCode = json[_BleErrorMetadata.androidErrorCode],
reason = json[_BleErrorMetadata.reason],
deviceID = json[_BleErrorMetadata.deviceId],
serviceUuid = json[_BleErrorMetadata.serviceUuid],
characteristicUuid = json[_BleErrorMetadata.characteristicUuid],
descriptorUuid = json[_BleErrorMetadata.descriptorUuid],
internalMessage = json[_BleErrorMetadata.internalMessage];

@override
String toString() => "BleError ("
Expand All @@ -45,57 +45,57 @@ class BleError {
"reason: $reason, "
"internal message: $internalMessage, "
"device ID: $deviceID, "
"service UUID: $serviceUUID, "
"characteristic UUID: $characteristicUUID, "
"descriptor UUID: $descriptorUUID)";
"service UUID: $serviceUuid, "
"characteristic UUID: $characteristicUuid, "
"descriptor UUID: $descriptorUuid)";
}

class BleErrorCode {
static const int UnknownError = 0;
static const int BluetoothManagerDestroyed = 1;
static const int OperationCancelled = 2;
static const int OperationTimedOut = 3;
static const int OperationStartFailed = 4;
static const int InvalidIdentifiers = 5;
static const int unknownError = 0;
static const int bluetoothManagerDestroyed = 1;
static const int operationCancelled = 2;
static const int operationTimedOut = 3;
static const int operationStartFailed = 4;
static const int invalidIdentifiers = 5;

static const int BluetoothUnsupported = 100;
static const int BluetoothUnauthorized = 101;
static const int BluetoothPoweredOff = 102;
static const int BluetoothInUnknownState = 103;
static const int BluetoothResetting = 104;
static const int BluetoothStateChangeFailed = 105;
static const int bluetoothUnsupported = 100;
static const int bluetoothUnauthorized = 101;
static const int bluetoothPoweredOff = 102;
static const int bluetoothInUnknownState = 103;
static const int bluetoothResetting = 104;
static const int bluetoothStateChangeFailed = 105;

static const int DeviceConnectionFailed = 200;
static const int DeviceDisconnected = 201;
static const int DeviceRSSIReadFailed = 202;
static const int DeviceAlreadyConnected = 203;
static const int DeviceNotFound = 204;
static const int DeviceNotConnected = 205;
static const int DeviceMTUChangeFailed = 206;
static const int deviceConnectionFailed = 200;
static const int deviceDisconnected = 201;
static const int deviceRSSIReadFailed = 202;
static const int deviceAlreadyConnected = 203;
static const int deviceNotFound = 204;
static const int deviceNotConnected = 205;
static const int deviceMTUChangeFailed = 206;

static const int ServicesDiscoveryFailed = 300;
static const int IncludedServicesDiscoveryFailed = 301;
static const int ServiceNotFound = 302;
static const int ServicesNotDiscovered = 303;
static const int servicesDiscoveryFailed = 300;
static const int includedServicesDiscoveryFailed = 301;
static const int serviceNotFound = 302;
static const int servicesNotDiscovered = 303;

static const int CharacteristicsDiscoveryFailed = 400;
static const int CharacteristicWriteFailed = 401;
static const int CharacteristicReadFailed = 402;
static const int CharacteristicNotifyChangeFailed = 403;
static const int CharacteristicNotFound = 404;
static const int CharacteristicsNotDiscovered = 405;
static const int CharacteristicInvalidDataFormat = 406;
static const int characteristicsDiscoveryFailed = 400;
static const int characteristicWriteFailed = 401;
static const int characteristicReadFailed = 402;
static const int characteristicNotifyChangeFailed = 403;
static const int characteristicNotFound = 404;
static const int characteristicsNotDiscovered = 405;
static const int characteristicInvalidDataFormat = 406;

static const int DescriptorsDiscoveryFailed = 500;
static const int DescriptorWriteFailed = 501;
static const int DescriptorReadFailed = 502;
static const int DescriptorNotFound = 503;
static const int DescriptorsNotDiscovered = 504;
static const int DescriptorInvalidDataFormat = 505;
static const int DescriptorWriteNotAllowed = 506;
static const int descriptorsDiscoveryFailed = 500;
static const int descriptorWriteFailed = 501;
static const int descriptorReadFailed = 502;
static const int descriptorNotFound = 503;
static const int descriptorsNotDiscovered = 504;
static const int descriptorInvalidDataFormat = 505;
static const int descriptorWriteNotAllowed = 506;

static const int ScanStartFailed = 600;
static const int LocationServicesDisabled = 601;
static const int scanStartFailed = 600;
static const int locationServicesDisabled = 601;

int value;

Expand Down
34 changes: 17 additions & 17 deletions lib/peripheral.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,39 +122,39 @@ class Peripheral {

/// Reads value of [Characteristic] matching specified UUIDs.
///
/// Returns value of characteristic with [characteristicUUID] for service with
/// [serviceUUID]. Optional [transactionId] could be used to cancel operation.
/// Returns value of characteristic with [characteristicUuid] for service with
/// [serviceUuid]. Optional [transactionId] could be used to cancel operation.
///
/// Will result in error if discovery was not done during this connection.
Future<CharacteristicWithValue> readCharacteristic(
String serviceUUID,
String characteristicUUID, {
String serviceUuid,
String characteristicUuid, {
String transactionId,
}) =>
_manager.readCharacteristicForDevice(
this,
serviceUUID,
characteristicUUID,
serviceUuid,
characteristicUuid,
transactionId ?? TransactionIdGenerator.getNextId(),
);

/// Writes value of [Characteristic] matching specified UUIDs.
///
/// Writes [value] to characteristic with [characteristicUUID] for service with
/// [serviceUUID]. Optional [transactionId] could be used to cancel operation.
/// Writes [value] to characteristic with [characteristicUuid] for service with
/// [serviceUuid]. Optional [transactionId] could be used to cancel operation.
///
/// Will result in error if discovery was not done during this connection.
Future<Characteristic> writeCharacteristic(
String serviceUUID,
String characteristicUUID,
String serviceUuid,
String characteristicUuid,
Uint8List value,
bool withResponse, {
String transactionId,
}) =>
_manager.writeCharacteristicForDevice(
this,
serviceUUID,
characteristicUUID,
serviceUuid,
characteristicUuid,
value,
withResponse,
transactionId ?? TransactionIdGenerator.getNextId(),
Expand Down Expand Up @@ -221,21 +221,21 @@ class Peripheral {
/// matching specified UUIDs.
///
/// Emits [CharacteristicWithValue] for every observed change of the
/// characteristic specified by [serviceUUID] and [characteristicUUID]
/// characteristic specified by [serviceUuid] and [characteristicUuid]
/// If notifications are enabled they will be used in favour of indications.
/// Optional [transactionId] could be used to cancel operation. Unsubscribing
/// from the stream cancels monitoring.
///
/// Will result in error if discovery was not done during this connection.
Stream<CharacteristicWithValue> monitorCharacteristic(
String serviceUUID,
String characteristicUUID, {
String serviceUuid,
String characteristicUuid, {
String transactionId,
}) =>
_manager.monitorCharacteristicForDevice(
this,
serviceUUID,
characteristicUUID,
serviceUuid,
characteristicUuid,
transactionId ?? TransactionIdGenerator.getNextId(),
);

Expand Down
13 changes: 7 additions & 6 deletions lib/scan_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class ScanResult {

/// Signal strength of the peripheral in dBm.
int rssi;

/// An indicator whether the peripheral is connectable (iOS only).
bool isConnectable;

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

/// A packet of data advertised by the peripheral.
AdvertisementData advertisementData;
Expand All @@ -33,7 +34,7 @@ class ScanResult {
: peripheral = Peripheral.fromJson(json, manager),
rssi = json[_ScanResultMetadata.rssi],
isConnectable = json[_ScanResultMetadata.isConnectable],
overflowServiceUUIDs = json[_ScanResultMetadata.overflowServiceUuids],
overflowServiceUuids = json[_ScanResultMetadata.overflowServiceUuids],
advertisementData = AdvertisementData._fromJson(json);
}

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

/// A list of service UUIDs.
List<String> serviceUUIDs;
List<String> serviceUuids;

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

/// A list of solicited service UUIDs.
List<String> solicitedServiceUUIDs;
List<String> solicitedServiceUuids;

AdvertisementData._fromJson(Map<String, dynamic> json)
: manufacturerData =
_decodeBase64OrNull(json[_ScanResultMetadata.manufacturerData]),
serviceData =
_getServiceDataOrNull(json[_ScanResultMetadata.serviceData]),
serviceUUIDs =
serviceUuids =
_mapToListOfStringsOrNull(json[_ScanResultMetadata.serviceUuids]),
localName = json[_ScanResultMetadata.localName],
txPowerLevel = json[_ScanResultMetadata.txPowerLevel],
solicitedServiceUUIDs = _mapToListOfStringsOrNull(
solicitedServiceUuids = _mapToListOfStringsOrNull(
json[_ScanResultMetadata.solicitedServiceUuids]);

static Map<String, Uint8List> _getServiceDataOrNull(
Expand Down
18 changes: 9 additions & 9 deletions lib/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Service extends InternalService {
_manager.characteristicsForService(this);

/// Writes the [value] to the [Characteristic] identified by
/// [characteristicUUID].
/// [characteristicUuid].
///
/// It returns a [Future] that completes with the [Characteristic] for the
/// convenience of chaining operations.
Expand All @@ -40,52 +40,52 @@ class Service extends InternalService {
/// [Characteristic.isWritableWithoutResponse] is `true` and
/// [withResponse] is specified accordingly can be written to.
Future<Characteristic> writeCharacteristic(
String characteristicUUID,
String characteristicUuid,
Uint8List value,
bool withResponse, {
String transactionId,
}) =>
_manager.writeCharacteristicForService(
peripheral,
this,
characteristicUUID,
characteristicUuid,
value,
withResponse,
transactionId ?? TransactionIdGenerator.getNextId());

/// Reads the value of a [Characteristic] identified by [characteristicUUID].
/// Reads the value of a [Characteristic] identified by [characteristicUuid].
///
/// It returns a [Future] that completes with [CharacteristicWithValue],
/// which is just a [Characteristic] but with an additonal `value`
/// property of type [Uint8List]. Only [Characteristic] where
/// [Characteristic.isReadable] is `true` can be read.
Future<CharacteristicWithValue> readCharacteristic(
String characteristicUUID, {
String characteristicUuid, {
String transactionId,
}) =>
_manager.readCharacteristicForService(
peripheral,
this,
characteristicUUID,
characteristicUuid,
transactionId ?? TransactionIdGenerator.getNextId(),
);

/// Returns a [Stream] of values emitted by a [Characteristic] identified by
/// [characteristicUUID].
/// [characteristicUuid].
///
/// Just like [readCharacteristic()] method, values are emitted as
/// [CharacteristicWithValue] objects, which are the same as [Characteristic]
/// but with an additonal `value` property of type [Uint8List]. Only
/// [Characteristic] where [Characteristic.isNotifiable] is `true` can be
/// monitored.
Stream<CharacteristicWithValue> monitorCharacteristic(
String characteristicUUID, {
String characteristicUuid, {
String transactionId,
}) =>
_manager.monitorCharacteristicForService(
peripheral,
this,
characteristicUUID,
characteristicUuid,
transactionId ?? TransactionIdGenerator.getNextId(),
);

Expand Down
Loading