Commit b96cf65

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2024-06-15 15:19:47
fix value insert
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent f23bcd8
Changed files (2)
app/lib/bluetooth/characteristic_decoder.dart
@@ -56,7 +56,18 @@ class CharacteristicDecoder {
       return null;
     }
 
-    return BloodPressureRecord(DateTime.now(), systolic!.toInt(), diastolic!.toInt(), -1, '');
+    if (timestampPresent) {
+      // TODO: decode timestamp
+      offset += 7;
+    }
+
+    double? pulse;
+    if (pulseRatePresent) {
+      pulse = _readSFloat(data, offset);
+      offset += 2;
+    }
+
+    return BloodPressureRecord(DateTime.now(), systolic.toInt(), diastolic.toInt(), pulse?.toInt(), '');
     /*return BleMeasurementData(
       systolic: systolic,
       diastolic: diastolic,
app/lib/components/bluetooth_input.dart
@@ -95,11 +95,13 @@ class _BluetoothInputState extends State<BluetoothInput> {
             onAccepted: (dev) => _deviceScanCubit!.acceptDevice(dev),
           ),
             // distinction
-          DeviceSelected() => BlocBuilder<BleReadCubit, BleReadState>(
+          DeviceSelected() => BlocConsumer<BleReadCubit, BleReadState>(
             bloc: () { _deviceReadCubit = BleReadCubit(state.device); return _deviceReadCubit; }(),
+            listener: (BuildContext context, BleReadState state) {
+              if (state is BleReadSuccess) widget.onMeasurement(state.data);
+            },
             builder: (BuildContext context, BleReadState state) {
               Log.trace('_BluetoothInputState BleReadCubit: $state');
-              if (state is BleReadSuccess) widget.onMeasurement(state.data);
               return switch (state) {
                 BleReadInProgress() => _buildMainCard(context,
                   child: const CircularProgressIndicator(),