1import 'package:blood_pressure_app/features/bluetooth/logic/characteristics/decoding_util.dart';
 2
 3class BleMeasurementStatus {
 4  BleMeasurementStatus({
 5    required this.bodyMovementDetected,
 6    required this.cuffTooLose,
 7    required this.irregularPulseDetected,
 8    required this.pulseRateInRange,
 9    required this.pulseRateExceedsUpperLimit,
10    required this.pulseRateIsLessThenLowerLimit,
11    required this.improperMeasurementPosition,
12  });
13
14  factory BleMeasurementStatus.decode(int byte) => BleMeasurementStatus(
15    bodyMovementDetected: isBitIntByteSet(byte, 1),
16    cuffTooLose: isBitIntByteSet(byte, 2),
17    irregularPulseDetected: isBitIntByteSet(byte, 3),
18    pulseRateInRange: (byte & (1 << 4) >> 3) == 0,
19    pulseRateExceedsUpperLimit: (byte & (1 << 4) >> 3) == 1,
20    pulseRateIsLessThenLowerLimit: (byte & (1 << 4) >> 3) == 2,
21    improperMeasurementPosition: isBitIntByteSet(byte, 5),
22  );
23
24  final bool bodyMovementDetected;
25  final bool cuffTooLose;
26  final bool irregularPulseDetected;
27  final bool pulseRateInRange;
28  final bool pulseRateExceedsUpperLimit;
29  final bool pulseRateIsLessThenLowerLimit;
30  final bool improperMeasurementPosition;
31
32  @override
33  String toString() => 'BleMeasurementStatus{bodyMovementDetected: $bodyMovementDetected, cuffTooLose: $cuffTooLose, irregularPulseDetected: $irregularPulseDetected, pulseRateInRange: $pulseRateInRange, pulseRateExceedsUpperLimit: $pulseRateExceedsUpperLimit, pulseRateIsLessThenLowerLimit: $pulseRateIsLessThenLowerLimit, improperMeasurementPosition: $improperMeasurementPosition}';
34}