From f4a1e21022a0043dfbf2d72cbfd7dd148eb30d0f Mon Sep 17 00:00:00 2001 From: hith-1801 Date: Tue, 28 Apr 2026 10:58:04 +0200 Subject: [PATCH 1/3] sensor error streaming added for imu and some others and initialization notification too --- .../lib/view_models/wearables_provider.dart | 26 +++++++++++++++++-- open_wearable/pubspec.lock | 11 ++++---- open_wearable/pubspec.yaml | 5 +++- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/open_wearable/lib/view_models/wearables_provider.dart b/open_wearable/lib/view_models/wearables_provider.dart index f81bba4e..46781b0c 100644 --- a/open_wearable/lib/view_models/wearables_provider.dart +++ b/open_wearable/lib/view_models/wearables_provider.dart @@ -6,7 +6,7 @@ import 'package:open_wearable/models/device_name_formatter.dart'; import 'package:open_wearable/models/wearable_display_group.dart'; import 'package:open_wearable/models/wearable_status_cache.dart'; import 'package:open_wearable/view_models/sensor_configuration_provider.dart'; - +import 'package:open_earable_flutter/src/models/error/sensor_error.dart'; import '../models/logger.dart'; /// Event emitted when a newer firmware version is available for a wearable. @@ -282,7 +282,7 @@ class WearablesProvider with ChangeNotifier { ), ); } - + _handleWearableErrors(wearable); // Disconnect listener (sync) wearable.addDisconnectListener(() { removeWearable(wearable); @@ -564,4 +564,26 @@ class WearablesProvider with ChangeNotifier { unawaited(_wearableEventController.close()); super.dispose(); } + // Add this method to the WearablesProvider class +void _handleWearableErrors(Wearable wearable) { + wearable.onError.listen((error) { + if (error is SensorError) { + _emitWearableEvent( + WearableErrorEvent( + wearable: wearable, + errorMessage: error.formattedMessage, + description: error.formattedMessage, + ), + ); + } else { + _emitWearableEvent( + WearableErrorEvent( + wearable: wearable, + errorMessage: error.toString(), + description: error.toString(), + ), + ); + } + }); +} } diff --git a/open_wearable/pubspec.lock b/open_wearable/pubspec.lock index 7031a8b8..fe916d6f 100644 --- a/open_wearable/pubspec.lock +++ b/open_wearable/pubspec.lock @@ -563,11 +563,12 @@ packages: open_earable_flutter: dependency: "direct main" description: - name: open_earable_flutter - sha256: "078c8a64ad05265b5b7afae991830549e08729fecacfd255dc4a8e038f8ad12b" - url: "https://pub.dev" - source: hosted - version: "2.3.5" + path: "." + ref: main + resolved-ref: adc3eaa24c721eb970afdd9fe7e2415315defd5d + url: "https://github.com/hith-1801/open_earable_flutter-ble-errors.git" + source: git + version: "2.3.6" open_file: dependency: "direct main" description: diff --git a/open_wearable/pubspec.yaml b/open_wearable/pubspec.yaml index 6147e6aa..0bb4a372 100644 --- a/open_wearable/pubspec.yaml +++ b/open_wearable/pubspec.yaml @@ -35,7 +35,10 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 open_file: ^3.3.2 - open_earable_flutter: ^2.3.5 + open_earable_flutter: + git: + url: https://github.com/hith-1801/open_earable_flutter-ble-errors.git + ref: main universal_ble: ^0.21.1 flutter_platform_widgets: ^9.0.0 provider: ^6.1.2 From 774a85c4118a62d1c5090c4403b2df213f2f5e1a Mon Sep 17 00:00:00 2001 From: habibialireza Date: Tue, 9 Jun 2026 20:05:29 +0200 Subject: [PATCH 2/3] Add BLE device error notifications --- open_wearable/android/gradle.properties | 4 ++ open_wearable/lib/main.dart | 32 +++++++---- .../lib/view_models/wearables_provider.dart | 57 ++++++++++++------- open_wearable/pubspec.lock | 16 +++--- open_wearable/pubspec.yaml | 6 +- 5 files changed, 71 insertions(+), 44 deletions(-) diff --git a/open_wearable/android/gradle.properties b/open_wearable/android/gradle.properties index 25971708..4147ba38 100644 --- a/open_wearable/android/gradle.properties +++ b/open_wearable/android/gradle.properties @@ -1,3 +1,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true +# This builtInKotlin flag was added automatically by Flutter migrator +android.builtInKotlin=false +# This newDsl flag was added automatically by Flutter migrator +android.newDsl=false diff --git a/open_wearable/lib/main.dart b/open_wearable/lib/main.dart index d0a34cce..b9ed66e0 100644 --- a/open_wearable/lib/main.dart +++ b/open_wearable/lib/main.dart @@ -190,25 +190,37 @@ class _MyAppState extends State with WidgetsBindingObserver { appBannerController.showBanner( (id) { final colorScheme = Theme.of(context).colorScheme; - final bool isError = event is WearableErrorEvent; + final severity = + event is WearableErrorEvent ? event.severity : null; + final bool isError = severity == DeviceErrorLevel.error || + severity == DeviceErrorLevel.fatal; + final bool isWarning = severity == DeviceErrorLevel.warning; final bool isTimeSync = event is WearableTimeSynchronizedEvent; const timeSyncBackground = Color(0xFFEDE4FF); const timeSyncForeground = Color(0xFF5A2EA6); + const warningBackground = Color(0xFFFFF3CD); + const warningForeground = Color(0xFF6B4E00); final backgroundColor = isError ? colorScheme.errorContainer - : isTimeSync - ? timeSyncBackground - : colorScheme.primaryContainer; + : isWarning + ? warningBackground + : isTimeSync + ? timeSyncBackground + : colorScheme.primaryContainer; final textColor = isError ? colorScheme.onErrorContainer - : isTimeSync - ? timeSyncForeground - : colorScheme.onPrimaryContainer; + : isWarning + ? warningForeground + : isTimeSync + ? timeSyncForeground + : colorScheme.onPrimaryContainer; final icon = isError ? Icons.error_outline_rounded - : isTimeSync - ? Icons.schedule_rounded - : Icons.info_outline_rounded; + : isWarning + ? Icons.warning_amber_rounded + : isTimeSync + ? Icons.schedule_rounded + : Icons.info_outline_rounded; final textStyle = Theme.of(context).textTheme.bodyMedium?.copyWith( color: textColor, fontWeight: FontWeight.w600, diff --git a/open_wearable/lib/view_models/wearables_provider.dart b/open_wearable/lib/view_models/wearables_provider.dart index 46781b0c..0f0d2235 100644 --- a/open_wearable/lib/view_models/wearables_provider.dart +++ b/open_wearable/lib/view_models/wearables_provider.dart @@ -75,9 +75,12 @@ class WearableTimeSynchronizedEvent extends WearableEvent { /// Emitted when wearable-side operations fail and should surface in UI. class WearableErrorEvent extends WearableEvent { final String errorMessage; + final DeviceErrorLevel severity; + WearableErrorEvent({ required super.wearable, required this.errorMessage, + this.severity = DeviceErrorLevel.error, String? description, }) : super( description: description ?? @@ -156,6 +159,7 @@ class WearablesProvider with ChangeNotifier { _wearableEventController.stream; final Map _capabilitySubscriptions = {}; + final Map _errorSubscriptions = {}; // MARK: Internal helpers @@ -179,12 +183,14 @@ class WearablesProvider with ChangeNotifier { void _emitWearableError({ required Wearable wearable, required String errorMessage, + DeviceErrorLevel severity = DeviceErrorLevel.error, String? description, }) { _emitWearableEvent( WearableErrorEvent( wearable: wearable, errorMessage: errorMessage, + severity: severity, description: description, ), ); @@ -506,6 +512,7 @@ class WearablesProvider with ChangeNotifier { _wearables.remove(wearable); _sensorConfigurationProviders.remove(wearable)?.dispose(); _capabilitySubscriptions.remove(wearable)?.cancel(); + _errorSubscriptions.remove(wearable)?.cancel(); if (!_disposed) { notifyListeners(); } @@ -552,6 +559,10 @@ class WearablesProvider with ChangeNotifier { unawaited(sub.cancel()); } _capabilitySubscriptions.clear(); + for (final sub in _errorSubscriptions.values) { + unawaited(sub.cancel()); + } + _errorSubscriptions.clear(); for (final provider in _sensorConfigurationProviders.values) { provider.dispose(); @@ -564,26 +575,28 @@ class WearablesProvider with ChangeNotifier { unawaited(_wearableEventController.close()); super.dispose(); } - // Add this method to the WearablesProvider class -void _handleWearableErrors(Wearable wearable) { - wearable.onError.listen((error) { - if (error is SensorError) { - _emitWearableEvent( - WearableErrorEvent( - wearable: wearable, - errorMessage: error.formattedMessage, - description: error.formattedMessage, - ), - ); - } else { - _emitWearableEvent( - WearableErrorEvent( - wearable: wearable, - errorMessage: error.toString(), - description: error.toString(), - ), - ); - } - }); -} + + void _handleWearableErrors(Wearable wearable) { + _errorSubscriptions[wearable]?.cancel(); + _errorSubscriptions[wearable] = wearable.onError.listen((error) { + if (error is SensorError) { + _emitWearableEvent( + WearableErrorEvent( + wearable: wearable, + errorMessage: error.formattedMessage, + severity: error.level, + description: error.formattedMessage, + ), + ); + } else { + _emitWearableEvent( + WearableErrorEvent( + wearable: wearable, + errorMessage: error.toString(), + description: error.toString(), + ), + ); + } + }); + } } diff --git a/open_wearable/pubspec.lock b/open_wearable/pubspec.lock index fe916d6f..854a46ac 100644 --- a/open_wearable/pubspec.lock +++ b/open_wearable/pubspec.lock @@ -524,10 +524,10 @@ packages: dependency: transitive description: name: meta - sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.18.0" mime: dependency: transitive description: @@ -563,11 +563,9 @@ packages: open_earable_flutter: dependency: "direct main" description: - path: "." - ref: main - resolved-ref: adc3eaa24c721eb970afdd9fe7e2415315defd5d - url: "https://github.com/hith-1801/open_earable_flutter-ble-errors.git" - source: git + path: "C:/teco/ble error/open_earable_flutter" + relative: false + source: path version: "2.3.6" open_file: dependency: "direct main" @@ -946,10 +944,10 @@ packages: dependency: transitive description: name: test_api - sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" + sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" url: "https://pub.dev" source: hosted - version: "0.7.10" + version: "0.7.11" tuple: dependency: transitive description: diff --git a/open_wearable/pubspec.yaml b/open_wearable/pubspec.yaml index 0bb4a372..c65ed015 100644 --- a/open_wearable/pubspec.yaml +++ b/open_wearable/pubspec.yaml @@ -36,9 +36,9 @@ dependencies: cupertino_icons: ^1.0.8 open_file: ^3.3.2 open_earable_flutter: - git: - url: https://github.com/hith-1801/open_earable_flutter-ble-errors.git - ref: main + git: + url: https://github.com/habibialireza/open_earable_flutter.git + ref: ble-device-errors universal_ble: ^0.21.1 flutter_platform_widgets: ^9.0.0 provider: ^6.1.2 From 91765ea5b016825676f94420c1a73d80807780a9 Mon Sep 17 00:00:00 2001 From: habibialireza Date: Sat, 27 Jun 2026 03:23:12 +0200 Subject: [PATCH 3/3] ble error service --- open_wearable/pubspec.lock | 2 +- open_wearable/pubspec.yaml | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/open_wearable/pubspec.lock b/open_wearable/pubspec.lock index 854a46ac..1f49553b 100644 --- a/open_wearable/pubspec.lock +++ b/open_wearable/pubspec.lock @@ -563,7 +563,7 @@ packages: open_earable_flutter: dependency: "direct main" description: - path: "C:/teco/ble error/open_earable_flutter" + path: "E:/teco/bluetooth_error/open_earable_flutter" relative: false source: path version: "2.3.6" diff --git a/open_wearable/pubspec.yaml b/open_wearable/pubspec.yaml index c65ed015..91e5806d 100644 --- a/open_wearable/pubspec.yaml +++ b/open_wearable/pubspec.yaml @@ -36,9 +36,7 @@ dependencies: cupertino_icons: ^1.0.8 open_file: ^3.3.2 open_earable_flutter: - git: - url: https://github.com/habibialireza/open_earable_flutter.git - ref: ble-device-errors + path: E:/teco/bluetooth_error/open_earable_flutter universal_ble: ^0.21.1 flutter_platform_widgets: ^9.0.0 provider: ^6.1.2