From 0ce24514a32c28ce960c37951d5c76bcaa62cfac Mon Sep 17 00:00:00 2001 From: R0m4in-dooz <72380352+R0m4in-dooz@users.noreply.github.com> Date: Mon, 24 Jan 2022 12:53:59 +0100 Subject: [PATCH 1/3] Feature : sync ble status (#217) * [BleScanner] expose BleStatus getter from BLE lib * bump pkg version & update CHANGELOG.md --- CHANGELOG.md | 4 ++++ example/pubspec.lock | 2 +- lib/src/ble/ble_scanner.dart | 4 +++- lib/src/nrf_mesh.dart | 5 ++++- pubspec.yaml | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a58d71dbf..4de30b3ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.7.0 + +- added getter for `BleStatus` + ## 0.6.0 - fix bug in adding a provisioner on iOS device diff --git a/example/pubspec.lock b/example/pubspec.lock index 99d7634dd..588575618 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -326,7 +326,7 @@ packages: path: ".." relative: true source: path - version: "0.6.0" + version: "0.7.0" package_config: dependency: transitive description: diff --git a/lib/src/ble/ble_scanner.dart b/lib/src/ble/ble_scanner.dart index 107b20fb0..5177195ca 100644 --- a/lib/src/ble/ble_scanner.dart +++ b/lib/src/ble/ble_scanner.dart @@ -25,7 +25,9 @@ class BleScanner { final FlutterReactiveBle _flutterReactiveBle = FlutterReactiveBle(); - Stream get bleStatus => _flutterReactiveBle.statusStream; + Stream get bleStatusStream => _flutterReactiveBle.statusStream; + + BleStatus get bleStatus => _flutterReactiveBle.status; late final StreamController _onScanErrorController = StreamController.broadcast(); diff --git a/lib/src/nrf_mesh.dart b/lib/src/nrf_mesh.dart index 9c2b745b9..61b2fa45e 100644 --- a/lib/src/nrf_mesh.dart +++ b/lib/src/nrf_mesh.dart @@ -130,5 +130,8 @@ class NordicNrfMesh { _bleScanner.searchForSpecificNode(deviceNameOrId, timeoutDuration, isProxy); /// Provide a [Stream] of the current [BleStatus] of the host device. - Stream get bleStatus => _bleScanner.bleStatus; + Stream get bleStatusStream => _bleScanner.bleStatusStream; + + /// Will return the last known [BleStatus] (tracked via stream by BLE library, so it should always be up-to-date) + BleStatus get bleStatus => _bleScanner.bleStatus; } diff --git a/pubspec.yaml b/pubspec.yaml index 2e3e08ede..646eb14fc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: nordic_nrf_mesh description: A Flutter plugin to enable mesh network management and communication using Nordic's SDKs. It also provides the ability to open BLE connection with mesh nodes using some other flutter package. -version: 0.6.0 +version: 0.7.0 environment: sdk: ">=2.12.0 <3.0.0" From 386ea40450882a5f35788b200955bf4ea95d3adb Mon Sep 17 00:00:00 2001 From: R0m4in-dooz <72380352+R0m4in-dooz@users.noreply.github.com> Date: Fri, 4 Feb 2022 10:03:16 +0100 Subject: [PATCH 2/3] [ProvisioningEvent] now passes around the `DiscoveredDevice` (#219) --- CHANGELOG.md | 1 + lib/src/utils/provisioning.dart | 36 ++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4de30b3ac..0fdee9184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.7.0 - added getter for `BleStatus` +- provisioning events now pass the target BLE device data ## 0.6.0 diff --git a/lib/src/utils/provisioning.dart b/lib/src/utils/provisioning.dart index 3c26f8f91..7c4de111e 100644 --- a/lib/src/utils/provisioning.dart +++ b/lib/src/utils/provisioning.dart @@ -14,27 +14,27 @@ import 'package:nordic_nrf_mesh/src/mesh_manager_api.dart'; import 'package:nordic_nrf_mesh/src/models/models.dart'; class _ProvisioningEvent { - final _provisioningController = StreamController(); - final _provisioningCapabilitiesController = StreamController(); - final _provisioningInvitationController = StreamController(); - final _provisioningReconnectController = StreamController(); - final _onConfigCompositionDataStatusController = StreamController(); - final _onConfigAppKeyStatusController = StreamController(); + final _provisioningController = StreamController(); + final _provisioningCapabilitiesController = StreamController(); + final _provisioningInvitationController = StreamController(); + final _provisioningReconnectController = StreamController(); + final _onConfigCompositionDataStatusController = StreamController(); + final _onConfigAppKeyStatusController = StreamController(); final _provisioningGattErrorController = StreamController(); } class ProvisioningEvent extends _ProvisioningEvent { - Stream get onProvisioning => _provisioningController.stream; + Stream get onProvisioning => _provisioningController.stream; - Stream get onProvisioningCapabilities => _provisioningCapabilitiesController.stream; + Stream get onProvisioningCapabilities => _provisioningCapabilitiesController.stream; - Stream get onProvisioningInvitation => _provisioningInvitationController.stream; + Stream get onProvisioningInvitation => _provisioningInvitationController.stream; - Stream get onProvisioningReconnect => _provisioningReconnectController.stream; + Stream get onProvisioningReconnect => _provisioningReconnectController.stream; - Stream get onConfigCompositionDataStatus => _onConfigCompositionDataStatusController.stream; + Stream get onConfigCompositionDataStatus => _onConfigCompositionDataStatusController.stream; - Stream get onConfigAppKeyStatus => _onConfigAppKeyStatusController.stream; + Stream get onConfigAppKeyStatus => _onConfigAppKeyStatusController.stream; Stream get onProvisioningGattError => _provisioningGattErrorController.stream; Future dispose() => Future.wait([ @@ -117,7 +117,7 @@ Future _provisioning( if (device == null) { completer.completeError(NrfMeshProvisioningException(ProvisioningFailureCode.notFound, 'Didn\'t find module')); } - events?._provisioningReconnectController.add(null); + events?._provisioningReconnectController.add(deviceToProvision); try { _connectRetryCount = 0; isHandlingConnectErrors = true; @@ -141,7 +141,7 @@ Future _provisioning( }); onProvisioningStateChangedSubscription = meshManagerApi.onProvisioningStateChanged.listen((event) async { if (event.state == 'PROVISIONING_CAPABILITIES') { - events?._provisioningCapabilitiesController.add(null); + events?._provisioningCapabilitiesController.add(deviceToProvision); final unprovisionedMeshNode = UnprovisionedMeshNode(event.meshNode!.uuid, event.meshNode!.provisionerPublicKeyXY!); final elementSize = await unprovisionedMeshNode.getNumberOfElements(); @@ -167,11 +167,11 @@ Future _provisioning( } _log('successfully assigned $unicast to node !'); } - events?._provisioningController.add(null); + events?._provisioningController.add(deviceToProvision); await meshManagerApi.provisioning(unprovisionedMeshNode); } else if (event.state == 'PROVISIONING_INVITE') { if (!bleMeshManager.isProvisioningCompleted) { - events?._provisioningInvitationController.add(null); + events?._provisioningInvitationController.add(deviceToProvision); } else if (bleMeshManager.isProvisioningCompleted) { final unicast = await provisionedMeshNode.unicastAddress; await meshManagerApi.sendConfigCompositionDataGet(unicast); @@ -216,11 +216,11 @@ Future _provisioning( } }); onConfigCompositionDataStatusSubscription = meshManagerApi.onConfigCompositionDataStatus.listen((event) async { - events?._onConfigCompositionDataStatusController.add(null); + events?._onConfigCompositionDataStatusController.add(deviceToProvision); await meshManagerApi.sendConfigAppKeyAdd(await provisionedMeshNode.unicastAddress); }); onConfigAppKeyStatusSubscription = meshManagerApi.onConfigAppKeyStatus.listen((event) async { - events?._onConfigAppKeyStatusController.add(null); + events?._onConfigAppKeyStatusController.add(deviceToProvision); completer.complete(provisionedMeshNode); }); try { From edfdf337ca39c474643014c9a9661b18f20e57ff Mon Sep 17 00:00:00 2001 From: R0m4in-dooz <72380352+R0m4in-dooz@users.noreply.github.com> Date: Fri, 4 Feb 2022 10:17:54 +0100 Subject: [PATCH 3/3] Bug : GitHub Actions (#220) * force flutter version to 2.5.3 in `on_pr.yml` workflow * update CHANGELOG.md --- .github/workflows/on_pr.yaml | 2 +- CHANGELOG.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/on_pr.yaml b/.github/workflows/on_pr.yaml index 74e308195..a117fd8b7 100644 --- a/.github/workflows/on_pr.yaml +++ b/.github/workflows/on_pr.yaml @@ -18,7 +18,7 @@ jobs: java-version: "12.x" - uses: subosito/flutter-action@v1 with: - channel: "stable" + flutter-version: '2.5.3' - name: Get dependencies run: flutter packages get - name: Check format diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fdee9184..bdb7180bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - added getter for `BleStatus` - provisioning events now pass the target BLE device data +- workflow `on_pr.yml` now forces Flutter version to 2.5.3 ## 0.6.0