@ovok/native 1.10.11 → 1.10.13
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-device/constants/device-instruction-pdfs.js +2 -0
- package/lib/commonjs/modules/bt-device/constants/device-instruction-pdfs.js.map +1 -1
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-transtek-a6-bp-variants.js +577 -0
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-transtek-a6-bp-variants.js.map +1 -0
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-transtek-a6-variants.js +107 -0
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-transtek-a6-variants.js.map +1 -0
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-variants.js +4 -0
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-variants.js.map +1 -1
- package/lib/commonjs/modules/bt-device/constants/supported-devices.js +3 -0
- package/lib/commonjs/modules/bt-device/constants/supported-devices.js.map +1 -1
- package/lib/commonjs/modules/bt-management/constants/built-in-measurement-types.js +3 -0
- package/lib/commonjs/modules/bt-management/constants/built-in-measurement-types.js.map +1 -1
- package/lib/commonjs/modules/bt-management/constants/device-variants.js +3 -1
- package/lib/commonjs/modules/bt-management/constants/device-variants.js.map +1 -1
- package/lib/commonjs/modules/bt-management/constants/integrated-devices-map.js +1 -1
- package/lib/commonjs/modules/bt-management/constants/integrated-devices-map.js.map +1 -1
- package/lib/commonjs/modules/bt-management/constants/transtek-a6-bp-device-variants.js +478 -0
- package/lib/commonjs/modules/bt-management/constants/transtek-a6-bp-device-variants.js.map +1 -0
- package/lib/commonjs/modules/bt-management/constants/transtek-a6-device-variants.js +89 -0
- package/lib/commonjs/modules/bt-management/constants/transtek-a6-device-variants.js.map +1 -0
- package/lib/commonjs/modules/bt-management/core/resolve-device-key.js +13 -0
- package/lib/commonjs/modules/bt-management/core/resolve-device-key.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/device-classes.js +6 -0
- package/lib/commonjs/modules/bt-management/services/device-classes.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/device-creator.js +5 -3
- package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js +3 -2
- package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-blood-pressure.device.js +50 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-blood-pressure.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-blood-pressure.measurements.js +103 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-blood-pressure.measurements.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-blood-pressure.sequencer.js +146 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-blood-pressure.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-scale.device.js +50 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-scale.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-scale.measurements.js +78 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-scale.measurements.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-scale.protocol.js +140 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-scale.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-scale.sequencer.js +102 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/a6-scale.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/mambo-a5.device.js +51 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/mambo-a5.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/mambo-a5.measurements.js +48 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/mambo-a5.measurements.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/mambo-a5.protocol.js +181 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/mambo-a5.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/mambo-a5.sequencer.js +73 -0
- package/lib/commonjs/modules/bt-management/services/devices/transtek/mambo-a5.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/clock-sync.js +3 -0
- package/lib/commonjs/modules/bt-management/types/clock-sync.js.map +1 -1
- package/lib/commonjs/modules/bt-management/types/integrated-devices.js +2 -0
- package/lib/commonjs/modules/bt-management/types/integrated-devices.js.map +1 -1
- package/lib/module/modules/bt-device/constants/device-instruction-pdfs.js +2 -0
- package/lib/module/modules/bt-device/constants/device-instruction-pdfs.js.map +1 -1
- package/lib/module/modules/bt-device/constants/supported-device-catalog-transtek-a6-bp-variants.js +575 -0
- package/lib/module/modules/bt-device/constants/supported-device-catalog-transtek-a6-bp-variants.js.map +1 -0
- package/lib/module/modules/bt-device/constants/supported-device-catalog-transtek-a6-variants.js +105 -0
- package/lib/module/modules/bt-device/constants/supported-device-catalog-transtek-a6-variants.js.map +1 -0
- package/lib/module/modules/bt-device/constants/supported-device-catalog-variants.js +4 -0
- package/lib/module/modules/bt-device/constants/supported-device-catalog-variants.js.map +1 -1
- package/lib/module/modules/bt-device/constants/supported-devices.js +3 -0
- package/lib/module/modules/bt-device/constants/supported-devices.js.map +1 -1
- package/lib/module/modules/bt-management/constants/built-in-measurement-types.js +3 -0
- package/lib/module/modules/bt-management/constants/built-in-measurement-types.js.map +1 -1
- package/lib/module/modules/bt-management/constants/device-variants.js +3 -1
- package/lib/module/modules/bt-management/constants/device-variants.js.map +1 -1
- package/lib/module/modules/bt-management/constants/integrated-devices-map.js +1 -1
- package/lib/module/modules/bt-management/constants/integrated-devices-map.js.map +1 -1
- package/lib/module/modules/bt-management/constants/transtek-a6-bp-device-variants.js +476 -0
- package/lib/module/modules/bt-management/constants/transtek-a6-bp-device-variants.js.map +1 -0
- package/lib/module/modules/bt-management/constants/transtek-a6-device-variants.js +87 -0
- package/lib/module/modules/bt-management/constants/transtek-a6-device-variants.js.map +1 -0
- package/lib/module/modules/bt-management/core/resolve-device-key.js +12 -0
- package/lib/module/modules/bt-management/core/resolve-device-key.js.map +1 -1
- package/lib/module/modules/bt-management/services/device-classes.js +6 -0
- package/lib/module/modules/bt-management/services/device-classes.js.map +1 -1
- package/lib/module/modules/bt-management/services/device-creator.js +5 -3
- package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-data-processor.js +3 -2
- package/lib/module/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/transtek/a6-blood-pressure.device.js +45 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-blood-pressure.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-blood-pressure.measurements.js +98 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-blood-pressure.measurements.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-blood-pressure.sequencer.js +141 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-blood-pressure.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-scale.device.js +45 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-scale.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-scale.measurements.js +73 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-scale.measurements.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-scale.protocol.js +127 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-scale.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-scale.sequencer.js +97 -0
- package/lib/module/modules/bt-management/services/devices/transtek/a6-scale.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/mambo-a5.device.js +46 -0
- package/lib/module/modules/bt-management/services/devices/transtek/mambo-a5.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/mambo-a5.measurements.js +43 -0
- package/lib/module/modules/bt-management/services/devices/transtek/mambo-a5.measurements.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/mambo-a5.protocol.js +174 -0
- package/lib/module/modules/bt-management/services/devices/transtek/mambo-a5.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/transtek/mambo-a5.sequencer.js +68 -0
- package/lib/module/modules/bt-management/services/devices/transtek/mambo-a5.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/types/clock-sync.js +3 -0
- package/lib/module/modules/bt-management/types/clock-sync.js.map +1 -1
- package/lib/module/modules/bt-management/types/device-measurement-map.js.map +1 -1
- package/lib/module/modules/bt-management/types/integrated-devices.js +2 -0
- package/lib/module/modules/bt-management/types/integrated-devices.js.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-sign-in.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/bt-device/constants/device-instruction-pdfs.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-device-catalog-transtek-a6-bp-variants.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-device-catalog-transtek-a6-bp-variants.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-device-catalog-transtek-a6-variants.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-device-catalog-transtek-a6-variants.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-device-catalog-variants.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-devices.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/constants/built-in-measurement-types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/constants/device-variants.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/constants/integrated-devices-map.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/constants/transtek-a6-bp-device-variants.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/bt-management/constants/transtek-a6-bp-device-variants.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/constants/transtek-a6-device-variants.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/bt-management/constants/transtek-a6-device-variants.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/core/resolve-device-key.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/device-classes.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/device-classes.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/bt-data-processor.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.device.d.ts +16 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.measurements.d.ts +19 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.measurements.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.sequencer.d.ts +33 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-scale.device.d.ts +16 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-scale.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-scale.measurements.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-scale.measurements.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-scale.protocol.d.ts +28 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-scale.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-scale.sequencer.d.ts +28 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/a6-scale.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/mambo-a5.device.d.ts +16 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/mambo-a5.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/mambo-a5.measurements.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/mambo-a5.measurements.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/mambo-a5.protocol.d.ts +18 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/mambo-a5.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/mambo-a5.sequencer.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/transtek/mambo-a5.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/clock-sync.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-measurement-map.d.ts +3 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-measurement-map.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/frame-reader.d.ts +2 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/frame-reader.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/integrated-devices.d.ts +2 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/integrated-devices.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/hooks/use-sign-in.d.ts +1 -1
- package/lib/typescript/module/src/modules/bt-device/constants/device-instruction-pdfs.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-device/constants/supported-device-catalog-transtek-a6-bp-variants.d.ts +5 -0
- package/lib/typescript/module/src/modules/bt-device/constants/supported-device-catalog-transtek-a6-bp-variants.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-device/constants/supported-device-catalog-transtek-a6-variants.d.ts +5 -0
- package/lib/typescript/module/src/modules/bt-device/constants/supported-device-catalog-transtek-a6-variants.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-device/constants/supported-device-catalog-variants.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-device/constants/supported-devices.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/constants/built-in-measurement-types.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/constants/device-variants.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/constants/integrated-devices-map.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/constants/transtek-a6-bp-device-variants.d.ts +5 -0
- package/lib/typescript/module/src/modules/bt-management/constants/transtek-a6-bp-device-variants.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/constants/transtek-a6-device-variants.d.ts +5 -0
- package/lib/typescript/module/src/modules/bt-management/constants/transtek-a6-device-variants.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/core/resolve-device-key.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/device-classes.d.ts +6 -0
- package/lib/typescript/module/src/modules/bt-management/services/device-classes.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/bt-data-processor.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.device.d.ts +16 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.measurements.d.ts +19 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.measurements.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.sequencer.d.ts +33 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-blood-pressure.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-scale.device.d.ts +16 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-scale.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-scale.measurements.d.ts +5 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-scale.measurements.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-scale.protocol.d.ts +28 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-scale.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-scale.sequencer.d.ts +28 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/a6-scale.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/mambo-a5.device.d.ts +16 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/mambo-a5.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/mambo-a5.measurements.d.ts +6 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/mambo-a5.measurements.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/mambo-a5.protocol.d.ts +18 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/mambo-a5.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/mambo-a5.sequencer.d.ts +21 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/transtek/mambo-a5.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/clock-sync.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/device-measurement-map.d.ts +3 -1
- package/lib/typescript/module/src/modules/bt-management/types/device-measurement-map.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/frame-reader.d.ts +2 -1
- package/lib/typescript/module/src/modules/bt-management/types/frame-reader.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/integrated-devices.d.ts +2 -0
- package/lib/typescript/module/src/modules/bt-management/types/integrated-devices.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable import/group-exports */
|
|
4
|
+
|
|
5
|
+
import CryptoJS from "crypto-js";
|
|
6
|
+
import { FrameReadStatus } from "../../../types/frame-read-status.js";
|
|
7
|
+
import { base64ToHex } from "../../../utils/base-64-to-hex.js";
|
|
8
|
+
export const A6_SCALE_SERVICE = "0000a602-0000-1000-8000-00805f9b34fb";
|
|
9
|
+
export const A6_BPM_SERVICE = "0000a610-0000-1000-8000-00805f9b34fb";
|
|
10
|
+
export const A6_SCALE_NOTIFY = "0000a621-0000-1000-8000-00805f9b34fb";
|
|
11
|
+
export const A6_SCALE_WRITE = "0000a624-0000-1000-8000-00805f9b34fb";
|
|
12
|
+
export const A6_SCALE_ACK = "0000a622-0000-1000-8000-00805f9b34fb";
|
|
13
|
+
export const A6_SCALE_WEIGHT = 0x4802;
|
|
14
|
+
export const A6_BPM_SYNC = 0x4901;
|
|
15
|
+
export const A6_BPM_MEASUREMENT = 0x4902;
|
|
16
|
+
export const A6_BPM_START_MEASURING_RESPONSE = 0x4906;
|
|
17
|
+
export const A6_BPM_TIME = 0x1102;
|
|
18
|
+
export const A6_BPM_SETTING_RESPONSE = 0x1100;
|
|
19
|
+
const byte = value => Number.parseInt(value ?? "00", 16) || 0;
|
|
20
|
+
export const readA6Uint = (bytes, offset, length) => bytes.slice(offset, offset + length).reduce((value, current) => value * 256 + byte(current), 0);
|
|
21
|
+
const bytesToHex = bytes => bytes.map(value => (value & 0xff).toString(16).padStart(2, "0")).join("");
|
|
22
|
+
const hexToBytes = hex => hex.match(/.{2}/g)?.map(value => Number.parseInt(value, 16)) ?? [];
|
|
23
|
+
export const a6EncryptionKey = (deviceId, manufacturerData) => {
|
|
24
|
+
const mac = deviceId.replace(/[:-]/g, "").toLowerCase();
|
|
25
|
+
const manufacturer = manufacturerData ? base64ToHex(manufacturerData).join("").toLowerCase() : "";
|
|
26
|
+
if (!/^[\da-f]{12}$/.test(mac) || !manufacturer.startsWith("ae12")) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const prefix = Array.from("TranstekA6", character => character.charCodeAt(0).toString(16).padStart(2, "0")).join("");
|
|
30
|
+
return `${prefix}${mac}`;
|
|
31
|
+
};
|
|
32
|
+
export const encryptA6Body = (body, key) => {
|
|
33
|
+
if (!key) {
|
|
34
|
+
return [...body];
|
|
35
|
+
}
|
|
36
|
+
if (body.length > 16) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const padded = [...body, ...Array(16 - body.length).fill(0)];
|
|
40
|
+
const encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Hex.parse(bytesToHex(padded)), CryptoJS.enc.Hex.parse(key), {
|
|
41
|
+
mode: CryptoJS.mode.ECB,
|
|
42
|
+
padding: CryptoJS.pad.NoPadding
|
|
43
|
+
});
|
|
44
|
+
return hexToBytes(CryptoJS.enc.Hex.stringify(encrypted.ciphertext));
|
|
45
|
+
};
|
|
46
|
+
export const decryptA6Body = (body, key) => {
|
|
47
|
+
if (!key) {
|
|
48
|
+
return body.map(byte);
|
|
49
|
+
}
|
|
50
|
+
if (body.length !== 16) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const ciphertext = CryptoJS.lib.CipherParams.create({
|
|
54
|
+
ciphertext: CryptoJS.enc.Hex.parse(body.join(""))
|
|
55
|
+
});
|
|
56
|
+
const decrypted = CryptoJS.AES.decrypt(ciphertext, CryptoJS.enc.Hex.parse(key), {
|
|
57
|
+
mode: CryptoJS.mode.ECB,
|
|
58
|
+
padding: CryptoJS.pad.NoPadding
|
|
59
|
+
});
|
|
60
|
+
return hexToBytes(CryptoJS.enc.Hex.stringify(decrypted));
|
|
61
|
+
};
|
|
62
|
+
export const encodeA6Command = (command, body, key) => {
|
|
63
|
+
const encodedBody = encryptA6Body(body, key);
|
|
64
|
+
if (!encodedBody) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const content = [command >> 8, command & 0xff, ...encodedBody];
|
|
68
|
+
if (content.length > 18) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
return ["10", content.length.toString(16).padStart(2, "0"), ...content.map(value => (value & 0xff).toString(16).padStart(2, "0"))];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Extracts each length-prefixed A6 notification frame; command fragments are joined by its sequencer. */
|
|
75
|
+
export class A6ScaleFrameReader {
|
|
76
|
+
readFrame(buffer) {
|
|
77
|
+
if (buffer.length < 2) {
|
|
78
|
+
return {
|
|
79
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
80
|
+
consumedBytes: 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const control = byte(buffer[0]);
|
|
84
|
+
const frameCount = control >> 4;
|
|
85
|
+
const frameIndex = control & 0x0f;
|
|
86
|
+
const contentLength = byte(buffer[1]);
|
|
87
|
+
if (frameCount === 0 && contentLength === 1 && buffer.length < 3) {
|
|
88
|
+
return {
|
|
89
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
90
|
+
consumedBytes: 0
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (frameCount === 0 && (contentLength !== 1 || buffer.length < 3 || byte(buffer[2]) !== 1) || frameCount !== 0 && (frameIndex >= frameCount || contentLength === 0 || contentLength > 18)) {
|
|
94
|
+
return {
|
|
95
|
+
status: FrameReadStatus.CORRUPT,
|
|
96
|
+
consumedBytes: 1
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (buffer.length < contentLength + 2) {
|
|
100
|
+
return {
|
|
101
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
102
|
+
consumedBytes: 0
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
status: FrameReadStatus.COMPLETE,
|
|
107
|
+
consumedBytes: contentLength + 2,
|
|
108
|
+
frame: buffer.slice(0, contentLength + 2)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export const decodeA6Command = (content, key) => {
|
|
113
|
+
if (content.length < 2) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
const command = readA6Uint(content, 0, 2);
|
|
117
|
+
const body = decryptA6Body(content.slice(2), key);
|
|
118
|
+
return body ? {
|
|
119
|
+
command,
|
|
120
|
+
body
|
|
121
|
+
} : undefined;
|
|
122
|
+
};
|
|
123
|
+
export const a6CommandBody = frame => {
|
|
124
|
+
const contentLength = byte(frame[1]);
|
|
125
|
+
return frame.slice(2, 2 + contentLength);
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=a6-scale.protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CryptoJS","FrameReadStatus","base64ToHex","A6_SCALE_SERVICE","A6_BPM_SERVICE","A6_SCALE_NOTIFY","A6_SCALE_WRITE","A6_SCALE_ACK","A6_SCALE_WEIGHT","A6_BPM_SYNC","A6_BPM_MEASUREMENT","A6_BPM_START_MEASURING_RESPONSE","A6_BPM_TIME","A6_BPM_SETTING_RESPONSE","byte","value","Number","parseInt","readA6Uint","bytes","offset","length","slice","reduce","current","bytesToHex","map","toString","padStart","join","hexToBytes","hex","match","a6EncryptionKey","deviceId","manufacturerData","mac","replace","toLowerCase","manufacturer","test","startsWith","undefined","prefix","Array","from","character","charCodeAt","encryptA6Body","body","key","padded","fill","encrypted","AES","encrypt","enc","Hex","parse","mode","ECB","padding","pad","NoPadding","stringify","ciphertext","decryptA6Body","lib","CipherParams","create","decrypted","decrypt","encodeA6Command","command","encodedBody","content","A6ScaleFrameReader","readFrame","buffer","status","INCOMPLETE","consumedBytes","control","frameCount","frameIndex","contentLength","CORRUPT","COMPLETE","frame","decodeA6Command","a6CommandBody"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/transtek/a6-scale.protocol.ts"],"mappings":";;AAAA;;AAEA,OAAOA,QAAQ,MAAM,WAAW;AAGhC,SAASC,eAAe,QAAQ,qCAAkC;AAElE,SAASC,WAAW,QAAQ,kCAA+B;AAE3D,OAAO,MAAMC,gBAAgB,GAAG,sCAAsC;AACtE,OAAO,MAAMC,cAAc,GAAG,sCAAsC;AACpE,OAAO,MAAMC,eAAe,GAAG,sCAAsC;AACrE,OAAO,MAAMC,cAAc,GAAG,sCAAsC;AACpE,OAAO,MAAMC,YAAY,GAAG,sCAAsC;AAClE,OAAO,MAAMC,eAAe,GAAG,MAAM;AACrC,OAAO,MAAMC,WAAW,GAAG,MAAM;AACjC,OAAO,MAAMC,kBAAkB,GAAG,MAAM;AACxC,OAAO,MAAMC,+BAA+B,GAAG,MAAM;AACrD,OAAO,MAAMC,WAAW,GAAG,MAAM;AACjC,OAAO,MAAMC,uBAAuB,GAAG,MAAM;AAE7C,MAAMC,IAAI,GAAIC,KAAyB,IACrCC,MAAM,CAACC,QAAQ,CAACF,KAAK,IAAI,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;AAEzC,OAAO,MAAMG,UAAU,GAAGA,CACxBC,KAAwB,EACxBC,MAAc,EACdC,MAAc,KAEdF,KAAK,CACFG,KAAK,CAACF,MAAM,EAAEA,MAAM,GAAGC,MAAM,CAAC,CAC9BE,MAAM,CAAC,CAACR,KAAK,EAAES,OA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,GAAGA,CAC7Bd,OAA0B,EAC1BzB,GAAY,KACwC;EACpD,IAAIyB,OAAO,CAACtD,MAAM,GAAG,CAAC,EAAE;IACtB,OAAOqB,SAAS;EAClB;EAEA,MAAM+B,OAAO,GAAGvD,UAAU,CAACyD,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;EACzC,MAAM1B,IAAI,GAAGiB,aAAa,CAACS,OAAO,CAACrD,KAAK,CAAC,CAAC,CAAC,EAAE4B,GAAG,CAAC;EAEjD,OAAOD,IAAI,GAAG;IAAEwB,OAAO;IAAExB;EAAK,CAAC,GAAGP,SAAS;AAC7C,CAAC;AAED,OAAO,MAAMgD,aAAa,GAAIF,KAAwB,IAAe;EACnE,MAAMH,aAAa,GAAGvE,IAAI,CAAC0E,KAAK,CAAC,CAAC,CAAC,CAAC;EAEpC,OAAOA,KAAK,CAAClE,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG+D,aAAa,CAAC;AAC1C,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MeasurementTypeKey } from "@ovok/core";
|
|
4
|
+
import { CaseType } from "../../../types/case-type.js";
|
|
5
|
+
import { parseA6Weight } from "./a6-scale.measurements.js";
|
|
6
|
+
import { A6_SCALE_ACK, A6_SCALE_SERVICE, A6_SCALE_WEIGHT, A6_SCALE_WRITE, a6CommandBody, a6EncryptionKey, decodeA6Command, encodeA6Command } from "./a6-scale.protocol.js";
|
|
7
|
+
const command = (characteristicUuid, frame, delayBeforeWriteMs) => ({
|
|
8
|
+
serviceUuid: A6_SCALE_SERVICE,
|
|
9
|
+
characteristicUuid,
|
|
10
|
+
frame,
|
|
11
|
+
...(delayBeforeWriteMs ? {
|
|
12
|
+
delayBeforeWriteMs
|
|
13
|
+
} : {})
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/** Answers A6 authentication/init requests and decodes the scale's weight records. */
|
|
17
|
+
export class A6ScaleSequencer {
|
|
18
|
+
expectedFragmentCount = 0;
|
|
19
|
+
userNumber = 0;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.key = a6EncryptionKey(options.deviceId, options.manufacturerData);
|
|
23
|
+
}
|
|
24
|
+
initialCommands = () => [];
|
|
25
|
+
isHistoryTransfer = () => true;
|
|
26
|
+
nextCommand = frame => {
|
|
27
|
+
const content = a6CommandBody(frame);
|
|
28
|
+
const control = Number.parseInt(frame[0] ?? "00", 16) || 0;
|
|
29
|
+
const count = control >> 4;
|
|
30
|
+
const index = control & 0x0f;
|
|
31
|
+
const replies = [];
|
|
32
|
+
if (count === 0) {
|
|
33
|
+
return replies;
|
|
34
|
+
}
|
|
35
|
+
if (!(count === 1 && content.length === 1 && content[0] === "01")) {
|
|
36
|
+
replies.push(command(A6_SCALE_ACK, ["00", "01", "01"]));
|
|
37
|
+
}
|
|
38
|
+
if (count === 1) {
|
|
39
|
+
replies.push(...this.processMessage(content));
|
|
40
|
+
return replies;
|
|
41
|
+
}
|
|
42
|
+
if (index === 0) {
|
|
43
|
+
this.fragments = Array.from({
|
|
44
|
+
length: count
|
|
45
|
+
}, () => []);
|
|
46
|
+
this.expectedFragmentCount = count;
|
|
47
|
+
}
|
|
48
|
+
if (!this.fragments || this.expectedFragmentCount !== count) {
|
|
49
|
+
this.fragments = undefined;
|
|
50
|
+
this.expectedFragmentCount = 0;
|
|
51
|
+
return replies;
|
|
52
|
+
}
|
|
53
|
+
this.fragments[index] = content;
|
|
54
|
+
if (this.fragments.some(part => part.length === 0)) {
|
|
55
|
+
return replies;
|
|
56
|
+
}
|
|
57
|
+
const assembled = this.fragments.flat();
|
|
58
|
+
this.fragments = undefined;
|
|
59
|
+
this.expectedFragmentCount = 0;
|
|
60
|
+
replies.push(...this.processMessage(assembled));
|
|
61
|
+
return replies;
|
|
62
|
+
};
|
|
63
|
+
processMessage = content => {
|
|
64
|
+
const message = decodeA6Command(content, this.key);
|
|
65
|
+
if (!message) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
if (message.command === 0x0007) {
|
|
69
|
+
if (message.body.length < 8) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
this.userNumber = message.body[6] ?? 0;
|
|
73
|
+
const response = encodeA6Command(0x0008, [0x01, ...message.body.slice(0, 6), 0x00, 0x02], this.key);
|
|
74
|
+
return response ? [command(A6_SCALE_WRITE, response)] : [];
|
|
75
|
+
}
|
|
76
|
+
if (message.command === 0x0009) {
|
|
77
|
+
const now = this.options.clockSync?.now?.() ?? new Date();
|
|
78
|
+
const seconds = Math.floor(now.getTime() / 1000);
|
|
79
|
+
const timezone = this.options.clockSync?.timezone === "utc" ? 48 : 48 - Math.round(now.getTimezoneOffset() / 15);
|
|
80
|
+
const response = encodeA6Command(0x000a, [0x18, seconds >>> 24 & 0xff, seconds >>> 16 & 0xff, seconds >>> 8 & 0xff, seconds & 0xff, timezone], this.key);
|
|
81
|
+
const sync = encodeA6Command(0x4801, [this.userNumber, 1], this.key);
|
|
82
|
+
return [...(response ? [command(A6_SCALE_WRITE, response)] : []), ...(sync ? [command(A6_SCALE_WRITE, sync, 500)] : [])];
|
|
83
|
+
}
|
|
84
|
+
if (message.command === A6_SCALE_WEIGHT) {
|
|
85
|
+
const weight = parseA6Weight(message.body);
|
|
86
|
+
if (weight) {
|
|
87
|
+
this.options.onResult({
|
|
88
|
+
caseType: CaseType.RESULT,
|
|
89
|
+
measurementTypeKey: MeasurementTypeKey.bodyWeight,
|
|
90
|
+
...weight
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return [];
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=a6-scale.sequencer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MeasurementTypeKey","CaseType","parseA6Weight","A6_SCALE_ACK","A6_SCALE_SERVICE","A6_SCALE_WEIGHT","A6_SCALE_WRITE","a6CommandBody","a6EncryptionKey","decodeA6Command","encodeA6Command","command","characteristicUuid","frame","delayBeforeWriteMs","serviceUuid","A6ScaleSequencer","expectedFragmentCount","userNumber","constructor","options","key","deviceId","manufacturerData","initialCommands","isHistoryTransfer","nextCommand","content","control","Number","parseInt","count","index","replies","length","push","processMessage","fragments","Array","from","undefined","some","part","assembled","flat","message","body","response","slice","now","clockSync","Date","seconds","Math","floor","getTime","timezone","round","getTimezoneOffset","sync","weight","onResult","caseType","RESULT","measurementTypeKey","bodyWeight"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/transtek/a6-scale.sequencer.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,YAAY;AAE/C,SAASC,QAAQ,QAAQ,6BAA0B;AAQnD,SAASC,aAAa,QAAQ,4BAAyB;AACvD,SACEC,YAAY,EACZC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,EACdC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,eAAe,QACV,wBAAqB;AAa5B,MAAMC,OAAO,GAAGA,CACdC,kBAA0B,EAC1BC,KAAwB,EACxBC,kBAA2B,MACR;EACnBC,WAAW,EAAEX,gBAAgB;EAC7BQ,kBAAkB;EAClBC,KAAK;EACL,IAAIC,kBAAkB,GAAG;IAAEA;EAAmB,CAAC,GAAG,CAAC,CAAC;AACtD,CAAC,CAAC;;AAEF;AACA,OAAO,MAAME,gBAAgB,CAA6B;EAEhDC,qBAAqB,GAAG,CAAC;EACzBC,UAAU,GAAG,CAAC;EAGfC,WAAWA,CAAkBC,OAAgC,EAAE;IAAA,KAAlCA,OAAgC,GAAhCA,OAAgC;IAClE,IAAI,CAACC,GAAG,GAAGb,eAAe,CAACY,OAAO,CAACE,QAAQ,EAAEF,OAAO,CAACG,gBAAgB,CAAC;EACxE;EAEOC,eAAe,GAAGA,CAAA,KAAgC,EAAE;EAEpDC,iBAAiB,GAAGA,CAAA,KAAe,IAAI;EAEvCC,WAAW,GAAIb,KAAwB,IAA+B;IAC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|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MeasurementTypeKey } from "@ovok/core";
|
|
4
|
+
import { BTManagedDevice } from "../bt-managed-device.js";
|
|
5
|
+
import { MAMBO_A5_LOGIN, MAMBO_A5_NOTIFY, MAMBO_A5_SERVICE, MAMBO_A5_WRITE, MamboA5FrameReader } from "./mambo-a5.protocol.js";
|
|
6
|
+
import { MamboA5Sequencer } from "./mambo-a5.sequencer.js";
|
|
7
|
+
const acceptNothing = {
|
|
8
|
+
caseValuePosition: [],
|
|
9
|
+
cases: []
|
|
10
|
+
};
|
|
11
|
+
const mainServices = [{
|
|
12
|
+
uuid: MAMBO_A5_SERVICE,
|
|
13
|
+
monitorUuids: [{
|
|
14
|
+
uuid: MAMBO_A5_LOGIN,
|
|
15
|
+
parsingModel: acceptNothing
|
|
16
|
+
}, {
|
|
17
|
+
uuid: MAMBO_A5_NOTIFY,
|
|
18
|
+
parsingModel: acceptNothing
|
|
19
|
+
}],
|
|
20
|
+
writeUuid: {
|
|
21
|
+
uuid: MAMBO_A5_WRITE,
|
|
22
|
+
mainCommandUuid: "8000"
|
|
23
|
+
}
|
|
24
|
+
}];
|
|
25
|
+
|
|
26
|
+
/** Mambo A5 tracker exposing the vendor A5 activity-data protocol. */
|
|
27
|
+
export class MamboA5Device extends BTManagedDevice {
|
|
28
|
+
mainServices = mainServices;
|
|
29
|
+
stuckDataTimeout = 60_000;
|
|
30
|
+
onStreamStart = undefined;
|
|
31
|
+
getSupportedMeasurementTypeKeys() {
|
|
32
|
+
return [MeasurementTypeKey.bloodOxygenPulseRate];
|
|
33
|
+
}
|
|
34
|
+
constructor(device, params) {
|
|
35
|
+
super(device, params);
|
|
36
|
+
this.frameReader = new MamboA5FrameReader();
|
|
37
|
+
this.createCommandSequencer = () => new MamboA5Sequencer({
|
|
38
|
+
clockSync: params.clockSync,
|
|
39
|
+
onResult: result => this.onResult?.(result)
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
handleSuccessResult() {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=mambo-a5.device.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MeasurementTypeKey","BTManagedDevice","MAMBO_A5_LOGIN","MAMBO_A5_NOTIFY","MAMBO_A5_SERVICE","MAMBO_A5_WRITE","MamboA5FrameReader","MamboA5Sequencer","acceptNothing","caseValuePosition","cases","mainServices","uuid","monitorUuids","parsingModel","writeUuid","mainCommandUuid","MamboA5Device","stuckDataTimeout","onStreamStart","undefined","getSupportedMeasurementTypeKeys","bloodOxygenPulseRate","constructor","device","params","frameReader","createCommandSequencer","clockSync","onResult","result","handleSuccessResult"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/transtek/mambo-a5.device.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,YAAY;AAQ/C,SAASC,eAAe,QAAQ,yBAAsB;AAEtD,SACEC,cAAc,EACdC,eAAe,EACfC,gBAAgB,EAChBC,cAAc,EACdC,kBAAkB,QACb,wBAAqB;AAC5B,SAASC,gBAAgB,QAAQ,yBAAsB;AAEvD,MAAMC,aAAa,GAAG;EAAEC,iBAAiB,EAAE,EAAE;EAAEC,KAAK,EAAE;AAAG,CAAC;AAE1D,MAAMC,YAAwB,GAAG,CAC/B;EACEC,IAAI,EAAER,gBAAgB;EACtBS,YAAY,EAAE,CACZ;IAAED,IAAI,EAAEV,cAAc;IAAEY,YAAY,EAAEN;EAAc,CAAC,EACrD;IAAEI,IAAI,EAAET,eAAe;IAAEW,YAAY,EAAEN;EAAc,CAAC,CACvD;EACDO,SAAS,EAAE;IAAEH,IAAI,EAAEP,cAAc;IAAEW,eAAe,EAAE;EAAO;AAC7D,CAAC,CACF;;AAED;AACA,OAAO,MAAMC,aAAa,SAAShB,eAAe,CAA6B;EACnEU,YAAY,GAAGA,YAAY;EAC3BO,gBAAgB,GAAG,MAAM;EACzBC,aAAa,GAAGC,SAAS;EAEhBC,+BAA+BA,CAAA,EAAyB;IACzE,OAAO,CAACrB,kBAAkB,CAACsB,oBAAoB,CAAC;EAClD;EAEOC,WAAWA,CAChBC,MAAc,EACdC,MAAsD,EACtD;IACA,KAAK,CAACD,MAAM,EAAEC,MAAM,CAAC;IACrB,IAAI,CAACC,WAAW,GAAG,IAAIpB,kBAAkB,CAAC,CAAC;IAC3C,IAAI,CAACqB,sBAAsB,GAAG,MAC5B,IAAIpB,gBAAgB,CAAC;MACnBqB,SAAS,EAAEH,MAAM,CAACG,SAAS;MAC3BC,QAAQ,EAAGC,MAAM,IACf,IAAI,CAACD,QAAQ,GACXC,MAGF;IACJ,CAAC,CAAC;EACN;EAEUC,mBAAmBA,CAAA,EAAS;IACpC;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const parseMamboA5Oxygen = payload => {
|
|
4
|
+
const command = payload[0];
|
|
5
|
+
let offset;
|
|
6
|
+
let baseTimestamp;
|
|
7
|
+
let intervalSeconds = 0;
|
|
8
|
+
let recordBytes;
|
|
9
|
+
if (command === 0x83) {
|
|
10
|
+
offset = 7;
|
|
11
|
+
recordBytes = 6;
|
|
12
|
+
} else if (command === 0x8e) {
|
|
13
|
+
offset = 10;
|
|
14
|
+
recordBytes = 3;
|
|
15
|
+
baseTimestamp = payload.slice(5, 9).reduce((value, current) => value * 256 + current, 0);
|
|
16
|
+
intervalSeconds = (payload[9] ?? 0) * 300;
|
|
17
|
+
} else {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
if (payload.length < offset || (payload.length - offset) % recordBytes !== 0) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
const records = [];
|
|
24
|
+
let index = 0;
|
|
25
|
+
while (offset < payload.length) {
|
|
26
|
+
const timestamp = command === 0x83 ? payload.slice(offset, offset + 4).reduce((value, current) => value * 256 + current, 0) : (baseTimestamp ?? 0) + index * intervalSeconds;
|
|
27
|
+
const valueOffset = command === 0x83 ? offset + 4 : offset + 1;
|
|
28
|
+
const bloodOxygen = payload[valueOffset] ?? 0;
|
|
29
|
+
const pulseRate = payload[valueOffset + 1] ?? 0;
|
|
30
|
+
const recordedAt = new Date(timestamp * 1000);
|
|
31
|
+
if (bloodOxygen >= 50 && bloodOxygen <= 100 && pulseRate >= 20 && pulseRate <= 300 && timestamp > 0 && !Number.isNaN(recordedAt.getTime())) {
|
|
32
|
+
records.push({
|
|
33
|
+
bloodOxygen,
|
|
34
|
+
pulseRate,
|
|
35
|
+
recordedAt
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
offset += recordBytes;
|
|
39
|
+
index += 1;
|
|
40
|
+
}
|
|
41
|
+
return records;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=mambo-a5.measurements.js.map
|
package/lib/module/modules/bt-management/services/devices/transtek/mambo-a5.measurements.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseMamboA5Oxygen","payload","command","offset","baseTimestamp","intervalSeconds","recordBytes","slice","reduce","value","current","length","records","index","timestamp","valueOffset","bloodOxygen","pulseRate","recordedAt","Date","Number","isNaN","getTime","push"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/transtek/mambo-a5.measurements.ts"],"mappings":";;AAAA,OAAO,MAAMA,kBAAkB,GAC7BC,OAA0B,IAC8C;EACxE,MAAMC,OAAO,GAAGD,OAAO,CAAC,CAAC,CAAC;EAC1B,IAAIE,MAAc;EAClB,IAAIC,aAAiC;EACrC,IAAIC,eAAe,GAAG,CAAC;EACvB,IAAIC,WAAmB;EAEvB,IAAIJ,OAAO,KAAK,IAAI,EAAE;IACpBC,MAAM,GAAG,CAAC;IACVG,WAAW,GAAG,CAAC;EACjB,CAAC,MAAM,IAAIJ,OAAO,KAAK,IAAI,EAAE;IAC3BC,MAAM,GAAG,EAAE;IACXG,W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AI,GAAG,IAChBH,SAAS,GAAG,CAAC,IACb,CAACM,MAAM,CAACC,KAAK,CAACH,UAAU,CAACI,OAAO,CAAC,CAAC,CAAC,EACnC;MACAV,OAAO,CAACW,IAAI,CAAC;QAAEP,WAAW;QAAEC,SAAS;QAAEC;MAAW,CAAC,CAAC;IACtD;IAEAf,MAAM,IAAIG,WAAW;IACrBO,KAAK,IAAI,CAAC;EACZ;EAEA,OAAOD,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable import/group-exports */
|
|
4
|
+
|
|
5
|
+
import { FrameReadStatus } from "../../../types/frame-read-status.js";
|
|
6
|
+
export const MAMBO_A5_SERVICE = "0000a500-0000-1000-8000-00805f9b34fb";
|
|
7
|
+
export const MAMBO_A5_LOGIN = "0000a501-0000-1000-8000-00805f9b34fb";
|
|
8
|
+
export const MAMBO_A5_WRITE = "0000a502-0000-1000-8000-00805f9b34fb";
|
|
9
|
+
export const MAMBO_A5_NOTIFY = "0000a503-0000-1000-8000-00805f9b34fb";
|
|
10
|
+
export const MAMBO_A5_VERSION = [0xaa, 0x01];
|
|
11
|
+
const MAX_LOGICAL_LENGTH = 109;
|
|
12
|
+
const byte = value => Number.parseInt(value ?? "00", 16) || 0;
|
|
13
|
+
const hex = value => (value & 0xff).toString(16).padStart(2, "0");
|
|
14
|
+
const crcTable = Array.from({
|
|
15
|
+
length: 256
|
|
16
|
+
}, (_, index) => {
|
|
17
|
+
let value = index;
|
|
18
|
+
for (let bit = 0; bit < 8; bit += 1) {
|
|
19
|
+
value = (value & 1) !== 0 ? value >>> 1 ^ 0xedb88320 : value >>> 1;
|
|
20
|
+
}
|
|
21
|
+
return value >>> 0;
|
|
22
|
+
});
|
|
23
|
+
export const mamboA5Crc32 = bytes => bytes.reduce((crc, value) => (crc >>> 8 ^ (crcTable[(crc ^ value) & 0xff] ?? 0)) >>> 0, 0);
|
|
24
|
+
/** Reassembles A5's indexed BLE fragments and verifies the vendor CRC before decoding. */
|
|
25
|
+
export class MamboA5FrameReader {
|
|
26
|
+
pending = new Map();
|
|
27
|
+
reset = () => {
|
|
28
|
+
this.pending.clear();
|
|
29
|
+
};
|
|
30
|
+
readFrame = (buffer, uuid = "") => {
|
|
31
|
+
const key = uuid.toLowerCase();
|
|
32
|
+
let pending = this.pending.get(key);
|
|
33
|
+
if (pending && this.isStart(buffer)) {
|
|
34
|
+
this.pending.delete(key);
|
|
35
|
+
pending = undefined;
|
|
36
|
+
}
|
|
37
|
+
if (pending) {
|
|
38
|
+
const chunkLength = Math.min(19, pending.remaining);
|
|
39
|
+
const frameLength = chunkLength + 1;
|
|
40
|
+
if (buffer.length < frameLength) {
|
|
41
|
+
return {
|
|
42
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
43
|
+
consumedBytes: 0
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (byte(buffer[0]) !== pending.nextIndex) {
|
|
47
|
+
this.pending.delete(key);
|
|
48
|
+
return {
|
|
49
|
+
status: FrameReadStatus.CORRUPT,
|
|
50
|
+
consumedBytes: 1
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const packet = [...pending.packet, ...buffer.slice(1, frameLength)];
|
|
54
|
+
const remaining = pending.remaining - chunkLength;
|
|
55
|
+
if (remaining > 0) {
|
|
56
|
+
this.pending.set(key, {
|
|
57
|
+
...pending,
|
|
58
|
+
remaining,
|
|
59
|
+
nextIndex: pending.nextIndex + 1,
|
|
60
|
+
packet
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
64
|
+
consumedBytes: frameLength
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
this.pending.delete(key);
|
|
68
|
+
return this.complete(pending.serial, packet, frameLength);
|
|
69
|
+
}
|
|
70
|
+
const start = buffer.findIndex((value, index) => byte(value) === 0x80 && [0x00, 0x01].includes(byte(buffer[index + 1])));
|
|
71
|
+
if (start === -1) {
|
|
72
|
+
return {
|
|
73
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
74
|
+
consumedBytes: Math.max(0, buffer.length - 1)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (buffer.length < start + 3) {
|
|
78
|
+
return {
|
|
79
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
80
|
+
consumedBytes: start
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const totalLength = byte(buffer[start + 2]);
|
|
84
|
+
if (totalLength < 4 || totalLength > MAX_LOGICAL_LENGTH) {
|
|
85
|
+
return {
|
|
86
|
+
status: FrameReadStatus.CORRUPT,
|
|
87
|
+
consumedBytes: start + 1
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const serial = buffer.slice(start, start + 2);
|
|
91
|
+
if (totalLength <= 16) {
|
|
92
|
+
const frameLength = totalLength + 4;
|
|
93
|
+
if (buffer.length < start + frameLength) {
|
|
94
|
+
return {
|
|
95
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
96
|
+
consumedBytes: start
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return this.complete(serial, buffer.slice(start + 4, start + frameLength), start + frameLength);
|
|
100
|
+
}
|
|
101
|
+
const firstLength = 20;
|
|
102
|
+
if (buffer.length < start + firstLength) {
|
|
103
|
+
return {
|
|
104
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
105
|
+
consumedBytes: start
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (byte(buffer[start + 3]) !== 1) {
|
|
109
|
+
return {
|
|
110
|
+
status: FrameReadStatus.CORRUPT,
|
|
111
|
+
consumedBytes: start + 1
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const packet = buffer.slice(start + 4, start + firstLength);
|
|
115
|
+
const remaining = totalLength - packet.length;
|
|
116
|
+
this.pending.set(key, {
|
|
117
|
+
serial,
|
|
118
|
+
remaining,
|
|
119
|
+
nextIndex: 2,
|
|
120
|
+
packet
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
124
|
+
consumedBytes: start + firstLength
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
isStart = buffer => byte(buffer[0]) === 0x80 && [0x00, 0x01].includes(byte(buffer[1]));
|
|
128
|
+
complete = (serial, packetAndCrc, consumedBytes) => {
|
|
129
|
+
if (packetAndCrc.length < 4) {
|
|
130
|
+
return {
|
|
131
|
+
status: FrameReadStatus.CORRUPT,
|
|
132
|
+
consumedBytes
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const payload = packetAndCrc.slice(0, -4);
|
|
136
|
+
const expectedCrc = Number.parseInt(packetAndCrc.slice(-4).join(""), 16) >>> 0;
|
|
137
|
+
const actualCrc = mamboA5Crc32(payload.map(byte));
|
|
138
|
+
if (actualCrc !== expectedCrc) {
|
|
139
|
+
return {
|
|
140
|
+
status: FrameReadStatus.CORRUPT,
|
|
141
|
+
consumedBytes
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
status: FrameReadStatus.COMPLETE,
|
|
146
|
+
consumedBytes,
|
|
147
|
+
frame: [...serial, ...payload]
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
export const encodeMamboA5Packet = (serial, payload, versioned) => {
|
|
152
|
+
const logical = [...(versioned ? MAMBO_A5_VERSION : []), ...payload];
|
|
153
|
+
const packetLength = logical.length + 4;
|
|
154
|
+
if (serial.length !== 2 || packetLength > MAX_LOGICAL_LENGTH) {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
const crc = mamboA5Crc32(logical);
|
|
158
|
+
const packet = [...logical, crc >>> 24 & 0xff, crc >>> 16 & 0xff, crc >>> 8 & 0xff, crc & 0xff];
|
|
159
|
+
if (packetLength <= 16) {
|
|
160
|
+
return [[...serial, hex(packetLength), "01", ...packet.map(hex)]];
|
|
161
|
+
}
|
|
162
|
+
const fragments = [];
|
|
163
|
+
let offset = 0;
|
|
164
|
+
let index = 1;
|
|
165
|
+
while (offset < packet.length) {
|
|
166
|
+
const capacity = index === 1 ? 16 : 19;
|
|
167
|
+
const chunk = packet.slice(offset, offset + capacity);
|
|
168
|
+
fragments.push(index === 1 ? [...serial, hex(packetLength), hex(index), ...chunk.map(hex)] : [hex(index), ...chunk.map(hex)]);
|
|
169
|
+
offset += chunk.length;
|
|
170
|
+
index += 1;
|
|
171
|
+
}
|
|
172
|
+
return fragments;
|
|
173
|
+
};
|
|
174
|
+
//# sourceMappingURL=mambo-a5.protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FrameReadStatus","MAMBO_A5_SERVICE","MAMBO_A5_LOGIN","MAMBO_A5_WRITE","MAMBO_A5_NOTIFY","MAMBO_A5_VERSION","MAX_LOGICAL_LENGTH","byte","value","Number","parseInt","hex","toString","padStart","crcTable","Array","from","length","_","index","bit","mamboA5Crc32","bytes","reduce","crc","MamboA5FrameReader","pending","Map","reset","clear","readFrame","buffer","uuid","key","toLowerCase","get","isStart","delete","undefined","chunkLength","Math","min","remaining","frameLength","status","INCOMPLETE","consumedBytes","nextIndex","CORRUPT","packet","slice","set","complete","serial","start","findIndex","includes","max","totalLength","firstLength","packetAndCrc","payload","expectedCrc","join","actualCrc","map","COMPLETE","frame","encodeMamboA5Packet","versioned","logical","packetLength","fragments","offset","capacity","chunk","push"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/transtek/mambo-a5.protocol.ts"],"mappings":";;AAAA;;AAGA,SAASA,eAAe,QAAQ,qCAAkC;AAGlE,OAAO,MAAMC,gBAAgB,GAAG,sCAAsC;AACtE,OAAO,MAAMC,cAAc,GAAG,sCAAsC;AACpE,OAAO,MAAMC,cAAc,GAAG,sCAAsC;AACpE,OAAO,MAAMC,eAAe,GAAG,sCAAsC;AACrE,OAAO,MAAMC,gBAAgB,GAA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C","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MeasurementTypeKey } from "@ovok/core";
|
|
4
|
+
import { CaseType } from "../../../types/case-type.js";
|
|
5
|
+
import { parseMamboA5Oxygen } from "./mambo-a5.measurements.js";
|
|
6
|
+
import { encodeMamboA5Packet, MAMBO_A5_SERVICE, MAMBO_A5_WRITE } from "./mambo-a5.protocol.js";
|
|
7
|
+
const command = frame => ({
|
|
8
|
+
serviceUuid: MAMBO_A5_SERVICE,
|
|
9
|
+
characteristicUuid: MAMBO_A5_WRITE,
|
|
10
|
+
frame
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/** Performs the safe login/time exchange and decodes A5 blood-oxygen history. */
|
|
14
|
+
export class MamboA5Sequencer {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// shortcut: 0x62 pairing needs mode and burn-code inputs; add them before unpaired tracking.
|
|
20
|
+
initialCommands = () => [];
|
|
21
|
+
isHistoryTransfer = () => true;
|
|
22
|
+
nextCommand = (frame, uuid) => {
|
|
23
|
+
if (frame.length < 3) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const serial = frame.slice(0, 2);
|
|
27
|
+
const hasVersion = frame[2]?.toLowerCase() === "aa" && frame[3]?.toLowerCase() === "01";
|
|
28
|
+
const payload = frame.slice(hasVersion ? 4 : 2).map(value => Number.parseInt(value, 16));
|
|
29
|
+
const packetMarker = serial.join("").toLowerCase();
|
|
30
|
+
const isLogin = packetMarker === "8001" || /a501$/i.test(uuid ?? "");
|
|
31
|
+
if (isLogin) {
|
|
32
|
+
if (payload[0] === 0x62 || payload[0] === 0x63) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const now = this.options.clockSync?.now?.() ?? new Date();
|
|
36
|
+
const seconds = Math.floor(now.getTime() / 1000);
|
|
37
|
+
const timezone = this.options.clockSync?.timezone === "utc" ? 48 : 48 - Math.round(now.getTimezoneOffset() / 15);
|
|
38
|
+
const loginResponse = [0x01, seconds >>> 24 & 0xff, seconds >>> 16 & 0xff, seconds >>> 8 & 0xff, seconds & 0xff, timezone, 0x02];
|
|
39
|
+
return encodeMamboA5Packet(serial, loginResponse, hasVersion).map(command);
|
|
40
|
+
}
|
|
41
|
+
if (packetMarker !== "8000") {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
if (payload.length === 0) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const dataType = payload[0] ?? 0;
|
|
48
|
+
const oxygenRecords = parseMamboA5Oxygen(payload);
|
|
49
|
+
oxygenRecords.forEach(record => {
|
|
50
|
+
this.options.onResult({
|
|
51
|
+
caseType: CaseType.RESULT,
|
|
52
|
+
measurementTypeKey: MeasurementTypeKey.bloodOxygenPulseRate,
|
|
53
|
+
...record
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Oxygen history uses the same command/device-type acknowledgement as the vendor sync worker.
|
|
58
|
+
if (dataType === 0x50) {
|
|
59
|
+
// shortcut: 0x50 needs user settings, add a profile input before answering it.
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
if (dataType !== 0x83 && dataType !== 0x8e) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
return encodeMamboA5Packet(serial, [dataType, 0x01], hasVersion).flatMap(frameBytes => [command(frameBytes)]);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=mambo-a5.sequencer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MeasurementTypeKey","CaseType","parseMamboA5Oxygen","encodeMamboA5Packet","MAMBO_A5_SERVICE","MAMBO_A5_WRITE","command","frame","serviceUuid","characteristicUuid","MamboA5Sequencer","constructor","options","initialCommands","isHistoryTransfer","nextCommand","uuid","length","serial","slice","hasVersion","toLowerCase","payload","map","value","Number","parseInt","packetMarker","join","isLogin","test","now","clockSync","Date","seconds","Math","floor","getTime","timezone","round","getTimezoneOffset","loginResponse","dataType","oxygenRecords","forEach","record","onResult","caseType","RESULT","measurementTypeKey","bloodOxygenPulseRate","flatMap","frameBytes"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/transtek/mambo-a5.sequencer.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,YAAY;AAE/C,SAASC,QAAQ,QAAQ,6BAA0B;AAQnD,SAASC,kBAAkB,QAAQ,4BAAyB;AAC5D,SACEC,mBAAmB,EACnBC,gBAAgB,EAChBC,cAAc,QACT,wBAAqB;AAW5B,MAAMC,OAAO,GAAIC,KAAwB,KAAqB;EAC5DC,WAAW,EAAEJ,gBAAgB;EAC7BK,kBAAkB,EAAEJ,cAAc;EAClCE;AACF,CAAC,CAAC;;AAEF;AACA,OAAO,MAAMG,gBAAgB,CAA6B;EACjDC,WAAWA,CAAkBC,OAAgC,EAAE;IAAA,KAAlCA,OAAgC,GAAhCA,OAAgC;EAAG;;EAEvE;EACOC,eAAe,GAAGA,CAAA,KAAgC,EAAE;EAEpDC,iBAAiB,GAAGA,CAAA,KAAe,IAAI;EAEvCC,WAAW,GAAGA,CACnBR,KAAwB,EACxBS,IAAa,KACgB;IAC7B,IAAIT,KAAK,CAACU,MAAM,GAAG,CAAC,EAAE;MACpB,OAAO,EAAE;IACX;IAEA,MAAMC,MAAM,GAAGX,KAAK,CAACY,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IAEhC,MAAMC,UAAU,GACdb,KAAK,CAAC,CAAC,CAAC,EAAEc,WAAW,CAAC,CAAC,KAAK,IAAI,IAAId,KAAK,CAAC,CAAC,CAAC,EAAEc,WAAW,CAAC,CAAC,KAAK,IAAI;IAEtE,MAAMC,OAAO,GAAGf,KAAK,CAACY,KAAK,CAACC,UAAU,GAAG,CAAC,GAAG,CAAC,CAAC,CAACG,GAAG,CAAEC,KAAK,IACxD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AAE;IACX;IAEA,MAAMyB,QAAQ,GAAGpB,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAChC,MAAMqB,aAAa,GAAGzC,kBAAkB,CAACoB,OAAO,CAAC;IAEjDqB,aAAa,CAACC,OAAO,CAAEC,MAAM,IAAK;MAChC,IAAI,CAACjC,OAAO,CAACkC,QAAQ,CAAC;QACpBC,QAAQ,EAAE9C,QAAQ,CAAC+C,MAAM;QACzBC,kBAAkB,EAAEjD,kBAAkB,CAACkD,oBAAoB;QAC3D,GAAGL;MACL,CAAkB,CAAC;IACrB,CAAC,CAAC;;IAEF;IACA,IAAIH,QAAQ,KAAK,IAAI,EAAE;MACrB;MACA,OAAO,EAAE;IACX;IACA,IAAIA,QAAQ,KAAK,IAAI,IAAIA,QAAQ,KAAK,IAAI,EAAE;MAC1C,OAAO,EAAE;IACX;IAEA,OAAOvC,mBAAmB,CAACe,MAAM,EAAE,CAACwB,QAAQ,EAAE,IAAI,CAAC,EAAEtB,UAAU,CAAC,CAAC+B,OAAO,CACrEC,UAAU,IAAK,CAAC9C,OAAO,CAAC8C,UAAU,CAAC,CACtC,CAAC;EACH,CAAC;AACH","ignoreList":[]}
|
|
@@ -30,6 +30,9 @@ export const clockSyncCapabilityForDevice = deviceName => {
|
|
|
30
30
|
case IntegratedDevices.VEROVAL_ECG:
|
|
31
31
|
case IntegratedDevices.AOJ20A:
|
|
32
32
|
case IntegratedDevices.BP2:
|
|
33
|
+
case IntegratedDevices.RPM_SCALE:
|
|
34
|
+
case IntegratedDevices.TRANSTEK_A6_BPM:
|
|
35
|
+
case IntegratedDevices.MAMBO_A5:
|
|
33
36
|
case IntegratedDevices.VIATOM_R20:
|
|
34
37
|
case IntegratedDevices.VIATOM_R200:
|
|
35
38
|
case IntegratedDevices.VIATOM_BBSM_BS1:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["IntegratedDevices","isClockSyncEnabled","options","enabled","getClockParts","date","timezone","year","getUTCFullYear","month","getUTCMonth","day","getUTCDate","hours","getUTCHours","minutes","getUTCMinutes","seconds","getUTCSeconds","milliseconds","getUTCMilliseconds","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getMilliseconds","clockSyncCapabilityForDevice","deviceName","BC01","MYSENSE","VEROVAL_ECG","AOJ20A","BP2","VIATOM_R20","VIATOM_R200","VIATOM_BBSM_BS1","VEROVAL_ACTIVITY","GENIAL_T31","ZH_SG_A606","TRASENSE_S9"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/clock-sync.ts"],"mappings":";;AAAA;;AAEA,SAASA,iBAAiB,QAAQ,yBAAsB;AAkBxD,OAAO,MAAMC,kBAAkB,GAAIC,OAA0B,IAC3DA,OAAO,EAAEC,OAAO,KAAK,KAAK;AAE5B,OAAO,MAAMC,aAAa,GAAGA,CAC3BC,IAAU,EACVC,QAA2B,GAAG,OAAO,KAErCA,QAAQ,KAAK,KAAK,GACd;EACEC,IAAI,EAAEF,IAAI,CAACG,cAAc,CAAC,CAAC;EAC3BC,KAAK,EAAEJ,IAAI,CAACK,WAAW,CAAC,CAAC,GAAG,CAAC;EAC7BC,GAAG,EAAEN,IAAI,CAACO,UAAU,CAAC,CAAC;EACtBC,KAAK,EAAER,IAAI,CAACS,WAAW,CAAC,CAAC;EACzBC,OAAO,EAAEV,IAAI,CAACW,aAAa,CAAC,CAAC;EAC7BC,OAAO,EAAEZ,IAAI,CAACa,aAAa,CAAC,CAAC;EAC7BC,YAAY,EAAEd,IAAI,CAACe,kBAAkB,CAAC;AACxC,CAAC,GACD;EACEb,IAAI,EAAEF,IAAI,CAACgB,WAAW,CAAC,CAAC;EACxBZ,KAAK,EAAEJ,IAAI,CAACiB,QAAQ,CAAC,CAAC,GAAG,CAAC;EAC1BX,GAAG,EAAEN,IAAI,CAACkB,OAAO,CAAC,CAAC;EACnBV,KAAK,EAAER,IAAI,CAACmB,QAAQ,CAAC,CAAC;EACtBT,OAAO,EAAEV,IAAI,CAACoB,UAAU,CAAC,CAAC;EAC1BR,OAAO,EAAEZ,IAAI,CAACqB,UAAU,CAAC,CAAC;EAC1BP,YAAY,EAAEd,IAAI,CAACsB,eAAe,CAAC;AACrC,CAAC;;AAEP;AACA,OAAO,MAAMC,4BAA4B,GACvCC,UAAkB,IACM;EACxB,QAAQA,UAAU;IAChB,KAAK7B,iBAAiB,CAAC8B,IAAI;IAC3B,KAAK9B,iBAAiB,CAAC+B,OAAO;IAC9B,KAAK/B,iBAAiB,CAACgC,WAAW;IAClC,KAAKhC,iBAAiB,CAACiC,MAAM;IAC7B,KAAKjC,iBAAiB,CAACkC,GAAG;IAC1B,KAAKlC,iBAAiB,CAACmC,
|
|
1
|
+
{"version":3,"names":["IntegratedDevices","isClockSyncEnabled","options","enabled","getClockParts","date","timezone","year","getUTCFullYear","month","getUTCMonth","day","getUTCDate","hours","getUTCHours","minutes","getUTCMinutes","seconds","getUTCSeconds","milliseconds","getUTCMilliseconds","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getMilliseconds","clockSyncCapabilityForDevice","deviceName","BC01","MYSENSE","VEROVAL_ECG","AOJ20A","BP2","RPM_SCALE","TRANSTEK_A6_BPM","MAMBO_A5","VIATOM_R20","VIATOM_R200","VIATOM_BBSM_BS1","VEROVAL_ACTIVITY","GENIAL_T31","ZH_SG_A606","TRASENSE_S9"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/clock-sync.ts"],"mappings":";;AAAA;;AAEA,SAASA,iBAAiB,QAAQ,yBAAsB;AAkBxD,OAAO,MAAMC,kBAAkB,GAAIC,OAA0B,IAC3DA,OAAO,EAAEC,OAAO,KAAK,KAAK;AAE5B,OAAO,MAAMC,aAAa,GAAGA,CAC3BC,IAAU,EACVC,QAA2B,GAAG,OAAO,KAErCA,QAAQ,KAAK,KAAK,GACd;EACEC,IAAI,EAAEF,IAAI,CAACG,cAAc,CAAC,CAAC;EAC3BC,KAAK,EAAEJ,IAAI,CAACK,WAAW,CAAC,CAAC,GAAG,CAAC;EAC7BC,GAAG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