diff --git a/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_background_notifications_use_case.dart b/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_background_notifications_use_case.dart index a13ad0cf..efd5154a 100644 --- a/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_background_notifications_use_case.dart +++ b/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_background_notifications_use_case.dart @@ -27,8 +27,7 @@ class BlueberryRingBackgroundNotificationsUseCase extends ReactiveUseCase { Future checkActivityReminder() async { final data = await _blueberryRingUseCase.readSteps(); - print( - 'checkActivityReminder:data ${data.map((e) => e.toJson()).toList()}'); + print('checkActivityReminder:data ${data.map((e) => e.toJson()).toList()}'); // Get spteps data from cache and compare // If steps is below a certain number then show a // Below 5000 @@ -41,8 +40,7 @@ class BlueberryRingBackgroundNotificationsUseCase extends ReactiveUseCase { now.month == lastDate.month && now.day == lastDate.day; - // isToday && - if (latestData.step < 5000) { + if (isToday && latestData.step < 5000) { AXSNotification().showNotification( cTranslate('activity_reminder'), cTranslate('blueberry_ring_inactive_alert_text'), @@ -52,23 +50,23 @@ class BlueberryRingBackgroundNotificationsUseCase extends ReactiveUseCase { Future checkSleepInsight() async { final data = await _blueberryRingUseCase.readSleep(); - print( - 'checkSleepInsight:data ${data.map((e) => e.toJson()).toList()}'); + print('checkSleepInsight:data ${data.map((e) => e.toJson()).toList()}'); // If sleeps is below standard level // loop throug all and get average final now = DateTime.now(); final todaysData = data.where((element) { - // final date = DateTime.fromMillisecondsSinceEpoch( - // element.date * 1000, - // ); - // final isToday = now.year == date.year && - // now.month == date.month && - // now.day == date.day; - // return isToday; - return true; + final date = DateTime.fromMillisecondsSinceEpoch( + element.date * 1000, + ); + final isToday = now.year == date.year && + now.month == date.month && + now.day == date.day; + return isToday; }); + print( + 'checkSleepInsight:todaysData ${todaysData.map((e) => e.toJson()).toList()}'); if (todaysData.isEmpty) { return; } @@ -97,8 +95,7 @@ class BlueberryRingBackgroundNotificationsUseCase extends ReactiveUseCase { now.month == lastDate.month && now.day == lastDate.day; - // isToday && - if (latestData.value >= 100) { + if (isToday && latestData.value >= 100) { AXSNotification().showNotification( cTranslate('heart_alert'), cTranslate('blueberry_ring_heart_rate_alert_text'), diff --git a/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_use_case.dart b/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_use_case.dart index 096e0807..3d1b34f8 100644 --- a/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_use_case.dart +++ b/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_use_case.dart @@ -179,9 +179,8 @@ class BlueberryRingUseCase extends ReactiveUseCase { stream.listen((element) { if (element.isNotEmpty && element.first == command.first) { timer?.cancel(); - collectLog('read$dataName:value $element'); + collectLog('read$dataName:element $element'); data.addAll(element); - collectLog('read$dataName:value $data'); if (!completer.isCompleted && !isFrag) { completer.complete(data); diff --git a/lib/features/common/packages/bluetooth/blueberry_ring/utils/blueberry_commands_utils.dart b/lib/features/common/packages/bluetooth/blueberry_ring/utils/blueberry_commands_utils.dart index 5f079853..79c5a1a2 100644 --- a/lib/features/common/packages/bluetooth/blueberry_ring/utils/blueberry_commands_utils.dart +++ b/lib/features/common/packages/bluetooth/blueberry_ring/utils/blueberry_commands_utils.dart @@ -24,7 +24,8 @@ class BlueberryCommandsUtils { static List> splitArrayByLength(List arr, int length) { List> result = []; for (int i = 0; i < arr.length; i += length) { - result.add(arr.sublist(i, i + length)); + int end = (i + length < arr.length) ? i + length : arr.length; + result.add(arr.sublist(i, end)); } return result; }