@ovok/native 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE +8 -667
  2. package/lib/commonjs/modules/bt-management/services/bt-manager.js +15 -13
  3. package/lib/commonjs/modules/bt-management/services/bt-manager.js.map +1 -1
  4. package/lib/commonjs/modules/bt-management/services/device-creator.js +7 -1
  5. package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
  6. package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js +184 -0
  7. package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js.map +1 -0
  8. package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-frame-parser.js +114 -0
  9. package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-frame-parser.js.map +1 -0
  10. package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.device.js +113 -51
  11. package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.device.js.map +1 -1
  12. package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.main-services.js +41 -77
  13. package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.main-services.js.map +1 -1
  14. package/lib/module/modules/bt-management/services/bt-manager.js +15 -13
  15. package/lib/module/modules/bt-management/services/bt-manager.js.map +1 -1
  16. package/lib/module/modules/bt-management/services/device-creator.js +7 -1
  17. package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
  18. package/lib/module/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js +180 -0
  19. package/lib/module/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js.map +1 -0
  20. package/lib/module/modules/bt-management/services/devices/bc01/bc01-frame-parser.js +110 -0
  21. package/lib/module/modules/bt-management/services/devices/bc01/bc01-frame-parser.js.map +1 -0
  22. package/lib/module/modules/bt-management/services/devices/bc01/bc01.device.js +113 -51
  23. package/lib/module/modules/bt-management/services/devices/bc01/bc01.device.js.map +1 -1
  24. package/lib/module/modules/bt-management/services/devices/bc01/bc01.main-services.js +41 -77
  25. package/lib/module/modules/bt-management/services/devices/bc01/bc01.main-services.js.map +1 -1
  26. package/lib/typescript/commonjs/src/modules/bt-management/services/bt-manager.d.ts +0 -1
  27. package/lib/typescript/commonjs/src/modules/bt-management/services/bt-manager.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts +53 -0
  30. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts.map +1 -0
  31. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts +53 -0
  32. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts.map +1 -0
  33. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts +33 -13
  34. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts.map +1 -1
  35. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts +11 -17
  36. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts.map +1 -1
  37. package/lib/typescript/module/src/modules/bt-management/services/bt-manager.d.ts +0 -1
  38. package/lib/typescript/module/src/modules/bt-management/services/bt-manager.d.ts.map +1 -1
  39. package/lib/typescript/module/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
  40. package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts +53 -0
  41. package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts.map +1 -0
  42. package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts +53 -0
  43. package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts.map +1 -0
  44. package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts +33 -13
  45. package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts.map +1 -1
  46. package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts +11 -17
  47. package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts.map +1 -1
  48. package/package.json +1 -1
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+
3
+ import { hexToByte } from "../../../utils/hex-to-byte.js";
4
+
5
+ /**
6
+ * The FF01/FF02 opcodes the BC401 firmware speaks, as reverse-engineered from
7
+ * PHMS 3.0.03 (`I1/b.java` for the switch, `B3/B5.java` for the builders and
8
+ * checksum, `L1/f.java` for the reset write).
9
+ */
10
+ const OP_RESET = 0x80;
11
+ const OP_REQUEST_VERSION = 0x82;
12
+ const OP_SET_TIME = 0x83;
13
+ const OP_REQUEST_COUNT = 0x90;
14
+ const OP_REQUEST_RECORDS = 0x92;
15
+
16
+ /** Payload byte for `OP_REQUEST_RECORDS` that acknowledges the last record of the set. */
17
+ const ACK_LAST_OF_SET = 0x7e;
18
+
19
+ /** Payload byte for `OP_REQUEST_COUNT` and the initial `OP_REQUEST_RECORDS`. */
20
+ const REQUEST_ALL = 0x00;
21
+
22
+ /**
23
+ * Device-to-host frame prefixes the FSM keys on. Values are decimal opcodes as
24
+ * they appear in the decompiled Java (`switch(bArr[0])`), rendered here as
25
+ * their real hex opcodes.
26
+ */
27
+ const RX = {
28
+ ACK: 0xf0,
29
+ VERSION_REPLY: 0xf2,
30
+ TIME_SYNC_ACK: 0xf3,
31
+ COUNT_REPLY: 0xe0,
32
+ STORED_RECORD_URS: 0xe1,
33
+ STORED_RECORD_PAGED: 0xe2,
34
+ FINISH: 0xe3
35
+ };
36
+
37
+ /** Position in a 16-byte URS record where the flags byte sits; bit 0x40 marks the last of a set. */
38
+ const RECORD_FLAGS_INDEX = 1;
39
+ const RECORD_LAST_OF_SET_BIT = 0x40;
40
+ /**
41
+ * Formats one byte as a two-digit lowercase hex string, matching the way the
42
+ * SDK's transport already spells raw bytes.
43
+ */
44
+ const asHex = byte => (byte & 0xff).toString(16).padStart(2, "0");
45
+
46
+ /**
47
+ * BC401 checksum: sum of the low 7 bits of every byte, folded back into 7 bits.
48
+ * Matches `B5.a` in the decompiled Java exactly.
49
+ */
50
+ const bc401Checksum = bytes => bytes.reduce((acc, byte) => acc + (byte & 0x7f), 0) & 0x7f;
51
+
52
+ /**
53
+ * Builds a "one payload byte plus checksum" command frame. This is the shape
54
+ * of every BC401 host-to-device command that carries an argument: opcode,
55
+ * argument, checksum-over-both.
56
+ */
57
+ const buildCommand = (opcode, arg) => {
58
+ const chk = bc401Checksum([opcode, arg]);
59
+ return [opcode, arg, chk];
60
+ };
61
+
62
+ /**
63
+ * Builds the two-byte reset frame. It is the one command that does not carry
64
+ * an argument or a checksum — PHMS writes it as `[0x80, 0x00]` verbatim
65
+ * (`L1/f.java:694`).
66
+ */
67
+ const buildResetCommand = () => [OP_RESET, 0x00];
68
+
69
+ /**
70
+ * Builds the request-version reply. The Java sends it as `[0x82, 0x02]` where
71
+ * `0x02` doubles as the checksum of `0x82` under the BC401 rule
72
+ * (`0x82 & 0x7f = 0x02`), so the same formula that guards every other command
73
+ * produces the right byte here.
74
+ */
75
+ const buildRequestVersionCommand = () => {
76
+ const chk = bc401Checksum([OP_REQUEST_VERSION]);
77
+ return [OP_REQUEST_VERSION, chk];
78
+ };
79
+
80
+ /**
81
+ * Builds the `SET_TIME` frame for the moment the sequencer receives it. The
82
+ * device does not run its own clock across power cycles, so timestamps on
83
+ * stored records only make sense once the app tells it what "now" is.
84
+ * Millisecond field is written little-endian, matching `I1/b.java`.
85
+ */
86
+ const buildSetTimeCommand = now => {
87
+ const yy = now.getFullYear() - 2000;
88
+ const mo = now.getMonth() + 1;
89
+ const dd = now.getDate();
90
+ const hh = now.getHours();
91
+ const mi = now.getMinutes();
92
+ const ss = now.getSeconds();
93
+ const ms = now.getMilliseconds();
94
+ const msLo = ms & 0xff;
95
+ const msHi = ms >> 8 & 0xff;
96
+ const payload = [OP_SET_TIME, yy, mo, dd, hh, mi, ss, msLo, msHi];
97
+ const chk = bc401Checksum(payload);
98
+ return [...payload, chk];
99
+ };
100
+
101
+ /**
102
+ * Walks the BC401 through its post-reset handshake and pulls every stored
103
+ * record.
104
+ *
105
+ * The device is self-clocking: it answers each command with a single frame,
106
+ * and the first byte of that frame names what it is. So the sequencer keeps
107
+ * no counter of its own — it looks at the reply, decides what belongs next,
108
+ * and returns that. A frame whose opcode is not part of the handshake is left
109
+ * unanswered so the driver's stuck-data watchdog surfaces the stall rather
110
+ * than the sequencer sending a command the device did not ask for.
111
+ *
112
+ * `initialCommands()` returns only the reset. The rest of the handshake -
113
+ * VERSION, SET_TIME, GET_COUNT, GET_RECORDS - is driven entirely by the
114
+ * device's own replies, because sending them any earlier would race the
115
+ * firmware boot the reset triggers.
116
+ */
117
+ // eslint-disable-next-line import/group-exports
118
+ export class Bc01CommandSequencer {
119
+ isDone = false;
120
+
121
+ /** Injectable for tests; production reads `Date.now()`. */
122
+
123
+ constructor(params, clock = () => new Date()) {
124
+ this.params = params;
125
+ this.clock = clock;
126
+ }
127
+ initialCommands = () => [this.commandFor(buildResetCommand())];
128
+ nextCommand = frame => {
129
+ if (this.isDone || frame.length === 0) {
130
+ return undefined;
131
+ }
132
+ const opcode = hexToByte(frame[0] ?? "0");
133
+ switch (opcode) {
134
+ case RX.ACK:
135
+ return [this.commandFor(buildRequestVersionCommand())];
136
+ case RX.VERSION_REPLY:
137
+ return [this.commandFor(buildSetTimeCommand(this.clock()))];
138
+ case RX.TIME_SYNC_ACK:
139
+ return [this.commandFor(buildCommand(OP_REQUEST_COUNT, REQUEST_ALL))];
140
+ case RX.COUNT_REPLY:
141
+ return [this.commandFor(buildCommand(OP_REQUEST_RECORDS, REQUEST_ALL))];
142
+ case RX.STORED_RECORD_URS:
143
+ case RX.STORED_RECORD_PAGED:
144
+ return this.answerStoredRecord(frame);
145
+ case RX.FINISH:
146
+ this.isDone = true;
147
+ return undefined;
148
+ default:
149
+ return undefined;
150
+ }
151
+ };
152
+
153
+ /**
154
+ * The device pages every record it holds, one 16-byte frame at a time. Only
155
+ * the frame whose flags byte carries `0x40` needs an acknowledgement; every
156
+ * other page is a status update we let ride while the transfer continues.
157
+ */
158
+ answerStoredRecord = frame => {
159
+ const flags = hexToByte(frame[RECORD_FLAGS_INDEX] ?? "0");
160
+ if ((flags & RECORD_LAST_OF_SET_BIT) === 0) {
161
+ return undefined;
162
+ }
163
+ return [this.commandFor(buildCommand(OP_REQUEST_RECORDS, ACK_LAST_OF_SET))];
164
+ };
165
+ commandFor = bytes => ({
166
+ ...this.params.write,
167
+ frame: bytes.map(asHex),
168
+ withoutResponse: true
169
+ });
170
+ }
171
+
172
+ // eslint-disable-next-line import/group-exports
173
+ export const bc01CommandSequencerInternals = {
174
+ bc401Checksum,
175
+ buildCommand,
176
+ buildResetCommand,
177
+ buildRequestVersionCommand,
178
+ buildSetTimeCommand
179
+ };
180
+ //# sourceMappingURL=bc01-command-sequencer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hexToByte","OP_RESET","OP_REQUEST_VERSION","OP_SET_TIME","OP_REQUEST_COUNT","OP_REQUEST_RECORDS","ACK_LAST_OF_SET","REQUEST_ALL","RX","ACK","VERSION_REPLY","TIME_SYNC_ACK","COUNT_REPLY","STORED_RECORD_URS","STORED_RECORD_PAGED","FINISH","RECORD_FLAGS_INDEX","RECORD_LAST_OF_SET_BIT","asHex","byte","toString","padStart","bc401Checksum","bytes","reduce","acc","buildCommand","opcode","arg","chk","buildResetCommand","buildRequestVersionCommand","buildSetTimeCommand","now","yy","getFullYear","mo","getMonth","dd","getDate","hh","getHours","mi","getMinutes","ss","getSeconds","ms","getMilliseconds","msLo","msHi","payload","Bc01CommandSequencer","isDone","constructor","params","clock","Date","initialCommands","commandFor","nextCommand","frame","length","undefined","answerStoredRecord","flags","write","map","withoutResponse","bc01CommandSequencerInternals"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/bc01/bc01-command-sequencer.ts"],"mappings":";;AAEA,SAASA,SAAS,QAAQ,+BAA4B;;AAEtD;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAG,IAAI;AACrB,MAAMC,kBAAkB,GAAG,IAAI;AAC/B,MAAMC,WAAW,GAAG,IAAI;AACxB,MAAMC,gBAAgB,GAAG,IAAI;AAC7B,MAAMC,kBAAkB,GAAG,IAAI;;AAE/B;AACA,MAAMC,eAAe,GAAG,IAAI;;AAE5B;AACA,MAAMC,WAAW,GAAG,IAAI;;AAExB;AACA;AACA;AACA;AACA;AACA,MAAMC,EAAE,GAAG;EACTC,GAAG,EAAE,IAAI;EACTC,aAAa,EAAE,IAAI;EACnBC,aAAa,EAAE,IAAI;EACnBC,WAAW,EAAE,IAAI;EACjBC,iBAAiB,EAAE,IAAI;EACvBC,mBAAmB,EAAE,IAAI;EACzBC,MAAM,EAAE;AACV,CAAU;;AAEV;AACA,MAAMC,kBAAkB,GAAG,CAAC;AAC5B,MAAMC,sBAAsB,GAAG,IAAI;AAenC;AACA;AACA;AACA;AACA,MAAMC,KAAK,GAAIC,IAAY,IACzB,CAACA,IAAI,GAAG,IAAI,EAAEC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;;AAE7C;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,KAAwB,IAC7CA,KAAK,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEN,IAAI,KAAKM,GAAG,IAAIN,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;;AAE5D;AACA;AACA;AACA;AACA;AACA,MAAMO,YAAY,GAAGA,CAACC,MAAc,EAAEC,GAAW,KAAe;EAC9D,MAAMC,GAAG,GAAGP,aAAa,CAAC,CAACK,MAAM,EAAEC,GAAG,CAAC,CAAC;E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AKL,EAAE,CAACM,mBAAmB;QACzB,OAAO,IAAI,CAACiD,kBAAkB,CAACH,KAAK,CAAC;MAEvC,KAAKpD,EAAE,CAACO,MAAM;QACZ,IAAI,CAACqC,MAAM,GAAG,IAAI;QAElB,OAAOU,SAAS;MAElB;QACE,OAAOA,SAAS;IACpB;EACF,CAAC;;EAED;AACF;AACA;AACA;AACA;EACUC,kBAAkB,GACxBH,KAAwB,IACiB;IACzC,MAAMI,KAAK,GAAGhE,SAAS,CAAC4D,KAAK,CAAC5C,kBAAkB,CAAC,IAAI,GAAG,CAAC;IAEzD,IAAI,CAACgD,KAAK,GAAG/C,sBAAsB,MAAM,CAAC,EAAE;MAC1C,OAAO6C,SAAS;IAClB;IAEA,OAAO,CAAC,IAAI,CAACJ,UAAU,CAAChC,YAAY,CAACrB,kBAAkB,EAAEC,eAAe,CAAC,CAAC,CAAC;EAC7E,CAAC;EAEOoD,UAAU,GAAInC,KAAwB,KAAqB;IACjE,GAAG,IAAI,CAAC+B,MAAM,CAACW,KAAK;IACpBL,KAAK,EAAErC,KAAK,CAAC2C,GAAG,CAAChD,KAAK,CAAC;IACvBiD,eAAe,EAAE;EACnB,CAAC,CAAC;AACJ;;AAEA;AACA,OAAO,MAAMC,6BAA6B,GAAG;EAC3C9C,aAAa;EACbI,YAAY;EACZI,iBAAiB;EACjBC,0BAA0B;EAC1BC;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ import { hexToByte } from "../../../utils/hex-to-byte.js";
4
+
5
+ /** BC401 stored-record frame is always sixteen bytes: header, timestamp, analytes, checksum. */
6
+ const BC01_RECORD_LENGTH = 16;
7
+
8
+ /** The two opcodes the firmware uses for a stored URS-7 record. */
9
+ const BC01_URS_OPCODE = 0xe1;
10
+ const BC01_PAGED_URS_OPCODE = 0xe2;
11
+
12
+ /**
13
+ * The bit `0x40` of the flags byte marks the last record of a paginated set.
14
+ * The sequencer keys off it to send the `[0x92, 0x7E, chk]` acknowledgement.
15
+ */
16
+ const BC01_LAST_OF_SET_BIT = 0x40;
17
+
18
+ /**
19
+ * A pad reading of `7` means the strip was not measured on that reagent.
20
+ * We drop those pads from the output rather than reporting them as level "7".
21
+ */
22
+ const UNMEASURED = 7;
23
+ const YEAR_BASE = 2000;
24
+ const MONTH_MASK = 0x0f;
25
+ const DAY_MASK = 0x1f;
26
+ const HOUR_MASK = 0x1f;
27
+ const MINUTE_MASK = 0x3f;
28
+ const SECOND_MASK = 0x3f;
29
+
30
+ /**
31
+ * URS-7 pad names, in the exact order they occupy the packed 3-bit slots
32
+ * across bytes 8..14 (see M1/a.java). The eleventh slot is a Contec-firmware
33
+ * field the vendor's own catalog calls "vc" and no other name is documented.
34
+ */
35
+ const BC01_ANALYTE_ORDER = ["uro", "bld", "bil", "ket", "glu", "pro", "ph", "nit", "leu", "sg", "vc"];
36
+
37
+ /** Where the packed analyte pairs start in a 16-byte E1/E2 frame. */
38
+ const ANALYTES_START = 8;
39
+
40
+ /** The result of decoding one 16-byte record. `lastOfSet` is what the sequencer keys on. */
41
+
42
+ /**
43
+ * Extracts one pad's level index from the packed byte. Two pads share a byte:
44
+ * the first uses the low 3 bits, the second uses bits 3..5. Bit 6 and 7 are
45
+ * unused reserved space per the vendor's own decoding in M1/a.java.
46
+ */
47
+ const readPad = (packed, slot) => slot === 0 ? packed & 0x07 : packed >> 3 & 0x07;
48
+
49
+ /**
50
+ * Decodes a 16-byte E1 or E2 frame into its timestamp and analyte indices.
51
+ *
52
+ * Returns `undefined` for any frame that is not the right length or does not
53
+ * open with an E1/E2 opcode — the caller is not asked to guess whether a
54
+ * frame is a record or a heartbeat, and a frame that fails these checks is
55
+ * skipped rather than parsed into a plausible-looking wrong reading.
56
+ *
57
+ * The checksum byte is not verified here: the SDK's read path already ensures
58
+ * frame integrity before the parser sees the bytes, and a URS-7 pad value can
59
+ * only land in [0, 7] anyway — a corrupt payload would fail the pad-value
60
+ * check before it made it into a measurement.
61
+ */
62
+ const parseBc01Record = frame => {
63
+ if (frame.length < BC01_RECORD_LENGTH) {
64
+ return undefined;
65
+ }
66
+ const opcode = hexToByte(frame[0] ?? "");
67
+ if (opcode !== BC01_URS_OPCODE && opcode !== BC01_PAGED_URS_OPCODE) {
68
+ return undefined;
69
+ }
70
+ const flags = hexToByte(frame[1] ?? "");
71
+ const yy = hexToByte(frame[2] ?? "") + YEAR_BASE;
72
+ const mm = hexToByte(frame[3] ?? "") & MONTH_MASK;
73
+ const dd = hexToByte(frame[4] ?? "") & DAY_MASK;
74
+ const hh = hexToByte(frame[5] ?? "") & HOUR_MASK;
75
+ const mi = hexToByte(frame[6] ?? "") & MINUTE_MASK;
76
+ const ss = hexToByte(frame[7] ?? "") & SECOND_MASK;
77
+ const timestamp = new Date(yy, mm - 1, dd, hh, mi, ss, 0);
78
+ const values = {};
79
+ BC01_ANALYTE_ORDER.forEach((analyte, position) => {
80
+ const byteIndex = ANALYTES_START + Math.floor(position / 2);
81
+ const slot = position % 2;
82
+ const packed = hexToByte(frame[byteIndex] ?? "");
83
+ const level = readPad(packed, slot);
84
+ if (level === UNMEASURED) {
85
+ return;
86
+ }
87
+ values[analyte] = level;
88
+ });
89
+ return {
90
+ timestamp,
91
+ lastOfSet: (flags & BC01_LAST_OF_SET_BIT) !== 0,
92
+ pageIndex: flags & 0x0f,
93
+ values
94
+ };
95
+ };
96
+
97
+ /**
98
+ * True when the buffer holds a complete BC401 stored record. Used by the
99
+ * driver's `validatePackage` hook so the SDK's read path only advances once
100
+ * the notification carries a whole 16-byte frame.
101
+ */
102
+ const isBc01Record = frame => {
103
+ if (frame.length < BC01_RECORD_LENGTH) {
104
+ return false;
105
+ }
106
+ const opcode = hexToByte(frame[0] ?? "");
107
+ return opcode === BC01_URS_OPCODE || opcode === BC01_PAGED_URS_OPCODE;
108
+ };
109
+ export { BC01_ANALYTE_ORDER, BC01_LAST_OF_SET_BIT, BC01_PAGED_URS_OPCODE, BC01_RECORD_LENGTH, BC01_URS_OPCODE, isBc01Record, parseBc01Record };
110
+ //# sourceMappingURL=bc01-frame-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hexToByte","BC01_RECORD_LENGTH","BC01_URS_OPCODE","BC01_PAGED_URS_OPCODE","BC01_LAST_OF_SET_BIT","UNMEASURED","YEAR_BASE","MONTH_MASK","DAY_MASK","HOUR_MASK","MINUTE_MASK","SECOND_MASK","BC01_ANALYTE_ORDER","ANALYTES_START","readPad","packed","slot","parseBc01Record","frame","length","undefined","opcode","flags","yy","mm","dd","hh","mi","ss","timestamp","Date","values","forEach","analyte","position","byteIndex","Math","floor","level","lastOfSet","pageIndex","isBc01Record"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/bc01/bc01-frame-parser.ts"],"mappings":";;AAEA,SAASA,SAAS,QAAQ,+BAA4B;;AAEtD;AACA,MAAMC,kBAAkB,GAAG,EAAE;;AAE7B;AACA,MAAMC,eAAe,GAAG,IAAI;AAC5B,MAAMC,qBAAqB,GAAG,IAAI;;AAElC;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAG,IAAI;;AAEjC;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAG,CAAC;AAEpB,MAAMC,SAAS,GAAG,IAAI;AACtB,MAAMC,UAAU,GAAG,IAAI;AACvB,MAAMC,QAAQ,GAAG,IAAI;AACrB,MAAMC,SAAS,GAAG,IAAI;AACtB,MAAMC,WAAW,GAAG,IAAI;AACxB,MAAMC,WAAW,GAAG,IAAI;;AAExB;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG,CACzB,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,CACyD;;AAE/D;AACA,MAAMC,cAAc,GAAG,CAAC;;AAExB;;AAoBA;AACA;AACA;AACA;AACA;AACA,MAAMC,OAAO,GAAGA,CAACC,MAAc,EAAEC,IAAW,KAC1CA,IAAI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AAE,EAAE,CAAC,CAAC;EAEzD,MAAMG,MAAkC,GAAG,CAAC,CAAC;EAE7CnB,kBAAkB,CAACoB,OAAO,CAAC,CAACC,OAAO,EAAEC,QAAQ,KAAK;IAChD,MAAMC,SAAS,GAAGtB,cAAc,GAAGuB,IAAI,CAACC,KAAK,CAACH,QAAQ,GAAG,CAAC,CAAC;IAC3D,MAAMlB,IAAI,GAAIkB,QAAQ,GAAG,CAAW;IACpC,MAAMnB,MAAM,GAAGf,SAAS,CAACkB,KAAK,CAACiB,SAAS,CAAC,IAAI,EAAE,CAAC;IAChD,MAAMG,KAAK,GAAGxB,OAAO,CAACC,MAAM,EAAEC,IAAI,CAAC;IAEnC,IAAIsB,KAAK,KAAKjC,UAAU,EAAE;MACxB;IACF;IAEA0B,MAAM,CAACE,OAAO,CAAC,GAAGK,KAAK;EACzB,CAAC,CAAC;EAEF,OAAO;IACLT,SAAS;IACTU,SAAS,EAAE,CAACjB,KAAK,GAAGlB,oBAAoB,MAAM,CAAC;IAC/CoC,SAAS,EAAElB,KAAK,GAAG,IAAI;IACvBS;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMU,YAAY,GAAIvB,KAAwB,IAAc;EAC1D,IAAIA,KAAK,CAACC,MAAM,GAAGlB,kBAAkB,EAAE;IACrC,OAAO,KAAK;EACd;EAEA,MAAMoB,MAAM,GAAGrB,SAAS,CAACkB,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;EAExC,OAAOG,MAAM,KAAKnB,eAAe,IAAImB,MAAM,KAAKlB,qBAAqB;AACvE,CAAC;AAED,SACES,kBAAkB,EAClBR,oBAAoB,EACpBD,qBAAqB,EACrBF,kBAAkB,EAClBC,eAAe,EAEfuC,YAAY,EACZxB,eAAe","ignoreList":[]}
@@ -1,16 +1,43 @@
1
1
  "use strict";
2
2
 
3
+ import { MeasurementTypeKey } from "@ovok/core";
3
4
  import { CaseType } from "../../../types/case-type.js";
5
+ import { hexToByte } from "../../../utils/hex-to-byte.js";
4
6
  import { BTManagedDevice } from "../bt-managed-device.js";
7
+ import { Bc01CommandSequencer } from "./bc01-command-sequencer.js";
8
+ import { BC01_ANALYTE_ORDER, parseBc01Record } from "./bc01-frame-parser.js";
5
9
  import { bc01MainServices } from "./bc01.main-services.js";
6
10
 
11
+ /** Minimum bytes a complete frame carries, keyed by its opening opcode. */
12
+ const BC01_FRAME_MIN_LENGTH = {
13
+ 0xf0: 2,
14
+ // ACK
15
+ 0xf2: 8,
16
+ // Version reply (variable — 8 is the minimum PHMS reads before answering)
17
+ 0xf3: 3,
18
+ // Time-sync ack
19
+ 0xe0: 7,
20
+ // Record-count reply
21
+ 0xe1: 16,
22
+ // Stored URS record
23
+ 0xe2: 16,
24
+ // Paginated URS record
25
+ 0xe3: 3,
26
+ // Finish
27
+ 0xe4: 36,
28
+ // Quantitative record (optional path)
29
+ 0xe5: 36 // Quantitative record (optional path)
30
+ };
31
+
7
32
  /**
8
33
  * Contec BC401 (BC01) urine analyzer driver.
9
34
  *
10
- * The BC401 is a single-shot device: the patient dips a URS-7 strip, presses
11
- * the button, and the device pushes exactly one result frame on 0xFF01. There
12
- * is no streaming state, no per-tick updates, and no measurement session to
13
- * open — the device auto-starts on button press.
35
+ * The BC401 is a memory device, not a live stream: every measurement the
36
+ * patient takes is written to onboard 500-slot flash the moment the strip
37
+ * finishes reacting, and the app pulls stored records over BLE only after the
38
+ * host walks the reset → version → set-time → count → get-records handshake
39
+ * documented in `bc01-command-sequencer.ts`. Every record arrives as one
40
+ * 16-byte E1/E2 frame on 0xFF02.
14
41
  */
15
42
  export class BC01Device extends BTManagedDevice {
16
43
  onStreamStart = () => {};
@@ -18,66 +45,101 @@ export class BC01Device extends BTManagedDevice {
18
45
 
19
46
  /**
20
47
  * 90 s covers the maximum firmware-side reagent-pad settle time on a URS-7
21
- * strip. If the device does not push a result frame within that window the
22
- * data-processor times out and the driver surfaces "device unreachable".
48
+ * strip and leaves headroom for a bulk memory dump of every stored record.
49
+ * If the device does not push a frame within that window the data processor
50
+ * times out and the driver surfaces "device unreachable".
23
51
  */
24
52
  stuckDataTimeout = 90_000;
53
+ constructor(device, params) {
54
+ super(device, params);
55
+
56
+ /**
57
+ * The BC401 answers one command with one frame and picks the next command
58
+ * by the first byte of that frame. The sequencer walks reset → version →
59
+ * set-time → count → records, and acknowledges the last record of every
60
+ * set. The parent's default `pollingSequencerFor` would only re-send the
61
+ * declared reset forever, which the firmware ignores after the first one.
62
+ */
63
+ this.createCommandSequencer = () => new Bc01CommandSequencer({
64
+ write: {
65
+ serviceUuid: bc01MainServices[0].uuid,
66
+ characteristicUuid: bc01MainServices[0].writeUuid.uuid
67
+ },
68
+ onRefused: reason => this.onError?.(new Error(`BC401 handshake: ${reason}`))
69
+ });
70
+ }
71
+
72
+ /**
73
+ * Returns true once the notification buffer holds a complete BC401 frame,
74
+ * classified by its opening opcode. Anything else — a heartbeat opcode we
75
+ * do not recognise, or a partial buffer — is held back until enough bytes
76
+ * arrive to make sense of it. There is no aa55 header on this hardware.
77
+ */
25
78
  validatePackage = pkg => {
26
- pkg = pkg.map(b => b.toLowerCase());
27
- let headIndex = -1;
28
- for (let i = 0; i < pkg.length - 1; i++) {
29
- if (pkg[i] === "aa" && pkg[i + 1] === "55") {
30
- headIndex = i;
31
- break;
32
- }
33
- }
34
- if (headIndex === -1) {
35
- return false;
36
- }
37
- if (headIndex > 0) {
38
- pkg = pkg.slice(headIndex);
39
- }
40
- if (pkg.length < 5) {
79
+ if (pkg.length === 0) {
41
80
  return false;
42
81
  }
43
- const lengthByte = parseInt(pkg[2] ?? "0", 16) || 0;
44
- const totalLen = 3 + lengthByte;
45
- if (pkg.length < totalLen) {
82
+ const opcode = hexToByte(pkg[0] ?? "");
83
+ const minLength = BC01_FRAME_MIN_LENGTH[opcode];
84
+ if (minLength === undefined) {
46
85
  return false;
47
86
  }
48
- return true;
87
+ return pkg.length >= minLength;
49
88
  };
50
- handleSuccessResult(successResult) {
51
- if (successResult.caseType !== CaseType.RESULT) {
52
- return;
53
- }
54
- if (!successResult.measurementTypeKey) {
55
- this.onError?.(new Error(`Measurement type is undefined for case ${successResult.caseType}`));
56
- return;
57
- }
58
- this.handleUrinalysisResult(successResult);
59
- }
60
- handleUrinalysisResult(successResult) {
61
- const error = this.checkIfHasError(successResult);
62
- if (error) {
63
- this.onError?.(error);
64
- return;
89
+
90
+ /**
91
+ * The parsing model declares every E1/E2 frame as `DEPENDENT`, so this hook
92
+ * runs for each record. We decode the raw bytes here — the packed 3-bits-per
93
+ * -pad layout is not expressible in the declaration parser — and report the
94
+ * reading directly through `onResult`. The frame is then handed back as
95
+ * `OTHER` so the state machine does not report it a second time and does
96
+ * not dedupe consecutive records that happen to share the same opcode.
97
+ */
98
+ handleDependentResult = data => {
99
+ if (data.frame) {
100
+ this.reportUrsRecord(data.frame);
65
101
  }
66
- this.onResult?.(successResult);
67
- }
102
+ return {
103
+ ...data,
104
+ parsingCase: {
105
+ ...data.parsingCase,
106
+ caseType: CaseType.OTHER
107
+ }
108
+ };
109
+ };
68
110
 
69
111
  /**
70
- * A well-formed frame with all analyte fields still undefined means the
71
- * device produced an empty read — typically a strip inserted upside down or
72
- * removed before the reagent-pad timer completed.
112
+ * Nothing to do here for the BC401. Every reading arrives through the
113
+ * dependent-result path, and the state machine sees only the `OTHER`-typed
114
+ * echo we return from `handleDependentResult`.
73
115
  */
74
- checkIfHasError(successResult) {
75
- const analytes = ["uro", "bld", "bil", "ket", "glu", "pro", "ph", "nit", "leu", "sg", "vc"];
76
- const hasAnyReading = analytes.some(key => successResult[key] !== undefined);
77
- if (!hasAnyReading) {
78
- return "feedback-messages.measurement.disturb-detected-error";
116
+ handleSuccessResult() {
117
+ return;
118
+ }
119
+ reportUrsRecord(frame) {
120
+ const parsed = parseBc01Record(frame);
121
+ if (!parsed) {
122
+ return;
123
+ }
124
+ const measuredValues = BC01_ANALYTE_ORDER.reduce((acc, analyte) => {
125
+ const value = parsed.values[analyte];
126
+ if (value !== undefined) {
127
+ acc[analyte] = value;
128
+ }
129
+ return acc;
130
+ }, {});
131
+ if (Object.keys(measuredValues).length === 0) {
132
+ this.onError?.("feedback-messages.measurement.disturb-detected-error");
133
+ return;
79
134
  }
80
- return undefined;
135
+ const reading = {
136
+ caseType: CaseType.RESULT,
137
+ measurementTypeKey: MeasurementTypeKey.uricAcid,
138
+ urineValues: [],
139
+ recordedAt: parsed.timestamp,
140
+ ...measuredValues
141
+ };
142
+ this.onResult?.(reading);
81
143
  }
82
144
  }
83
145
  //# sourceMappingURL=bc01.device.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CaseType","BTManagedDevice","bc01MainServices","BC01Device","onStreamStart","mainServices","stuckDataTimeout","validatePackage","pkg","map","b","toLowerCase","headIndex","i","length","slice","lengthByte","parseInt","totalLen","handleSuccessResult","successResult","caseType","RESULT","measurementTypeKey","onError","Error","handleUrinalysisResult","error","checkIfHasError","onResult","analytes","hasAnyReading","some","key","undefined"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/bc01/bc01.device.ts"],"mappings":";;AAEA,SAASA,QAAQ,QAAQ,6BAA0B;AAKnD,SAASC,eAAe,QAAQ,yBAAsB;AAEtD,SAASC,gBAAgB,QAAQ,yBAAsB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,SAASF,eAAe,CAAyB;EAC5DG,aAAa,GAAeA,CAAA,KAAM,CAAC,CAAC;EAEpCC,YAAY,GAAeH,gBAAgB;;EAErD;AACF;AACA;AACA;AACA;EACYI,gBAAgB,GAAG,MAAM;EAEzBC,eAAe,GAAgCC,GAAG,IAAK;IAC/DA,GAAG,GAAGA,GAAG,CAACC,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACC,WAAW,CAAC,CAAC,CAAC;IAErC,IAAIC,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,GAAG,CAACM,MAAM,GA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ACF;AACA;AACA;AACA;EACUQ,eAAeA,CACrBR,aAA+D,EAC3C;IACpB,MAAMU,QAA8C,GAAG,CACrD,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,CACL;IAED,MAAMC,aAAa,GAAGD,QAAQ,CAACE,IAAI,CAChCC,GAAG,IAAKb,aAAa,CAACa,GAAG,CAAC,KAAKC,SAClC,CAAC;IAED,IAAI,CAACH,aAAa,EAAE;MAClB,OAAO,sDAAsD;IAC/D;IAEA,OAAOG,SAAS;EAClB;AACF","ignoreList":[]}
1
+ {"version":3,"names":["MeasurementTypeKey","CaseType","hexToByte","BTManagedDevice","Bc01CommandSequencer","BC01_ANALYTE_ORDER","parseBc01Record","bc01MainServices","BC01_FRAME_MIN_LENGTH","BC01Device","onStreamStart","mainServices","stuckDataTimeout","constructor","device","params","createCommandSequencer","write","serviceUuid","uuid","characteristicUuid","writeUuid","onRefused","reason","onError","Error","validatePackage","pkg","length","opcode","minLength","undefined","handleDependentResult","data","frame","reportUrsRecord","parsingCase","caseType","OTHER","handleSuccessResult","parsed","measuredValues","reduce","acc","analyte","value","values","Object","keys","reading","RESULT","measurementTypeKey","uricAcid","urineValues","recordedAt","timestamp","onResult"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/bc01/bc01.device.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAiC,YAAY;AAGxE,SAASC,QAAQ,QAAQ,6BAA0B;AAQnD,SAASC,SAAS,QAAQ,+BAA4B;AACtD,SAASC,eAAe,QAAQ,yBAAsB;AAEtD,SAASC,oBAAoB,QAAQ,6BAA0B;AAC/D,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,wBAAqB;AACzE,SAASC,gBAAgB,QAAQ,yBAAsB;;AAEvD;AACA,MAAMC,qBAA6C,GAAG;EACpD,IAAI,EAAE,CAAC;EAAE;EACT,IAAI,EAA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