Skip to content

Commit

Permalink
Release 2.2.9
Browse files Browse the repository at this point in the history
Release 2.2.9
  • Loading branch information
mikolak authored Jul 24, 2020
2 parents 6f05b2f + 832e18c commit 12a0861
Show file tree
Hide file tree
Showing 7 changed files with 404 additions and 39 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.9

* Fixed issue with incorrectly typed Stream

## 2.2.8

* Formatted all sources according to dartfmt for consistency
Expand Down
2 changes: 1 addition & 1 deletion 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.8'
version '2.2.9'

buildscript {
repositories {
Expand Down
2 changes: 1 addition & 1 deletion 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.8'
s.version = '2.2.9'
s.summary = 'A new flutter plugin project.'
s.description = <<-DESC
A new flutter plugin project.
Expand Down
32 changes: 19 additions & 13 deletions lib/src/bridge/device_connection_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mixin DeviceConnectionMixin on FlutterBLE {

Stream<PeripheralConnectionState> observePeripheralConnectionState(
String identifier, bool emitCurrentValue) {
var controller = StreamController<String>(
var controller = StreamController<PeripheralConnectionState>(
onListen: () => _methodChannel.invokeMethod(
MethodName.observeConnectionState,
<String, dynamic>{
Expand All @@ -37,18 +37,15 @@ mixin DeviceConnectionMixin on FlutterBLE {
),
);

controller
.addStream(_peripheralConnectionStateChanges)
.then((value) => controller?.close());

return controller.stream
.map((jsonString) =>
ConnectionStateContainer.fromJson(jsonDecode(jsonString)))
.where((connectionStateContainer) =>
connectionStateContainer.peripheralIdentifier == identifier)
.map((connectionStateContainer) =>
connectionStateContainer.connectionState)
.map((connectionStateString) {
var sourceStream =
_peripheralConnectionStateChanges
.map((jsonString) =>
ConnectionStateContainer.fromJson(jsonDecode(jsonString)))
.where((connectionStateContainer) =>
connectionStateContainer.peripheralIdentifier == identifier)
.map((connectionStateContainer) =>
connectionStateContainer.connectionState)
.map((connectionStateString) {
switch (connectionStateString.toLowerCase()) {
case NativeConnectionState.connected:
return PeripheralConnectionState.connected;
Expand All @@ -64,6 +61,15 @@ mixin DeviceConnectionMixin on FlutterBLE {
);
}
});

controller
.addStream(
sourceStream,
cancelOnError: true,
)
.then((value) => controller?.close());

return controller.stream;
}

Future<bool> isPeripheralConnected(String peripheralIdentifier) async {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_ble_lib
description: FlutterBle Library is a flutter library that supports BLE operations. It uses MultiPlatformBleAdapter as a native backend..
version: 2.2.8
version: 2.2.9
homepage: https://github.com/Polidea/FlutterBleLib

environment:
Expand Down
Loading

0 comments on commit 12a0861

Please sign in to comment.