diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e7792a..a9a96d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Version 1.3.1+11 + +- (Android) Fixed multiple devices not showing up. +- (Android) Fixed device state not reporting correctly in the ui (only for the second device somehow). + # Version 1.3.0+10 08-12-2023 - (Android) Update to support new features from 12, 13, and 14. diff --git a/lib/lighthouse_provider/widgets/lighthouse_widget.dart b/lib/lighthouse_provider/widgets/lighthouse_widget.dart index a8ffc7a..ae75f5a 100644 --- a/lib/lighthouse_provider/widgets/lighthouse_widget.dart +++ b/lib/lighthouse_provider/widgets/lighthouse_widget.dart @@ -201,8 +201,7 @@ class LighthouseWidget extends StatefulWidget { required this.selecting, this.nickname, this.sleepState = LighthousePowerState.sleep, - super.key}) - : statefulDevice = lighthouseDevice is StatefulLighthouseDevice; + super.key}); final LighthouseDevice lighthouseDevice; final VoidCallback onSelected; @@ -210,7 +209,6 @@ class LighthouseWidget extends StatefulWidget { final String? nickname; final LighthousePowerState sleepState; final bool selecting; - final bool statefulDevice; @override State createState() { @@ -219,22 +217,17 @@ class LighthouseWidget extends StatefulWidget { } class LighthouseWidgetState extends State { - Stream? _powerStateStream; - @override void initState() { super.initState(); - if (widget.statefulDevice) { - _powerStateStream = - (widget.lighthouseDevice as StatefulLighthouseDevice).powerState; - } } @override Widget build(final BuildContext context) { - if (widget.statefulDevice) { + if (widget.lighthouseDevice is StatefulLighthouseDevice) { return StreamBuilder( - stream: _powerStateStream, + stream: + (widget.lighthouseDevice as StatefulLighthouseDevice).powerState, builder: (final BuildContext context, final AsyncSnapshot powerStateSnapshot) { final powerStateData = powerStateSnapshot.data ?? 0xFF; diff --git a/lighthouse_provider/lighthouse_back_ends/flutter_blue_plus_back_end/lib/src/flutter_blue_plus_back_end_io.dart b/lighthouse_provider/lighthouse_back_ends/flutter_blue_plus_back_end/lib/src/flutter_blue_plus_back_end_io.dart index 0fce6e4..b611f3f 100644 --- a/lighthouse_provider/lighthouse_back_ends/flutter_blue_plus_back_end/lib/src/flutter_blue_plus_back_end_io.dart +++ b/lighthouse_provider/lighthouse_back_ends/flutter_blue_plus_back_end/lib/src/flutter_blue_plus_back_end_io.dart @@ -56,8 +56,9 @@ class FlutterBluePlusLighthouseBackEnd extends BLELighthouseBackEnd { await blue_plus.FlutterBluePlus.startScan( androidScanMode: blue_plus.AndroidScanMode.lowLatency, timeout: timeout, - oneByOne: true, - //TODO: use the extra features + oneByOne: false, + withKeywords: + providers.map((final e) => e.namePrefix).toList(growable: false), ); } on PlatformException catch (e, s) { if (e.code == "bluetooth_unavailable") { diff --git a/lighthouse_provider/lighthouse_provider/lib/src/devices/stateful_lighthouse_device.dart b/lighthouse_provider/lighthouse_provider/lib/src/devices/stateful_lighthouse_device.dart index 3c3807c..89c6380 100644 --- a/lighthouse_provider/lighthouse_provider/lib/src/devices/stateful_lighthouse_device.dart +++ b/lighthouse_provider/lighthouse_provider/lib/src/devices/stateful_lighthouse_device.dart @@ -128,7 +128,7 @@ mixin StatefulLighthouseDevice on LighthouseDevice { } } catch (e, s) { lighthouseLogger.severe( - "Could not get state, maybe the device is already disconnected", + "Could not get state from $name, maybe the device is already disconnected", e, s); await disconnect(); @@ -138,18 +138,19 @@ mixin StatefulLighthouseDevice on LighthouseDevice { } } else { if (retryCount++ > 5) { - lighthouseLogger.shout("Unable to get power state because the " - "mutex has been locked for a while ($retryCount)." - "\nLocked by: ${transactionMutex.lockTrace?.toString()}"); + lighthouseLogger + .shout("Unable to get power state from $name because the " + "mutex has been locked for a while ($retryCount)." + "\nLocked by: ${transactionMutex.lockTrace?.toString()}"); } } } else { - lighthouseLogger.info("Cleaning-up old subscription!"); + lighthouseLogger.info("Cleaning-up old subscription! For $name"); disconnect(); } }); powerStateSubscription.onDone(() { - lighthouseLogger.info("Cleaning-up power state subscription!"); + lighthouseLogger.info("Cleaning-up power state subscription! For $name"); _powerStateSubscription = null; }); _powerStateSubscription = powerStateSubscription; diff --git a/pubspec.yaml b/pubspec.yaml index a98f384..7706696 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.3.0+10 +version: 1.3.1-beta2+11 environment: sdk: ">=2.19.0 <3.0.0" diff --git a/scripts/build-release-apks-fat.sh b/scripts/build-release-apks-fat.sh new file mode 100755 index 0000000..083e767 --- /dev/null +++ b/scripts/build-release-apks-fat.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) + +cd "$SCRIPT_DIR/../" || exit + +flutter build apk --release --no-obfuscate \ + --flavor=defaultVersion \ + --dart-define=includeGooglePlayInAppPurchases=false \ + --dart-define=includeSupportButtons=true \ + --dart-define=includeSupportPage=true \ + --dart-define=includePaypal=true \ + --dart-define=includeGithubSponsor=true \ + --target-platform=android-arm,android-arm64,android-x64 + +EXIT_CODE=$? + +if [ $EXIT_CODE != 0 ]; then + echo 'Could not build' + exit $EXIT_CODE +fi + +set -e + +mkdir -p "$SCRIPT_DIR/../output" + +VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+(-.+)?\+\d+' "${SCRIPT_DIR}/../pubspec.yaml") + +cp -vrf "${SCRIPT_DIR}/../build/app/outputs/flutter-apk/app-defaultversion-release.apk" "${SCRIPT_DIR}/../output/lighthouse_pm-${VERSION}.fat.apk" diff --git a/scripts/build-release-apks-github.sh b/scripts/build-release-apks-github.sh index 249bea5..d91adea 100755 --- a/scripts/build-release-apks-github.sh +++ b/scripts/build-release-apks-github.sh @@ -29,7 +29,7 @@ set -e mkdir -p "$SCRIPT_DIR/../output" -VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+\+\d+' "${SCRIPT_DIR}/../pubspec.yaml") +VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+(-.+)?\+\d+' "${SCRIPT_DIR}/../pubspec.yaml") function copy_result() { VERSION=$1 diff --git a/scripts/build-release-bundle-playstore.sh b/scripts/build-release-bundle-playstore.sh index 6243456..6778d3c 100755 --- a/scripts/build-release-bundle-playstore.sh +++ b/scripts/build-release-bundle-playstore.sh @@ -24,6 +24,6 @@ set -e mkdir -p "$SCRIPT_DIR/../output" -VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+\+\d+' "${SCRIPT_DIR}/../pubspec.yaml") +VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+(-.+)?\+\d+' "${SCRIPT_DIR}/../pubspec.yaml") cp -vrf "${SCRIPT_DIR}/../build/app/outputs/bundle/googlePlayRelease/app-googlePlay-release.aab" "$SCRIPT_DIR/../output/googlePlay-${VERSION}.aab"