@ovok/native 0.4.4 → 0.4.6
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/devices/bp2/bp2.device.js +8 -23
- package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.frame-reader.js +89 -0
- package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.frame-reader.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.main-services.js +50 -21
- package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.main-services.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js +32 -2
- package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js +80 -85
- package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +25 -3
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/frame-parser.js +54 -0
- package/lib/commonjs/modules/bt-management/services/devices/frame-parser.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/measurement-state-machine.js +63 -0
- package/lib/commonjs/modules/bt-management/services/devices/measurement-state-machine.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/frame-read-result.js +6 -0
- package/lib/commonjs/modules/bt-management/types/frame-read-result.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/frame-read-status.js +17 -0
- package/lib/commonjs/modules/bt-management/types/frame-read-status.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/frame-reader.js +6 -0
- package/lib/commonjs/modules/bt-management/types/frame-reader.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/calculate-crc-8.js +43 -0
- package/lib/commonjs/modules/bt-management/utils/calculate-crc-8.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/convert-bp-state-flag.js +8 -1
- package/lib/commonjs/modules/bt-management/utils/convert-bp-state-flag.js.map +1 -1
- package/lib/commonjs/modules/bt-management/utils/le-16-from-hex.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.device.js +9 -23
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.frame-reader.js +84 -0
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.frame-reader.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.main-services.js +50 -21
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.main-services.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js +32 -2
- package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-data-processor.js +80 -85
- package/lib/module/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +25 -3
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/frame-parser.js +50 -0
- package/lib/module/modules/bt-management/services/devices/frame-parser.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/measurement-state-machine.js +58 -0
- package/lib/module/modules/bt-management/services/devices/measurement-state-machine.js.map +1 -0
- package/lib/module/modules/bt-management/types/frame-read-result.js +4 -0
- package/lib/module/modules/bt-management/types/frame-read-result.js.map +1 -0
- package/lib/module/modules/bt-management/types/frame-read-status.js +13 -0
- package/lib/module/modules/bt-management/types/frame-read-status.js.map +1 -0
- package/lib/module/modules/bt-management/types/frame-reader.js +4 -0
- package/lib/module/modules/bt-management/types/frame-reader.js.map +1 -0
- package/lib/module/modules/bt-management/utils/calculate-crc-8.js +38 -0
- package/lib/module/modules/bt-management/utils/calculate-crc-8.js.map +1 -0
- package/lib/module/modules/bt-management/utils/convert-bp-state-flag.js +9 -1
- package/lib/module/modules/bt-management/utils/convert-bp-state-flag.js.map +1 -1
- package/lib/module/modules/bt-management/utils/le-16-from-hex.js.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts +3 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.main-services.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +9 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts +27 -10
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts +23 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/frame-parser.d.ts +19 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/frame-parser.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/measurement-state-machine.d.ts +30 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/measurement-state-machine.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/frame-read-result.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/frame-read-result.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/frame-read-status.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/frame-read-status.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/frame-reader.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/frame-reader.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/calculate-crc-8.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/calculate-crc-8.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/convert-bp-state-flag.d.ts +7 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/convert-bp-state-flag.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/utils/le-16-from-hex.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/utils/le-16-from-hex.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts +3 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts +14 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.main-services.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +9 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts +27 -10
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts +23 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/frame-parser.d.ts +19 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/frame-parser.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/measurement-state-machine.d.ts +30 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/measurement-state-machine.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/frame-read-result.d.ts +21 -0
- package/lib/typescript/module/src/modules/bt-management/types/frame-read-result.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/frame-read-status.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/types/frame-read-status.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/frame-reader.d.ts +13 -0
- package/lib/typescript/module/src/modules/bt-management/types/frame-reader.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/calculate-crc-8.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/utils/calculate-crc-8.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/convert-bp-state-flag.d.ts +7 -0
- package/lib/typescript/module/src/modules/bt-management/utils/convert-bp-state-flag.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/utils/le-16-from-hex.d.ts +1 -1
- package/lib/typescript/module/src/modules/bt-management/utils/le-16-from-hex.d.ts.map +1 -1
- package/package.json +12 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CaseType } from "../../types/case-type.js";
|
|
4
|
+
import { DeviceStatus } from "../../types/device-status.js";
|
|
5
|
+
/**
|
|
6
|
+
* Moves a device between measuring and connected as parsed frames arrive, and decides
|
|
7
|
+
* which of them is worth reporting.
|
|
8
|
+
*
|
|
9
|
+
* A result is reported whether or not a stream preceded it, because a device already
|
|
10
|
+
* holding a finished measurement when the app connects has a real reading to hand over.
|
|
11
|
+
* Repeats are suppressed on the case transition rather than on the values, so a second
|
|
12
|
+
* measurement that happens to read the same as the first is still reported.
|
|
13
|
+
*/
|
|
14
|
+
export class MeasurementStateMachine {
|
|
15
|
+
isMeasuring = false;
|
|
16
|
+
constructor(callbacks) {
|
|
17
|
+
this.callbacks = callbacks;
|
|
18
|
+
}
|
|
19
|
+
reset = () => {
|
|
20
|
+
this.isMeasuring = false;
|
|
21
|
+
this.lastCaseValue = undefined;
|
|
22
|
+
};
|
|
23
|
+
advance = ({
|
|
24
|
+
parsingCase,
|
|
25
|
+
measurementTypeKey,
|
|
26
|
+
parsedData
|
|
27
|
+
}, frame) => {
|
|
28
|
+
const isResult = parsingCase.caseType === CaseType.RESULT;
|
|
29
|
+
const isRepeatedResult = isResult && parsingCase.caseValue === this.lastCaseValue;
|
|
30
|
+
this.lastCaseValue = parsingCase.caseValue;
|
|
31
|
+
if (parsingCase.caseType === CaseType.STREAM && !this.isMeasuring) {
|
|
32
|
+
this.startMeasuring(measurementTypeKey);
|
|
33
|
+
}
|
|
34
|
+
if (this.isMeasuring && parsingCase.caseType === CaseType.OTHER) {
|
|
35
|
+
this.stopMeasuring(measurementTypeKey);
|
|
36
|
+
}
|
|
37
|
+
if (isRepeatedResult) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let keepMeasuring = false;
|
|
41
|
+
if (this.isMeasuring || isResult) {
|
|
42
|
+
keepMeasuring = this.callbacks.onResult?.(parsedData, frame) ?? false;
|
|
43
|
+
}
|
|
44
|
+
if (isResult && !keepMeasuring) {
|
|
45
|
+
this.stopMeasuring(measurementTypeKey);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
startMeasuring = measurementTypeKey => {
|
|
49
|
+
this.callbacks.onStreamStart?.();
|
|
50
|
+
this.callbacks.onStatusChanged?.(DeviceStatus.MEASURING, measurementTypeKey);
|
|
51
|
+
this.isMeasuring = true;
|
|
52
|
+
};
|
|
53
|
+
stopMeasuring = measurementTypeKey => {
|
|
54
|
+
this.isMeasuring = false;
|
|
55
|
+
this.callbacks.onStatusChanged?.(DeviceStatus.CONNECTED, measurementTypeKey);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=measurement-state-machine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CaseType","DeviceStatus","MeasurementStateMachine","isMeasuring","constructor","callbacks","reset","lastCaseValue","undefined","advance","parsingCase","measurementTypeKey","parsedData","frame","isResult","caseType","RESULT","isRepeatedResult","caseValue","STREAM","startMeasuring","OTHER","stopMeasuring","keepMeasuring","onResult","onStreamStart","onStatusChanged","MEASURING","CONNECTED"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/devices/measurement-state-machine.ts"],"mappings":";;AAEA,SAASA,QAAQ,QAAQ,0BAAuB;AAEhD,SAASC,YAAY,QAAQ,8BAA2B;AAexD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,CAAwB;EAClDC,WAAW,GAAY,KAAK;EAGpCC,WAAWA,CAAkBC,SAAoC,EAAE;IAAA,KAAtCA,SAAoC,GAApCA,SAAoC;EAAG;EAE7DC,KAAK,GAAGA,CAAA,KAAY;IACzB,IAAI,CAACH,WAAW,GAAG,KAAK;IACxB,IAAI,CAACI,aAAa,GAAGC,SAAS;EAChC,CAAC;EAEMC,OAAO,GAAGA,CACf;IACEC,WAAW;IACXC,kBAAkB;IAClBC;EAC+B,CAAC,EAClCC,KAAe,KACN;IACT,MAAMC,QAAQ,GAAGJ,WAAW,CAACK,QAAQ,KAAKf,QAAQ,CAACgB,MAAM;IAEzD,MAAMC,gBAAgB,GACpBH,QAAQ,IAAIJ,WAAW,CAACQ,SAAS,KAAK,IAAI,CAACX,aAAa;IAE1D,IAAI,CAACA,aAAa,GAAGG,WAAW,CAACQ,SAAS;IAE1C,IAAIR,WAAW,CAACK,QAAQ,KAAKf,QAAQ,CAACmB,MAAM,IAAI,CAAC,IAAI,CAAChB,WAAW,EAAE;MACjE,IAAI,CAACiB,cAAc,CAACT,kBAAkB,CAAC;IACzC;IAEA,IAAI,IAAI,CAACR,WAAW,IAAIO,WAAW,CAACK,QAAQ,KAAKf,QAAQ,CAACqB,KAAK,EAAE;MAC/D,IAAI,CAACC,aAAa,CAACX,kBAAkB,CAAC;IACxC;IAEA,IAAIM,gBAAgB,EAAE;MACpB;IACF;IAEA,IAAIM,aAAa,GAAG,KAAK;IAEzB,IAAI,IAAI,CAACpB,WAAW,IAAIW,QAAQ,EAAE;MAChCS,aAAa,GAAG,IAAI,CAAClB,SAAS,CAACmB,QAAQ,GAAGZ,UAAU,EAAEC,KAAK,CAAC,IAAI,KAAK;IACvE;IAEA,IAAIC,QAAQ,IAAI,CAACS,aAAa,EAAE;MAC9B,IAAI,CAACD,aAAa,CAACX,kBAAkB,CAAC;IACxC;EACF,CAAC;EAEOS,cAAc,GAAIT,kBAAuC,IAAW;IAC1E,IAAI,CAACN,SAAS,CAACoB,aAAa,GAAG,CAAC;IAChC,IAAI,CAACpB,SAAS,CAACqB,eAAe,GAAGzB,YAAY,CAAC0B,SAAS,EAAEhB,kBAAkB,CAAC;IAC5E,IAAI,CAACR,WAAW,GAAG,IAAI;EACzB,CAAC;EAEOmB,aAAa,GAAIX,kBAAuC,IAAW;IACzE,IAAI,CAACR,WAAW,GAAG,KAAK;IACxB,IAAI,CAACE,SAAS,CAACqB,eAAe,GAC5BzB,YAAY,CAAC2B,SAAS,EACtBjB,kBACF,CAAC;EACH,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/frame-read-result.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** Outcome of trying to read one frame from a notification buffer. */
|
|
4
|
+
export let FrameReadStatus = /*#__PURE__*/function (FrameReadStatus) {
|
|
5
|
+
/** No complete frame yet. The buffer must keep growing. */
|
|
6
|
+
FrameReadStatus["INCOMPLETE"] = "incomplete";
|
|
7
|
+
/** A frame was found but failed its integrity check and must not be parsed. */
|
|
8
|
+
FrameReadStatus["CORRUPT"] = "corrupt";
|
|
9
|
+
/** A complete, verified frame was isolated. */
|
|
10
|
+
FrameReadStatus["COMPLETE"] = "complete";
|
|
11
|
+
return FrameReadStatus;
|
|
12
|
+
}({});
|
|
13
|
+
//# sourceMappingURL=frame-read-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FrameReadStatus"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/frame-read-status.ts"],"mappings":";;AAAA;AACA,WAAYA,eAAe,0BAAfA,eAAe;EAEzB;EAFUA,eAAe;EAKzB;EALUA,eAAe;EAQzB;EARUA,eAAe;EAAA,OAAfA,eAAe;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/frame-reader.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { hexToByte } from "./hex-to-byte.js";
|
|
4
|
+
const CRC8_POLYNOMIAL = 0x07;
|
|
5
|
+
const BYTE_VALUE_COUNT = 256;
|
|
6
|
+
const BITS_PER_BYTE = 8;
|
|
7
|
+
const HIGH_BIT = 0x80;
|
|
8
|
+
const BYTE_MASK = 0xff;
|
|
9
|
+
const buildLookupTable = () => {
|
|
10
|
+
const table = new Uint8Array(BYTE_VALUE_COUNT);
|
|
11
|
+
for (let value = 0; value < BYTE_VALUE_COUNT; value++) {
|
|
12
|
+
let remainder = value;
|
|
13
|
+
for (let bit = 0; bit < BITS_PER_BYTE; bit++) {
|
|
14
|
+
const isHighBitSet = (remainder & HIGH_BIT) !== 0;
|
|
15
|
+
remainder = isHighBitSet ? (remainder << 1 ^ CRC8_POLYNOMIAL) & BYTE_MASK : remainder << 1 & BYTE_MASK;
|
|
16
|
+
}
|
|
17
|
+
table[value] = remainder;
|
|
18
|
+
}
|
|
19
|
+
return table;
|
|
20
|
+
};
|
|
21
|
+
const LOOKUP_TABLE = buildLookupTable();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* CRC-8/ATM (polynomial 0x07, initial value 0x00) over the first `byteCount` bytes.
|
|
25
|
+
*
|
|
26
|
+
* Lepu devices store a frame's checksum in its final byte, so a frame is verified by
|
|
27
|
+
* running this over every byte except that one and comparing the result against it.
|
|
28
|
+
* The byte count is explicit rather than implied so the caller states which bytes are
|
|
29
|
+
* covered instead of relying on a convention hidden in here.
|
|
30
|
+
*/
|
|
31
|
+
export const calculateCrc8 = (hex, byteCount) => {
|
|
32
|
+
let remainder = 0;
|
|
33
|
+
for (let index = 0; index < byteCount; index++) {
|
|
34
|
+
remainder = LOOKUP_TABLE[remainder ^ hexToByte(hex[index] || "0")] || 0;
|
|
35
|
+
}
|
|
36
|
+
return remainder;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=calculate-crc-8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hexToByte","CRC8_POLYNOMIAL","BYTE_VALUE_COUNT","BITS_PER_BYTE","HIGH_BIT","BYTE_MASK","buildLookupTable","table","Uint8Array","value","remainder","bit","isHighBitSet","LOOKUP_TABLE","calculateCrc8","hex","byteCount","index"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/utils/calculate-crc-8.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,kBAAe;AAEzC,MAAMC,eAAe,GAAG,IAAI;AAC5B,MAAMC,gBAAgB,GAAG,GAAG;AAC5B,MAAMC,aAAa,GAAG,CAAC;AACvB,MAAMC,QAAQ,GAAG,IAAI;AACrB,MAAMC,SAAS,GAAG,IAAI;AAEtB,MAAMC,gBAAgB,GAAGA,CAAA,KAAkB;EACzC,MAAMC,KAAK,GAAG,IAAIC,UAAU,CAACN,gBAAgB,CAAC;EAE9C,KAAK,IAAIO,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGP,gBAAgB,EAAEO,KAAK,EAAE,EAAE;IACrD,IAAIC,SAAS,GAAGD,KAAK;IAErB,KAAK,IAAIE,GAAG,GAAG,CAAC,EAAEA,GAAG,GAAGR,aAAa,EAAEQ,GAAG,EAAE,EAAE;MAC5C,MAAMC,YAAY,GAAG,CAACF,SAAS,GAAGN,QAAQ,MAAM,CAAC;MAEjDM,SAAS,GAAGE,YAAY,GACpB,CAAEF,SAAS,IAAI,CAAC,GAAIT,eAAe,IAAII,SAAS,GAC/CK,SAAS,IAAI,CAAC,GAAIL,SAAS;IAClC;IAEAE,KAAK,CAACE,KAAK,CAAC,GAAGC,SAAS;EAC1B;EAEA,OAAOH,KAAK;AACd,CAAC;AAED,MAAMM,YAAY,GAAGP,gBAAgB,CAAC,CAAC;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMQ,aAAa,GAAGA,CAACC,GAAa,EAAEC,SAAiB,KAAa;EACzE,IAAIN,SAAS,GAAG,CAAC;EAEjB,KAAK,IAAIO,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGD,SAAS,EAAEC,KAAK,EAAE,EAAE;IAC9CP,SAAS,GAAGG,YAAY,CAACH,SAAS,GAAGV,SAAS,CAACe,GAAG,CAACE,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;EACzE;EAEA,OAAOP,SAAS;AAClB,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { BloodPressureStates } from "../types/blood-pressure-states.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Maps the device's measurement status byte onto a known state.
|
|
7
|
+
*
|
|
8
|
+
* An unrecognised flag reports a device error rather than a regular reading: firmware
|
|
9
|
+
* may report a failure this SDK has not seen, and treating that as a good measurement
|
|
10
|
+
* would publish a reading the device did not vouch for.
|
|
11
|
+
*/
|
|
4
12
|
export const convertBpStateFlag = stateFlag => {
|
|
5
13
|
switch (stateFlag) {
|
|
6
14
|
case "00":
|
|
@@ -14,7 +22,7 @@ export const convertBpStateFlag = stateFlag => {
|
|
|
14
22
|
case "04":
|
|
15
23
|
return BloodPressureStates.DEVICE_ERROR;
|
|
16
24
|
default:
|
|
17
|
-
return BloodPressureStates.
|
|
25
|
+
return BloodPressureStates.DEVICE_ERROR;
|
|
18
26
|
}
|
|
19
27
|
};
|
|
20
28
|
//# sourceMappingURL=convert-bp-state-flag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BloodPressureStates","convertBpStateFlag","stateFlag","REGULAR","LOOSE_SLEEVE","DISTURB_DETECTED","WEAK_SIGNAL","DEVICE_ERROR"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/utils/convert-bp-state-flag.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,mCAAgC;
|
|
1
|
+
{"version":3,"names":["BloodPressureStates","convertBpStateFlag","stateFlag","REGULAR","LOOSE_SLEEVE","DISTURB_DETECTED","WEAK_SIGNAL","DEVICE_ERROR"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/utils/convert-bp-state-flag.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,mCAAgC;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAIC,SAAiB,IAA0B;EAC5E,QAAQA,SAAS;IACf,KAAK,IAAI;MACP,OAAOF,mBAAmB,CAACG,OAAO;IACpC,KAAK,IAAI;MACP,OAAOH,mBAAmB,CAACI,YAAY;IACzC,KAAK,IAAI;MACP,OAAOJ,mBAAmB,CAACK,gBAAgB;IAC7C,KAAK,IAAI;MACP,OAAOL,mBAAmB,CAACM,WAAW;IACxC,KAAK,IAAI;MACP,OAAON,mBAAmB,CAACO,YAAY;IACzC;MACE,OAAOP,mBAAmB,CAACO,YAAY;EAC3C;AACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hexToByte","le16FromHex","hex","i","lo","hi"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/utils/le-16-from-hex.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,kBAAe;;AAEzC;AACA,OAAO,MAAMC,WAAW,GAAGA,CAACC,
|
|
1
|
+
{"version":3,"names":["hexToByte","le16FromHex","hex","i","lo","hi"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/utils/le-16-from-hex.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,kBAAe;;AAEzC;AACA,OAAO,MAAMC,WAAW,GAAGA,CAACC,GAAsB,EAAEC,CAAS,KAAa;EACxE,MAAMC,EAAE,GAAGJ,SAAS,CAACE,GAAG,CAACC,CAAC,CAAC,IAAI,GAAG,CAAC;EACnC,MAAME,EAAE,GAAGL,SAAS,CAACE,GAAG,CAACC,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC;EAEvC,OAAOC,EAAE,GAAIC,EAAE,IAAI,CAAE;AACvB,CAAC","ignoreList":[]}
|
package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IntegratedDevices } from "../../../types/integrated-devices";
|
|
|
3
3
|
import { MeasurementWithCaseType } from "../../../types/measurement-with-case-type";
|
|
4
4
|
import { IService } from "../../../types/service.type";
|
|
5
5
|
import { BTManagedDevice } from "../bt-managed-device";
|
|
6
|
+
import { BP2FrameReader } from "./bp2.frame-reader";
|
|
6
7
|
export declare class BP2Device extends BTManagedDevice<IntegratedDevices.BP2> {
|
|
7
8
|
private collectedValues;
|
|
8
9
|
private diagramPoints;
|
|
@@ -10,7 +11,8 @@ export declare class BP2Device extends BTManagedDevice<IntegratedDevices.BP2> {
|
|
|
10
11
|
protected mainServices: IService[];
|
|
11
12
|
protected stuckDataTimeout: number;
|
|
12
13
|
protected onStreamStart: () => void;
|
|
13
|
-
protected
|
|
14
|
+
protected frameReader: BP2FrameReader;
|
|
15
|
+
protected preferredMtu: number;
|
|
14
16
|
protected handleSuccessResult(successResult: MeasurementWithCaseType<MeasurementTypeForDevices<[IntegratedDevices.BP2]>>, collectedValues: string[]): void | boolean;
|
|
15
17
|
private handleEcgResult;
|
|
16
18
|
private handleEcgStream;
|
package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bp2.device.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bp2/bp2.device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bp2.device.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bp2/bp2.device.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAKvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AASpD,qBAAa,SAAU,SAAQ,eAAe,CAAC,iBAAiB,CAAC,GAAG,CAAC;IACnE,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,QAAQ,CAAa;IAE7B,SAAS,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAmB;IACrD,SAAS,CAAC,gBAAgB,EAAE,MAAM,CAAS;IAE3C,SAAS,CAAC,aAAa,EAAE,MAAM,IAAI,CAIjC;IAEF,SAAS,CAAC,WAAW,EAAE,cAAc,CAAwB;IAC7D,SAAS,CAAC,YAAY,EAAE,MAAM,CAAqB;IAEnD,SAAS,CAAC,mBAAmB,CAC3B,aAAa,EAAE,uBAAuB,CACpC,yBAAyB,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CACnD,EACD,eAAe,EAAE,MAAM,EAAE,GACxB,IAAI,GAAG,OAAO;IA0BjB,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,yBAAyB;IAgBjC,OAAO,CAAC,+BAA+B;IAwCvC,OAAO,CAAC,qBAAqB;CAuC9B"}
|
package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FrameReadResult } from "../../../types/frame-read-result";
|
|
2
|
+
import { FrameReader } from "../../../types/frame-reader";
|
|
3
|
+
/**
|
|
4
|
+
* Reads Lepu protocol frames as used by the BP2.
|
|
5
|
+
*
|
|
6
|
+
* Layout: `a5 | cmd | ~cmd | type | seq | lenLow lenHigh | payload | crc8`, where the
|
|
7
|
+
* checksum covers every byte before it. The complement of the command byte only narrows
|
|
8
|
+
* the search for a start; the checksum is what actually decides a frame is trustworthy.
|
|
9
|
+
*/
|
|
10
|
+
export declare class BP2FrameReader implements FrameReader {
|
|
11
|
+
readFrame(buffer: readonly string[]): FrameReadResult;
|
|
12
|
+
private hasValidChecksum;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=bp2.frame-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bp2.frame-reader.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bp2/bp2.frame-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AA8C1D;;;;;;GAMG;AACH,qBAAa,cAAe,YAAW,WAAW;IACzC,SAAS,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,eAAe;IAiC5D,OAAO,CAAC,gBAAgB;CAMzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bp2.main-services.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bp2/bp2.main-services.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bp2.main-services.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bp2/bp2.main-services.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA+BvD,eAAO,MAAM,eAAe,EAAE,QAAQ,EAmIrC,CAAC"}
|
|
@@ -10,14 +10,22 @@ export declare class BTConnectionHandler {
|
|
|
10
10
|
private readonly device;
|
|
11
11
|
private readonly mainServices;
|
|
12
12
|
private readonly callbacks;
|
|
13
|
+
private readonly preferredMtu?;
|
|
13
14
|
private onDisconnectSubscription;
|
|
14
15
|
private characteristicSubscriptions;
|
|
15
16
|
private isSendingCommand;
|
|
16
17
|
private retryCount;
|
|
17
|
-
constructor(device: Device, mainServices: IMedicalDevice["mainService"], callbacks: ConnectionHandlerCallbacks);
|
|
18
|
+
constructor(device: Device, mainServices: IMedicalDevice["mainService"], callbacks: ConnectionHandlerCallbacks, preferredMtu?: number | undefined);
|
|
18
19
|
connect: () => Promise<void>;
|
|
19
20
|
destroy: () => void;
|
|
20
21
|
sendCommandToDevice: () => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Asks for a larger MTU so a frame arrives in fewer notifications.
|
|
24
|
+
*
|
|
25
|
+
* A device or platform that will not grant it keeps working at the default, so a
|
|
26
|
+
* refusal is recorded and the connection continues.
|
|
27
|
+
*/
|
|
28
|
+
private requestPreferredMtu;
|
|
21
29
|
private connectWithRetries;
|
|
22
30
|
private onDeviceDisconnected;
|
|
23
31
|
private subscribeToAllCharacteristics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bt-connection-handler.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/bt-management/services/devices/bt-connection-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAgB,MAAM,sBAAsB,CAAC;AAItE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAK9D,UAAU,0BAA0B;IAClC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC1D;AAED,qBAAa,mBAAmB;IAO5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS;
|
|
1
|
+
{"version":3,"file":"bt-connection-handler.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/bt-management/services/devices/bt-connection-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAgB,MAAM,sBAAsB,CAAC;AAItE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAK9D,UAAU,0BAA0B;IAClC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC1D;AAED,qBAAa,mBAAmB;IAO5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAThC,OAAO,CAAC,wBAAwB,CAA2B;IAC3D,OAAO,CAAC,2BAA2B,CAAsB;IACzD,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,UAAU,CAAa;gBAGZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,cAAc,CAAC,aAAa,CAAC,EAC3C,SAAS,EAAE,0BAA0B,EACrC,YAAY,CAAC,EAAE,MAAM,YAAA;IAGjC,OAAO,sBAsBZ;IAEK,OAAO,aAOZ;IAEK,mBAAmB,QAAa,OAAO,CAAC,IAAI,CAAC,CAelD;IAEF;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB,CAezB;IAEF,OAAO,CAAC,kBAAkB,CA2CxB;IAEF,OAAO,CAAC,oBAAoB,CAiB1B;IAEF,OAAO,CAAC,6BAA6B,CA4CnC;IAEF,OAAO,CAAC,WAAW,CAkCjB;CACH"}
|
package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Measurement, MeasurementTypeKey } from "@ovok/core";
|
|
|
2
2
|
import { Device } from "react-native-ble-plx";
|
|
3
3
|
import { DependentResultHandlerParams } from "../../types/dependent-result-handler-params";
|
|
4
4
|
import { DeviceStatus } from "../../types/device-status";
|
|
5
|
+
import { FrameReader } from "../../types/frame-reader";
|
|
5
6
|
import { IMedicalDevice } from "../../types/i-medical-device";
|
|
6
7
|
import { MeasurementWithCaseType } from "../../types/measurement-with-case-type";
|
|
7
8
|
interface DataProcessorCallbacks<T extends Measurement> {
|
|
@@ -15,9 +16,9 @@ interface DataProcessorCallbacks<T extends Measurement> {
|
|
|
15
16
|
}
|
|
16
17
|
export declare class BTDataProcessor<T extends Measurement> {
|
|
17
18
|
private readonly device;
|
|
18
|
-
private readonly mainServices;
|
|
19
19
|
private readonly stuckDataTimeoutDuration;
|
|
20
20
|
private readonly callbacks;
|
|
21
|
+
private readonly frameReader?;
|
|
21
22
|
/**
|
|
22
23
|
* One buffer per characteristic.
|
|
23
24
|
*
|
|
@@ -28,19 +29,35 @@ export declare class BTDataProcessor<T extends Measurement> {
|
|
|
28
29
|
* error. Keeping the buffers apart makes that impossible.
|
|
29
30
|
*/
|
|
30
31
|
private buffers;
|
|
31
|
-
private
|
|
32
|
+
private readonly frameParser;
|
|
33
|
+
private readonly measurementState;
|
|
32
34
|
private stuckDataTimeout;
|
|
33
|
-
constructor(device: Device, mainServices: IMedicalDevice["mainService"], stuckDataTimeoutDuration: number, callbacks: DataProcessorCallbacks<T
|
|
34
|
-
private get collectedValues();
|
|
35
|
+
constructor(device: Device, mainServices: IMedicalDevice["mainService"], stuckDataTimeoutDuration: number, callbacks: DataProcessorCallbacks<T>, frameReader?: FrameReader | undefined);
|
|
35
36
|
private currentUuid;
|
|
36
37
|
destroy: () => void;
|
|
37
38
|
processData: (uuid: string, hexValue: string[]) => void;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Drains every complete frame the buffer holds.
|
|
41
|
+
*
|
|
42
|
+
* One notification can complete several frames and can also carry bytes that belong to
|
|
43
|
+
* no frame at all, so the reader is asked repeatedly until it stops making progress.
|
|
44
|
+
* A frame that fails its integrity check is reported and skipped rather than parsed.
|
|
45
|
+
*/
|
|
46
|
+
private readFramesFromBuffer;
|
|
47
|
+
/**
|
|
48
|
+
* Treats the whole buffer as one frame, for devices that have not declared a reader.
|
|
49
|
+
*/
|
|
50
|
+
private readWholeBuffer;
|
|
51
|
+
private handleFrame;
|
|
52
|
+
private reportCorruptFrame;
|
|
53
|
+
/**
|
|
54
|
+
* Reports a parsed frame and moves the device between measuring and connected.
|
|
55
|
+
*
|
|
56
|
+
* A result is reported whether or not a stream preceded it, because a device already
|
|
57
|
+
* holding a finished measurement when the app connects has a real reading to hand over.
|
|
58
|
+
* Repeats are suppressed on the case transition rather than on the values, so a second
|
|
59
|
+
* measurement that happens to read the same is still reported.
|
|
60
|
+
*/
|
|
44
61
|
private startStuckTimeout;
|
|
45
62
|
}
|
|
46
63
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bt-data-processor.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/bt-management/services/devices/bt-data-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"bt-data-processor.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/bt-management/services/devices/bt-data-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAKjF,UAAU,sBAAsB,CAAC,CAAC,SAAS,WAAW;IACpD,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC1D,eAAe,CAAC,EAAE,CAChB,MAAM,EAAE,YAAY,EACpB,kBAAkB,CAAC,EAAE,kBAAkB,KACpC,IAAI,CAAC;IACV,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,CACT,UAAU,EAAE,uBAAuB,CAAC,WAAW,CAAC,EAChD,eAAe,EAAE,MAAM,EAAE,KACtB,OAAO,GAAG,IAAI,CAAC;IACpB,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,qBAAqB,CAAC,EAAE,CACtB,IAAI,EAAE,4BAA4B,CAAC,CAAC,CAAC,KAClC,4BAA4B,CAAC,CAAC,CAAC,CAAC;CACtC;AAED,qBAAa,eAAe,CAAC,CAAC,SAAS,WAAW;IAe9C,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,wBAAwB;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAlB/B;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiB;IAC7C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA6B;IAC9D,OAAO,CAAC,gBAAgB,CAA4C;gBAEjD,MAAM,EAAE,MAAM,EAC/B,YAAY,EAAE,cAAc,CAAC,aAAa,CAAC,EAC1B,wBAAwB,EAAE,MAAM,EAChC,SAAS,EAAE,sBAAsB,CAAC,CAAC,CAAC,EACpC,WAAW,CAAC,EAAE,WAAW,YAAA;IAU5C,OAAO,CAAC,WAAW,CAAc;IAE1B,OAAO,aAMZ;IAEK,WAAW,GAAI,MAAM,MAAM,EAAE,UAAU,MAAM,EAAE,UAgBpD;IAEF;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB,CAgC1B;IAEF;;OAEG;IACH,OAAO,CAAC,eAAe,CAQrB;IAEF,OAAO,CAAC,WAAW,CAuBjB;IAEF,OAAO,CAAC,kBAAkB,CAQxB;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB,CAevB;CACH"}
|
package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { DeviceData } from "../../types/device-data";
|
|
|
6
6
|
import { DeviceKey } from "../../types/device-key";
|
|
7
7
|
import { MeasurementTypeForDevices } from "../../types/device-measurement-map";
|
|
8
8
|
import { DeviceStatus } from "../../types/device-status";
|
|
9
|
+
import { FrameReader } from "../../types/frame-reader";
|
|
9
10
|
import { IBTManagedDevice } from "../../types/i-bt-managed-device";
|
|
10
11
|
import { IMedicalDevice } from "../../types/i-medical-device";
|
|
11
12
|
import { IntegratedDevices } from "../../types/integrated-devices";
|
|
@@ -30,7 +31,28 @@ export declare abstract class BTManagedDevice<T extends DeviceKey = IntegratedDe
|
|
|
30
31
|
*/
|
|
31
32
|
protected handleDependentResult?: (data: DependentResultHandlerParams<MeasurementTypeForDevices<[T]>>) => DependentResultHandlerParams<MeasurementTypeForDevices<[T]>>;
|
|
32
33
|
protected abstract mainServices: IMedicalDevice["mainService"];
|
|
33
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Locates frame boundaries inside the notification buffer.
|
|
36
|
+
*
|
|
37
|
+
* A device that leaves this undefined has its whole buffer handed to
|
|
38
|
+
* `validatePackage` and parsed as a single frame, which only holds while a
|
|
39
|
+
* notification can neither split a frame nor carry more than one.
|
|
40
|
+
*/
|
|
41
|
+
protected frameReader?: FrameReader;
|
|
42
|
+
/**
|
|
43
|
+
* MTU to ask for once connected.
|
|
44
|
+
*
|
|
45
|
+
* A larger MTU carries a frame in fewer notifications, which matters most for the
|
|
46
|
+
* long payloads. Devices that leave this undefined keep the platform default.
|
|
47
|
+
*/
|
|
48
|
+
protected preferredMtu?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Decides whether the buffer holds a parseable frame.
|
|
51
|
+
*
|
|
52
|
+
* Only consulted for devices that declare no frameReader. A device that declares
|
|
53
|
+
* neither parses nothing, so an unknown buffer is never decoded on trust.
|
|
54
|
+
*/
|
|
55
|
+
protected validatePackage?: (pkg: string[], uuid: string) => boolean;
|
|
34
56
|
protected abstract onStreamStart?: () => void;
|
|
35
57
|
protected abstract handleSuccessResult(successResult: MeasurementWithCaseType<Measurement>, collectedValues: string[]): void | boolean;
|
|
36
58
|
onError?: (error: BleError | Error | string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bt-managed-device.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/bt-management/services/devices/bt-managed-device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAKjF,8BAAsB,eAAe,CAAC,CAAC,SAAS,SAAS,GAAG,iBAAiB,CAAC,GAAG,CAC/E,YAAW,gBAAgB;
|
|
1
|
+
{"version":3,"file":"bt-managed-device.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/bt-management/services/devices/bt-managed-device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAKjF,8BAAsB,eAAe,CAAC,CAAC,SAAS,SAAS,GAAG,iBAAiB,CAAC,GAAG,CAC/E,YAAW,gBAAgB;aAqET,MAAM,EAAE,MAAM;IAnEzB,EAAE,EAAE,MAAM,CAAC;IAElB,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,aAAa,CAEP;IACP,UAAU,EAAE,UAAU,CAAC;IAE9B;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAE5C;;;;;;;OAOG;IACH,SAAS,CAAC,qBAAqB,CAAC,EAAE,CAChC,IAAI,EAAE,4BAA4B,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAC/D,4BAA4B,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAElE,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IAE/D;;;;;;OAMG;IACH,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAEpC;;;;;OAKG;IACH,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;;OAKG;IACH,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACrE,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9C,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CACpC,aAAa,EAAE,uBAAuB,CAAC,WAAW,CAAC,EACnD,eAAe,EAAE,MAAM,EAAE,GACxB,IAAI,GAAG,OAAO;IAEV,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,KAAK,IAAI,CAAC;IACrD,qBAAqB,CAAC,EAAE,CAC7B,MAAM,EAAE,YAAY,EACpB,kBAAkB,CAAC,EAAE,kBAAkB,KACpC,IAAI,CAAC;IACH,QAAQ,CAAC,EAAE,CAChB,IAAI,EAAE,uBAAuB,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAC1D,IAAI,CAAC;IACH,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;gBAEvB,MAAM,EAAE,MAAM,EAE9B,EACE,UAAU,EACV,OAAO,EAAE,eAAe,EACxB,qBAAqB,EAAE,6BAA6B,EACpD,QAAQ,EAAE,gBAAgB,EAC1B,oBAAoB,EAAE,4BAA4B,GACnD,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAsEnB,OAAO,aAUZ;IAEK,OAAO,sBAkDZ;IAEF,OAAO,CAAC,+BAA+B,CAarC;CACH"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Measurement } from "@ovok/core";
|
|
2
|
+
import { DependentResultHandlerParams } from "../../types/dependent-result-handler-params";
|
|
3
|
+
import { IMedicalDevice } from "../../types/i-medical-device";
|
|
4
|
+
/**
|
|
5
|
+
* Turns a verified frame into a measurement, by selecting the parsing case the frame
|
|
6
|
+
* matches and applying that case's field definitions.
|
|
7
|
+
*
|
|
8
|
+
* A frame whose characteristic is unknown, whose selector bytes match no declared case,
|
|
9
|
+
* or whose fields do not parse yields nothing: it is the caller's decision whether that
|
|
10
|
+
* is worth reporting.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FrameParser<T extends Measurement> {
|
|
13
|
+
private readonly mainServices;
|
|
14
|
+
constructor(mainServices: IMedicalDevice["mainService"]);
|
|
15
|
+
parse(uuid: string, frame: string[]): DependentResultHandlerParams<T> | undefined;
|
|
16
|
+
private findParsingModel;
|
|
17
|
+
private readCaseValue;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=frame-parser.d.ts.map
|
package/lib/typescript/commonjs/src/modules/bt-management/services/devices/frame-parser.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-parser.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/bt-management/services/devices/frame-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAK9D;;;;;;;GAOG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,WAAW;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,EAAE,cAAc,CAAC,aAAa,CAAC;IAEjE,KAAK,CACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EAAE,GACd,4BAA4B,CAAC,CAAC,CAAC,GAAG,SAAS;IA8B9C,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,aAAa;CAMtB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Measurement, MeasurementTypeKey } from "@ovok/core";
|
|
2
|
+
import { DependentResultHandlerParams } from "../../types/dependent-result-handler-params";
|
|
3
|
+
import { DeviceStatus } from "../../types/device-status";
|
|
4
|
+
import { MeasurementWithCaseType } from "../../types/measurement-with-case-type";
|
|
5
|
+
interface MeasurementStateCallbacks {
|
|
6
|
+
onStatusChanged?: (status: DeviceStatus, measurementTypeKey?: MeasurementTypeKey) => void;
|
|
7
|
+
onStreamStart?: () => void;
|
|
8
|
+
onResult?: (parsedData: MeasurementWithCaseType<Measurement>, frame: string[]) => boolean | void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Moves a device between measuring and connected as parsed frames arrive, and decides
|
|
12
|
+
* which of them is worth reporting.
|
|
13
|
+
*
|
|
14
|
+
* A result is reported whether or not a stream preceded it, because a device already
|
|
15
|
+
* holding a finished measurement when the app connects has a real reading to hand over.
|
|
16
|
+
* Repeats are suppressed on the case transition rather than on the values, so a second
|
|
17
|
+
* measurement that happens to read the same as the first is still reported.
|
|
18
|
+
*/
|
|
19
|
+
export declare class MeasurementStateMachine<T extends Measurement> {
|
|
20
|
+
private readonly callbacks;
|
|
21
|
+
private isMeasuring;
|
|
22
|
+
private lastCaseValue;
|
|
23
|
+
constructor(callbacks: MeasurementStateCallbacks);
|
|
24
|
+
reset: () => void;
|
|
25
|
+
advance: ({ parsingCase, measurementTypeKey, parsedData, }: DependentResultHandlerParams<T>, frame: string[]) => void;
|
|
26
|
+
private startMeasuring;
|
|
27
|
+
private stopMeasuring;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=measurement-state-machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurement-state-machine.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/bt-management/services/devices/measurement-state-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAG7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,UAAU,yBAAyB;IACjC,eAAe,CAAC,EAAE,CAChB,MAAM,EAAE,YAAY,EACpB,kBAAkB,CAAC,EAAE,kBAAkB,KACpC,IAAI,CAAC;IACV,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,CACT,UAAU,EAAE,uBAAuB,CAAC,WAAW,CAAC,EAChD,KAAK,EAAE,MAAM,EAAE,KACZ,OAAO,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,qBAAa,uBAAuB,CAAC,CAAC,SAAS,WAAW;IAI5C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAHtC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,aAAa,CAAqB;gBAEb,SAAS,EAAE,yBAAyB;IAE1D,KAAK,QAAO,IAAI,CAGrB;IAEK,OAAO,GACZ,kDAIG,4BAA4B,CAAC,CAAC,CAAC,EAClC,OAAO,MAAM,EAAE,KACd,IAAI,CA6BL;IAEF,OAAO,CAAC,cAAc,CAIpB;IAEF,OAAO,CAAC,aAAa,CAMnB;CACH"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FrameReadStatus } from "./frame-read-status";
|
|
2
|
+
/**
|
|
3
|
+
* What a FrameReader found, and how much of the buffer it has finished with.
|
|
4
|
+
*
|
|
5
|
+
* `consumedBytes` is always the number of leading bytes the caller should drop: bytes
|
|
6
|
+
* before a frame start are junk, a verified frame is spent once parsed, and a corrupt
|
|
7
|
+
* one is skipped far enough to resynchronise on the next start byte. A frame is only
|
|
8
|
+
* present when the read succeeded, so an unverified frame cannot reach a parser.
|
|
9
|
+
*/
|
|
10
|
+
export type FrameReadResult = {
|
|
11
|
+
status: FrameReadStatus.INCOMPLETE;
|
|
12
|
+
consumedBytes: number;
|
|
13
|
+
} | {
|
|
14
|
+
status: FrameReadStatus.CORRUPT;
|
|
15
|
+
consumedBytes: number;
|
|
16
|
+
} | {
|
|
17
|
+
status: FrameReadStatus.COMPLETE;
|
|
18
|
+
consumedBytes: number;
|
|
19
|
+
frame: string[];
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=frame-read-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-read-result.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/types/frame-read-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GACvB;IACE,MAAM,EAAE,eAAe,CAAC,UAAU,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,GACD;IACE,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;CACvB,GACD;IACE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Outcome of trying to read one frame from a notification buffer. */
|
|
2
|
+
export declare enum FrameReadStatus {
|
|
3
|
+
/** No complete frame yet. The buffer must keep growing. */
|
|
4
|
+
INCOMPLETE = "incomplete",
|
|
5
|
+
/** A frame was found but failed its integrity check and must not be parsed. */
|
|
6
|
+
CORRUPT = "corrupt",
|
|
7
|
+
/** A complete, verified frame was isolated. */
|
|
8
|
+
COMPLETE = "complete"
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=frame-read-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-read-status.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/types/frame-read-status.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,oBAAY,eAAe;IAEzB,2DAA2D;IAC3D,UAAU,eAAe;IAEzB,+EAA+E;IAC/E,OAAO,YAAY;IAEnB,+CAA+C;IAC/C,QAAQ,aAAa;CACtB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FrameReadResult } from "./frame-read-result";
|
|
2
|
+
/**
|
|
3
|
+
* Isolates one complete, verified frame from a notification buffer.
|
|
4
|
+
*
|
|
5
|
+
* Notifications do not respect frame boundaries: one frame can arrive across several
|
|
6
|
+
* notifications, and several frames can arrive in one. A device that declares a reader
|
|
7
|
+
* hands the SDK enough knowledge to find frame edges itself instead of assuming a
|
|
8
|
+
* notification is a frame.
|
|
9
|
+
*/
|
|
10
|
+
export interface FrameReader {
|
|
11
|
+
readFrame(buffer: readonly string[]): FrameReadResult;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=frame-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-reader.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/types/frame-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,eAAe,CAAC;CACvD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CRC-8/ATM (polynomial 0x07, initial value 0x00) over the first `byteCount` bytes.
|
|
3
|
+
*
|
|
4
|
+
* Lepu devices store a frame's checksum in its final byte, so a frame is verified by
|
|
5
|
+
* running this over every byte except that one and comparing the result against it.
|
|
6
|
+
* The byte count is explicit rather than implied so the caller states which bytes are
|
|
7
|
+
* covered instead of relying on a convention hidden in here.
|
|
8
|
+
*/
|
|
9
|
+
export declare const calculateCrc8: (hex: string[], byteCount: number) => number;
|
|
10
|
+
//# sourceMappingURL=calculate-crc-8.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculate-crc-8.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/utils/calculate-crc-8.ts"],"names":[],"mappings":"AA8BA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,EAAE,WAAW,MAAM,KAAG,MAQhE,CAAC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { BloodPressureStates } from "../types/blood-pressure-states";
|
|
2
|
+
/**
|
|
3
|
+
* Maps the device's measurement status byte onto a known state.
|
|
4
|
+
*
|
|
5
|
+
* An unrecognised flag reports a device error rather than a regular reading: firmware
|
|
6
|
+
* may report a failure this SDK has not seen, and treating that as a good measurement
|
|
7
|
+
* would publish a reading the device did not vouch for.
|
|
8
|
+
*/
|
|
2
9
|
export declare const convertBpStateFlag: (stateFlag: string) => BloodPressureStates;
|
|
3
10
|
//# sourceMappingURL=convert-bp-state-flag.d.ts.map
|
package/lib/typescript/commonjs/src/modules/bt-management/utils/convert-bp-state-flag.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-bp-state-flag.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/utils/convert-bp-state-flag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,mBAetD,CAAC"}
|
|
1
|
+
{"version":3,"file":"convert-bp-state-flag.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/utils/convert-bp-state-flag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,mBAetD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const le16FromHex: (hex: string[], i: number) => number;
|
|
1
|
+
export declare const le16FromHex: (hex: readonly string[], i: number) => number;
|
|
2
2
|
//# sourceMappingURL=le-16-from-hex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"le-16-from-hex.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/utils/le-16-from-hex.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,EAAE,GAAG,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"le-16-from-hex.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/bt-management/utils/le-16-from-hex.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,GAAI,KAAK,SAAS,MAAM,EAAE,EAAE,GAAG,MAAM,KAAG,MAK/D,CAAC"}
|
package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IntegratedDevices } from "../../../types/integrated-devices";
|
|
|
3
3
|
import { MeasurementWithCaseType } from "../../../types/measurement-with-case-type";
|
|
4
4
|
import { IService } from "../../../types/service.type";
|
|
5
5
|
import { BTManagedDevice } from "../bt-managed-device";
|
|
6
|
+
import { BP2FrameReader } from "./bp2.frame-reader";
|
|
6
7
|
export declare class BP2Device extends BTManagedDevice<IntegratedDevices.BP2> {
|
|
7
8
|
private collectedValues;
|
|
8
9
|
private diagramPoints;
|
|
@@ -10,7 +11,8 @@ export declare class BP2Device extends BTManagedDevice<IntegratedDevices.BP2> {
|
|
|
10
11
|
protected mainServices: IService[];
|
|
11
12
|
protected stuckDataTimeout: number;
|
|
12
13
|
protected onStreamStart: () => void;
|
|
13
|
-
protected
|
|
14
|
+
protected frameReader: BP2FrameReader;
|
|
15
|
+
protected preferredMtu: number;
|
|
14
16
|
protected handleSuccessResult(successResult: MeasurementWithCaseType<MeasurementTypeForDevices<[IntegratedDevices.BP2]>>, collectedValues: string[]): void | boolean;
|
|
15
17
|
private handleEcgResult;
|
|
16
18
|
private handleEcgStream;
|
package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bp2.device.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bp2/bp2.device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bp2.device.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/bt-management/services/devices/bp2/bp2.device.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAKvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AASpD,qBAAa,SAAU,SAAQ,eAAe,CAAC,iBAAiB,CAAC,GAAG,CAAC;IACnE,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,QAAQ,CAAa;IAE7B,SAAS,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAmB;IACrD,SAAS,CAAC,gBAAgB,EAAE,MAAM,CAAS;IAE3C,SAAS,CAAC,aAAa,EAAE,MAAM,IAAI,CAIjC;IAEF,SAAS,CAAC,WAAW,EAAE,cAAc,CAAwB;IAC7D,SAAS,CAAC,YAAY,EAAE,MAAM,CAAqB;IAEnD,SAAS,CAAC,mBAAmB,CAC3B,aAAa,EAAE,uBAAuB,CACpC,yBAAyB,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CACnD,EACD,eAAe,EAAE,MAAM,EAAE,GACxB,IAAI,GAAG,OAAO;IA0BjB,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,yBAAyB;IAgBjC,OAAO,CAAC,+BAA+B;IAwCvC,OAAO,CAAC,qBAAqB;CAuC9B"}
|
package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FrameReadResult } from "../../../types/frame-read-result";
|
|
2
|
+
import { FrameReader } from "../../../types/frame-reader";
|
|
3
|
+
/**
|
|
4
|
+
* Reads Lepu protocol frames as used by the BP2.
|
|
5
|
+
*
|
|
6
|
+
* Layout: `a5 | cmd | ~cmd | type | seq | lenLow lenHigh | payload | crc8`, where the
|
|
7
|
+
* checksum covers every byte before it. The complement of the command byte only narrows
|
|
8
|
+
* the search for a start; the checksum is what actually decides a frame is trustworthy.
|
|
9
|
+
*/
|
|
10
|
+
export declare class BP2FrameReader implements FrameReader {
|
|
11
|
+
readFrame(buffer: readonly string[]): FrameReadResult;
|
|
12
|
+
private hasValidChecksum;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=bp2.frame-reader.d.ts.map
|