@@ -6,58 +6,11 @@ import 'dart:typed_data';
66import '../../protocol/decoded_packet.dart' ;
77import '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///
0 commit comments