@ovok/native 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/modules/bt-management/index.js +176 -0
- package/lib/commonjs/modules/bt-management/index.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/custom/compile-case-fields.js +49 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-case-fields.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-case.js +47 -41
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-case.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-frame.js +48 -2
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-frame.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-lepu.js +98 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-lepu.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js +24 -1
- package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/device-creator.js +15 -8
- package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/aoj/aoj.thermometers.js +85 -0
- package/lib/commonjs/modules/bt-management/services/devices/aoj/aoj.thermometers.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.frame-reader.js +8 -74
- package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.frame-reader.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-command-writer.js +141 -0
- package/lib/commonjs/modules/bt-management/services/devices/bt-command-writer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js +9 -49
- package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js +17 -6
- package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +21 -14
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js +36 -0
- package/lib/commonjs/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js +81 -14
- package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.command-builder.js +48 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.command-builder.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.commands.js +37 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.commands.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-info.js +83 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-info.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-names.js +26 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-names.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-names.js +36 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-names.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-transfer.js +155 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-transfer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame-reader.js +98 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame-reader.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame.js +29 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.identity-gate.js +103 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.identity-gate.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.name-match.js +32 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.name-match.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.response-type.js +64 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.response-type.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.transports.js +143 -0
- package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.transports.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/polling-command-sequencer.js +38 -0
- package/lib/commonjs/modules/bt-management/services/devices/polling-command-sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js +156 -0
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js +124 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js +113 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.lepod.js +117 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.lepod.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.oximeters.js +82 -0
- package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.oximeters.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/command-sequencer.js +6 -0
- package/lib/commonjs/modules/bt-management/types/command-sequencer.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-checksum-algorithm.js +2 -0
- package/lib/commonjs/modules/bt-management/types/custom-checksum-algorithm.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-checksum-spec.js +6 -0
- package/lib/commonjs/modules/bt-management/types/custom-checksum-spec.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-lepu-spec.js +2 -0
- package/lib/commonjs/modules/bt-management/types/custom-lepu-spec.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-measurement-spec.js +6 -0
- package/lib/commonjs/modules/bt-management/types/custom-measurement-spec.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/device-command.js +2 -0
- package/lib/commonjs/modules/bt-management/types/device-command.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/measurement-group.js +6 -0
- package/lib/commonjs/modules/bt-management/types/measurement-group.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/calculate-checksum.js +49 -0
- package/lib/commonjs/modules/bt-management/utils/calculate-checksum.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/create-frame-validator.js +9 -0
- package/lib/commonjs/modules/bt-management/utils/create-frame-validator.js.map +1 -1
- package/lib/commonjs/modules/bt-management/utils/hex-to-bytes.js +19 -0
- package/lib/commonjs/modules/bt-management/utils/hex-to-bytes.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/le-32-to-bytes.js +13 -0
- package/lib/commonjs/modules/bt-management/utils/le-32-to-bytes.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/summarise-measurement-for-log.js +22 -0
- package/lib/commonjs/modules/bt-management/utils/summarise-measurement-for-log.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/supported-measurement-type-keys.js +18 -0
- package/lib/commonjs/modules/bt-management/utils/supported-measurement-type-keys.js.map +1 -0
- package/lib/module/modules/bt-management/index.js +16 -0
- package/lib/module/modules/bt-management/index.js.map +1 -1
- package/lib/module/modules/bt-management/services/custom/compile-case-fields.js +44 -0
- package/lib/module/modules/bt-management/services/custom/compile-case-fields.js.map +1 -0
- package/lib/module/modules/bt-management/services/custom/compile-custom-case.js +47 -41
- package/lib/module/modules/bt-management/services/custom/compile-custom-case.js.map +1 -1
- package/lib/module/modules/bt-management/services/custom/compile-custom-frame.js +48 -2
- package/lib/module/modules/bt-management/services/custom/compile-custom-frame.js.map +1 -1
- package/lib/module/modules/bt-management/services/custom/compile-custom-lepu.js +93 -0
- package/lib/module/modules/bt-management/services/custom/compile-custom-lepu.js.map +1 -0
- package/lib/module/modules/bt-management/services/custom/define-custom-device.js +24 -1
- package/lib/module/modules/bt-management/services/custom/define-custom-device.js.map +1 -1
- package/lib/module/modules/bt-management/services/device-creator.js +16 -8
- package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/aoj/aoj.thermometers.js +81 -0
- package/lib/module/modules/bt-management/services/devices/aoj/aoj.thermometers.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.frame-reader.js +8 -73
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.frame-reader.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-command-writer.js +136 -0
- package/lib/module/modules/bt-management/services/devices/bt-command-writer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js +9 -49
- package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-data-processor.js +17 -6
- package/lib/module/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +21 -14
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js +32 -0
- package/lib/module/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/custom/custom.device.js +81 -14
- package/lib/module/modules/bt-management/services/devices/custom/custom.device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.command-builder.js +43 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.command-builder.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.commands.js +33 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.commands.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-info.js +79 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-info.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-names.js +22 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-names.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-names.js +32 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-names.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-transfer.js +150 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-transfer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame-reader.js +93 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame-reader.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame.js +24 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.identity-gate.js +98 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.identity-gate.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.name-match.js +27 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.name-match.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.response-type.js +59 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.response-type.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.transports.js +140 -0
- package/lib/module/modules/bt-management/services/devices/lepu/lepu.transports.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/polling-command-sequencer.js +34 -0
- package/lib/module/modules/bt-management/services/devices/polling-command-sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js +149 -0
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js +118 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js +108 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.lepod.js +114 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.lepod.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.oximeters.js +79 -0
- package/lib/module/modules/bt-management/services/devices/viatom/viatom.oximeters.js.map +1 -0
- package/lib/module/modules/bt-management/types/command-sequencer.js +4 -0
- package/lib/module/modules/bt-management/types/command-sequencer.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-checksum-algorithm.js +2 -0
- package/lib/module/modules/bt-management/types/custom-checksum-algorithm.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-checksum-spec.js +4 -0
- package/lib/module/modules/bt-management/types/custom-checksum-spec.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-device-definition.js.map +1 -1
- package/lib/module/modules/bt-management/types/custom-lepu-spec.js +2 -0
- package/lib/module/modules/bt-management/types/custom-lepu-spec.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-measurement-spec.js +4 -0
- package/lib/module/modules/bt-management/types/custom-measurement-spec.js.map +1 -0
- package/lib/module/modules/bt-management/types/device-command.js +2 -0
- package/lib/module/modules/bt-management/types/device-command.js.map +1 -0
- package/lib/module/modules/bt-management/types/measurement-group.js +4 -0
- package/lib/module/modules/bt-management/types/measurement-group.js.map +1 -0
- package/lib/module/modules/bt-management/utils/calculate-checksum.js +44 -0
- package/lib/module/modules/bt-management/utils/calculate-checksum.js.map +1 -0
- package/lib/module/modules/bt-management/utils/create-frame-validator.js +9 -0
- package/lib/module/modules/bt-management/utils/create-frame-validator.js.map +1 -1
- package/lib/module/modules/bt-management/utils/hex-to-bytes.js +14 -0
- package/lib/module/modules/bt-management/utils/hex-to-bytes.js.map +1 -0
- package/lib/module/modules/bt-management/utils/le-32-to-bytes.js +8 -0
- package/lib/module/modules/bt-management/utils/le-32-to-bytes.js.map +1 -0
- package/lib/module/modules/bt-management/utils/summarise-measurement-for-log.js +17 -0
- package/lib/module/modules/bt-management/utils/summarise-measurement-for-log.js.map +1 -0
- package/lib/module/modules/bt-management/utils/supported-measurement-type-keys.js +13 -0
- package/lib/module/modules/bt-management/utils/supported-measurement-type-keys.js.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts +16 -0
- package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-case-fields.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-case-fields.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-case.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-frame.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts +11 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/define-custom-device.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/aoj/aoj.thermometers.d.ts +24 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts +5 -8
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-command-writer.d.ts +67 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-command-writer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +6 -4
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts +20 -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/bt-managed-device.d.ts +12 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom.device.d.ts +33 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom.device.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts +24 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts +32 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts +27 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts +20 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts +75 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts +28 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts +12 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts +81 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts +17 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts +33 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts +85 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts +27 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts +44 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts +44 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts +32 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts +25 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts +39 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts +26 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-spec.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-spec.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-algorithm.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-algorithm.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-spec.d.ts +23 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-definition.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-definition.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-spec.d.ts +12 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-spec.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-frame-spec.d.ts +8 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-frame-spec.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-lepu-spec.d.ts +44 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-lepu-spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-measurement-spec.d.ts +9 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-measurement-spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-command.d.ts +18 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-command.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/measurement-group.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/measurement-group.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/parsing-case.d.ts +9 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/parsing-case.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/utils/calculate-checksum.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/calculate-checksum.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/create-frame-validator.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/utils/hex-to-bytes.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/hex-to-bytes.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/le-32-to-bytes.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/le-32-to-bytes.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts +9 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/index.d.ts +16 -0
- package/lib/typescript/module/src/modules/bt-management/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-case-fields.d.ts +13 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-case-fields.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-case.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-frame.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts +11 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/define-custom-device.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/aoj/aoj.thermometers.d.ts +24 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts +5 -8
- package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-command-writer.d.ts +67 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-command-writer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +6 -4
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts +20 -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/bt-managed-device.d.ts +12 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts +21 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom.device.d.ts +33 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom.device.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts +24 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts +32 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts +27 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts +20 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts +14 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts +75 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts +28 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts +12 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts +81 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts +17 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts +33 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts +85 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts +27 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts +44 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts +44 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts +32 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts +25 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts +39 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts +26 -0
- package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-case-spec.d.ts +13 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-case-spec.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-algorithm.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-algorithm.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-spec.d.ts +23 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-spec.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-device-definition.d.ts +5 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-device-definition.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/custom-device-spec.d.ts +12 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-device-spec.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/custom-frame-spec.d.ts +8 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-frame-spec.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/custom-lepu-spec.d.ts +44 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-lepu-spec.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-measurement-spec.d.ts +9 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-measurement-spec.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/device-command.d.ts +18 -0
- package/lib/typescript/module/src/modules/bt-management/types/device-command.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/measurement-group.d.ts +14 -0
- package/lib/typescript/module/src/modules/bt-management/types/measurement-group.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/parsing-case.d.ts +9 -0
- package/lib/typescript/module/src/modules/bt-management/types/parsing-case.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/utils/calculate-checksum.d.ts +13 -0
- package/lib/typescript/module/src/modules/bt-management/utils/calculate-checksum.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/create-frame-validator.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/utils/hex-to-bytes.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/utils/hex-to-bytes.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/le-32-to-bytes.d.ts +3 -0
- package/lib/typescript/module/src/modules/bt-management/utils/le-32-to-bytes.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts +9 -0
- package/lib/typescript/module/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compileCustomLepu = void 0;
|
|
7
|
+
var _customDeviceError = require("./custom-device-error.js");
|
|
8
|
+
var _normalizeBleUuid = require("./normalize-ble-uuid.js");
|
|
9
|
+
const HEX_BYTE = /^[0-9a-f]{2}$/;
|
|
10
|
+
const MAX_OPCODE = 0xff;
|
|
11
|
+
const MAX_DEVICE_TYPE = 0xffff;
|
|
12
|
+
const assertStartBytes = (id, startBytes) => {
|
|
13
|
+
if (!Array.isArray(startBytes) || startBytes.length === 0) {
|
|
14
|
+
throw (0, _customDeviceError.customDeviceError)(id, "lepu.startBytes", "must list at least one frame start byte, such as [\"a5\"]");
|
|
15
|
+
}
|
|
16
|
+
return startBytes.map((byte, index) => {
|
|
17
|
+
const normalized = String(byte).toLowerCase();
|
|
18
|
+
if (!HEX_BYTE.test(normalized)) {
|
|
19
|
+
throw (0, _customDeviceError.customDeviceError)(id, `lepu.startBytes[${index}]`, `is "${String(byte)}"; it must be exactly two hex digits`);
|
|
20
|
+
}
|
|
21
|
+
return normalized;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const assertDeviceTypes = (id, deviceTypes) => {
|
|
25
|
+
if (!Array.isArray(deviceTypes)) {
|
|
26
|
+
throw (0, _customDeviceError.customDeviceError)(id, "lepu.expectedDeviceTypes", "must be an array of the model numbers this declaration was written for");
|
|
27
|
+
}
|
|
28
|
+
return deviceTypes.map((deviceType, index) => {
|
|
29
|
+
if (!Number.isInteger(deviceType) || deviceType < 0 || deviceType > MAX_DEVICE_TYPE) {
|
|
30
|
+
throw (0, _customDeviceError.customDeviceError)(id, `lepu.expectedDeviceTypes[${index}]`, `is ${String(deviceType)}; a model number is a whole number between 0 and ${MAX_DEVICE_TYPE}`);
|
|
31
|
+
}
|
|
32
|
+
return deviceType;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The opcode to poll with, once the device has been identified.
|
|
38
|
+
*
|
|
39
|
+
* Identification is the advertised name unless `expectedDeviceTypes` narrows it further.
|
|
40
|
+
* The name is what the vendor's own SDK binds every one of its products on - a 732-line
|
|
41
|
+
* cascade of name checks resolving to 176 models - so requiring more than that to poll at
|
|
42
|
+
* all would hold this SDK to a bar the hardware's own maker does not meet, and would leave
|
|
43
|
+
* every device undeclarable.
|
|
44
|
+
*
|
|
45
|
+
* Naming the models is still the stronger declaration, and is worth doing once the numbers
|
|
46
|
+
* are known: the family's low opcodes act, and a frame built for the wrong product is still
|
|
47
|
+
* well formed, so a name that matched the wrong hardware would not be caught by anything
|
|
48
|
+
* else in the protocol.
|
|
49
|
+
*/
|
|
50
|
+
const assertPollCommand = (id, lepu) => {
|
|
51
|
+
const {
|
|
52
|
+
pollCommand
|
|
53
|
+
} = lepu;
|
|
54
|
+
if (pollCommand === undefined) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
if (!Number.isInteger(pollCommand) || pollCommand < 0 || pollCommand > MAX_OPCODE) {
|
|
58
|
+
throw (0, _customDeviceError.customDeviceError)(id, "lepu.pollCommand", `is ${String(pollCommand)}; an opcode is a whole number between 0 and ${MAX_OPCODE}`);
|
|
59
|
+
}
|
|
60
|
+
return pollCommand;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Validates the Lepu declaration and normalises its UUIDs.
|
|
65
|
+
*
|
|
66
|
+
* The write service has to be one the declaration already monitors: a command written to a
|
|
67
|
+
* service the device never opened is accepted by nothing and answered by nothing, which
|
|
68
|
+
* looks exactly like hardware that is simply not responding.
|
|
69
|
+
*/
|
|
70
|
+
const compileCustomLepu = (id, spec, serviceUuids) => {
|
|
71
|
+
const lepu = spec.lepu;
|
|
72
|
+
if (!lepu) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
if (spec.services.some(service => service.write)) {
|
|
76
|
+
throw (0, _customDeviceError.customDeviceError)(id, "services[].write", "cannot be declared alongside lepu, which builds its own commands and addresses them through lepu.write");
|
|
77
|
+
}
|
|
78
|
+
const startBytes = assertStartBytes(id, lepu.startBytes);
|
|
79
|
+
const expectedDeviceTypes = assertDeviceTypes(id, lepu.expectedDeviceTypes);
|
|
80
|
+
const pollCommand = assertPollCommand(id, lepu);
|
|
81
|
+
const serviceUuid = (0, _normalizeBleUuid.normalizeBleUuid)(id, "lepu.write.serviceUuid", lepu.write?.serviceUuid);
|
|
82
|
+
if (!serviceUuids.includes(serviceUuid)) {
|
|
83
|
+
throw (0, _customDeviceError.customDeviceError)(id, "lepu.write.serviceUuid", `is "${serviceUuid}", which this device does not declare among its services`);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
startBytes,
|
|
87
|
+
expectedDeviceTypes,
|
|
88
|
+
...(pollCommand === undefined ? {} : {
|
|
89
|
+
pollCommand
|
|
90
|
+
}),
|
|
91
|
+
write: {
|
|
92
|
+
serviceUuid,
|
|
93
|
+
characteristicUuid: (0, _normalizeBleUuid.normalizeBleUuid)(id, "lepu.write.characteristicUuid", lepu.write?.characteristicUuid)
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
exports.compileCustomLepu = compileCustomLepu;
|
|
98
|
+
//# sourceMappingURL=compile-custom-lepu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_customDeviceError","require","_normalizeBleUuid","HEX_BYTE","MAX_OPCODE","MAX_DEVICE_TYPE","assertStartBytes","id","startBytes","Array","isArray","length","customDeviceError","map","byte","index","normalized","String","toLowerCase","test","assertDeviceTypes","deviceTypes","deviceType","Number","isInteger","assertPollCommand","lepu","pollCommand","undefined","compileCustomLepu","spec","serviceUuids","services","some","service","write","expectedDeviceTypes","serviceUuid","normalizeBleUuid","includes","characteristicUuid","exports"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/compile-custom-lepu.ts"],"mappings":";;;;;;AAGA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,MAAME,QAAQ,GAAG,eAAe;AAChC,MAAMC,UAAU,GAAG,IAAI;AACvB,MAAMC,eAAe,GAAG,MAAM;AAE9B,MAAMC,gBAAgB,GAAGA,CAACC,EAAU,EAAEC,UAAmB,KAAe;EACtE,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,UAAU,CAAC,IAAIA,UAAU,CAACG,MAAM,KAAK,CAAC,EAAE;IACzD,MAAM,IAAAC,oCAAiB,EACrBL,EAAE,EACF,iBAAiB,EACjB,2DACF,CAAC;EACH;EAEA,OAAOC,UAAU,CAACK,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;IACrC,MAA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CAAgB,EAClC/B,EAAE,EACF,+BAA+B,EAC/BmB,IAAI,CAACS,KAAK,EAAEK,kBACd;IACF;EACF,CAAC;AACH,CAAC;AAACC,OAAA,CAAAZ,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -6,11 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.defineCustomDevice = void 0;
|
|
7
7
|
var _customDeviceBrand = require("../../constants/custom-device-brand.js");
|
|
8
8
|
var _integratedDevices = require("../../types/integrated-devices.js");
|
|
9
|
+
var _compileCustomLepu = require("./compile-custom-lepu.js");
|
|
9
10
|
var _compileCustomMonitor = require("./compile-custom-monitor.js");
|
|
10
11
|
var _customDeviceError = require("./custom-device-error.js");
|
|
11
12
|
var _normalizeBleUuid = require("./normalize-ble-uuid.js");
|
|
12
13
|
const MIN_STUCK_TIMEOUT_MS = 1_000;
|
|
13
14
|
|
|
15
|
+
/** The smallest MTU a BLE link has, and the largest an ATT packet may declare. */
|
|
16
|
+
const MIN_MTU = 23;
|
|
17
|
+
const MAX_MTU = 517;
|
|
18
|
+
|
|
14
19
|
// The SDK's own F4 scale waits this long, because it sleeps while still connected.
|
|
15
20
|
const MAX_STUCK_TIMEOUT_MS = 6_000_000;
|
|
16
21
|
const HEX_BYTES = /^([0-9a-f]{2})+$/;
|
|
@@ -46,6 +51,16 @@ const assertStuckTimeout = (id, spec) => {
|
|
|
46
51
|
}
|
|
47
52
|
return timeout;
|
|
48
53
|
};
|
|
54
|
+
const assertPreferredMtu = (id, spec) => {
|
|
55
|
+
const mtu = spec.preferredMtu;
|
|
56
|
+
if (mtu === undefined) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
if (!Number.isInteger(mtu) || mtu < MIN_MTU || mtu > MAX_MTU) {
|
|
60
|
+
throw (0, _customDeviceError.customDeviceError)(id, "preferredMtu", `is ${String(mtu)}; it must be a whole number between ${MIN_MTU} and ${MAX_MTU}`);
|
|
61
|
+
}
|
|
62
|
+
return mtu;
|
|
63
|
+
};
|
|
49
64
|
const compileWrite = (id, path, write) => {
|
|
50
65
|
if (!write) {
|
|
51
66
|
return undefined;
|
|
@@ -72,6 +87,7 @@ const defineCustomDevice = spec => {
|
|
|
72
87
|
const id = assertIdentity(spec);
|
|
73
88
|
const nameMatch = compileNameMatch(id, spec);
|
|
74
89
|
const stuckDataTimeout = assertStuckTimeout(id, spec);
|
|
90
|
+
const preferredMtu = assertPreferredMtu(id, spec);
|
|
75
91
|
if (!Array.isArray(spec.services) || spec.services.length === 0) {
|
|
76
92
|
throw (0, _customDeviceError.customDeviceError)(id, "services", "must declare at least one service");
|
|
77
93
|
}
|
|
@@ -105,6 +121,7 @@ const defineCustomDevice = spec => {
|
|
|
105
121
|
writeUuid: compileWrite(id, path, service.write)
|
|
106
122
|
};
|
|
107
123
|
});
|
|
124
|
+
const lepu = (0, _compileCustomLepu.compileCustomLepu)(id, spec, mainServices.map(service => service.uuid));
|
|
108
125
|
return {
|
|
109
126
|
[_customDeviceBrand.CUSTOM_DEVICE_BRAND]: true,
|
|
110
127
|
id: id,
|
|
@@ -113,7 +130,13 @@ const defineCustomDevice = spec => {
|
|
|
113
130
|
mainServices,
|
|
114
131
|
stuckDataTimeout,
|
|
115
132
|
fields,
|
|
116
|
-
frames
|
|
133
|
+
frames,
|
|
134
|
+
...(preferredMtu === undefined ? {} : {
|
|
135
|
+
preferredMtu
|
|
136
|
+
}),
|
|
137
|
+
...(lepu === undefined ? {} : {
|
|
138
|
+
lepu
|
|
139
|
+
})
|
|
117
140
|
};
|
|
118
141
|
};
|
|
119
142
|
exports.defineCustomDevice = defineCustomDevice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_customDeviceBrand","require","_integratedDevices","_compileCustomMonitor","_customDeviceError","_normalizeBleUuid","MIN_STUCK_TIMEOUT_MS","MAX_STUCK_TIMEOUT_MS","HEX_BYTES","assertIdentity","spec","id","trim","customDeviceError","String","builtIn","Object","values","IntegratedDevices","find","name","toLowerCase","compileNameMatch","nameMatch","RegExp","global","sticky","exact","replace","assertStuckTimeout","timeout","stuckDataTimeoutMs","Number","isInteger","
|
|
1
|
+
{"version":3,"names":["_customDeviceBrand","require","_integratedDevices","_compileCustomLepu","_compileCustomMonitor","_customDeviceError","_normalizeBleUuid","MIN_STUCK_TIMEOUT_MS","MIN_MTU","MAX_MTU","MAX_STUCK_TIMEOUT_MS","HEX_BYTES","assertIdentity","spec","id","trim","customDeviceError","String","builtIn","Object","values","IntegratedDevices","find","name","toLowerCase","compileNameMatch","nameMatch","RegExp","global","sticky","exact","replace","assertStuckTimeout","timeout","stuckDataTimeoutMs","Number","isInteger","assertPreferredMtu","mtu","preferredMtu","undefined","compileWrite","path","write","commandHex","test","uuid","normalizeBleUuid","mainCommandUuid","defineCustomDevice","stuckDataTimeout","Array","isArray","services","length","fields","Map","frames","seenCharacteristics","Set","mainServices","map","service","serviceIndex","monitor","monitorUuids","monitorIndex","monitorPath","characteristic","frame","compileCustomMonitor","has","add","set","writeUuid","lepu","compileCustomLepu","CUSTOM_DEVICE_BRAND","exports"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/define-custom-device.ts"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAMA,IAAAC,kBAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAEA,MAAMM,oBAAoB,GAAG,KAAK;;AAElC;AACA,MAAMC,OAAO,GAAG,EAAE;AAClB,MAAMC,OAAO,GAAG,GAAG;;AAEnB;AACA,MAAMC,oBAAoB,GAAG,SAAS;AACtC,MAAMC,SAAS,GAAG,kBAAkB;AAEpC,MAAMC,cAAc,GAAIC,IAAsB,IAAa;EACzD,MAAMC,EAAE,GAAG,OAAOD,IAAI,EAAEC,EAAE,KAAK,QAAQ,GAA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I;IACJa,SAAS;IACTkC,YAAY;IACZV,gBAAgB;IAChBK,MAAM;IACNE,MAAM;IACN,IAAIlB,YAAY,KAAKC,SAAS,GAAG,CAAC,CAAC,GAAG;MAAED;IAAa,CAAC,CAAC;IACvD,IAAIoC,IAAI,KAAKnC,SAAS,GAAG,CAAC,CAAC,GAAG;MAAEmC;IAAK,CAAC;EACxC,CAAC;AACH,CAAC;AAACG,OAAA,CAAA7B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -12,6 +12,19 @@ var _bp2Device = require("./devices/bp2/bp2.device.js");
|
|
|
12
12
|
var _customDevice = require("./devices/custom/custom.device.js");
|
|
13
13
|
var _f4Device = require("./devices/f4/f4.device.js");
|
|
14
14
|
var _spo2Device = require("./devices/spo/spo2.device.js");
|
|
15
|
+
/**
|
|
16
|
+
* The built-in names the SDK can actually build.
|
|
17
|
+
*
|
|
18
|
+
* `integratedDevicesMap` matches more names than this, on purpose: matching is what names a
|
|
19
|
+
* device in a scan result and a device list, which is useful for hardware the SDK cannot
|
|
20
|
+
* yet decode. Connecting to one of those is what fails, and it fails saying so.
|
|
21
|
+
*/
|
|
22
|
+
const DEVICE_CLASSES = {
|
|
23
|
+
[_integratedDevices.IntegratedDevices.BP2]: _bp2Device.BP2Device,
|
|
24
|
+
[_integratedDevices.IntegratedDevices.F4]: _f4Device.F4Device,
|
|
25
|
+
[_integratedDevices.IntegratedDevices.PC60WF]: _spo2Device.SPO2Device,
|
|
26
|
+
[_integratedDevices.IntegratedDevices.BC01]: _bc01Device.BC01Device
|
|
27
|
+
};
|
|
15
28
|
const collectCustomDevices = acceptedDevices => {
|
|
16
29
|
const customDevices = new Map();
|
|
17
30
|
const matchers = new Set();
|
|
@@ -71,15 +84,9 @@ class DeviceCreator {
|
|
|
71
84
|
// @ts-expect-error - the caller asked for this custom device by its own id
|
|
72
85
|
return new _customDevice.CustomDevice(params.device, params, custom);
|
|
73
86
|
}
|
|
74
|
-
const
|
|
75
|
-
[_integratedDevices.IntegratedDevices.BP2]: _bp2Device.BP2Device,
|
|
76
|
-
[_integratedDevices.IntegratedDevices.F4]: _f4Device.F4Device,
|
|
77
|
-
[_integratedDevices.IntegratedDevices.PC60WF]: _spo2Device.SPO2Device,
|
|
78
|
-
[_integratedDevices.IntegratedDevices.BC01]: _bc01Device.BC01Device
|
|
79
|
-
};
|
|
80
|
-
const deviceClass = deviceMap[params.deviceName];
|
|
87
|
+
const deviceClass = DEVICE_CLASSES[params.deviceName];
|
|
81
88
|
if (!deviceClass) {
|
|
82
|
-
throw new Error(`
|
|
89
|
+
throw new Error(`"${params.deviceName}" is a name the SDK matches during a scan but has no decoder for, so "${params.device.name}" cannot be connected. The names it can decode are ${Object.keys(DEVICE_CLASSES).join(", ")}; anything else needs a declaration registered with defineCustomDevice and passed in acceptedDevices.`);
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
// @ts-expect-error - This is a workaround to allow the deviceClass to be instantiated with the correct type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_integratedDevicesMap","require","_integratedDevices","_isCustomDeviceDefinition","_bc01Device","_bp2Device","_customDevice","_f4Device","_spo2Device","collectCustomDevices","acceptedDevices","customDevices","Map","matchers","Set","forEach","entry","index","isCustomDeviceDefinition","Error","has","id","nameMatch","source","set","add","DeviceCreator","deviceNameCache","CACHE_MAX_SIZE","constructor","acceptedDeviceNames","getDeviceName","foundName","undefined","get","matched","matchDeviceName","cacheDeviceName","createDevice","params","String","deviceName","trim","device","name","custom","CustomDevice","
|
|
1
|
+
{"version":3,"names":["_integratedDevicesMap","require","_integratedDevices","_isCustomDeviceDefinition","_bc01Device","_bp2Device","_customDevice","_f4Device","_spo2Device","DEVICE_CLASSES","IntegratedDevices","BP2","BP2Device","F4","F4Device","PC60WF","SPO2Device","BC01","BC01Device","collectCustomDevices","acceptedDevices","customDevices","Map","matchers","Set","forEach","entry","index","isCustomDeviceDefinition","Error","has","id","nameMatch","source","set","add","DeviceCreator","deviceNameCache","CACHE_MAX_SIZE","constructor","acceptedDeviceNames","getDeviceName","foundName","undefined","get","matched","matchDeviceName","cacheDeviceName","createDevice","params","String","deviceName","trim","device","name","custom","CustomDevice","deviceClass","Object","keys","join","destroy","clear","regex","deviceType","integratedDevicesMap","test","some","values","size","firstKey","next","value","delete","exports"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/services/device-creator.ts"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAMA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,yBAAA,GAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMQ,cAAc,GAAG;EACrB,CAACC,oCAAiB,CAACC,GAAG,GAAGC,oBAAS;EAClC,CAACF,oCAAiB,CAACG,EAAE,GAAGC,kBAAQ;EAChC,CAACJ,oCAAiB,CAACK,MAAM,GAAGC,sBAAU;EACtC,CAACN,oCAAiB,CAACO,IAAI,GAAGC;AAC5B,CAAC;AAID,MAAMC,oBAAoB,GACxBC,eAA0C,IACF;EACxC,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAiC,CAAC;EAC/D,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAElCJ,eAAe,CAACK,OAAO,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAK;IACxC,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;MAC7B;IACF;IAEA,IAAI,CAAC,IAAAE,kDAAwB,EAACF,KAAK,CAAC,EAAE;MACpC,MAAM,IAAIG,KAAK,CACb,mBAAmBF,KAAK,sDAC1B,CAAC;IACH;IAEA,IAAIN,aAAa,CAACS,GAAG,CAACJ,KAAK,CAACK,EAAE,CAAC,EAAE;MAC/B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CAAC,IACtB,IAAI,CAACX,mBAAmB,CAAC2B,IAAI,CAAEb,IAAI,IAAKA,IAAI,KAAKU,UAAU,CAAC,EAC5D;QACA,OAAOA,UAAU;MACnB;IACF;IAEA,KAAK,MAAMT,MAAM,IAAI,IAAI,CAAClC,aAAa,CAAC+C,MAAM,CAAC,CAAC,EAAE;MAChD,IAAIb,MAAM,CAACvB,SAAS,CAACkC,IAAI,CAACf,UAAU,CAAC,EAAE;QACrC,OAAOI,MAAM,CAACxB,EAAE;MAClB;IACF;IAEA,OAAOY,SAAS;EAClB,CAAC;EAEOI,eAAeA,CACrBI,UAAkB,EAClBa,UAA4B,EACtB;IACN;IACA,IAAI,IAAI,CAAC3B,eAAe,CAACgC,IAAI,IAAI,IAAI,CAAC/B,cAAc,EAAE;MACpD,MAAMgC,QAAQ,GAAG,IAAI,CAACjC,eAAe,CAACsB,IAAI,CAAC,CAAC,CAACY,IAAI,CAAC,CAAC,CAACC,KAAK;MAEzD,IAAIF,QAAQ,KAAK3B,SAAS,EAAE;QAC1B,IAAI,CAACN,eAAe,CAACoC,MAAM,CAACH,QAAQ,CAAC;MACvC;IACF;IAEA,IAAI,CAACjC,eAAe,CAACH,GAAG,CAACiB,UAAU,EAAEa,UAAU,CAAC;EAClD;AACF;AAACU,OAAA,CAAAtC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.aoj20aThermometer = void 0;
|
|
7
|
+
var _core = require("@ovok/core");
|
|
8
|
+
var _defineCustomDevice = require("../../custom/define-custom-device.js");
|
|
9
|
+
/**
|
|
10
|
+
* Declarations for the AOJ Medical thermometers.
|
|
11
|
+
*
|
|
12
|
+
* Their frame is `aa | 01 | cmd | len | payload | xor`, where the checksum covers everything
|
|
13
|
+
* from the device-type byte up to itself. It is not the Lepu framing, despite both being
|
|
14
|
+
* reachable from the same vendor app: no complement byte, no sequence number, a one-byte
|
|
15
|
+
* length and an exclusive-or rather than a CRC.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** Every frame opens with these two: a fixed start byte and a fixed device type. */
|
|
19
|
+
const FRAME_HEADER = ["aa", "01"];
|
|
20
|
+
const COMMAND_BYTE = 2;
|
|
21
|
+
|
|
22
|
+
/** Header, a three-byte payload and the checksum. */
|
|
23
|
+
const FRAME_BYTES = 8;
|
|
24
|
+
const CHECKSUM_INDEX = 7;
|
|
25
|
+
|
|
26
|
+
/** The checksum starts after the start byte, which it does not cover. */
|
|
27
|
+
const CHECKSUM_FROM = 1;
|
|
28
|
+
const PAYLOAD = 4;
|
|
29
|
+
|
|
30
|
+
/** The device answers a realtime-temperature request with this. */
|
|
31
|
+
const TEMPERATURE_REPLY = "c1";
|
|
32
|
+
|
|
33
|
+
/** Hundredths of a degree, big-endian - the one field in this family that is not little. */
|
|
34
|
+
const TEMPERATURE_SCALE = 0.01;
|
|
35
|
+
const TEMPERATURE_DECIMALS = 2;
|
|
36
|
+
const SPOT_CHECK_TIMEOUT_MS = 60_000;
|
|
37
|
+
/**
|
|
38
|
+
* The AOJ-20A infrared thermometer.
|
|
39
|
+
*
|
|
40
|
+
* Declared without a write characteristic, because the device sends its reading rather than
|
|
41
|
+
* waiting to be asked: the vendor app has a request for it, calls it from nowhere, and still
|
|
42
|
+
* displays temperatures - so the reply arrives when someone takes a measurement. Not writing
|
|
43
|
+
* also means not polling, which for a spot-check device would otherwise re-report the same
|
|
44
|
+
* reading for as long as the link stayed up.
|
|
45
|
+
*
|
|
46
|
+
* Only the realtime reply is declared. The stored-history reply shares the header and would
|
|
47
|
+
* need its own case; nothing reads history yet, and a case that decoded it into the same
|
|
48
|
+
* measurement would post old readings as though they had just been taken.
|
|
49
|
+
*/
|
|
50
|
+
const aoj20aThermometer = params => (0, _defineCustomDevice.defineCustomDevice)({
|
|
51
|
+
id: params.id,
|
|
52
|
+
nameMatch: params.nameMatch,
|
|
53
|
+
stuckDataTimeoutMs: params.stuckDataTimeoutMs ?? SPOT_CHECK_TIMEOUT_MS,
|
|
54
|
+
services: [{
|
|
55
|
+
uuid: "ffe0",
|
|
56
|
+
monitor: [{
|
|
57
|
+
uuid: "ffe1",
|
|
58
|
+
frame: {
|
|
59
|
+
header: FRAME_HEADER,
|
|
60
|
+
minLengthBytes: FRAME_BYTES,
|
|
61
|
+
checksum: {
|
|
62
|
+
algorithm: "xor",
|
|
63
|
+
index: CHECKSUM_INDEX,
|
|
64
|
+
from: CHECKSUM_FROM
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
caseSelectorBytes: [COMMAND_BYTE],
|
|
68
|
+
cases: [{
|
|
69
|
+
selector: TEMPERATURE_REPLY,
|
|
70
|
+
kind: "result",
|
|
71
|
+
measurementTypeKey: _core.MeasurementTypeKey.temperature,
|
|
72
|
+
fields: [{
|
|
73
|
+
name: "bodyTemp",
|
|
74
|
+
byteIndexes: [PAYLOAD, PAYLOAD + 1],
|
|
75
|
+
byteOrder: "big",
|
|
76
|
+
unit: "Cel",
|
|
77
|
+
scale: TEMPERATURE_SCALE,
|
|
78
|
+
decimals: TEMPERATURE_DECIMALS
|
|
79
|
+
}]
|
|
80
|
+
}]
|
|
81
|
+
}]
|
|
82
|
+
}]
|
|
83
|
+
});
|
|
84
|
+
exports.aoj20aThermometer = aoj20aThermometer;
|
|
85
|
+
//# sourceMappingURL=aoj.thermometers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_core","require","_defineCustomDevice","FRAME_HEADER","COMMAND_BYTE","FRAME_BYTES","CHECKSUM_INDEX","CHECKSUM_FROM","PAYLOAD","TEMPERATURE_REPLY","TEMPERATURE_SCALE","TEMPERATURE_DECIMALS","SPOT_CHECK_TIMEOUT_MS","aoj20aThermometer","params","defineCustomDevice","id","nameMatch","stuckDataTimeoutMs","services","uuid","monitor","frame","header","minLengthBytes","checksum","algorithm","index","from","caseSelectorBytes","cases","selector","kind","measurementTypeKey","MeasurementTypeKey","temperature","fields","name","byteIndexes","byteOrder","unit","scale","decimals","exports"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/aoj/aoj.thermometers.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,mBAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAME,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;AAEjC,MAAMC,YAAY,GAAG,CAAC;;AAEtB;AACA,MAAMC,WAAW,GAAG,CAAC;AACrB,MAAMC,cAAc,GAAG,CAAC;;AAExB;AACA,MAAMC,aAAa,GAAG,CAAC;AAEvB,MAAMC,OAAO,GAAG,CAAC;;AAEjB;AACA,MAAMC,iBAAiB,GAAG,IAAI;;AAE9B;AACA,MAAMC,iBAAiB,GAAG,IAAI;AAC9B,MAAMC,oBAAoB,GAAG,CAAC;AAE9B,MAAMC,qBAAqB,GAAG,MAAM;AAapC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAC5BC,MAAuB,IAEvB,IAAAC,sCAAkB,EAAC;EACjBC,EAAE,EAAEF,MAAM,CAACE,EAAE;EACbC,SAAS,EAAEH,MAAM,CAACG,SAAS;EAC3BC,kBAAkB,EAAEJ,MAAM,CAACI,kBAAkB,IAAIN,qBAAqB;EACtEO,QAAQ,EAAE,CACR;IACEC,IAAI,EAAE,MAAM;IACZC,OAAO,EAAE,CACP;MACED,IAAI,EAAE,MAAM;MACZE,KAAK,EAAE;QACLC,MAAM,EAAEpB,YAAY;QACpBqB,cAAc,EAAEnB,WAAW;QAC3BoB,QAAQ,EAAE;UACRC,SAAS,EAAE,KAAK;UAChBC,KAAK,EAAErB,cAAc;UACrBsB,IAAI,EAAErB;QACR;MACF,CAAC;MACDsB,iBAAiB,EAAE,CAACzB,YAAY,CAAC;MACjC0B,KAAK,EAAE,CACL;QACEC,QAAQ,EAAEtB,iBAAiB;QAC3BuB,IAAI,EAAE,QAAQ;QACdC,kBAAkB,EAAEC,wBAAkB,CAACC,WAAW;QAClDC,MAAM,EAAE,CACN;UACEC,IAAI,EAAE,UAAU;UAChBC,WAAW,EAAE,CAAC9B,OAAO,EAAEA,OAAO,GAAG,CAAC,CAAC;UACnC+B,SAAS,EAAE,KAAK;UAChBC,IAAI,EAAE,KAAK;UACXC,KAAK,EAAE/B,iBAAiB;UACxBgC,QAAQ,EAAE/B;QACZ,CAAC;MAEL,CAAC;IAEL,CAAC;EAEL,CAAC;AAEL,CAAC,CAAC;AAACgC,OAAA,CAAA9B,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -4,85 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BP2FrameReader = void 0;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _le16FromHex = require("../../../utils/le-16-from-hex.js");
|
|
11
|
-
const FRAME_START_BYTE = "a5";
|
|
12
|
-
const COMMAND_INDEX = 1;
|
|
13
|
-
const COMMAND_COMPLEMENT_INDEX = 2;
|
|
14
|
-
const PAYLOAD_LENGTH_INDEX = 5;
|
|
15
|
-
const HEADER_BYTES = 7;
|
|
16
|
-
const CHECKSUM_BYTES = 1;
|
|
17
|
-
const BYTE_MASK = 0xff;
|
|
18
|
-
|
|
19
|
-
/** Start byte, command and its complement: the shortest run that can identify a start. */
|
|
20
|
-
const START_PATTERN_BYTES = 3;
|
|
21
|
-
const isFrameStart = (buffer, index) => {
|
|
22
|
-
if ((buffer[index] || "").toLowerCase() !== FRAME_START_BYTE) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const command = (0, _hexToByte.hexToByte)(buffer[index + COMMAND_INDEX] || "0");
|
|
26
|
-
const complement = (0, _hexToByte.hexToByte)(buffer[index + COMMAND_COMPLEMENT_INDEX] || "0");
|
|
27
|
-
return command === (~complement & BYTE_MASK);
|
|
28
|
-
};
|
|
29
|
-
const findFrameStart = buffer => {
|
|
30
|
-
const lastCandidate = buffer.length - START_PATTERN_BYTES;
|
|
31
|
-
for (let index = 0; index <= lastCandidate; index++) {
|
|
32
|
-
if (isFrameStart(buffer, index)) {
|
|
33
|
-
return index;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return -1;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Bytes that cannot begin a frame start, and are therefore safe to drop when no start
|
|
41
|
-
* was found. The trailing bytes are kept because a start pattern may still be arriving.
|
|
42
|
-
*/
|
|
43
|
-
const droppableLeadingBytes = buffer => Math.max(0, buffer.length - (START_PATTERN_BYTES - 1));
|
|
7
|
+
var _lepuFrameReader = require("../lepu/lepu.frame-reader.js");
|
|
8
|
+
/** The start byte the BP2 and most of its family use. */
|
|
9
|
+
const BP2_START_BYTES = ["a5"];
|
|
44
10
|
|
|
45
11
|
/**
|
|
46
12
|
* Reads Lepu protocol frames as used by the BP2.
|
|
47
13
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* the search for a start; the checksum is what actually decides a frame is trustworthy.
|
|
14
|
+
* The frame itself is shared across the family, so it lives in `LepuFrameReader`; the only
|
|
15
|
+
* thing that makes it a BP2 is which start byte it accepts.
|
|
51
16
|
*/
|
|
52
|
-
class BP2FrameReader {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (start === -1) {
|
|
56
|
-
return {
|
|
57
|
-
status: _frameReadStatus.FrameReadStatus.INCOMPLETE,
|
|
58
|
-
consumedBytes: droppableLeadingBytes(buffer)
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const payloadLength = (0, _le16FromHex.le16FromHex)(buffer, start + PAYLOAD_LENGTH_INDEX);
|
|
62
|
-
const frameLength = HEADER_BYTES + payloadLength + CHECKSUM_BYTES;
|
|
63
|
-
if (start + frameLength > buffer.length) {
|
|
64
|
-
return {
|
|
65
|
-
status: _frameReadStatus.FrameReadStatus.INCOMPLETE,
|
|
66
|
-
consumedBytes: start
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const frame = buffer.slice(start, start + frameLength);
|
|
70
|
-
if (!this.hasValidChecksum(frame)) {
|
|
71
|
-
return {
|
|
72
|
-
status: _frameReadStatus.FrameReadStatus.CORRUPT,
|
|
73
|
-
consumedBytes: start + START_PATTERN_BYTES
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
status: _frameReadStatus.FrameReadStatus.COMPLETE,
|
|
78
|
-
consumedBytes: start + frameLength,
|
|
79
|
-
frame
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
hasValidChecksum(frame) {
|
|
83
|
-
const checksummedBytes = frame.length - CHECKSUM_BYTES;
|
|
84
|
-
const declared = (0, _hexToByte.hexToByte)(frame[checksummedBytes] || "0");
|
|
85
|
-
return declared === (0, _calculateCrc.calculateCrc8)(frame, checksummedBytes);
|
|
17
|
+
class BP2FrameReader extends _lepuFrameReader.LepuFrameReader {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(BP2_START_BYTES);
|
|
86
20
|
}
|
|
87
21
|
}
|
|
88
22
|
exports.BP2FrameReader = BP2FrameReader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_lepuFrameReader","require","BP2_START_BYTES","BP2FrameReader","LepuFrameReader","constructor","exports"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/bp2/bp2.frame-reader.ts"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAEA;AACA,MAAMC,eAAe,GAAG,CAAC,IAAI,CAAC;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,SAASC,gCAAe,CAAC;EAC3CC,WAAWA,CAAA,EAAG;IACnB,KAAK,CAACH,eAAe,CAAC;EACxB;AACF;AAACI,OAAA,CAAAH,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BTCommandWriter = void 0;
|
|
7
|
+
var _sLog = require("../../../helpers/utils/s-log.js");
|
|
8
|
+
var _sentryLogger = require("../../../helpers/utils/sentry-logger.js");
|
|
9
|
+
var _hexToBase = require("../../utils/hex-to-base-64.js");
|
|
10
|
+
const MAX_WRITE_ATTEMPTS = 3;
|
|
11
|
+
|
|
12
|
+
/** The MTU every BLE link starts at, before either side asks for more. */
|
|
13
|
+
const DEFAULT_ATT_MTU = 23;
|
|
14
|
+
|
|
15
|
+
/** An ATT write spends three bytes on its own header. */
|
|
16
|
+
const ATT_WRITE_HEADER_BYTES = 3;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The write channel to a connected device.
|
|
20
|
+
*
|
|
21
|
+
* These protocols allow one command outstanding at a time, and the reply to it is what
|
|
22
|
+
* decides the next one, so writes are serialised rather than merely guarded against
|
|
23
|
+
* re-entry. Refusing a command while another is in flight stalls a self-clocking exchange
|
|
24
|
+
* permanently: the refused command is the one that would have provoked the next reply, and
|
|
25
|
+
* nothing retries it.
|
|
26
|
+
*/
|
|
27
|
+
class BTCommandWriter {
|
|
28
|
+
pendingWrites = Promise.resolve();
|
|
29
|
+
mtu = DEFAULT_ATT_MTU;
|
|
30
|
+
constructor(device, onError) {
|
|
31
|
+
this.device = device;
|
|
32
|
+
this.onError = onError;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Records what the link actually negotiated.
|
|
37
|
+
*
|
|
38
|
+
* The floor stands until something says otherwise, because a link that has not
|
|
39
|
+
* negotiated is at the minimum, and over-estimating truncates while under-estimating
|
|
40
|
+
* only costs a second packet.
|
|
41
|
+
*/
|
|
42
|
+
useNegotiatedMtu = mtu => {
|
|
43
|
+
if (typeof mtu === "number" && Number.isInteger(mtu) && mtu > this.mtu) {
|
|
44
|
+
this.mtu = mtu;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Drops anything still queued, for a link that is going away. */
|
|
49
|
+
reset = () => {
|
|
50
|
+
this.pendingWrites = Promise.resolve();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Queues commands behind whatever is already being written.
|
|
55
|
+
*
|
|
56
|
+
* The returned promise settles when the last of them has been written and never rejects.
|
|
57
|
+
* A write that fails is retried and reported where it happens; the catch here is a
|
|
58
|
+
* backstop, so that anything that gets past that still cannot poison the queue and
|
|
59
|
+
* silence every command after it.
|
|
60
|
+
*/
|
|
61
|
+
send = commands => {
|
|
62
|
+
this.pendingWrites = this.pendingWrites.then(() => this.writeInOrder(commands)).catch(error => {
|
|
63
|
+
this.onError?.(error);
|
|
64
|
+
});
|
|
65
|
+
return this.pendingWrites;
|
|
66
|
+
};
|
|
67
|
+
writeInOrder = async commands => {
|
|
68
|
+
for (const command of commands) {
|
|
69
|
+
await this.writeCommand(command);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Writes one command, split to fit the link.
|
|
75
|
+
*
|
|
76
|
+
* A write longer than the negotiated MTU is truncated by the stack rather than refused,
|
|
77
|
+
* so an oversized command arrives as a shorter one whose header still looks valid. The
|
|
78
|
+
* Er2 negotiates the 23-byte minimum where the rest of the family grants 247, which is
|
|
79
|
+
* enough to cut a 28-byte file-read request in half.
|
|
80
|
+
*
|
|
81
|
+
* A chunk that cannot be written abandons the rest of the command. The device reassembles
|
|
82
|
+
* by arrival, so continuing past a gap would hand it a frame that is not the one asked
|
|
83
|
+
* for - worse than sending nothing, because it would be answered.
|
|
84
|
+
*/
|
|
85
|
+
writeCommand = async command => {
|
|
86
|
+
for (const chunk of this.chunksOf(command.frame)) {
|
|
87
|
+
const written = await this.writeChunk(command, chunk);
|
|
88
|
+
if (!written) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Splits a frame into writes the link will carry whole.
|
|
96
|
+
*
|
|
97
|
+
* A frame that already fits yields one chunk, so the common command - a poll of a handful
|
|
98
|
+
* of bytes - is written exactly as it was before there was any splitting at all.
|
|
99
|
+
*/
|
|
100
|
+
chunksOf = frame => {
|
|
101
|
+
const size = Math.max(1, this.mtu - ATT_WRITE_HEADER_BYTES);
|
|
102
|
+
const chunks = [];
|
|
103
|
+
for (let start = 0; start < frame.length; start += size) {
|
|
104
|
+
chunks.push(frame.slice(start, start + size));
|
|
105
|
+
}
|
|
106
|
+
return chunks;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Writes one chunk, retrying a failed write.
|
|
111
|
+
*
|
|
112
|
+
* The attempt count is local rather than an instance field, so a write that exhausted its
|
|
113
|
+
* retries cannot leave the next one with none left - which is what a shared counter did
|
|
114
|
+
* on any path that failed to reset it.
|
|
115
|
+
*/
|
|
116
|
+
writeChunk = async (command, chunk) => {
|
|
117
|
+
for (let attempt = 1; attempt <= MAX_WRITE_ATTEMPTS; attempt++) {
|
|
118
|
+
try {
|
|
119
|
+
const isConnected = await this.device.isConnected();
|
|
120
|
+
if (!isConnected) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
await this.device.writeCharacteristicWithResponseForService(command.serviceUuid, command.characteristicUuid, (0, _hexToBase.hexToBase64)(chunk.join("")));
|
|
124
|
+
return true;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
(0, _sentryLogger.sentryLogger)("error", "DEVICE: Error sending command", {
|
|
127
|
+
error: error instanceof Error ? error.message : error,
|
|
128
|
+
deviceName: this.device.name
|
|
129
|
+
});
|
|
130
|
+
if (attempt === MAX_WRITE_ATTEMPTS) {
|
|
131
|
+
(0, _sLog.slog)(error, "BT_CONNECTION_HANDLER: Error sending command", {
|
|
132
|
+
deviceName: this.device.name
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
exports.BTCommandWriter = BTCommandWriter;
|
|
141
|
+
//# sourceMappingURL=bt-command-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_sLog","require","_sentryLogger","_hexToBase","MAX_WRITE_ATTEMPTS","DEFAULT_ATT_MTU","ATT_WRITE_HEADER_BYTES","BTCommandWriter","pendingWrites","Promise","resolve","mtu","constructor","device","onError","useNegotiatedMtu","Number","isInteger","reset","send","commands","then","writeInOrder","catch","error","command","writeCommand","chunk","chunksOf","frame","written","writeChunk","size","Math","max","chunks","start","length","push","slice","attempt","isConnected","writeCharacteristicWithResponseForService","serviceUuid","characteristicUuid","hexToBase64","join","sentryLogger","Error","message","deviceName","name","slog","exports"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/devices/bt-command-writer.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AAEA,MAAMG,kBAAkB,GAAG,CAAC;;AAE5B;AACA,MAAMC,eAAe,GAAG,EAAE;;AAE1B;AACA,MAAMC,sBAAsB,GAAG,CAAC;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,CAAC;EACnBC,aAAa,GAAkBC,OAAO,CAACC,OAAO,CAAC,CAAC;EAChDC,GAAG,GAAGN,eAAe;EAEtBO,WAAWA,CACCC,MAAc,EACdC,OAA2C,EAC5D;IAAA,KAFiBD,MAAc,GAAdA,MAAc;IAAA,KACdC,OAA2C,GAA3CA,OAA2C;EAC3D;;EAEH;AAC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