Skip to content

Commit

Permalink
Release 2.2.3 (#445)
Browse files Browse the repository at this point in the history
* 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

* Add unit tests for Service (#439)

* unit test for BleManager

* [descriptor] override equals & hashcode functions

* [tests] add: mock classes for managers

* [service] add: service tests

* [tests] create characteristics and descriptors using separate generators

* [service][tests] cover generating transactionId when it's not specified

* [service][tests] clear mocks interactions after each test

* [service][tests] add missing test for getting all descriptors for specified characteristic

Co-authored-by: Paweł Byszewski <4048063+pawelByszewski@users.noreply.github.com>

* Bump MBA and lib version

Co-authored-by: Łukasz Rejman <lukasz.rejman@polidea.com>
Co-authored-by: Bartosz Wilk <bartosz.wilk@polidea.com>
Co-authored-by: Paweł Byszewski <4048063+pawelByszewski@users.noreply.github.com>
  • Loading branch information
4 people committed Mar 10, 2020
1 parent 76e6fcf commit 47d12e1
Show file tree
Hide file tree
Showing 21 changed files with 564 additions and 170 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.2.3

* Fix issue with duplicated or malformed notification values

## 2.2.2

* Fix issue with invalid characteristic value base64 coding when performing characteristic operations on iOS
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.polidea.flutter_ble_lib'
version '2.2.0'
version '2.2.3'

buildscript {
repositories {
Expand Down Expand Up @@ -36,5 +36,5 @@ android {

dependencies {
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.github.Polidea:MultiPlatformBleAdapter:0.1.4'
implementation 'com.github.Polidea:MultiPlatformBleAdapter:0.1.5'
}
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- Flutter (1.0.0)
- flutter_ble_lib (2.1.0):
- flutter_ble_lib (2.2.3):
- Flutter
- MultiplatformBleAdapter (= 0.1.4)
- MultiplatformBleAdapter (0.1.4)
- MultiplatformBleAdapter (= 0.1.5)
- MultiplatformBleAdapter (0.1.5)
- "permission_handler (4.2.0+hotfix.3)":
- Flutter

Expand All @@ -26,8 +26,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_ble_lib: b2cf6d76a88368075db66966d782630318c6e67d
MultiplatformBleAdapter: 1ef6e0c8d11f753c56cbad1654b36c8e24142648
flutter_ble_lib: 20e79f0b1d78d921d9ed68ab4451e190029bc3d9
MultiplatformBleAdapter: 3c4391d428382738a47662ae1f665a29ce78ff39
permission_handler: 40520ab8ad1bb78a282b832464e995ec87f77ec6

PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83
Expand Down
4 changes: 2 additions & 2 deletions ios/flutter_ble_lib.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'flutter_ble_lib'
s.version = '2.2.0'
s.version = '2.2.3'
s.summary = 'A new flutter plugin project.'
s.description = <<-DESC
A new flutter plugin project.
Expand All @@ -16,7 +16,7 @@ A new flutter plugin project.
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.swift_versions = ['4.0', '4.2', '5.0']
s.dependency 'MultiplatformBleAdapter', '0.1.4'
s.dependency 'MultiplatformBleAdapter', '0.1.5'

s.ios.deployment_target = '8.0'
end
Expand Down
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
15 changes: 15 additions & 0 deletions lib/descriptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ class Descriptor extends InternalDescriptor {
value,
transactionId ?? TransactionIdGenerator.getNextId(),
);

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Descriptor &&
runtimeType == other.runtimeType &&
_manager == other._manager &&
characteristic == other.characteristic &&
uuid == other.uuid;

@override
int get hashCode =>
_manager.hashCode ^
characteristic.hashCode ^
uuid.hashCode;
}

class DescriptorWithValue extends Descriptor with WithValue {
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
Loading

0 comments on commit 47d12e1

Please sign in to comment.