Skip to content

Commit 3e2d024

Browse files
committed
Remove the legacy HealthyPi 0x02 packet decoder
That single-sample combined format is no longer sent by current firmware, which batches into the 0x03 (ECG/BioZ) and 0x04 (PPG) packets. Drops the PacketSpec and decodeHealthypiPkt2; docs and code now agree. flutter analyze clean (13 pre-existing infos); flutter test passes.
1 parent a5612cf commit 3e2d024

2 files changed

Lines changed: 3 additions & 56 deletions

File tree

lib/boards/decoders/healthypi_decoders.dart

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,11 @@ import 'dart:typed_data';
66
import '../../protocol/decoded_packet.dart';
77
import 'shared_codecs.dart';
88

9-
/// HealthyPi 5 (USB) — pktType 2 — Combined ECG, BioZ & PPG single-sample packet.
10-
///
11-
/// Payload layout (22 bytes):
12-
/// [0-3] ecg_sample int32 LE — sign-extended 24-bit ADC value
13-
/// [4-7] bioz_sample int32 LE — bio-impedance / respiration waveform
14-
/// [8] bioZSkipSample uint8 — 0 = valid BioZ; 1 = skip (do not plot/process)
15-
/// [9-12] raw_red int32 LE — PPG red-channel raw photodiode counts
16-
/// [13-16] raw_ir int32 LE — PPG IR-channel raw photodiode counts
17-
/// [17-18] temp int16 LE — °C × 100 (only low 16 bits of int32 used;
18-
/// e.g. 3650 → 36.50 °C)
19-
/// [19] spo2 uint8 — SpO₂ in %
20-
/// [20] hr uint8 — heart rate in bpm
21-
/// [21] rr uint8 — respiration rate in breaths/min
22-
///
23-
/// Note: bioz_sample is always emitted in channelSamples. Consumers must check
24-
/// the 'bioZSkip' event flag (1 = invalid) before plotting or processing the
25-
/// 'bioz' channel for this sample.
26-
DecodedPacket decodeHealthypiPkt2(Uint8List p) {
27-
final ecgSample = Codec.readInt32LE(p, 0).toDouble();
28-
final biozSample = Codec.readInt32LE(p, 4).toDouble();
29-
final bioZSkip = p[8] != 0; // true → firmware says skip this BioZ sample
30-
final rawRed = Codec.readInt32LE(p, 9).toDouble();
31-
final rawIr = Codec.readInt32LE(p, 13).toDouble();
32-
final temp = Codec.readInt16LE(p, 17).toDouble() / 100.0;
33-
final spo2 = p[19];
34-
final hr = p[20];
35-
final rr = p[21];
36-
37-
return DecodedPacket(
38-
pktType: 2,
39-
channelSamples: {
40-
'ecg': [ecgSample],
41-
'bioz': [biozSample], // check events['bioZSkip'] before using
42-
'ppgRed': [rawRed],
43-
'ppgIr': [rawIr],
44-
},
45-
events: {
46-
'heartRate': hr,
47-
'respRate': rr,
48-
'spo2': spo2,
49-
'temperature': temp,
50-
'bioZSkip': bioZSkip ? 1 : 0,
51-
},
52-
);
53-
}
54-
559
// ── HealthyPi 5 firmware v1.0.0+ (USB) — separate ECG/BioZ and PPG packets ──
5610
//
57-
// From firmware 1.0.0, HealthyPi 5's USB stream batches samples into two
58-
// framed packet types instead of the combined single-sample packet above (see
59-
// README wire-format tables). All multi-byte fields are little-endian, matching
60-
// pktType 2 and the BLE stream (verified against ProtoCentral OpenView 2).
11+
// HealthyPi 5's USB stream batches samples into two framed packet types (see
12+
// the README wire-format diagram). All multi-byte fields are little-endian,
13+
// matching the BLE stream.
6114

6215
/// HealthyPi 5 — pktType 3 — ECG + Respiration (BioZ) batch (USB).
6316
///

lib/boards/descriptors/healthypi.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@ final BoardDescriptor healthypiDescriptor = BoardDescriptor(
121121
_ppgRedChannel,
122122
],
123123
packets: [
124-
PacketSpec(
125-
pktType: 2,
126-
label: 'ECG/BioZ/PPG-Red/PPG-IR/Temp/SpO2/HR/RR',
127-
expectedPayloadLength: 22,
128-
decode: decodeHealthypiPkt2,
129-
),
130124
// Firmware v1.0.0+ USB batch packets.
131125
PacketSpec(
132126
pktType: 3,

0 commit comments

Comments
 (0)