Skip to content

Commit

Permalink
Merge pull request #491 from Polidea/release/2.2.6
Browse files Browse the repository at this point in the history
Release 2.2.6
  • Loading branch information
mikolak authored Jul 16, 2020
2 parents e0b4415 + d23f2cd commit cedaee1
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ res/values/strings_en.arb
lib/generated/
example/lib/generated/
example/.flutter-plugins-dependencies
.dart_tool/
.dart_tool/
example/ios/Podfile.lock
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ _android_job_template: &android_job_template
_ios_job_template: &ios_job_template
language: objective-c
os: osx
osx_image: xcode11
osx_image: xcode11.6
xcode_workspave: example/ios/Runner.xcworkspace
xcode_scheme: Runner
before_script:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.2.6

* Fixed scan quick failures not being reported to the listener (race condition in scanning_mixin.dart)

## 2.2.5

* add missing handling of destroyClient call on iOS
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.5'
version '2.2.6'

buildscript {
repositories {
Expand Down
35 changes: 0 additions & 35 deletions example/ios/Podfile.lock

This file was deleted.

7 changes: 4 additions & 3 deletions example/lib/devices_list/devices_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DevicesListScreen extends StatefulWidget {
class DeviceListScreenState extends State<DevicesListScreen> {
DevicesBloc _devicesBloc;
StreamSubscription _appStateSubscription;
bool _shouldRunOnResume = true;

@override
void didUpdateWidget(DevicesListScreen oldWidget) {
Expand All @@ -39,13 +40,13 @@ class DeviceListScreenState extends State<DevicesListScreen> {
Fimber.d("navigate to details");
_onPause();
await Navigator.pushNamed(context, "/details");
_shouldRunOnResume = true;
setState(() {
_shouldRunOnResume = true;
});
Fimber.d("back from details");
});
}

bool _shouldRunOnResume = true;

@override
void didChangeDependencies() {
super.didChangeDependencies();
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.5'
s.version = '2.2.6'
s.summary = 'A new flutter plugin project.'
s.description = <<-DESC
A new flutter plugin project.
Expand Down
53 changes: 30 additions & 23 deletions lib/src/bridge/scanning_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
part of _internal;

mixin ScanningMixin on FlutterBLE {
Stream<dynamic> _scanEvents;
Stream<ScanResult> _scanEvents;

void _prepareScanEventsStream() {
_scanEvents =
const EventChannel(ChannelName.scanningEvents).receiveBroadcastStream();
_scanEvents = const EventChannel(ChannelName.scanningEvents)
.receiveBroadcastStream()
.handleError(
(errorJson) => throw BleError.fromJson(jsonDecode(errorJson.details)),
test: (error) => error is PlatformException,
)
.map(
(scanResultJson) =>
ScanResult.fromJson(jsonDecode(scanResultJson), _manager),
);
}

Stream<ScanResult> startDeviceScan(
int scanMode,
int callbackType,
List<String> uuids,
bool allowDuplicates,
) async* {
_methodChannel.invokeMethod(
MethodName.startDeviceScan,
<String, dynamic>{
ArgumentName.scanMode: scanMode,
ArgumentName.callbackType: callbackType,
ArgumentName.uuids: uuids,
ArgumentName.allowDuplicates: allowDuplicates,
},
);

) {
if (_scanEvents == null) {
_prepareScanEventsStream();
}

yield* _scanEvents.handleError(
(errorJson) {
throw BleError.fromJson(jsonDecode(errorJson.details));
},
test: (error) => error is PlatformException,
).map((scanResultJson) => ScanResult.fromJson(
jsonDecode(scanResultJson),
_manager,
));
StreamController<ScanResult> streamController = StreamController.broadcast(
onListen: () => _methodChannel.invokeMethod(
MethodName.startDeviceScan,
<String, dynamic>{
ArgumentName.scanMode: scanMode,
ArgumentName.callbackType: callbackType,
ArgumentName.uuids: uuids,
ArgumentName.allowDuplicates: allowDuplicates,
},
),
onCancel: () => stopDeviceScan(),
);

streamController
.addStream(_scanEvents, cancelOnError: true)
.then((_) => streamController?.close());

return streamController.stream;
}

Future<void> stopDeviceScan() 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.5
version: 2.2.6
homepage: https://github.com/Polidea/FlutterBleLib

environment:
Expand Down

0 comments on commit cedaee1

Please sign in to comment.