@ovok/native 0.4.8 → 0.4.9
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.
- package/lib/commonjs/modules/bt-management/services/bt-manager.js +15 -13
- package/lib/commonjs/modules/bt-management/services/bt-manager.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/device-creator.js +7 -1
- package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js +184 -0
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-frame-parser.js +114 -0
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01-frame-parser.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.device.js +113 -51
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.main-services.js +41 -77
- package/lib/commonjs/modules/bt-management/services/devices/bc01/bc01.main-services.js.map +1 -1
- package/lib/module/modules/bt-management/services/bt-manager.js +15 -13
- package/lib/module/modules/bt-management/services/bt-manager.js.map +1 -1
- package/lib/module/modules/bt-management/services/device-creator.js +7 -1
- package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js +180 -0
- package/lib/module/modules/bt-management/services/devices/bc01/bc01-command-sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/bc01/bc01-frame-parser.js +110 -0
- package/lib/module/modules/bt-management/services/devices/bc01/bc01-frame-parser.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/bc01/bc01.device.js +113 -51
- package/lib/module/modules/bt-management/services/devices/bc01/bc01.device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bc01/bc01.main-services.js +41 -77
- package/lib/module/modules/bt-management/services/devices/bc01/bc01.main-services.js.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/bt-manager.d.ts +0 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/bt-manager.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts +53 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts +53 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts +33 -13
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts +11 -17
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/bt-manager.d.ts +0 -1
- package/lib/typescript/module/src/modules/bt-management/services/bt-manager.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts +53 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts +53 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts +33 -13
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts +11 -17
- package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01.main-services.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -5,93 +5,57 @@ import { CaseType } from "../../../types/case-type.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Contec BC401 (a.k.a. BC01) urine analyzer — GATT profile.
|
|
7
7
|
*
|
|
8
|
-
* The BC401 uses Contec's proprietary FF12 service, shared across their
|
|
9
|
-
* medical devices.
|
|
10
|
-
*
|
|
8
|
+
* The BC401 uses Contec's proprietary FF12 service, shared across their
|
|
9
|
+
* consumer medical devices. Every stored URS-7 measurement is pushed as a
|
|
10
|
+
* 16-byte record on 0xFF02 after the host has walked the handshake documented
|
|
11
|
+
* in `bc01-command-sequencer.ts`.
|
|
11
12
|
*
|
|
12
13
|
* Service 0xFF12
|
|
13
|
-
* Notify (result)
|
|
14
|
-
* Write (command)
|
|
14
|
+
* Notify (result) 0xFF02 — CCCD 0x2902 must be written 01 00 to enable
|
|
15
|
+
* Write (command) 0xFF01 — RESET / SET_TIME / GET_COUNT / GET_RECORDS
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* [5..15] values one byte per analyte, encoding the discrete
|
|
22
|
-
* level index into diagnosticResults[key]
|
|
23
|
-
* [16] checksum xor over [2..15]
|
|
24
|
-
*
|
|
25
|
-
* Byte positions calibrated against PHMS 3.0.03 Android app; older firmware
|
|
26
|
-
* (< 1.2.x) uses a different command byte and is not supported by this driver
|
|
27
|
-
* (the validator will reject those frames).
|
|
17
|
+
* On the wire a stored URS record opens with 0xE1 (single) or 0xE2 (paginated).
|
|
18
|
+
* The remaining fifteen bytes carry the flags nibble, timestamp, seven bytes of
|
|
19
|
+
* packed 3-bit analyte indices, and a checksum. `bc01-frame-parser.ts` decodes
|
|
20
|
+
* them; this file just declares the GATT surface and hands every E1/E2 frame
|
|
21
|
+
* to the driver's dependent-result path so the parser can run.
|
|
28
22
|
*/
|
|
29
23
|
export const bc01MainServices = [{
|
|
30
24
|
uuid: "0000ff12-0000-1000-8000-00805f9b34fb",
|
|
31
|
-
|
|
25
|
+
/**
|
|
26
|
+
* PHMS 3.0.03 writes `[0x80, 0x00]` to 0xFF01 the moment its GATT
|
|
27
|
+
* subscription is up — decompiled at L1/f.java:694 ("发送复位命令" — "send
|
|
28
|
+
* reset command"). The device answers nothing until this reset lands. The
|
|
29
|
+
* `Bc01CommandSequencer` returns the same reset from `initialCommands()`
|
|
30
|
+
* so the SDK sends it whether or not the polling default is in play.
|
|
31
|
+
*/
|
|
32
|
+
writeUuid: {
|
|
32
33
|
uuid: "0000ff01-0000-1000-8000-00805f9b34fb",
|
|
34
|
+
mainCommandUuid: "8000"
|
|
35
|
+
},
|
|
36
|
+
monitorUuids: [{
|
|
37
|
+
uuid: "0000ff02-0000-1000-8000-00805f9b34fb",
|
|
38
|
+
/**
|
|
39
|
+
* We key on the first byte only. A `DEPENDENT` case fires
|
|
40
|
+
* `handleDependentResult` in the driver, which runs the real decoder
|
|
41
|
+
* (`parseBc01Record`) against the raw frame bytes and calls
|
|
42
|
+
* `onResult` directly. The parsing case itself carries no field
|
|
43
|
+
* definitions — the packed 3-bits-per-pad layout is not expressible
|
|
44
|
+
* with the ordinary declaration parser and would need the vendor's
|
|
45
|
+
* own decoding table pinned in a declaration to be so.
|
|
46
|
+
*/
|
|
33
47
|
parsingModel: {
|
|
34
|
-
caseValuePosition: [0
|
|
48
|
+
caseValuePosition: [0],
|
|
35
49
|
cases: [{
|
|
36
50
|
measurementTypeKey: MeasurementTypeKey.uricAcid,
|
|
37
|
-
caseType: CaseType.
|
|
38
|
-
caseValue: "
|
|
39
|
-
parseDefinitions: [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
name: "bld",
|
|
46
|
-
parseType: "number",
|
|
47
|
-
byteIndexes: [6],
|
|
48
|
-
parseReference: 16
|
|
49
|
-
}, {
|
|
50
|
-
name: "bil",
|
|
51
|
-
parseType: "number",
|
|
52
|
-
byteIndexes: [7],
|
|
53
|
-
parseReference: 16
|
|
54
|
-
}, {
|
|
55
|
-
name: "ket",
|
|
56
|
-
parseType: "number",
|
|
57
|
-
byteIndexes: [8],
|
|
58
|
-
parseReference: 16
|
|
59
|
-
}, {
|
|
60
|
-
name: "glu",
|
|
61
|
-
parseType: "number",
|
|
62
|
-
byteIndexes: [9],
|
|
63
|
-
parseReference: 16
|
|
64
|
-
}, {
|
|
65
|
-
name: "pro",
|
|
66
|
-
parseType: "number",
|
|
67
|
-
byteIndexes: [10],
|
|
68
|
-
parseReference: 16
|
|
69
|
-
}, {
|
|
70
|
-
name: "ph",
|
|
71
|
-
parseType: "number",
|
|
72
|
-
byteIndexes: [11],
|
|
73
|
-
parseReference: 16
|
|
74
|
-
}, {
|
|
75
|
-
name: "nit",
|
|
76
|
-
parseType: "number",
|
|
77
|
-
byteIndexes: [12],
|
|
78
|
-
parseReference: 16
|
|
79
|
-
}, {
|
|
80
|
-
name: "leu",
|
|
81
|
-
parseType: "number",
|
|
82
|
-
byteIndexes: [13],
|
|
83
|
-
parseReference: 16
|
|
84
|
-
}, {
|
|
85
|
-
name: "sg",
|
|
86
|
-
parseType: "number",
|
|
87
|
-
byteIndexes: [14],
|
|
88
|
-
parseReference: 16
|
|
89
|
-
}, {
|
|
90
|
-
name: "vc",
|
|
91
|
-
parseType: "number",
|
|
92
|
-
byteIndexes: [15],
|
|
93
|
-
parseReference: 16
|
|
94
|
-
}]
|
|
51
|
+
caseType: CaseType.DEPENDENT,
|
|
52
|
+
caseValue: "e1",
|
|
53
|
+
parseDefinitions: []
|
|
54
|
+
}, {
|
|
55
|
+
measurementTypeKey: MeasurementTypeKey.uricAcid,
|
|
56
|
+
caseType: CaseType.DEPENDENT,
|
|
57
|
+
caseValue: "e2",
|
|
58
|
+
parseDefinitions: []
|
|
95
59
|
}]
|
|
96
60
|
}
|
|
97
61
|
}]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MeasurementTypeKey","CaseType","bc01MainServices","uuid","monitorUuids","parsingModel","caseValuePosition","cases","measurementTypeKey","uricAcid","caseType","
|
|
1
|
+
{"version":3,"names":["MeasurementTypeKey","CaseType","bc01MainServices","uuid","writeUuid","mainCommandUuid","monitorUuids","parsingModel","caseValuePosition","cases","measurementTypeKey","uricAcid","caseType","DEPENDENT","caseValue","parseDefinitions"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/bc01/bc01.main-services.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,YAAY;AAE/C,SAASC,QAAQ,QAAQ,6BAA0B;AAGnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAA4B,GAAG,CAC1C;EACEC,IAAI,EAAE,sCAAsC;EAE5C;AACJ;AACA;AACA;AACA;AACA;AACA;EACIC,SAAS,EAAE;IACTD,IAAI,EAAE,sCAAsC;IAC5CE,eAAe,EAAE;EACnB,CAAC;EACDC,YAAY,EAAE,CACZ;IACEH,IAAI,EAAE,sCAAsC;IAE5C;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACQI,YAAY,EAAE;MACZC,iBAAiB,EAAE,CAAC,CAAC,CAAC;MACtBC,KAAK,EAAE,CACL;QACEC,kBAAkB,EAAEV,kBAAkB,CAACW,QAAQ;QAC/CC,QAAQ,EAAEX,QAAQ,CAACY,SAAS;QAC5BC,SAAS,EAAE,IAAI;QACfC,gBAAgB,EAAE;MACpB,CAAC,EACD;QACEL,kBAAkB,EAAEV,kBAAkB,CAACW,QAAQ;QAC/CC,QAAQ,EAAEX,QAAQ,CAACY,SAAS;QAC5BC,SAAS,EAAE,IAAI;QACfC,gBAAgB,EAAE;MACpB,CAAC;IAEL;EACF,CAAC;AAEL,CAAC,CACF","ignoreList":[]}
|
|
@@ -13,7 +13,6 @@ export declare class BTManager<T extends readonly AcceptedDevice[]> {
|
|
|
13
13
|
private stateChangeListener;
|
|
14
14
|
private eventSubscriptions;
|
|
15
15
|
private deviceCreator;
|
|
16
|
-
private lastScanTimestamp;
|
|
17
16
|
constructor(bleManager: BleManager, acceptedDevices: T);
|
|
18
17
|
destroy: () => void;
|
|
19
18
|
startScan: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bt-manager.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/services/bt-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EAKX,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,qBAAa,SAAS,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE;
|
|
1
|
+
{"version":3,"file":"bt-manager.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/services/bt-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EAKX,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,qBAAa,SAAS,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE;IAUtD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAVlC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAM;IACzC,OAAO,CAAC,OAAO,CAAsD;IAErE,OAAO,CAAC,mBAAmB,CAA2B;IACtD,OAAO,CAAC,kBAAkB,CAAsB;IAEhD,OAAO,CAAC,aAAa,CAAmB;gBAGrB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,CAAC;IAK9B,OAAO,aAuBZ;IAEK,SAAS,aAuDd;IAEK,QAAQ,aAmBb;IAEK,aAAa,GAClB,WAAW,CACT,MAAM,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EACvC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,KAClB,OAAO,CAAC,IAAI,CAAC,UAIlB;IAEK,OAAO,GAAI,WAAW,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,UAGxD;IAEK,qBAAqB,GAC1B,WAAW,CAAC,IAAI,EAAE,0BAA0B,KAAK,IAAI,UAIrD;IAEK,QAAQ,GACb,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,UAIzD;IAGF,OAAO,CAAC,gBAAgB,CAAC,CAAiD;IAC1E,OAAO,CAAC,eAAe,CAAC,CAAgC;IACxD,OAAO,CAAC,qBAAqB,CAAC,CAGX;IACnB,OAAO,CAAC,6BAA6B,CAAC,CAE5B;IAEV,OAAO,CAAC,YAAY,CA+ElB;IAEF,OAAO,CAAC,8BAA8B,CAUpC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-creator.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/services/device-creator.ts"],"names":[],"mappings":"AACA,OAA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AAO,CAAC,QAAQ,CAAC,aAAa,CAAsC;gBAEvC,mBAAmB,EAAE,CAAC;IAI5C,aAAa,GAAI,WAAW,MAAM,KAAG,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAkBpE;IAEK,YAAY,CAAC,CAAC,SAAS,SAAS,EACrC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC5B,eAAe,CAAC,CAAC,CAAC;IAwCd,OAAO,aAEZ;IAEF;;;OAGG;IACH,OAAO,CAAC,eAAe,CAmBrB;IAEF,OAAO,CAAC,eAAe;CAexB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CommandSequencer } from "../../../types/command-sequencer";
|
|
2
|
+
import { DeviceCommand } from "../../../types/device-command";
|
|
3
|
+
interface Bc01SequencerParams {
|
|
4
|
+
/** The write channel every command goes out on. FF01 for a real BC401. */
|
|
5
|
+
write: Omit<DeviceCommand, "frame">;
|
|
6
|
+
/**
|
|
7
|
+
* Called with why the exchange stopped. Optional; a refusal here does not
|
|
8
|
+
* end the connection because the device continues to accept fresh commands
|
|
9
|
+
* even after a bad handshake step. The parent driver decides what to do.
|
|
10
|
+
*/
|
|
11
|
+
onRefused?: (reason: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Walks the BC401 through its post-reset handshake and pulls every stored
|
|
15
|
+
* record.
|
|
16
|
+
*
|
|
17
|
+
* The device is self-clocking: it answers each command with a single frame,
|
|
18
|
+
* and the first byte of that frame names what it is. So the sequencer keeps
|
|
19
|
+
* no counter of its own — it looks at the reply, decides what belongs next,
|
|
20
|
+
* and returns that. A frame whose opcode is not part of the handshake is left
|
|
21
|
+
* unanswered so the driver's stuck-data watchdog surfaces the stall rather
|
|
22
|
+
* than the sequencer sending a command the device did not ask for.
|
|
23
|
+
*
|
|
24
|
+
* `initialCommands()` returns only the reset. The rest of the handshake -
|
|
25
|
+
* VERSION, SET_TIME, GET_COUNT, GET_RECORDS - is driven entirely by the
|
|
26
|
+
* device's own replies, because sending them any earlier would race the
|
|
27
|
+
* firmware boot the reset triggers.
|
|
28
|
+
*/
|
|
29
|
+
export declare class Bc01CommandSequencer implements CommandSequencer {
|
|
30
|
+
private readonly params;
|
|
31
|
+
private isDone;
|
|
32
|
+
/** Injectable for tests; production reads `Date.now()`. */
|
|
33
|
+
private readonly clock;
|
|
34
|
+
constructor(params: Bc01SequencerParams, clock?: () => Date);
|
|
35
|
+
initialCommands: () => readonly DeviceCommand[];
|
|
36
|
+
nextCommand: (frame: readonly string[]) => readonly DeviceCommand[] | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The device pages every record it holds, one 16-byte frame at a time. Only
|
|
39
|
+
* the frame whose flags byte carries `0x40` needs an acknowledgement; every
|
|
40
|
+
* other page is a status update we let ride while the transfer continues.
|
|
41
|
+
*/
|
|
42
|
+
private answerStoredRecord;
|
|
43
|
+
private commandFor;
|
|
44
|
+
}
|
|
45
|
+
export declare const bc01CommandSequencerInternals: {
|
|
46
|
+
bc401Checksum: (bytes: readonly number[]) => number;
|
|
47
|
+
buildCommand: (opcode: number, arg: number) => number[];
|
|
48
|
+
buildResetCommand: () => number[];
|
|
49
|
+
buildRequestVersionCommand: () => number[];
|
|
50
|
+
buildSetTimeCommand: (now: Date) => number[];
|
|
51
|
+
};
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=bc01-command-sequencer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bc01-command-sequencer.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAuC9D,UAAU,mBAAmB;IAE3B,0EAA0E;IAC1E,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAEpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAqED;;;;;;;;;;;;;;;GAeG;AAEH,qBAAa,oBAAqB,YAAW,gBAAgB;IAOzD,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,MAAM,CAAS;IAEvB,2DAA2D;IAC3D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;gBAGhB,MAAM,EAAE,mBAAmB,EAC5C,KAAK,GAAE,MAAM,IAAuB;IAK/B,eAAe,QAAO,SAAS,aAAa,EAAE,CAEnD;IAEK,WAAW,GAChB,OAAO,SAAS,MAAM,EAAE,KACvB,SAAS,aAAa,EAAE,GAAG,SAAS,CAoCrC;IAEF;;;;OAIG;IACH,OAAO,CAAC,kBAAkB,CAUxB;IAEF,OAAO,CAAC,UAAU,CAIf;CACJ;AAGD,eAAO,MAAM,6BAA6B;2BA3JZ,SAAS,MAAM,EAAE,KAAG,MAAM;2BAQ1B,MAAM,OAAO,MAAM,KAAG,MAAM,EAAE;6BAW9B,MAAM,EAAE;sCAQC,MAAM,EAAE;+BAYb,IAAI,KAAG,MAAM,EAAE;CA0HhD,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** BC401 stored-record frame is always sixteen bytes: header, timestamp, analytes, checksum. */
|
|
2
|
+
declare const BC01_RECORD_LENGTH = 16;
|
|
3
|
+
/** The two opcodes the firmware uses for a stored URS-7 record. */
|
|
4
|
+
declare const BC01_URS_OPCODE = 225;
|
|
5
|
+
declare const BC01_PAGED_URS_OPCODE = 226;
|
|
6
|
+
/**
|
|
7
|
+
* The bit `0x40` of the flags byte marks the last record of a paginated set.
|
|
8
|
+
* The sequencer keys off it to send the `[0x92, 0x7E, chk]` acknowledgement.
|
|
9
|
+
*/
|
|
10
|
+
declare const BC01_LAST_OF_SET_BIT = 64;
|
|
11
|
+
/**
|
|
12
|
+
* URS-7 pad names, in the exact order they occupy the packed 3-bit slots
|
|
13
|
+
* across bytes 8..14 (see M1/a.java). The eleventh slot is a Contec-firmware
|
|
14
|
+
* field the vendor's own catalog calls "vc" and no other name is documented.
|
|
15
|
+
*/
|
|
16
|
+
declare const BC01_ANALYTE_ORDER: readonly ["uro", "bld", "bil", "ket", "glu", "pro", "ph", "nit", "leu", "sg", "vc"];
|
|
17
|
+
/** The result of decoding one 16-byte record. `lastOfSet` is what the sequencer keys on. */
|
|
18
|
+
interface Bc01ParsedRecord {
|
|
19
|
+
/** Local wall-clock time the device recorded, with millisecond precision unavailable. */
|
|
20
|
+
timestamp: Date;
|
|
21
|
+
/** True when the flags byte set bit 0x40 — this is the frame that must be acknowledged. */
|
|
22
|
+
lastOfSet: boolean;
|
|
23
|
+
/** Low nibble of the flags byte; the page counter the firmware writes. */
|
|
24
|
+
pageIndex: number;
|
|
25
|
+
/**
|
|
26
|
+
* Analyte level indices, absent for any pad the strip did not measure.
|
|
27
|
+
* A pad the strip did measure carries a value in [0, 6]; the vendor's own
|
|
28
|
+
* lookup tables translate that to a categorical result per analyte.
|
|
29
|
+
*/
|
|
30
|
+
values: Partial<Record<(typeof BC01_ANALYTE_ORDER)[number], number>>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Decodes a 16-byte E1 or E2 frame into its timestamp and analyte indices.
|
|
34
|
+
*
|
|
35
|
+
* Returns `undefined` for any frame that is not the right length or does not
|
|
36
|
+
* open with an E1/E2 opcode — the caller is not asked to guess whether a
|
|
37
|
+
* frame is a record or a heartbeat, and a frame that fails these checks is
|
|
38
|
+
* skipped rather than parsed into a plausible-looking wrong reading.
|
|
39
|
+
*
|
|
40
|
+
* The checksum byte is not verified here: the SDK's read path already ensures
|
|
41
|
+
* frame integrity before the parser sees the bytes, and a URS-7 pad value can
|
|
42
|
+
* only land in [0, 7] anyway — a corrupt payload would fail the pad-value
|
|
43
|
+
* check before it made it into a measurement.
|
|
44
|
+
*/
|
|
45
|
+
declare const parseBc01Record: (frame: readonly string[]) => Bc01ParsedRecord | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* True when the buffer holds a complete BC401 stored record. Used by the
|
|
48
|
+
* driver's `validatePackage` hook so the SDK's read path only advances once
|
|
49
|
+
* the notification carries a whole 16-byte frame.
|
|
50
|
+
*/
|
|
51
|
+
declare const isBc01Record: (frame: readonly string[]) => boolean;
|
|
52
|
+
export { BC01_ANALYTE_ORDER, BC01_LAST_OF_SET_BIT, BC01_PAGED_URS_OPCODE, BC01_RECORD_LENGTH, BC01_URS_OPCODE, Bc01ParsedRecord, isBc01Record, parseBc01Record, };
|
|
53
|
+
//# sourceMappingURL=bc01-frame-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bc01-frame-parser.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01-frame-parser.ts"],"names":[],"mappings":"AAIA,gGAAgG;AAChG,QAAA,MAAM,kBAAkB,KAAK,CAAC;AAE9B,mEAAmE;AACnE,QAAA,MAAM,eAAe,MAAO,CAAC;AAC7B,QAAA,MAAM,qBAAqB,MAAO,CAAC;AAEnC;;;GAGG;AACH,QAAA,MAAM,oBAAoB,KAAO,CAAC;AAelC;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,qFAYuC,CAAC;AAKhE,4FAA4F;AAC5F,UAAU,gBAAgB;IAExB,yFAAyF;IACzF,SAAS,EAAE,IAAI,CAAC;IAEhB,2FAA2F;IAC3F,SAAS,EAAE,OAAO,CAAC;IAEnB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;CACtE;AAUD;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,eAAe,GACnB,OAAO,SAAS,MAAM,EAAE,KACvB,gBAAgB,GAAG,SA0CrB,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,YAAY,GAAI,OAAO,SAAS,MAAM,EAAE,KAAG,OAQhD,CAAC;AAEF,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,GAChB,CAAC"}
|
package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts
CHANGED
|
@@ -1,33 +1,53 @@
|
|
|
1
|
+
import { Device } from "react-native-ble-plx";
|
|
2
|
+
import { CreateDeviceParams } from "../../../types/create-device-params";
|
|
3
|
+
import { DependentResultHandlerParams } from "../../../types/dependent-result-handler-params";
|
|
1
4
|
import { MeasurementTypeForDevices } from "../../../types/device-measurement-map";
|
|
2
5
|
import { IntegratedDevices } from "../../../types/integrated-devices";
|
|
3
|
-
import { MeasurementWithCaseType } from "../../../types/measurement-with-case-type";
|
|
4
6
|
import { IService } from "../../../types/service.type";
|
|
5
7
|
import { BTManagedDevice } from "../bt-managed-device";
|
|
6
8
|
/**
|
|
7
9
|
* Contec BC401 (BC01) urine analyzer driver.
|
|
8
10
|
*
|
|
9
|
-
* The BC401 is a
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* The BC401 is a memory device, not a live stream: every measurement the
|
|
12
|
+
* patient takes is written to onboard 500-slot flash the moment the strip
|
|
13
|
+
* finishes reacting, and the app pulls stored records over BLE only after the
|
|
14
|
+
* host walks the reset → version → set-time → count → get-records handshake
|
|
15
|
+
* documented in `bc01-command-sequencer.ts`. Every record arrives as one
|
|
16
|
+
* 16-byte E1/E2 frame on 0xFF02.
|
|
13
17
|
*/
|
|
14
18
|
export declare class BC01Device extends BTManagedDevice<IntegratedDevices.BC01> {
|
|
15
19
|
protected onStreamStart: () => void;
|
|
16
20
|
protected mainServices: IService[];
|
|
17
21
|
/**
|
|
18
22
|
* 90 s covers the maximum firmware-side reagent-pad settle time on a URS-7
|
|
19
|
-
* strip
|
|
20
|
-
*
|
|
23
|
+
* strip and leaves headroom for a bulk memory dump of every stored record.
|
|
24
|
+
* If the device does not push a frame within that window the data processor
|
|
25
|
+
* times out and the driver surfaces "device unreachable".
|
|
21
26
|
*/
|
|
22
27
|
protected stuckDataTimeout: number;
|
|
28
|
+
constructor(device: Device, params: CreateDeviceParams<IntegratedDevices.BC01>);
|
|
29
|
+
/**
|
|
30
|
+
* Returns true once the notification buffer holds a complete BC401 frame,
|
|
31
|
+
* classified by its opening opcode. Anything else — a heartbeat opcode we
|
|
32
|
+
* do not recognise, or a partial buffer — is held back until enough bytes
|
|
33
|
+
* arrive to make sense of it. There is no aa55 header on this hardware.
|
|
34
|
+
*/
|
|
23
35
|
protected validatePackage: (pkg: string[]) => boolean;
|
|
24
|
-
protected handleSuccessResult(successResult: MeasurementWithCaseType<MeasurementTypeForDevices<[IntegratedDevices.BC01]>>): void | boolean;
|
|
25
|
-
private handleUrinalysisResult;
|
|
26
36
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
37
|
+
* The parsing model declares every E1/E2 frame as `DEPENDENT`, so this hook
|
|
38
|
+
* runs for each record. We decode the raw bytes here — the packed 3-bits-per
|
|
39
|
+
* -pad layout is not expressible in the declaration parser — and report the
|
|
40
|
+
* reading directly through `onResult`. The frame is then handed back as
|
|
41
|
+
* `OTHER` so the state machine does not report it a second time and does
|
|
42
|
+
* not dedupe consecutive records that happen to share the same opcode.
|
|
43
|
+
*/
|
|
44
|
+
protected handleDependentResult: (data: DependentResultHandlerParams<MeasurementTypeForDevices<[IntegratedDevices.BC01]>>) => DependentResultHandlerParams<MeasurementTypeForDevices<[IntegratedDevices.BC01]>>;
|
|
45
|
+
/**
|
|
46
|
+
* Nothing to do here for the BC401. Every reading arrives through the
|
|
47
|
+
* dependent-result path, and the state machine sees only the `OTHER`-typed
|
|
48
|
+
* echo we return from `handleDependentResult`.
|
|
30
49
|
*/
|
|
31
|
-
|
|
50
|
+
protected handleSuccessResult(): void | boolean;
|
|
51
|
+
private reportUrsRecord;
|
|
32
52
|
}
|
|
33
53
|
//# sourceMappingURL=bc01.device.d.ts.map
|
package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bc01/bc01.device.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bc01.device.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01.device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bc01.device.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01.device.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAmBvD;;;;;;;;;GASG;AACH,qBAAa,UAAW,SAAQ,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC;IACrE,SAAS,CAAC,aAAa,EAAE,MAAM,IAAI,CAAY;IAE/C,SAAS,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAoB;IAEtD;;;;;OAKG;IACH,SAAS,CAAC,gBAAgB,SAAU;gBAExB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC;IAqB9E;;;;;OAKG;IACH,SAAS,CAAC,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,OAAO,CAanD;IAEF;;;;;;;OAOG;IACH,SAAS,CAAC,qBAAqB,GAC7B,MAAM,4BAA4B,CAChC,yBAAyB,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CACpD,KACA,4BAA4B,CAC7B,yBAAyB,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CACpD,CASC;IAEF;;;;OAIG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI,GAAG,OAAO;IAI/C,OAAO,CAAC,eAAe;CAqCxB"}
|
|
@@ -2,26 +2,20 @@ import { IService } from "../../../types/service.type";
|
|
|
2
2
|
/**
|
|
3
3
|
* Contec BC401 (a.k.a. BC01) urine analyzer — GATT profile.
|
|
4
4
|
*
|
|
5
|
-
* The BC401 uses Contec's proprietary FF12 service, shared across their
|
|
6
|
-
* medical devices.
|
|
7
|
-
*
|
|
5
|
+
* The BC401 uses Contec's proprietary FF12 service, shared across their
|
|
6
|
+
* consumer medical devices. Every stored URS-7 measurement is pushed as a
|
|
7
|
+
* 16-byte record on 0xFF02 after the host has walked the handshake documented
|
|
8
|
+
* in `bc01-command-sequencer.ts`.
|
|
8
9
|
*
|
|
9
10
|
* Service 0xFF12
|
|
10
|
-
* Notify (result)
|
|
11
|
-
* Write (command)
|
|
11
|
+
* Notify (result) 0xFF02 — CCCD 0x2902 must be written 01 00 to enable
|
|
12
|
+
* Write (command) 0xFF01 — RESET / SET_TIME / GET_COUNT / GET_RECORDS
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* [5..15] values one byte per analyte, encoding the discrete
|
|
19
|
-
* level index into diagnosticResults[key]
|
|
20
|
-
* [16] checksum xor over [2..15]
|
|
21
|
-
*
|
|
22
|
-
* Byte positions calibrated against PHMS 3.0.03 Android app; older firmware
|
|
23
|
-
* (< 1.2.x) uses a different command byte and is not supported by this driver
|
|
24
|
-
* (the validator will reject those frames).
|
|
14
|
+
* On the wire a stored URS record opens with 0xE1 (single) or 0xE2 (paginated).
|
|
15
|
+
* The remaining fifteen bytes carry the flags nibble, timestamp, seven bytes of
|
|
16
|
+
* packed 3-bit analyte indices, and a checksum. `bc01-frame-parser.ts` decodes
|
|
17
|
+
* them; this file just declares the GATT surface and hands every E1/E2 frame
|
|
18
|
+
* to the driver's dependent-result path so the parser can run.
|
|
25
19
|
*/
|
|
26
20
|
export declare const bc01MainServices: IService[];
|
|
27
21
|
//# sourceMappingURL=bc01.main-services.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bc01.main-services.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01.main-services.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"bc01.main-services.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01.main-services.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,EAgDtC,CAAC"}
|
|
@@ -13,7 +13,6 @@ export declare class BTManager<T extends readonly AcceptedDevice[]> {
|
|
|
13
13
|
private stateChangeListener;
|
|
14
14
|
private eventSubscriptions;
|
|
15
15
|
private deviceCreator;
|
|
16
|
-
private lastScanTimestamp;
|
|
17
16
|
constructor(bleManager: BleManager, acceptedDevices: T);
|
|
18
17
|
destroy: () => void;
|
|
19
18
|
startScan: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bt-manager.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/services/bt-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EAKX,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,W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,GAAI,WAAW,MAAM,KAAG,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAkBpE;IAEK,YAAY,CAAC,CAAC,SAAS,SAAS,EACrC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC5B,eAAe,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"device-creator.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/services/device-creator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAMrD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AA6D9D,qBAAa,aAAa,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE;IAKhD,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAJhD,OAAO,CAAC,eAAe,CAAuC;IAC9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAO;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsC;gBAEvC,mBAAmB,EAAE,CAAC;IAI5C,aAAa,GAAI,WAAW,MAAM,KAAG,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAkBpE;IAEK,YAAY,CAAC,CAAC,SAAS,SAAS,EACrC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC5B,eAAe,CAAC,CAAC,CAAC;IAwCd,OAAO,aAEZ;IAEF;;;OAGG;IACH,OAAO,CAAC,eAAe,CAmBrB;IAEF,OAAO,CAAC,eAAe;CAexB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CommandSequencer } from "../../../types/command-sequencer";
|
|
2
|
+
import { DeviceCommand } from "../../../types/device-command";
|
|
3
|
+
interface Bc01SequencerParams {
|
|
4
|
+
/** The write channel every command goes out on. FF01 for a real BC401. */
|
|
5
|
+
write: Omit<DeviceCommand, "frame">;
|
|
6
|
+
/**
|
|
7
|
+
* Called with why the exchange stopped. Optional; a refusal here does not
|
|
8
|
+
* end the connection because the device continues to accept fresh commands
|
|
9
|
+
* even after a bad handshake step. The parent driver decides what to do.
|
|
10
|
+
*/
|
|
11
|
+
onRefused?: (reason: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Walks the BC401 through its post-reset handshake and pulls every stored
|
|
15
|
+
* record.
|
|
16
|
+
*
|
|
17
|
+
* The device is self-clocking: it answers each command with a single frame,
|
|
18
|
+
* and the first byte of that frame names what it is. So the sequencer keeps
|
|
19
|
+
* no counter of its own — it looks at the reply, decides what belongs next,
|
|
20
|
+
* and returns that. A frame whose opcode is not part of the handshake is left
|
|
21
|
+
* unanswered so the driver's stuck-data watchdog surfaces the stall rather
|
|
22
|
+
* than the sequencer sending a command the device did not ask for.
|
|
23
|
+
*
|
|
24
|
+
* `initialCommands()` returns only the reset. The rest of the handshake -
|
|
25
|
+
* VERSION, SET_TIME, GET_COUNT, GET_RECORDS - is driven entirely by the
|
|
26
|
+
* device's own replies, because sending them any earlier would race the
|
|
27
|
+
* firmware boot the reset triggers.
|
|
28
|
+
*/
|
|
29
|
+
export declare class Bc01CommandSequencer implements CommandSequencer {
|
|
30
|
+
private readonly params;
|
|
31
|
+
private isDone;
|
|
32
|
+
/** Injectable for tests; production reads `Date.now()`. */
|
|
33
|
+
private readonly clock;
|
|
34
|
+
constructor(params: Bc01SequencerParams, clock?: () => Date);
|
|
35
|
+
initialCommands: () => readonly DeviceCommand[];
|
|
36
|
+
nextCommand: (frame: readonly string[]) => readonly DeviceCommand[] | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The device pages every record it holds, one 16-byte frame at a time. Only
|
|
39
|
+
* the frame whose flags byte carries `0x40` needs an acknowledgement; every
|
|
40
|
+
* other page is a status update we let ride while the transfer continues.
|
|
41
|
+
*/
|
|
42
|
+
private answerStoredRecord;
|
|
43
|
+
private commandFor;
|
|
44
|
+
}
|
|
45
|
+
export declare const bc01CommandSequencerInternals: {
|
|
46
|
+
bc401Checksum: (bytes: readonly number[]) => number;
|
|
47
|
+
buildCommand: (opcode: number, arg: number) => number[];
|
|
48
|
+
buildResetCommand: () => number[];
|
|
49
|
+
buildRequestVersionCommand: () => number[];
|
|
50
|
+
buildSetTimeCommand: (now: Date) => number[];
|
|
51
|
+
};
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=bc01-command-sequencer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bc01-command-sequencer.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01-command-sequencer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAuC9D,UAAU,mBAAmB;IAE3B,0EAA0E;IAC1E,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAEpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAqED;;;;;;;;;;;;;;;GAeG;AAEH,qBAAa,oBAAqB,YAAW,gBAAgB;IAOzD,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,MAAM,CAAS;IAEvB,2DAA2D;IAC3D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;gBAGhB,MAAM,EAAE,mBAAmB,EAC5C,KAAK,GAAE,MAAM,IAAuB;IAK/B,eAAe,QAAO,SAAS,aAAa,EAAE,CAEnD;IAEK,WAAW,GAChB,OAAO,SAAS,MAAM,EAAE,KACvB,SAAS,aAAa,EAAE,GAAG,SAAS,CAoCrC;IAEF;;;;OAIG;IACH,OAAO,CAAC,kBAAkB,CAUxB;IAEF,OAAO,CAAC,UAAU,CAIf;CACJ;AAGD,eAAO,MAAM,6BAA6B;2BA3JZ,SAAS,MAAM,EAAE,KAAG,MAAM;2BAQ1B,MAAM,OAAO,MAAM,KAAG,MAAM,EAAE;6BAW9B,MAAM,EAAE;sCAQC,MAAM,EAAE;+BAYb,IAAI,KAAG,MAAM,EAAE;CA0HhD,CAAC"}
|
package/lib/typescript/module/src/modules/bt-management/services/devices/bc01/bc01-frame-parser.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** BC401 stored-record frame is always sixteen bytes: header, timestamp, analytes, checksum. */
|
|
2
|
+
declare const BC01_RECORD_LENGTH = 16;
|
|
3
|
+
/** The two opcodes the firmware uses for a stored URS-7 record. */
|
|
4
|
+
declare const BC01_URS_OPCODE = 225;
|
|
5
|
+
declare const BC01_PAGED_URS_OPCODE = 226;
|
|
6
|
+
/**
|
|
7
|
+
* The bit `0x40` of the flags byte marks the last record of a paginated set.
|
|
8
|
+
* The sequencer keys off it to send the `[0x92, 0x7E, chk]` acknowledgement.
|
|
9
|
+
*/
|
|
10
|
+
declare const BC01_LAST_OF_SET_BIT = 64;
|
|
11
|
+
/**
|
|
12
|
+
* URS-7 pad names, in the exact order they occupy the packed 3-bit slots
|
|
13
|
+
* across bytes 8..14 (see M1/a.java). The eleventh slot is a Contec-firmware
|
|
14
|
+
* field the vendor's own catalog calls "vc" and no other name is documented.
|
|
15
|
+
*/
|
|
16
|
+
declare const BC01_ANALYTE_ORDER: readonly ["uro", "bld", "bil", "ket", "glu", "pro", "ph", "nit", "leu", "sg", "vc"];
|
|
17
|
+
/** The result of decoding one 16-byte record. `lastOfSet` is what the sequencer keys on. */
|
|
18
|
+
interface Bc01ParsedRecord {
|
|
19
|
+
/** Local wall-clock time the device recorded, with millisecond precision unavailable. */
|
|
20
|
+
timestamp: Date;
|
|
21
|
+
/** True when the flags byte set bit 0x40 — this is the frame that must be acknowledged. */
|
|
22
|
+
lastOfSet: boolean;
|
|
23
|
+
/** Low nibble of the flags byte; the page counter the firmware writes. */
|
|
24
|
+
pageIndex: number;
|
|
25
|
+
/**
|
|
26
|
+
* Analyte level indices, absent for any pad the strip did not measure.
|
|
27
|
+
* A pad the strip did measure carries a value in [0, 6]; the vendor's own
|
|
28
|
+
* lookup tables translate that to a categorical result per analyte.
|
|
29
|
+
*/
|
|
30
|
+
values: Partial<Record<(typeof BC01_ANALYTE_ORDER)[number], number>>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Decodes a 16-byte E1 or E2 frame into its timestamp and analyte indices.
|
|
34
|
+
*
|
|
35
|
+
* Returns `undefined` for any frame that is not the right length or does not
|
|
36
|
+
* open with an E1/E2 opcode — the caller is not asked to guess whether a
|
|
37
|
+
* frame is a record or a heartbeat, and a frame that fails these checks is
|
|
38
|
+
* skipped rather than parsed into a plausible-looking wrong reading.
|
|
39
|
+
*
|
|
40
|
+
* The checksum byte is not verified here: the SDK's read path already ensures
|
|
41
|
+
* frame integrity before the parser sees the bytes, and a URS-7 pad value can
|
|
42
|
+
* only land in [0, 7] anyway — a corrupt payload would fail the pad-value
|
|
43
|
+
* check before it made it into a measurement.
|
|
44
|
+
*/
|
|
45
|
+
declare const parseBc01Record: (frame: readonly string[]) => Bc01ParsedRecord | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* True when the buffer holds a complete BC401 stored record. Used by the
|
|
48
|
+
* driver's `validatePackage` hook so the SDK's read path only advances once
|
|
49
|
+
* the notification carries a whole 16-byte frame.
|
|
50
|
+
*/
|
|
51
|
+
declare const isBc01Record: (frame: readonly string[]) => boolean;
|
|
52
|
+
export { BC01_ANALYTE_ORDER, BC01_LAST_OF_SET_BIT, BC01_PAGED_URS_OPCODE, BC01_RECORD_LENGTH, BC01_URS_OPCODE, Bc01ParsedRecord, isBc01Record, parseBc01Record, };
|
|
53
|
+
//# sourceMappingURL=bc01-frame-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bc01-frame-parser.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bc01/bc01-frame-parser.ts"],"names":[],"mappings":"AAIA,gGAAgG;AAChG,QAAA,MAAM,kBAAkB,KAAK,CAAC;AAE9B,mEAAmE;AACnE,QAAA,MAAM,eAAe,MAAO,CAAC;AAC7B,QAAA,MAAM,qBAAqB,MAAO,CAAC;AAEnC;;;GAGG;AACH,QAAA,MAAM,oBAAoB,KAAO,CAAC;AAelC;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,qFAYuC,CAAC;AAKhE,4FAA4F;AAC5F,UAAU,gBAAgB;IAExB,yFAAyF;IACzF,SAAS,EAAE,IAAI,CAAC;IAEhB,2FAA2F;IAC3F,SAAS,EAAE,OAAO,CAAC;IAEnB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;CACtE;AAUD;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,eAAe,GACnB,OAAO,SAAS,MAAM,EAAE,KACvB,gBAAgB,GAAG,SA0CrB,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,YAAY,GAAI,OAAO,SAAS,MAAM,EAAE,KAAG,OAQhD,CAAC;AAEF,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,GAChB,CAAC"}
|