@ovok/native 1.6.46 → 1.6.48
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/baby-sleep-clip-catalog-asset.js +10 -0
- package/lib/commonjs/modules/bt-device/constants/baby-sleep-clip-catalog-asset.js.map +1 -0
- package/lib/commonjs/modules/bt-device/constants/device-instruction-pdfs.js +14 -1
- package/lib/commonjs/modules/bt-device/constants/device-instruction-pdfs.js.map +1 -1
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-assets.js +5 -1
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-assets.js.map +1 -1
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-entries.js +19 -0
- package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-entries.js.map +1 -1
- package/lib/commonjs/modules/bt-device/constants/supported-devices.js +50 -0
- package/lib/commonjs/modules/bt-device/constants/supported-devices.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/services/background-sync/background-service-uuids.js +2 -0
- package/lib/commonjs/modules/bt-management/services/background-sync/background-service-uuids.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/device-classes.js +95 -0
- package/lib/commonjs/modules/bt-management/services/device-classes.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/device-creator.js +5 -78
- package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +6 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/viatom/baby-sleep-clip.device.js +57 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/baby-sleep-clip.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/baby-sleep-clip.protocol.js +106 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/baby-sleep-clip.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/baby-sleep-clip.sequencer.js +80 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/baby-sleep-clip.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/lpm311.device.js +55 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/lpm311.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/lpm311.protocol.js +103 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/lpm311.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/lpm311.sequencer.js +33 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/lpm311.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/oxy-s3.device.js +72 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/oxy-s3.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/oxy-s3.protocol.js +103 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/oxy-s3.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/oxy-s3.sequencer.js +110 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/oxy-s3.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/pf10aw1.device.js +53 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/pf10aw1.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/pf10aw1.protocol.js +64 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/pf10aw1.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/pf10aw1.sequencer.js +96 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/pf10aw1.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/sp20.device.js +54 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/sp20.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/sp20.protocol.js +102 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/sp20.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/sp20.sequencer.js +115 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/sp20.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom-lepu-crypto.js +81 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom-lepu-crypto.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom-r20.device.js +57 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom-r20.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom-r20.protocol.js +118 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom-r20.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom-r20.sequencer.js +95 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom-r20.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pm10.device.js +48 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pm10.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pm10.protocol.js +104 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pm10.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pm10.sequencer.js +57 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pm10.sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.wbp02.device.js +50 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.wbp02.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.wbp02.protocol.js +108 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.wbp02.protocol.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.wbp02.sequencer.js +64 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.wbp02.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/device-measurement-map.js.map +1 -1
- package/lib/commonjs/modules/bt-management/types/integrated-devices.js +13 -0
- package/lib/commonjs/modules/bt-management/types/integrated-devices.js.map +1 -1
- package/lib/module/modules/bt-device/constants/baby-sleep-clip-catalog-asset.js +7 -0
- package/lib/module/modules/bt-device/constants/baby-sleep-clip-catalog-asset.js.map +1 -0
- package/lib/module/modules/bt-device/constants/device-instruction-pdfs.js +14 -1
- package/lib/module/modules/bt-device/constants/device-instruction-pdfs.js.map +1 -1
- package/lib/module/modules/bt-device/constants/supported-device-catalog-assets.js +5 -1
- package/lib/module/modules/bt-device/constants/supported-device-catalog-assets.js.map +1 -1
- package/lib/module/modules/bt-device/constants/supported-device-catalog-entries.js +20 -1
- package/lib/module/modules/bt-device/constants/supported-device-catalog-entries.js.map +1 -1
- package/lib/module/modules/bt-device/constants/supported-devices.js +50 -0
- package/lib/module/modules/bt-device/constants/supported-devices.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/services/background-sync/background-service-uuids.js +2 -0
- package/lib/module/modules/bt-management/services/background-sync/background-service-uuids.js.map +1 -1
- package/lib/module/modules/bt-management/services/device-classes.js +92 -0
- package/lib/module/modules/bt-management/services/device-classes.js.map +1 -0
- package/lib/module/modules/bt-management/services/device-creator.js +3 -77
- package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +6 -1
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/viatom/baby-sleep-clip.device.js +52 -0
- package/lib/module/modules/bt-management/services/devices/viatom/baby-sleep-clip.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/baby-sleep-clip.protocol.js +99 -0
- package/lib/module/modules/bt-management/services/devices/viatom/baby-sleep-clip.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/baby-sleep-clip.sequencer.js +75 -0
- package/lib/module/modules/bt-management/services/devices/viatom/baby-sleep-clip.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/lpm311.device.js +50 -0
- package/lib/module/modules/bt-management/services/devices/viatom/lpm311.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/lpm311.protocol.js +98 -0
- package/lib/module/modules/bt-management/services/devices/viatom/lpm311.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/lpm311.sequencer.js +28 -0
- package/lib/module/modules/bt-management/services/devices/viatom/lpm311.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/oxy-s3.device.js +67 -0
- package/lib/module/modules/bt-management/services/devices/viatom/oxy-s3.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/oxy-s3.protocol.js +94 -0
- package/lib/module/modules/bt-management/services/devices/viatom/oxy-s3.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/oxy-s3.sequencer.js +105 -0
- package/lib/module/modules/bt-management/services/devices/viatom/oxy-s3.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/pf10aw1.device.js +48 -0
- package/lib/module/modules/bt-management/services/devices/viatom/pf10aw1.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/pf10aw1.protocol.js +57 -0
- package/lib/module/modules/bt-management/services/devices/viatom/pf10aw1.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/pf10aw1.sequencer.js +91 -0
- package/lib/module/modules/bt-management/services/devices/viatom/pf10aw1.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/sp20.device.js +49 -0
- package/lib/module/modules/bt-management/services/devices/viatom/sp20.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/sp20.protocol.js +94 -0
- package/lib/module/modules/bt-management/services/devices/viatom/sp20.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/sp20.sequencer.js +110 -0
- package/lib/module/modules/bt-management/services/devices/viatom/sp20.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom-lepu-crypto.js +71 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom-lepu-crypto.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom-r20.device.js +52 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom-r20.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom-r20.protocol.js +110 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom-r20.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom-r20.sequencer.js +90 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom-r20.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.pm10.device.js +43 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.pm10.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.pm10.protocol.js +92 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.pm10.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.pm10.sequencer.js +52 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.pm10.sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.wbp02.device.js +45 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.wbp02.device.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.wbp02.protocol.js +94 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.wbp02.protocol.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.wbp02.sequencer.js +59 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.wbp02.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 +13 -0
- package/lib/module/modules/bt-management/types/integrated-devices.js.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-device/constants/baby-sleep-clip-catalog-asset.d.ts +4 -0
- package/lib/typescript/commonjs/src/modules/bt-device/constants/baby-sleep-clip-catalog-asset.d.ts.map +1 -0
- 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-assets.d.ts +5 -1
- package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-device-catalog-assets.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-device-catalog-entries.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-devices.d.ts +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/integrated-devices-map.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/background-sync/background-service-uuids.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/device-classes.d.ts +89 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/device-classes.d.ts.map +1 -0
- 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-managed-device.d.ts +2 -0
- 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/viatom/baby-sleep-clip.device.d.ts +18 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.protocol.d.ts +27 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.sequencer.d.ts +32 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/lpm311.device.d.ts +9 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/lpm311.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/lpm311.protocol.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/lpm311.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/lpm311.sequencer.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/lpm311.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/oxy-s3.device.d.ts +18 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/oxy-s3.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/oxy-s3.protocol.d.ts +42 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/oxy-s3.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/oxy-s3.sequencer.d.ts +31 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/oxy-s3.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/pf10aw1.device.d.ts +19 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/pf10aw1.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/pf10aw1.protocol.d.ts +30 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/pf10aw1.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/pf10aw1.sequencer.d.ts +27 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/pf10aw1.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/sp20.device.d.ts +20 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/sp20.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/sp20.protocol.d.ts +28 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/sp20.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/sp20.sequencer.d.ts +26 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/sp20.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom-lepu-crypto.d.ts +7 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom-lepu-crypto.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom-r20.device.d.ts +20 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom-r20.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom-r20.protocol.d.ts +38 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom-r20.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom-r20.sequencer.d.ts +35 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom-r20.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pm10.device.d.ts +15 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pm10.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pm10.protocol.d.ts +25 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pm10.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pm10.sequencer.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pm10.sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.wbp02.device.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.wbp02.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.wbp02.protocol.d.ts +31 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.wbp02.protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.wbp02.sequencer.d.ts +20 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.wbp02.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 +14 -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/integrated-devices.d.ts +14 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/integrated-devices.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-device/constants/baby-sleep-clip-catalog-asset.d.ts +4 -0
- package/lib/typescript/module/src/modules/bt-device/constants/baby-sleep-clip-catalog-asset.d.ts.map +1 -0
- 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-assets.d.ts +5 -1
- package/lib/typescript/module/src/modules/bt-device/constants/supported-device-catalog-assets.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-device/constants/supported-device-catalog-entries.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-device/constants/supported-devices.d.ts +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/integrated-devices-map.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/background-sync/background-service-uuids.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/device-classes.d.ts +89 -0
- package/lib/typescript/module/src/modules/bt-management/services/device-classes.d.ts.map +1 -0
- 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-managed-device.d.ts +2 -0
- 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/viatom/baby-sleep-clip.device.d.ts +18 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.protocol.d.ts +27 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.sequencer.d.ts +32 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/baby-sleep-clip.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/lpm311.device.d.ts +9 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/lpm311.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/lpm311.protocol.d.ts +14 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/lpm311.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/lpm311.sequencer.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/lpm311.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/oxy-s3.device.d.ts +18 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/oxy-s3.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/oxy-s3.protocol.d.ts +42 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/oxy-s3.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/oxy-s3.sequencer.d.ts +31 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/oxy-s3.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/pf10aw1.device.d.ts +19 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/pf10aw1.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/pf10aw1.protocol.d.ts +30 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/pf10aw1.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/pf10aw1.sequencer.d.ts +27 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/pf10aw1.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/sp20.device.d.ts +20 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/sp20.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/sp20.protocol.d.ts +28 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/sp20.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/sp20.sequencer.d.ts +26 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/sp20.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom-lepu-crypto.d.ts +7 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom-lepu-crypto.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom-r20.device.d.ts +20 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom-r20.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom-r20.protocol.d.ts +38 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom-r20.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom-r20.sequencer.d.ts +35 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom-r20.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pm10.device.d.ts +15 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pm10.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pm10.protocol.d.ts +25 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pm10.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pm10.sequencer.d.ts +21 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pm10.sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.wbp02.device.d.ts +14 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.wbp02.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.wbp02.protocol.d.ts +31 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.wbp02.protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.wbp02.sequencer.d.ts +20 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.wbp02.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 +14 -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/integrated-devices.d.ts +14 -1
- package/lib/typescript/module/src/modules/bt-management/types/integrated-devices.d.ts.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MeasurementTypeKey } from "@ovok/core";
|
|
4
|
+
import { CaseType } from "../../../types/case-type.js";
|
|
5
|
+
import { LepuCommandBuilder } from "../lepu/lepu.command-builder.js";
|
|
6
|
+
import { decodePf10Aw1Response, parsePf10Aw1OximeterReading, Pf10Aw1Command } from "./pf10aw1.protocol.js";
|
|
7
|
+
import { createLepuAccessToken, decryptLepuHandshake, decryptLepuPayload, encryptLepuPayload, parseLepuSessionKey } from "./viatom-lepu-crypto.js";
|
|
8
|
+
const isValidOxygen = value => value >= 50 && value <= 100;
|
|
9
|
+
const isValidPulse = value => value > 0 && value <= 300;
|
|
10
|
+
|
|
11
|
+
/** Drives the vendor-encrypted A5 exchange used by the PF10AW1 oximeter models. */
|
|
12
|
+
export class Pf10Aw1Sequencer {
|
|
13
|
+
commands = new LepuCommandBuilder("a5");
|
|
14
|
+
phase = "authenticate";
|
|
15
|
+
constructor(params) {
|
|
16
|
+
this.params = params;
|
|
17
|
+
}
|
|
18
|
+
initialCommands = () => [this.write(this.commands.build(Pf10Aw1Command.authenticate, createLepuAccessToken(this.params.now?.() ?? new Date())))];
|
|
19
|
+
nextCommand = frame => {
|
|
20
|
+
const response = decodePf10Aw1Response(frame);
|
|
21
|
+
if (!response) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (this.phase === "authenticate") {
|
|
25
|
+
return this.acceptHandshake(response.command, response.status, response.payload);
|
|
26
|
+
}
|
|
27
|
+
if (this.phase === "clock" && response.command === Pf10Aw1Command.setUtcTime) {
|
|
28
|
+
if (response.status !== 1) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
this.phase = "parameters";
|
|
32
|
+
return [this.buildEncryptedCommand(Pf10Aw1Command.enableParameters, [1])];
|
|
33
|
+
}
|
|
34
|
+
if (this.phase === "parameters" && response.command === Pf10Aw1Command.enableParameters && response.status === 1) {
|
|
35
|
+
this.phase = "wave";
|
|
36
|
+
return [this.buildEncryptedCommand(Pf10Aw1Command.enableWave, [1])];
|
|
37
|
+
}
|
|
38
|
+
if (this.phase === "wave" && response.command === Pf10Aw1Command.enableWave && response.status === 1) {
|
|
39
|
+
this.phase = "ready";
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
if (this.phase === "ready" && response.command === Pf10Aw1Command.realtimeParameters && response.status === 1) {
|
|
43
|
+
this.report(this.decrypt(response.payload));
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
47
|
+
acceptHandshake = (command, status, payload) => {
|
|
48
|
+
if (command !== Pf10Aw1Command.authenticate || status !== 1) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const key = parseLepuSessionKey(decryptLepuHandshake(payload));
|
|
52
|
+
if (!key) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
this.sessionKey = key;
|
|
56
|
+
this.phase = "clock";
|
|
57
|
+
return [this.buildEncryptedCommand(Pf10Aw1Command.setUtcTime, this.timePayload())];
|
|
58
|
+
};
|
|
59
|
+
buildEncryptedCommand = (command, payload) => {
|
|
60
|
+
const encrypted = encryptLepuPayload(payload, this.sessionKey ?? []);
|
|
61
|
+
return this.write(this.commands.build(command, encrypted));
|
|
62
|
+
};
|
|
63
|
+
decrypt = payload => (this.sessionKey && decryptLepuPayload(payload, this.sessionKey)) ?? [];
|
|
64
|
+
timePayload = () => {
|
|
65
|
+
const date = this.params.now?.() ?? new Date();
|
|
66
|
+
const timezoneOffsetTenthHours = Math.round(-date.getTimezoneOffset() / 6);
|
|
67
|
+
return [date.getFullYear() & 0xff, date.getFullYear() >>> 8 & 0xff, date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), timezoneOffsetTenthHours & 0xff];
|
|
68
|
+
};
|
|
69
|
+
report = payload => {
|
|
70
|
+
const reading = parsePf10Aw1OximeterReading(payload);
|
|
71
|
+
if (!reading || reading.probeOff || !isValidOxygen(reading.bloodOxygen) || !isValidPulse(reading.pulseRate)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.params.onResult({
|
|
75
|
+
caseType: CaseType.RESULT,
|
|
76
|
+
measurementTypeKey: MeasurementTypeKey.bloodOxygenPulseRate,
|
|
77
|
+
bloodOxygen: reading.bloodOxygen,
|
|
78
|
+
pulseRate: reading.pulseRate,
|
|
79
|
+
...(reading.perfusionIndex > 0 ? {
|
|
80
|
+
perfusionIndex: reading.perfusionIndex
|
|
81
|
+
} : {}),
|
|
82
|
+
recordedAt: this.params.now?.() ?? new Date()
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
write = frame => ({
|
|
86
|
+
...this.params.write,
|
|
87
|
+
frame,
|
|
88
|
+
withoutResponse: true
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=pf10aw1.sequencer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MeasurementTypeKey","CaseType","LepuCommandBuilder","decodePf10Aw1Response","parsePf10Aw1OximeterReading","Pf10Aw1Command","createLepuAccessToken","decryptLepuHandshake","decryptLepuPayload","encryptLepuPayload","parseLepuSessionKey","isValidOxygen","value","isValidPulse","Pf10Aw1Sequencer","commands","phase","constructor","params","initialCommands","write","build","authenticate","now","Date","nextCommand","frame","response","undefined","acceptHandshake","command","status","payload","setUtcTime","buildEncryptedCommand","enableParameters","enableWave","realtimeParameters","report","decrypt","key","sessionKey","timePayload","encrypted","date","timezoneOffsetTenthHours","Math","round","getTimezoneOffset","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","reading","probeOff","bloodOxygen","pulseRate","onResult","caseType","RESULT","measurementTypeKey","bloodOxygenPulseRate","perfusionIndex","recordedAt","withoutResponse"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/pf10aw1.sequencer.ts"],"mappings":";;AAEA,SAASA,kBAAkB,QAAkC,YAAY;AAEzE,SAASC,QAAQ,QAAQ,6BAA0B;AAInD,SAASC,kBAAkB,QAAQ,iCAA8B;AAEjE,SACEC,qBAAqB,EACrBC,2BAA2B,EAC3BC,cAAc,QACT,uBAAoB;AAC3B,SACEC,qBAAqB,EACrBC,oBAAoB,EACpBC,kBAAkB,EAClBC,kBAAkB,EAClBC,mBAAmB,QACd,yBAAsB;AAU7B,MAAMC,aAAa,GAAIC,KAAa,IAAcA,KAAK,IAAI,EAAE,IAAIA,KAAK,IAAI,GAAG;AAC7E,MAAMC,YAAY,GAAID,KAAa,IAAcA,KAAK,GAAG,CAAC,IAAIA,KAAK,IAAI,GAAG;;AAE1E;AACA,OAAO,MAAME,gBAAgB,CAA6B;EACvCC,QAAQ,GAAG,IAAIb,kBAAkB,CAAC,IAAI,CAAC;EAChDc,KAAK,GAAU,cAAc;EAG9BC,WAAWA,CAAkBC,MAA8B,EAAE;IAAA,KAAhCA,MAA8B,GAA9BA,MAA8B;EAAG;EAE9DC,eAAe,GAAGA,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EA,cAAc,EAAET,OAAO,CAACS;MAAe,CAAC,GAC1C,CAAC,CAAC,CAAC;MACPC,UAAU,EAAE,IAAI,CAAC/C,MAAM,CAACK,GAAG,GAAG,CAAC,IAAI,IAAIC,IAAI,CAAC;IAC9C,CAAC,CAAC;EACJ,CAAC;EAEOJ,KAAK,GAAIM,KAAwB,KAAqB;IAC5D,GAAG,IAAI,CAACR,MAAM,CAACE,KAAK;IACpBM,KAAK;IACLwC,eAAe,EAAE;EACnB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable import/group-exports */
|
|
4
|
+
|
|
5
|
+
import { MeasurementTypeKey } from "@ovok/core";
|
|
6
|
+
import { BTManagedDevice } from "../bt-managed-device.js";
|
|
7
|
+
import { SP20_NOTIFY, SP20_SERVICE, SP20_WRITE, Sp20FrameReader } from "./sp20.protocol.js";
|
|
8
|
+
import { Sp20Sequencer } from "./sp20.sequencer.js";
|
|
9
|
+
const acceptNothing = {
|
|
10
|
+
caseValuePosition: [],
|
|
11
|
+
cases: []
|
|
12
|
+
};
|
|
13
|
+
export const sp20MainServices = [{
|
|
14
|
+
uuid: SP20_SERVICE,
|
|
15
|
+
monitorUuids: [{
|
|
16
|
+
uuid: SP20_NOTIFY,
|
|
17
|
+
parsingModel: acceptNothing
|
|
18
|
+
}],
|
|
19
|
+
writeUuid: {
|
|
20
|
+
uuid: SP20_WRITE,
|
|
21
|
+
mainCommandUuid: "aa55"
|
|
22
|
+
}
|
|
23
|
+
}];
|
|
24
|
+
|
|
25
|
+
/** ViHealth SP-20, SP-20-BLE, and SP-20-WPS encrypted realtime oximeter. */
|
|
26
|
+
export class Sp20Device extends BTManagedDevice {
|
|
27
|
+
mainServices = sp20MainServices;
|
|
28
|
+
stuckDataTimeout = 60_000;
|
|
29
|
+
onStreamStart = undefined;
|
|
30
|
+
preferredMtu = 247;
|
|
31
|
+
getSupportedMeasurementTypeKeys() {
|
|
32
|
+
return [MeasurementTypeKey.bloodOxygenPulseRate];
|
|
33
|
+
}
|
|
34
|
+
constructor(device, params) {
|
|
35
|
+
super(device, params);
|
|
36
|
+
this.frameReader = new Sp20FrameReader();
|
|
37
|
+
this.createCommandSequencer = () => new Sp20Sequencer({
|
|
38
|
+
write: {
|
|
39
|
+
serviceUuid: SP20_SERVICE,
|
|
40
|
+
characteristicUuid: SP20_WRITE
|
|
41
|
+
},
|
|
42
|
+
onResult: result => this.onResult?.(result)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
handleSuccessResult() {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=sp20.device.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MeasurementTypeKey","BTManagedDevice","SP20_NOTIFY","SP20_SERVICE","SP20_WRITE","Sp20FrameReader","Sp20Sequencer","acceptNothing","caseValuePosition","cases","sp20MainServices","uuid","monitorUuids","parsingModel","writeUuid","mainCommandUuid","Sp20Device","mainServices","stuckDataTimeout","onStreamStart","undefined","preferredMtu","getSupportedMeasurementTypeKeys","bloodOxygenPulseRate","constructor","device","params","frameReader","createCommandSequencer","write","serviceUuid","characteristicUuid","onResult","result","handleSuccessResult"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/sp20.device.ts"],"mappings":";;AAAA;;AAEA,SAASA,kBAAkB,QAAQ,YAAY;AAQ/C,SAASC,eAAe,QAAQ,yBAAsB;AAEtD,SACEC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,eAAe,QACV,oBAAiB;AACxB,SAASC,aAAa,QAAQ,qBAAkB;AAOhD,MAAMC,aAAa,GAAG;EAAEC,iBAAiB,EAAE,EAAE;EAAEC,KAAK,EAAE;AAAG,CAAC;AAE1D,OAAO,MAAMC,gBAA4B,GAAG,CAC1C;EACEC,IAAI,EAAER,YAAY;EAClBS,YAAY,EAAE,CAAC;IAAED,IAAI,EAAET,WAAW;IAAEW,YAAY,EAAEN;EAAc,CAAC,CAAC;EAClEO,SAAS,EAAE;IAAEH,IAAI,EAAEP,UAAU;IAAEW,eAAe,EAAE;EAAO;AACzD,CAAC,CACF;;AAED;AACA,OAAO,MAAMC,UAAU,SAASf,eAAe,CAAe;EAClDgB,YAAY,GAAGP,gBAAgB;EAC/BQ,gBAAgB,GAAG,MAAM;EACzBC,aAAa,GAAGC,SAAS;EAChBC,YAAY,GAAG,GAAG;EAClBC,+BAA+BA,CAAA,EAAyB;IACzE,OAAO,CAACtB,kBAAkB,CAACuB,oBAAoB,CAAC;EAClD;EAEOC,WAAWA,CAChBC,MAAc,EACdC,MAAwC,EACxC;IACA,KAAK,CAACD,MAAM,EAAEC,MAAM,CAAC;IACrB,IAAI,CAACC,WAAW,GAAG,IAAItB,eAAe,CAAC,CAAC;IACxC,IAAI,CAACuB,sBAAsB,GAAG,MAC5B,IAAItB,aAAa,CAAC;MAChBuB,KAAK,EAAE;QAAEC,WAAW,EAAE3B,YAAY;QAAE4B,kBAAkB,EAAE3B;MAAW,CAAC;MACpE4B,QAAQ,EAAGC,MAAM,IACf,IAAI,CAACD,QAAQ,GACXC,MAGF;IACJ,CAAC,CAAC;EACN;EAEUC,mBAAmBA,CAAA,EAAS;IACpC;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable import/group-exports */
|
|
4
|
+
|
|
5
|
+
import { FrameReadStatus } from "../../../types/frame-read-status.js";
|
|
6
|
+
import { calculateCrc8Pc } from "../../../utils/calculate-crc-8-pc.js";
|
|
7
|
+
import { hexToByte } from "../../../utils/hex-to-byte.js";
|
|
8
|
+
export const SP20_SERVICE = "0000fff0-0000-1000-8000-00805f9b34fb";
|
|
9
|
+
export const SP20_NOTIFY = "0000fff1-0000-1000-8000-00805f9b34fb";
|
|
10
|
+
export const SP20_WRITE = "0000fff2-0000-1000-8000-00805f9b34fb";
|
|
11
|
+
const byte = value => (value & 0xff).toString(16).padStart(2, "0");
|
|
12
|
+
export const buildSp20Frame = (token, type, payload = []) => {
|
|
13
|
+
const frame = ["aa", "55", byte(token), byte(payload.length + 2), byte(type), ...payload.map(byte), "00"];
|
|
14
|
+
frame[frame.length - 1] = byte(calculateCrc8Pc(frame));
|
|
15
|
+
return frame;
|
|
16
|
+
};
|
|
17
|
+
export const decodeSp20Frame = frame => {
|
|
18
|
+
if (hexToByte(frame[0] ?? "00") !== 0xaa || hexToByte(frame[1] ?? "00") !== 0x55 || frame.length < 6 || frame.length !== hexToByte(frame[3] ?? "00") + 4 || calculateCrc8Pc(frame) !== hexToByte(frame.at(-1) ?? "00")) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
token: hexToByte(frame[2] ?? "00"),
|
|
23
|
+
type: hexToByte(frame[4] ?? "00"),
|
|
24
|
+
content: frame.slice(5, -1).map(value => hexToByte(value)),
|
|
25
|
+
cipherText: frame.slice(4, -1).map(value => hexToByte(value))
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export const parseSp20OximeterReading = content => {
|
|
29
|
+
if (content.length < 6) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const flags = content[4] ?? 0;
|
|
33
|
+
return {
|
|
34
|
+
bloodOxygen: content[0] ?? 0,
|
|
35
|
+
pulseRate: (content[1] ?? 0) | (content[2] ?? 0) << 8,
|
|
36
|
+
perfusionIndex: content[3] ?? 0,
|
|
37
|
+
probeOff: (flags & 0x02) !== 0,
|
|
38
|
+
pulseSearching: (flags & 0x04) !== 0,
|
|
39
|
+
checkProbe: (flags & 0x08) !== 0
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** AA55 frames carry their length at byte 3; notifications may split or batch them. */
|
|
44
|
+
export class Sp20FrameReader {
|
|
45
|
+
readFrame(buffer) {
|
|
46
|
+
const start = this.findHeader(buffer);
|
|
47
|
+
if (start < 0) {
|
|
48
|
+
return {
|
|
49
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
50
|
+
consumedBytes: Math.max(0, buffer.length - 1)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (start + 4 > buffer.length) {
|
|
54
|
+
return {
|
|
55
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
56
|
+
consumedBytes: start
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const length = hexToByte(buffer[start + 3] ?? "00") + 4;
|
|
60
|
+
if (length < 6) {
|
|
61
|
+
return {
|
|
62
|
+
status: FrameReadStatus.CORRUPT,
|
|
63
|
+
consumedBytes: start + 2
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (start + length > buffer.length) {
|
|
67
|
+
return {
|
|
68
|
+
status: FrameReadStatus.INCOMPLETE,
|
|
69
|
+
consumedBytes: start
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const frame = buffer.slice(start, start + length);
|
|
73
|
+
if (calculateCrc8Pc(frame) !== hexToByte(frame.at(-1) ?? "00")) {
|
|
74
|
+
return {
|
|
75
|
+
status: FrameReadStatus.CORRUPT,
|
|
76
|
+
consumedBytes: start + 2
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
status: FrameReadStatus.COMPLETE,
|
|
81
|
+
consumedBytes: start + length,
|
|
82
|
+
frame
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
findHeader = buffer => {
|
|
86
|
+
for (let index = 0; index < buffer.length - 1; index += 1) {
|
|
87
|
+
if (hexToByte(buffer[index] ?? "00") === 0xaa && hexToByte(buffer[index + 1] ?? "00") === 0x55) {
|
|
88
|
+
return index;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return -1;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=sp20.protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FrameReadStatus","calculateCrc8Pc","hexToByte","SP20_SERVICE","SP20_NOTIFY","SP20_WRITE","byte","value","toString","padStart","buildSp20Frame","token","type","payload","frame","length","map","decodeSp20Frame","at","undefined","content","slice","cipherText","parseSp20OximeterReading","flags","bloodOxygen","pulseRate","perfusionIndex","probeOff","pulseSearching","checkProbe","Sp20FrameReader","readFrame","buffer","start","findHeader","status","INCOMPLETE","consumedBytes","Math","max","CORRUPT","COMPLETE","index"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/sp20.protocol.ts"],"mappings":";;AAAA;;AAGA,SAASA,eAAe,QAAQ,qCAAkC;AAElE,SAASC,eAAe,QAAQ,sCAAmC;AACnE,SAASC,SAAS,QAAQ,+BAA4B;AAEtD,OAAO,MAAMC,YAAY,GAAG,sCAAsC;AAClE,OAAO,MAAMC,WAAW,GAAG,sCAAsC;AACjE,OAAO,MAAMC,UAAU,GAAG,sCAAsC;AAEhE,MAAMC,IAAI,GAAIC,KAAa,IACzB,CAACA,KAAK,GAAG,IAAI,EAAEC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;AAS9C,OAAO,MAAMC,cAAc,GAAGA,CAC5BC,KAAa,EACbC,IAAY,EACZC,OAA0B,GAAG,EAAE,KAClB;EACb,MAAMC,KAAK,GAAG,CACZ,IAAI,EACJ,IAAI,EACJR,IAAI,CAACK,KAAK,CAAC,EACXL,IAAI,CAACO,OAAO,CAACE,MAAM,GAAG,CAAC,CAAC,EACxBT,IAAI,CAACM,IAAI,CAAC,EACV,GAAGC,OAAO,CAACG,GAAG,CAACV,IAAI,CAAC,EACpB,IAAI,CACL;EAEDQ,KAAK,CAACA,KAAK,CAACC,MAAM,GAAG,CAAC,CAAC,GAAGT,IAAI,CAACL,eAAe,CAACa,KAAK,CAAC,CAAC;EAEtD,OAAOA,KAAK;AACd,CAAC;AAED,OAAO,MAAMG,eAAe,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Z,KAAK,CAACa,KAAK,EAAEA,KAAK,GAAGnB,MAAM,CAAC;IAEjD,IAAId,eAAe,CAACa,KAAK,CAAC,KAAKZ,SAAS,CAACY,KAAK,CAACI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE;MAC9D,OAAO;QAAEkB,MAAM,EAAEpC,eAAe,CAACyC,OAAO;QAAEH,aAAa,EAAEJ,KAAK,GAAG;MAAE,CAAC;IACtE;IAEA,OAAO;MACLE,MAAM,EAAEpC,eAAe,CAAC0C,QAAQ;MAChCJ,aAAa,EAAEJ,KAAK,GAAGnB,MAAM;MAC7BD;IACF,CAAC;EACH;EAEQqB,UAAU,GAAIF,MAAyB,IAAa;IAC1D,KAAK,IAAIU,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGV,MAAM,CAAClB,MAAM,GAAG,CAAC,EAAE4B,KAAK,IAAI,CAAC,EAAE;MACzD,IACEzC,SAAS,CAAC+B,MAAM,CAACU,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,IACzCzC,SAAS,CAAC+B,MAAM,CAACU,KAAK,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,EAC7C;QACA,OAAOA,KAAK;MACd;IACF;IAEA,OAAO,CAAC,CAAC;EACX,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MeasurementTypeKey } from "@ovok/core";
|
|
4
|
+
import { CaseType } from "../../../types/case-type.js";
|
|
5
|
+
import { calculateCrc8Pc } from "../../../utils/calculate-crc-8-pc.js";
|
|
6
|
+
import { buildSp20Frame, decodeSp20Frame, parseSp20OximeterReading } from "./sp20.protocol.js";
|
|
7
|
+
import { decryptLepuHandshake, decryptLepuPayload, encryptLepuPayload, parseLepuSessionKey, createLepuAccessToken } from "./viatom-lepu-crypto.js";
|
|
8
|
+
const command = (write, frame) => ({
|
|
9
|
+
...write,
|
|
10
|
+
frame,
|
|
11
|
+
withoutResponse: true
|
|
12
|
+
});
|
|
13
|
+
const validOxygen = value => value >= 50 && value <= 100;
|
|
14
|
+
const validPulse = value => value > 0 && value <= 300;
|
|
15
|
+
|
|
16
|
+
/** Handles the encrypted AA55 exchange used by the ViHealth SP-20 variants. */
|
|
17
|
+
export class Sp20Sequencer {
|
|
18
|
+
phase = "authenticate";
|
|
19
|
+
constructor(params) {
|
|
20
|
+
this.params = params;
|
|
21
|
+
}
|
|
22
|
+
initialCommands = () => {
|
|
23
|
+
const token = createLepuAccessToken(this.params.now?.() ?? new Date());
|
|
24
|
+
return [this.write(buildSp20Frame(0xff, 0x81, token))];
|
|
25
|
+
};
|
|
26
|
+
nextCommand = frame => {
|
|
27
|
+
const raw = decodeSp20Frame(frame);
|
|
28
|
+
if (!raw) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const response = this.decodePayload(raw);
|
|
32
|
+
if (!response) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
if (this.phase === "authenticate") {
|
|
36
|
+
return this.acceptHandshake(raw, response);
|
|
37
|
+
}
|
|
38
|
+
if (this.phase === "clock" && response.token === 0x0f && response.type === 7) {
|
|
39
|
+
this.phase = "parameters";
|
|
40
|
+
return [this.encryptedCommand(0x84, [1])];
|
|
41
|
+
}
|
|
42
|
+
if (this.phase === "parameters" && response.token === 0x0f && response.type === 4) {
|
|
43
|
+
this.phase = "wave";
|
|
44
|
+
return [this.encryptedCommand(0x85, [1])];
|
|
45
|
+
}
|
|
46
|
+
if (this.phase === "wave" && response.token === 0x0f && response.type === 5) {
|
|
47
|
+
this.phase = "ready";
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
if (this.phase === "ready" && response.token === 0xf0 && response.type === 1) {
|
|
51
|
+
this.report(response.content);
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
};
|
|
55
|
+
decodePayload = response => {
|
|
56
|
+
if (response.token === 0xff && !this.sessionKey) {
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
if (!this.sessionKey) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const decrypted = decryptLepuPayload(response.cipherText, this.sessionKey);
|
|
63
|
+
return decrypted?.length ? {
|
|
64
|
+
token: response.token,
|
|
65
|
+
type: decrypted[0] ?? 0,
|
|
66
|
+
content: decrypted.slice(1),
|
|
67
|
+
cipherText: response.cipherText
|
|
68
|
+
} : undefined;
|
|
69
|
+
};
|
|
70
|
+
acceptHandshake = (raw, response) => {
|
|
71
|
+
if (raw.token !== 0xff || raw.type !== 1) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const key = parseLepuSessionKey(decryptLepuHandshake(response.content));
|
|
75
|
+
if (!key) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
this.sessionKey = key;
|
|
79
|
+
this.phase = "clock";
|
|
80
|
+
return [this.encryptedCommand(0x87, this.timePayload())];
|
|
81
|
+
};
|
|
82
|
+
encryptedCommand = (type, payload) => {
|
|
83
|
+
const encrypted = encryptLepuPayload([type, ...payload], this.sessionKey ?? []);
|
|
84
|
+
const frame = ["aa", "55", "0f", (encrypted.length + 1 & 0xff).toString(16).padStart(2, "0"), ...encrypted.map(value => value.toString(16).padStart(2, "0")), "00"];
|
|
85
|
+
frame[frame.length - 1] = calculateCrc8Pc(frame).toString(16).padStart(2, "0");
|
|
86
|
+
return this.write(frame);
|
|
87
|
+
};
|
|
88
|
+
timePayload = () => {
|
|
89
|
+
const date = this.params.now?.() ?? new Date();
|
|
90
|
+
return [date.getFullYear() >>> 8 & 0xff, date.getFullYear() & 0xff, date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()];
|
|
91
|
+
};
|
|
92
|
+
report = content => {
|
|
93
|
+
const reading = parseSp20OximeterReading(content);
|
|
94
|
+
if (!reading || reading.probeOff || reading.pulseSearching || reading.checkProbe || !validOxygen(reading.bloodOxygen) || !validPulse(reading.pulseRate)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.params.onResult({
|
|
98
|
+
caseType: CaseType.RESULT,
|
|
99
|
+
measurementTypeKey: MeasurementTypeKey.bloodOxygenPulseRate,
|
|
100
|
+
bloodOxygen: reading.bloodOxygen,
|
|
101
|
+
pulseRate: reading.pulseRate,
|
|
102
|
+
...(reading.perfusionIndex > 0 ? {
|
|
103
|
+
perfusionIndex: reading.perfusionIndex
|
|
104
|
+
} : {}),
|
|
105
|
+
recordedAt: this.params.now?.() ?? new Date()
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
write = frame => command(this.params.write, frame);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=sp20.sequencer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MeasurementTypeKey","CaseType","calculateCrc8Pc","buildSp20Frame","decodeSp20Frame","parseSp20OximeterReading","decryptLepuHandshake","decryptLepuPayload","encryptLepuPayload","parseLepuSessionKey","createLepuAccessToken","command","write","frame","withoutResponse","validOxygen","value","validPulse","Sp20Sequencer","phase","constructor","params","initialCommands","token","now","Date","nextCommand","raw","undefined","response","decodePayload","acceptHandshake","type","encryptedCommand","report","content","sessionKey","decrypted","cipherText","length","slice","key","timePayload","payload","encrypted","toString","padStart","map","date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","reading","probeOff","pulseSearching","checkProbe","bloodOxygen","pulseRate","onResult","caseType","RESULT","measurementTypeKey","bloodOxygenPulseRate","perfusionIndex","recordedAt"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/sp20.sequencer.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAkC,YAAY;AAEzE,SAASC,QAAQ,QAAQ,6BAA0B;AAInD,SAASC,eAAe,QAAQ,sCAAmC;AAEnE,SACEC,cAAc,EACdC,eAAe,EACfC,wBAAwB,QAEnB,oBAAiB;AACxB,SACEC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AC5B,IAAIL,OAAO,CAACW,cAAc,GAAG,CAAC,GAC1B;QAAEA,cAAc,EAAEX,OAAO,CAACW;MAAe,CAAC,GAC1C,CAAC,CAAC,CAAC;MACPC,UAAU,EAAE,IAAI,CAAC9C,MAAM,CAACG,GAAG,GAAG,CAAC,IAAI,IAAIC,IAAI,CAAC;IAC9C,CAAC,CAAC;EACJ,CAAC;EAEOb,KAAK,GAAIC,KAAwB,IACvCF,OAAO,CAAC,IAAI,CAACU,MAAM,CAACT,KAAK,EAAEC,KAAK,CAAC;AAErC","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable import/group-exports */
|
|
4
|
+
|
|
5
|
+
import CryptoJS from "crypto-js";
|
|
6
|
+
const LEPU_CIPHER_KEY = "c2a7cf50dafed885a8f8f7eac44335f3";
|
|
7
|
+
const DEFAULT_ENCRYPTION_ID = "0000";
|
|
8
|
+
const AES_BLOCK_BYTES = 16;
|
|
9
|
+
const toHex = bytes => bytes.map(value => (value & 0xff).toString(16).padStart(2, "0")).join("");
|
|
10
|
+
const fromHex = hex => hex.match(/.{2}/g)?.map(value => Number.parseInt(value, 16)) ?? [];
|
|
11
|
+
const lepuXor = bytes => {
|
|
12
|
+
const key = fromHex(LEPU_CIPHER_KEY);
|
|
13
|
+
return bytes.map((value, index) => value ^ (key[index % key.length] ?? 0));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Builds the vendor's four-character client token without logging identity or key bytes. */
|
|
17
|
+
export const createLepuAccessToken = (now = new Date(), encryptionId = DEFAULT_ENCRYPTION_ID) => {
|
|
18
|
+
const idBytes = Array.from(encryptionId, character => character.charCodeAt(0));
|
|
19
|
+
if (idBytes.length !== 4 || idBytes.some(value => value > 0x7f)) {
|
|
20
|
+
throw new Error("Lepu encryption ID must be four ASCII characters.");
|
|
21
|
+
}
|
|
22
|
+
const key = fromHex(LEPU_CIPHER_KEY);
|
|
23
|
+
const token = Array(16).fill(0);
|
|
24
|
+
for (let index = 0; index < 8; index += 1) {
|
|
25
|
+
token[index] = key[index * 2] ?? 0;
|
|
26
|
+
}
|
|
27
|
+
token.splice(8, 4, ...idBytes);
|
|
28
|
+
const epochSeconds = Math.floor(now.getTime() / 1000);
|
|
29
|
+
for (let index = 0; index < 4; index += 1) {
|
|
30
|
+
token[index + 12] = epochSeconds >> index & 0xff;
|
|
31
|
+
}
|
|
32
|
+
return lepuXor(token);
|
|
33
|
+
};
|
|
34
|
+
export const decryptLepuHandshake = encrypted => lepuXor(encrypted);
|
|
35
|
+
export const parseLepuSessionKey = handshake => {
|
|
36
|
+
if (handshake.length < 4 || handshake[0] !== 1) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const length = handshake[1] ?? 0;
|
|
40
|
+
const key = handshake.slice(4, 4 + length);
|
|
41
|
+
return key.length === length && [16, 24, 32].includes(length) ? key : undefined;
|
|
42
|
+
};
|
|
43
|
+
export const encryptLepuPayload = (payload, sessionKey) => {
|
|
44
|
+
if (![16, 24, 32].includes(sessionKey.length)) {
|
|
45
|
+
throw new Error("Invalid Lepu AES session key length.");
|
|
46
|
+
}
|
|
47
|
+
const encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Hex.parse(toHex(payload)), CryptoJS.enc.Hex.parse(toHex(sessionKey)), {
|
|
48
|
+
mode: CryptoJS.mode.ECB,
|
|
49
|
+
padding: CryptoJS.pad.Pkcs7
|
|
50
|
+
});
|
|
51
|
+
return fromHex(CryptoJS.enc.Hex.stringify(encrypted.ciphertext));
|
|
52
|
+
};
|
|
53
|
+
export const decryptLepuPayload = (encrypted, sessionKey) => {
|
|
54
|
+
if (![16, 24, 32].includes(sessionKey.length) || encrypted.length === 0 || encrypted.length % AES_BLOCK_BYTES !== 0) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const ciphertext = CryptoJS.lib.CipherParams.create({
|
|
58
|
+
ciphertext: CryptoJS.enc.Hex.parse(toHex(encrypted))
|
|
59
|
+
});
|
|
60
|
+
const decrypted = CryptoJS.AES.decrypt(ciphertext, CryptoJS.enc.Hex.parse(toHex(sessionKey)), {
|
|
61
|
+
mode: CryptoJS.mode.ECB,
|
|
62
|
+
padding: CryptoJS.pad.NoPadding
|
|
63
|
+
});
|
|
64
|
+
const unpadded = fromHex(CryptoJS.enc.Hex.stringify(decrypted));
|
|
65
|
+
const paddingLength = unpadded.at(-1) ?? 0;
|
|
66
|
+
if (paddingLength === 0 || paddingLength > AES_BLOCK_BYTES || unpadded.length < paddingLength || unpadded.slice(-paddingLength).some(value => value !== paddingLength)) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return unpadded.slice(0, -paddingLength);
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=viatom-lepu-crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CryptoJS","LEPU_CIPHER_KEY","DEFAULT_ENCRYPTION_ID","AES_BLOCK_BYTES","toHex","bytes","map","value","toString","padStart","join","fromHex","hex","match","Number","parseInt","lepuXor","key","index","length","createLepuAccessToken","now","Date","encryptionId","idBytes","Array","from","character","charCodeAt","some","Error","token","fill","splice","epochSeconds","Math","floor","getTime","decryptLepuHandshake","encrypted","parseLepuSessionKey","handshake","undefined","slice","includes","encryptLepuPayload","payload","sessionKey","AES","encrypt","enc","Hex","parse","mode","ECB","padding","pad","Pkcs7","stringify","ciphertext","decryptLepuPayload","lib","CipherParams","create","decrypted","decrypt","NoPadding","unpadded","paddingLength","at"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/viatom-lepu-crypto.ts"],"mappings":";;AAAA;;AAEA,OAAOA,QAAQ,MAAM,WAAW;AAEhC,MAAMC,eAAe,GAAG,kCAAkC;AAC1D,MAAMC,qBAAqB,GAAG,MAAM;AACpC,MAAMC,eAAe,GAAG,EAAE;AAE1B,MAAMC,KAAK,GAAIC,KAAwB,IACrC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AC2C,UAAU,CAAC,CAAC,EACzC;IAAEM,IAAI,EAAErD,QAAQ,CAACqD,IAAI,CAACC,GAAG;IAAEC,OAAO,EAAEvD,QAAQ,CAACwD,GAAG,CAACU;EAAU,CAC7D,CAAC;EAED,MAAMC,QAAQ,GAAGxD,OAAO,CAACX,QAAQ,CAACkD,GAAG,CAACC,GAAG,CAACO,SAAS,CAACM,SAAS,CAAC,CAAC;EAC/D,MAAMI,aAAa,GAAGD,QAAQ,CAACE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;EAE1C,IACED,aAAa,KAAK,CAAC,IACnBA,aAAa,GAAGjE,eAAe,IAC/BgE,QAAQ,CAAChD,MAAM,GAAGiD,aAAa,IAC/BD,QAAQ,CAACxB,KAAK,CAAC,CAACyB,aAAa,CAAC,CAACvC,IAAI,CAAEtB,KAAK,IAAKA,KAAK,KAAK6D,aAAa,CAAC,EACvE;IACA,OAAO1B,SAAS;EAClB;EAEA,OAAOyB,QAAQ,CAACxB,KAAK,CAAC,CAAC,EAAE,CAACyB,aAAa,CAAC;AAC1C,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable import/group-exports */
|
|
4
|
+
|
|
5
|
+
import { BTManagedDevice } from "../bt-managed-device.js";
|
|
6
|
+
import { parseViatomR20Advertisement, ViatomR20FrameReader, VIATOM_R20_MEASUREMENT_TYPE, VIATOM_R20_NOTIFY, VIATOM_R20_SERVICE, VIATOM_R20_WRITE } from "./viatom-r20.protocol.js";
|
|
7
|
+
import { ViatomR20Sequencer } from "./viatom-r20.sequencer.js";
|
|
8
|
+
const acceptNothing = {
|
|
9
|
+
caseValuePosition: [],
|
|
10
|
+
cases: []
|
|
11
|
+
};
|
|
12
|
+
export const viatomR20MainServices = [{
|
|
13
|
+
uuid: VIATOM_R20_SERVICE,
|
|
14
|
+
monitorUuids: [{
|
|
15
|
+
uuid: VIATOM_R20_NOTIFY,
|
|
16
|
+
parsingModel: acceptNothing
|
|
17
|
+
}],
|
|
18
|
+
writeUuid: {
|
|
19
|
+
uuid: VIATOM_R20_WRITE,
|
|
20
|
+
mainCommandUuid: "a5"
|
|
21
|
+
}
|
|
22
|
+
}];
|
|
23
|
+
/** ViHealth LeRes-A/R20 and LeRes-C/R200 ventilators use the same A5 BLE service. */
|
|
24
|
+
export class ViatomR20Device extends BTManagedDevice {
|
|
25
|
+
mainServices = viatomR20MainServices;
|
|
26
|
+
stuckDataTimeout = 60_000;
|
|
27
|
+
onStreamStart = undefined;
|
|
28
|
+
preferredMtu = 247;
|
|
29
|
+
getSupportedMeasurementTypeKeys() {
|
|
30
|
+
return [VIATOM_R20_MEASUREMENT_TYPE];
|
|
31
|
+
}
|
|
32
|
+
constructor(device, params) {
|
|
33
|
+
super(device, {
|
|
34
|
+
...params,
|
|
35
|
+
oneReadingPerConnection: params.oneReadingPerConnection ?? true
|
|
36
|
+
});
|
|
37
|
+
this.frameReader = new ViatomR20FrameReader();
|
|
38
|
+
this.createCommandSequencer = () => new ViatomR20Sequencer({
|
|
39
|
+
encrypted: parseViatomR20Advertisement(device.manufacturerData).encrypted,
|
|
40
|
+
write: {
|
|
41
|
+
serviceUuid: VIATOM_R20_SERVICE,
|
|
42
|
+
characteristicUuid: VIATOM_R20_WRITE
|
|
43
|
+
},
|
|
44
|
+
clockSync: params.clockSync,
|
|
45
|
+
onResult: result => this.onResult?.(result)
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
handleSuccessResult() {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=viatom-r20.device.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BTManagedDevice","parseViatomR20Advertisement","ViatomR20FrameReader","VIATOM_R20_MEASUREMENT_TYPE","VIATOM_R20_NOTIFY","VIATOM_R20_SERVICE","VIATOM_R20_WRITE","ViatomR20Sequencer","acceptNothing","caseValuePosition","cases","viatomR20MainServices","uuid","monitorUuids","parsingModel","writeUuid","mainCommandUuid","ViatomR20Device","mainServices","stuckDataTimeout","onStreamStart","undefined","preferredMtu","getSupportedMeasurementTypeKeys","constructor","device","params","oneReadingPerConnection","frameReader","createCommandSequencer","encrypted","manufacturerData","write","serviceUuid","characteristicUuid","clockSync","onResult","result","handleSuccessResult"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/viatom-r20.device.ts"],"mappings":";;AAAA;;AAUA,SAASA,eAAe,QAAQ,yBAAsB;AAEtD,SACEC,2BAA2B,EAC3BC,oBAAoB,EACpBC,2BAA2B,EAC3BC,iBAAiB,EACjBC,kBAAkB,EAClBC,gBAAgB,QACX,0BAAuB;AAC9B,SAASC,kBAAkB,QAAQ,2BAAwB;AAE3D,MAAMC,aAAa,GAAG;EAAEC,iBAAiB,EAAE,EAAE;EAAEC,KAAK,EAAE;AAAG,CAAC;AAE1D,OAAO,MAAMC,qBAAiC,GAAG,CAC/C;EACEC,IAAI,EAAEP,kBAAkB;EACxBQ,YAAY,EAAE,CAAC;IAAED,IAAI,EAAER,iBAAiB;IAAEU,YAAY,EAAEN;EAAc,CAAC,CAAC;EACxEO,SAAS,EAAE;IAAEH,IAAI,EAAEN,gBAAgB;IAAEU,eAAe,EAAE;EAAK;AAC7D,CAAC,CACF;AAMD;AACA,OAAO,MAAMC,eAAe,SAASjB,eAAe,CAAsB;EAC9DkB,YAAY,GAAGP,qBAAqB;EACpCQ,gBAAgB,GAAG,MAAM;EACzBC,aAAa,GAAGC,SAAS;EAChBC,YAAY,GAAG,GAAG;EAElBC,+BAA+BA,CAAA,EAAyB;IACzE,OAAO,CAACpB,2BAA2B,CAAC;EACtC;EAEOqB,WAAWA,CAChBC,MAAc,EACdC,MAA+C,EAC/C;IACA,KAAK,CAACD,MAAM,EAAE;MACZ,GAAGC,MAAM;MACTC,uBAAuB,EAAED,MAAM,CAACC,uBAAuB,IAAI;IAC7D,CAAC,CAAC;IACF,IAAI,CAACC,WAAW,GAAG,IAAI1B,oBAAoB,CAAC,CAAC;IAC7C,IAAI,CAAC2B,sBAAsB,GAAG,MAC5B,IAAItB,kBAAkB,CAAC;MACrBuB,SAAS,EAAE7B,2BAA2B,CAACwB,MAAM,CAACM,gBAAgB,CAAC,CAC5DD,SAAS;MACZE,KAAK,EAAE;QACLC,WAAW,EAAE5B,kBAAkB;QAC/B6B,kBAAkB,EAAE5B;MACtB,CAAC;MACD6B,SAAS,EAAET,MAAM,CAACS,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,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable import/group-exports */
|
|
4
|
+
|
|
5
|
+
import { MeasurementTypeKey } from "@ovok/core";
|
|
6
|
+
import { calculateCrc8 } from "../../../utils/calculate-crc-8.js";
|
|
7
|
+
import { hexToByte } from "../../../utils/hex-to-byte.js";
|
|
8
|
+
import { le16FromHex } from "../../../utils/le-16-from-hex.js";
|
|
9
|
+
import { manufacturerBytes } from "../lepu/lepu.advertisement.js";
|
|
10
|
+
import { LepuFrameReader } from "../lepu/lepu.frame-reader.js";
|
|
11
|
+
export const VIATOM_R20_SERVICE = "14839ac4-7d7e-415c-9a42-167340cf2339";
|
|
12
|
+
export const VIATOM_R20_WRITE = "8b00ace7-eb0b-49b0-bbe9-9aee0a26e1a3";
|
|
13
|
+
export const VIATOM_R20_NOTIFY = "0734594a-a8e7-4b1a-a6b1-cd5243059a57";
|
|
14
|
+
export const VIATOM_R20_MEASUREMENT_TYPE = MeasurementTypeKey.respiratoryTherapy;
|
|
15
|
+
export const ViatomR20Command = {
|
|
16
|
+
authenticate: 0xff,
|
|
17
|
+
syncTime: 0xc0,
|
|
18
|
+
readParameters: 54
|
|
19
|
+
};
|
|
20
|
+
const unitComponent = (name, value, unit, code) => ({
|
|
21
|
+
code: {
|
|
22
|
+
text: name
|
|
23
|
+
},
|
|
24
|
+
valueQuantity: {
|
|
25
|
+
value,
|
|
26
|
+
unit,
|
|
27
|
+
system: "http://unitsofmeasure.org",
|
|
28
|
+
code
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const u16 = (bytes, offset) => (bytes[offset] ?? 0) | (bytes[offset + 1] ?? 0) << 8;
|
|
32
|
+
const bounded = (value, min, max) => value >= min && value <= max ? value : undefined;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* ViHealth's `BleBroadcast` uses byte 3 for protocol v1 and byte 4 for v2. The selected
|
|
36
|
+
* byte's high nibble is the encryption level; levels 1 and 2 require the Lepu handshake.
|
|
37
|
+
*/
|
|
38
|
+
export const parseViatomR20Advertisement = manufacturerData => {
|
|
39
|
+
const bytes = manufacturerBytes(manufacturerData ?? undefined);
|
|
40
|
+
const uuid2 = bytes[4] ?? 0;
|
|
41
|
+
const selected = (uuid2 & 0x0f) === 2 ? uuid2 : bytes[3] ?? 0;
|
|
42
|
+
const level = (selected & 0xf0) >> 4;
|
|
43
|
+
return {
|
|
44
|
+
encrypted: level === 1 || level === 2
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Validates the A5 request/reply frame shared by the ViHealth ventilator models. */
|
|
49
|
+
export const decodeViatomR20Response = frame => {
|
|
50
|
+
if (frame.length < 8 || hexToByte(frame[0] ?? "00") !== 0xa5) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const command = hexToByte(frame[1] ?? "00");
|
|
54
|
+
const checksumIndex = frame.length - 1;
|
|
55
|
+
const payloadLength = le16FromHex(frame, 5);
|
|
56
|
+
if (hexToByte(frame[2] ?? "00") !== (~command & 0xff) || frame.length !== payloadLength + 8 || hexToByte(frame[checksumIndex] ?? "00") !== calculateCrc8([...frame], checksumIndex)) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
command,
|
|
61
|
+
status: hexToByte(frame[3] ?? "00"),
|
|
62
|
+
payload: frame.slice(7, checksumIndex).map(hexToByte)
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Converts the 24-byte RT_PARAM response documented in VentilatorBleResponse.RtParam.
|
|
68
|
+
* The device response has no measurement timestamp, so callers supply the receive time.
|
|
69
|
+
*/
|
|
70
|
+
export const decodeViatomR20Parameters = (bytes, recordedAt = new Date()) => {
|
|
71
|
+
if (bytes.length < 24) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const components = [];
|
|
75
|
+
const add = (name, value, min, max, unit, code, includeZero = false) => {
|
|
76
|
+
const valid = bounded(value, min, max);
|
|
77
|
+
if (valid !== undefined && (valid > 0 || includeZero)) {
|
|
78
|
+
components.push(unitComponent(name, valid, unit, code));
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
add("Airway pressure", u16(bytes, 0) / 10, 0, 60, "cmH2O", "cm[H2O]");
|
|
82
|
+
add("Inspiratory pressure", u16(bytes, 2) / 10, 0, 60, "cmH2O", "cm[H2O]");
|
|
83
|
+
add("Expiratory pressure", u16(bytes, 4) / 10, 0, 60, "cmH2O", "cm[H2O]");
|
|
84
|
+
add("Tidal volume", u16(bytes, 6), 0, 5000, "mL", "mL");
|
|
85
|
+
add("Minute ventilation", u16(bytes, 8) / 10, 0, 100, "L/min", "L/min");
|
|
86
|
+
add("Leak", u16(bytes, 10) / 10, 0, 200, "L/min", "L/min", true);
|
|
87
|
+
add("Respiratory rate", u16(bytes, 12), 0, 100, "breaths/min", "{breaths}/min");
|
|
88
|
+
add("Inspiratory time", u16(bytes, 14) / 10, 0, 10, "s", "s");
|
|
89
|
+
add("Inspiratory/expiratory ratio", u16(bytes, 16) / 10_000, 0, 10, "ratio", "1");
|
|
90
|
+
add("Blood oxygen saturation", u16(bytes, 18), 1, 100, "%", "%");
|
|
91
|
+
add("Pulse rate", u16(bytes, 20), 1, 300, "beats/min", "/min");
|
|
92
|
+
add("Heart rate", u16(bytes, 22), 1, 300, "beats/min", "/min");
|
|
93
|
+
if (components.length === 0 || components.every(({
|
|
94
|
+
valueQuantity
|
|
95
|
+
}) => (valueQuantity?.value ?? 0) === 0)) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
measurementTypeKey: VIATOM_R20_MEASUREMENT_TYPE,
|
|
100
|
+
components,
|
|
101
|
+
recordedAt
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** Reads complete A5 notifications and safely joins split or concatenated frames. */
|
|
106
|
+
export class ViatomR20FrameReader {
|
|
107
|
+
reader = new LepuFrameReader(["a5"]);
|
|
108
|
+
readFrame = buffer => this.reader.readFrame(buffer);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=viatom-r20.protocol.js.map
|