@ovok/native 0.4.1 → 0.4.3
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/components/bt-provider-child-wrapper.js.map +1 -1
- package/lib/commonjs/modules/bt-management/components/bt-provider.js.map +1 -1
- package/lib/commonjs/modules/bt-management/constants/custom-device-brand.js +12 -0
- package/lib/commonjs/modules/bt-management/constants/custom-device-brand.js.map +1 -0
- package/lib/commonjs/modules/bt-management/constants/measurement-field-catalog.js +111 -0
- package/lib/commonjs/modules/bt-management/constants/measurement-field-catalog.js.map +1 -0
- package/lib/commonjs/modules/bt-management/index.js +209 -0
- package/lib/commonjs/modules/bt-management/index.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/bt-manager.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-case.js +116 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-case.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-field.js +83 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-field.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-frame.js +64 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-frame.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-monitor.js +76 -0
- package/lib/commonjs/modules/bt-management/services/custom/compile-custom-monitor.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/custom/custom-device-error.js +13 -0
- package/lib/commonjs/modules/bt-management/services/custom/custom-device-error.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js +120 -0
- package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/custom/normalize-ble-uuid.js +32 -0
- package/lib/commonjs/modules/bt-management/services/custom/normalize-ble-uuid.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/device-creator.js +52 -26
- package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js +22 -5
- 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.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js +103 -0
- package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/accepted-device.js +6 -0
- package/lib/commonjs/modules/bt-management/types/accepted-device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/compiled-custom-field.js +6 -0
- package/lib/commonjs/modules/bt-management/types/compiled-custom-field.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-byte-order.js +2 -0
- package/lib/commonjs/modules/bt-management/types/custom-byte-order.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-case-kind.js +2 -0
- package/lib/commonjs/modules/bt-management/types/custom-case-kind.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-case-spec.js +6 -0
- package/lib/commonjs/modules/bt-management/types/custom-case-spec.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-device-definition.js +4 -0
- package/lib/commonjs/modules/bt-management/types/custom-device-definition.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-device-id.js +2 -0
- package/lib/commonjs/modules/bt-management/types/custom-device-id.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-device-spec.js +6 -0
- package/lib/commonjs/modules/bt-management/types/custom-device-spec.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-field-encoding.js +2 -0
- package/lib/commonjs/modules/bt-management/types/custom-field-encoding.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-field-spec.js +6 -0
- package/lib/commonjs/modules/bt-management/types/custom-field-spec.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-frame-spec.js +6 -0
- package/lib/commonjs/modules/bt-management/types/custom-frame-spec.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-measurement.js +6 -0
- package/lib/commonjs/modules/bt-management/types/custom-measurement.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-monitor-spec.js +6 -0
- package/lib/commonjs/modules/bt-management/types/custom-monitor-spec.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/custom-service-spec.js +6 -0
- package/lib/commonjs/modules/bt-management/types/custom-service-spec.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/device-key-of.js +6 -0
- package/lib/commonjs/modules/bt-management/types/device-key-of.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/device-key.js +6 -0
- package/lib/commonjs/modules/bt-management/types/device-key.js.map +1 -0
- package/lib/commonjs/modules/bt-management/types/device-measurement-map.js.map +1 -1
- package/lib/commonjs/modules/bt-management/utils/create-custom-field-parser.js +54 -0
- package/lib/commonjs/modules/bt-management/utils/create-custom-field-parser.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/create-frame-validator.js +40 -0
- package/lib/commonjs/modules/bt-management/utils/create-frame-validator.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/decode-medical-float.js +38 -0
- package/lib/commonjs/modules/bt-management/utils/decode-medical-float.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/is-custom-device-definition.js +15 -0
- package/lib/commonjs/modules/bt-management/utils/is-custom-device-definition.js.map +1 -0
- package/lib/module/modules/bt-management/components/bt-provider-child-wrapper.js.map +1 -1
- package/lib/module/modules/bt-management/components/bt-provider.js.map +1 -1
- package/lib/module/modules/bt-management/constants/custom-device-brand.js +8 -0
- package/lib/module/modules/bt-management/constants/custom-device-brand.js.map +1 -0
- package/lib/module/modules/bt-management/constants/measurement-field-catalog.js +108 -0
- package/lib/module/modules/bt-management/constants/measurement-field-catalog.js.map +1 -0
- package/lib/module/modules/bt-management/index.js +19 -0
- package/lib/module/modules/bt-management/index.js.map +1 -1
- package/lib/module/modules/bt-management/services/bt-manager.js.map +1 -1
- package/lib/module/modules/bt-management/services/custom/compile-custom-case.js +112 -0
- package/lib/module/modules/bt-management/services/custom/compile-custom-case.js.map +1 -0
- package/lib/module/modules/bt-management/services/custom/compile-custom-field.js +78 -0
- package/lib/module/modules/bt-management/services/custom/compile-custom-field.js.map +1 -0
- package/lib/module/modules/bt-management/services/custom/compile-custom-frame.js +59 -0
- package/lib/module/modules/bt-management/services/custom/compile-custom-frame.js.map +1 -0
- package/lib/module/modules/bt-management/services/custom/compile-custom-monitor.js +71 -0
- package/lib/module/modules/bt-management/services/custom/compile-custom-monitor.js.map +1 -0
- package/lib/module/modules/bt-management/services/custom/custom-device-error.js +8 -0
- package/lib/module/modules/bt-management/services/custom/custom-device-error.js.map +1 -0
- package/lib/module/modules/bt-management/services/custom/define-custom-device.js +115 -0
- package/lib/module/modules/bt-management/services/custom/define-custom-device.js.map +1 -0
- package/lib/module/modules/bt-management/services/custom/normalize-ble-uuid.js +27 -0
- package/lib/module/modules/bt-management/services/custom/normalize-ble-uuid.js.map +1 -0
- package/lib/module/modules/bt-management/services/device-creator.js +52 -26
- package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-data-processor.js +22 -5
- 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.map +1 -1
- package/lib/module/modules/bt-management/services/devices/custom/custom.device.js +98 -0
- package/lib/module/modules/bt-management/services/devices/custom/custom.device.js.map +1 -0
- package/lib/module/modules/bt-management/types/accepted-device.js +4 -0
- package/lib/module/modules/bt-management/types/accepted-device.js.map +1 -0
- package/lib/module/modules/bt-management/types/compiled-custom-field.js +4 -0
- package/lib/module/modules/bt-management/types/compiled-custom-field.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-byte-order.js +2 -0
- package/lib/module/modules/bt-management/types/custom-byte-order.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-case-kind.js +2 -0
- package/lib/module/modules/bt-management/types/custom-case-kind.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-case-spec.js +4 -0
- package/lib/module/modules/bt-management/types/custom-case-spec.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-device-definition.js +8 -0
- package/lib/module/modules/bt-management/types/custom-device-definition.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-device-id.js +2 -0
- package/lib/module/modules/bt-management/types/custom-device-id.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-device-spec.js +4 -0
- package/lib/module/modules/bt-management/types/custom-device-spec.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-field-encoding.js +2 -0
- package/lib/module/modules/bt-management/types/custom-field-encoding.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-field-spec.js +4 -0
- package/lib/module/modules/bt-management/types/custom-field-spec.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-frame-spec.js +4 -0
- package/lib/module/modules/bt-management/types/custom-frame-spec.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-measurement.js +4 -0
- package/lib/module/modules/bt-management/types/custom-measurement.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-monitor-spec.js +4 -0
- package/lib/module/modules/bt-management/types/custom-monitor-spec.js.map +1 -0
- package/lib/module/modules/bt-management/types/custom-service-spec.js +4 -0
- package/lib/module/modules/bt-management/types/custom-service-spec.js.map +1 -0
- package/lib/module/modules/bt-management/types/device-key-of.js +4 -0
- package/lib/module/modules/bt-management/types/device-key-of.js.map +1 -0
- package/lib/module/modules/bt-management/types/device-key.js +4 -0
- package/lib/module/modules/bt-management/types/device-key.js.map +1 -0
- package/lib/module/modules/bt-management/types/device-measurement-map.js +5 -0
- package/lib/module/modules/bt-management/types/device-measurement-map.js.map +1 -1
- package/lib/module/modules/bt-management/utils/create-custom-field-parser.js +49 -0
- package/lib/module/modules/bt-management/utils/create-custom-field-parser.js.map +1 -0
- package/lib/module/modules/bt-management/utils/create-frame-validator.js +35 -0
- package/lib/module/modules/bt-management/utils/create-frame-validator.js.map +1 -0
- package/lib/module/modules/bt-management/utils/decode-medical-float.js +33 -0
- package/lib/module/modules/bt-management/utils/decode-medical-float.js.map +1 -0
- package/lib/module/modules/bt-management/utils/is-custom-device-definition.js +10 -0
- package/lib/module/modules/bt-management/utils/is-custom-device-definition.js.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bt-provider.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/bt-management/components/bt-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/constants/custom-device-brand.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/bt-management/constants/custom-device-brand.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/constants/measurement-field-catalog.d.ts +26 -0
- package/lib/typescript/commonjs/src/modules/bt-management/constants/measurement-field-catalog.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts +19 -0
- package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/bt-manager.d.ts +5 -4
- package/lib/typescript/commonjs/src/modules/bt-management/services/bt-manager.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-case.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-case.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-field.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-field.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-frame.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-frame.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-monitor.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-monitor.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/custom-device-error.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/custom-device-error.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/define-custom-device.d.ts +12 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/define-custom-device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/normalize-ble-uuid.d.ts +7 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/custom/normalize-ble-uuid.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/device-creator.d.ts +12 -5
- package/lib/typescript/commonjs/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts +12 -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 +2 -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.device.d.ts +43 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom.device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/accepted-device.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/accepted-device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/btprovider-children-props.d.ts +5 -4
- package/lib/typescript/commonjs/src/modules/bt-management/types/btprovider-children-props.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/btprovider-props.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/bt-management/types/btprovider-props.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/compiled-custom-field.d.ts +16 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/compiled-custom-field.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/create-device-params.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/bt-management/types/create-device-params.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-byte-order.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-byte-order.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-kind.d.ts +12 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-kind.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-spec.d.ts +18 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-definition.d.ts +22 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-definition.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-id.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-id.d.ts.map +1 -0
- 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 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-field-encoding.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-field-encoding.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-field-spec.d.ts +33 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-field-spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-frame-spec.d.ts +27 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-frame-spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-measurement.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-measurement.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-monitor-spec.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-monitor-spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-service-spec.d.ts +15 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/custom-service-spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-data.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-data.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-key-of.d.ts +8 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-key-of.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-key.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-key.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/device-measurement-map.d.ts +10 -5
- 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/result-callback.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/bt-management/types/result-callback.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/utils/create-custom-field-parser.d.ts +12 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/create-custom-field-parser.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/create-frame-validator.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/create-frame-validator.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/decode-medical-float.d.ts +9 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/decode-medical-float.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/is-custom-device-definition.d.ts +9 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/is-custom-device-definition.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/data-sync/services/managers/sync-progress-manager.d.ts +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts +2 -2
- package/lib/typescript/module/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bt-provider.d.ts +2 -2
- package/lib/typescript/module/src/modules/bt-management/components/bt-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/constants/custom-device-brand.d.ts +6 -0
- package/lib/typescript/module/src/modules/bt-management/constants/custom-device-brand.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/constants/measurement-field-catalog.d.ts +26 -0
- package/lib/typescript/module/src/modules/bt-management/constants/measurement-field-catalog.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/index.d.ts +19 -0
- package/lib/typescript/module/src/modules/bt-management/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/bt-manager.d.ts +5 -4
- package/lib/typescript/module/src/modules/bt-management/services/bt-manager.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-case.d.ts +6 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-case.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-field.d.ts +6 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-field.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-frame.d.ts +13 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-frame.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-monitor.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-monitor.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/custom-device-error.d.ts +6 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/custom-device-error.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/define-custom-device.d.ts +12 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/define-custom-device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/normalize-ble-uuid.d.ts +7 -0
- package/lib/typescript/module/src/modules/bt-management/services/custom/normalize-ble-uuid.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/device-creator.d.ts +12 -5
- package/lib/typescript/module/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts +12 -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 +2 -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.device.d.ts +43 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom.device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/accepted-device.d.ts +5 -0
- package/lib/typescript/module/src/modules/bt-management/types/accepted-device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/btprovider-children-props.d.ts +5 -4
- package/lib/typescript/module/src/modules/bt-management/types/btprovider-children-props.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/btprovider-props.d.ts +2 -2
- package/lib/typescript/module/src/modules/bt-management/types/btprovider-props.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/compiled-custom-field.d.ts +16 -0
- package/lib/typescript/module/src/modules/bt-management/types/compiled-custom-field.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/create-device-params.d.ts +2 -2
- package/lib/typescript/module/src/modules/bt-management/types/create-device-params.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/custom-byte-order.d.ts +6 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-byte-order.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-case-kind.d.ts +12 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-case-kind.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-case-spec.d.ts +18 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-case-spec.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-device-definition.d.ts +22 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-device-definition.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-device-id.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-device-id.d.ts.map +1 -0
- 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 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-field-encoding.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-field-encoding.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-field-spec.d.ts +33 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-field-spec.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-frame-spec.d.ts +27 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-frame-spec.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-measurement.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-measurement.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-monitor-spec.d.ts +14 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-monitor-spec.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-service-spec.d.ts +15 -0
- package/lib/typescript/module/src/modules/bt-management/types/custom-service-spec.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/device-data.d.ts +2 -2
- package/lib/typescript/module/src/modules/bt-management/types/device-data.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/device-key-of.d.ts +8 -0
- package/lib/typescript/module/src/modules/bt-management/types/device-key-of.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/device-key.d.ts +5 -0
- package/lib/typescript/module/src/modules/bt-management/types/device-key.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/types/device-measurement-map.d.ts +10 -5
- 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/result-callback.d.ts +2 -2
- package/lib/typescript/module/src/modules/bt-management/types/result-callback.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/utils/create-custom-field-parser.d.ts +12 -0
- package/lib/typescript/module/src/modules/bt-management/utils/create-custom-field-parser.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/create-frame-validator.d.ts +10 -0
- package/lib/typescript/module/src/modules/bt-management/utils/create-frame-validator.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/decode-medical-float.d.ts +9 -0
- package/lib/typescript/module/src/modules/bt-management/utils/decode-medical-float.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/is-custom-device-definition.d.ts +9 -0
- package/lib/typescript/module/src/modules/bt-management/utils/is-custom-device-definition.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/data-sync/services/managers/sync-progress-manager.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CUSTOM_DEVICE_BRAND } from "../../constants/custom-device-brand.js";
|
|
4
|
+
import { IntegratedDevices } from "../../types/integrated-devices.js";
|
|
5
|
+
import { compileCustomMonitor } from "./compile-custom-monitor.js";
|
|
6
|
+
import { customDeviceError } from "./custom-device-error.js";
|
|
7
|
+
import { normalizeBleUuid } from "./normalize-ble-uuid.js";
|
|
8
|
+
const MIN_STUCK_TIMEOUT_MS = 1_000;
|
|
9
|
+
|
|
10
|
+
// The SDK's own F4 scale waits this long, because it sleeps while still connected.
|
|
11
|
+
const MAX_STUCK_TIMEOUT_MS = 6_000_000;
|
|
12
|
+
const HEX_BYTES = /^([0-9a-f]{2})+$/;
|
|
13
|
+
const assertIdentity = spec => {
|
|
14
|
+
const id = typeof spec?.id === "string" ? spec.id.trim() : "";
|
|
15
|
+
if (!id) {
|
|
16
|
+
throw customDeviceError(String(spec?.id), "id", "must not be empty");
|
|
17
|
+
}
|
|
18
|
+
const builtIn = Object.values(IntegratedDevices).find(name => name.toLowerCase() === id.toLowerCase());
|
|
19
|
+
if (builtIn) {
|
|
20
|
+
throw customDeviceError(id, "id", `collides with the built-in device "${builtIn}"`);
|
|
21
|
+
}
|
|
22
|
+
return id;
|
|
23
|
+
};
|
|
24
|
+
const compileNameMatch = (id, spec) => {
|
|
25
|
+
const nameMatch = spec.nameMatch;
|
|
26
|
+
if (nameMatch instanceof RegExp) {
|
|
27
|
+
if (nameMatch.global || nameMatch.sticky) {
|
|
28
|
+
throw customDeviceError(id, "nameMatch", `must not use the ${nameMatch.global ? "global" : "sticky"} flag, because it makes RegExp.test advance lastIndex and alternate between true and false across scan results`);
|
|
29
|
+
}
|
|
30
|
+
return nameMatch;
|
|
31
|
+
}
|
|
32
|
+
const exact = typeof nameMatch === "string" ? nameMatch.trim() : "";
|
|
33
|
+
if (!exact) {
|
|
34
|
+
throw customDeviceError(id, "nameMatch", "must not be empty");
|
|
35
|
+
}
|
|
36
|
+
return new RegExp(`^${exact.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`);
|
|
37
|
+
};
|
|
38
|
+
const assertStuckTimeout = (id, spec) => {
|
|
39
|
+
const timeout = spec.stuckDataTimeoutMs;
|
|
40
|
+
if (!Number.isInteger(timeout) || timeout < MIN_STUCK_TIMEOUT_MS || timeout > MAX_STUCK_TIMEOUT_MS) {
|
|
41
|
+
throw customDeviceError(id, "stuckDataTimeoutMs", `must be a whole number of milliseconds between ${MIN_STUCK_TIMEOUT_MS} and ${MAX_STUCK_TIMEOUT_MS}`);
|
|
42
|
+
}
|
|
43
|
+
return timeout;
|
|
44
|
+
};
|
|
45
|
+
const compileWrite = (id, path, write) => {
|
|
46
|
+
if (!write) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const commandHex = String(write.commandHex ?? "").toLowerCase();
|
|
50
|
+
if (!HEX_BYTES.test(commandHex)) {
|
|
51
|
+
throw customDeviceError(id, `${path}.write.commandHex`, `is "${write.commandHex}"; it must be an even number of hex digits`);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
uuid: normalizeBleUuid(id, `${path}.write.uuid`, write.uuid),
|
|
55
|
+
mainCommandUuid: commandHex
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Validates a declaration and compiles it into a runnable device.
|
|
61
|
+
*
|
|
62
|
+
* Every rule the declarative decoder relies on is checked here, at registration, because the
|
|
63
|
+
* alternative is a plausible wrong number at read time. Registration fails loudly - it
|
|
64
|
+
* throws, naming the exact position in the declaration - and a device that fails to compile
|
|
65
|
+
* is never scanned for.
|
|
66
|
+
*/
|
|
67
|
+
export const defineCustomDevice = spec => {
|
|
68
|
+
const id = assertIdentity(spec);
|
|
69
|
+
const nameMatch = compileNameMatch(id, spec);
|
|
70
|
+
const stuckDataTimeout = assertStuckTimeout(id, spec);
|
|
71
|
+
if (!Array.isArray(spec.services) || spec.services.length === 0) {
|
|
72
|
+
throw customDeviceError(id, "services", "must declare at least one service");
|
|
73
|
+
}
|
|
74
|
+
const fields = new Map();
|
|
75
|
+
const frames = new Map();
|
|
76
|
+
const seenCharacteristics = new Set();
|
|
77
|
+
const mainServices = spec.services.map((service, serviceIndex) => {
|
|
78
|
+
const path = `services[${serviceIndex}]`;
|
|
79
|
+
if (typeof service !== "object" || service === null) {
|
|
80
|
+
throw customDeviceError(id, path, "must be a service object");
|
|
81
|
+
}
|
|
82
|
+
if (!Array.isArray(service.monitor) || service.monitor.length === 0) {
|
|
83
|
+
throw customDeviceError(id, `${path}.monitor`, "must declare at least one monitor characteristic");
|
|
84
|
+
}
|
|
85
|
+
const monitorUuids = service.monitor.map((monitor, monitorIndex) => {
|
|
86
|
+
const monitorPath = `${path}.monitor[${monitorIndex}]`;
|
|
87
|
+
const {
|
|
88
|
+
characteristic,
|
|
89
|
+
frame
|
|
90
|
+
} = compileCustomMonitor(id, monitorPath, monitor, fields);
|
|
91
|
+
if (seenCharacteristics.has(characteristic.uuid)) {
|
|
92
|
+
throw customDeviceError(id, `${monitorPath}.uuid`, `is declared twice; a characteristic may appear only once`);
|
|
93
|
+
}
|
|
94
|
+
seenCharacteristics.add(characteristic.uuid);
|
|
95
|
+
frames.set(characteristic.uuid, frame);
|
|
96
|
+
return characteristic;
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
uuid: normalizeBleUuid(id, `${path}.uuid`, service.uuid),
|
|
100
|
+
monitorUuids,
|
|
101
|
+
writeUuid: compileWrite(id, path, service.write)
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
[CUSTOM_DEVICE_BRAND]: true,
|
|
106
|
+
id: id,
|
|
107
|
+
spec,
|
|
108
|
+
nameMatch,
|
|
109
|
+
mainServices,
|
|
110
|
+
stuckDataTimeout,
|
|
111
|
+
fields,
|
|
112
|
+
frames
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=define-custom-device.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CUSTOM_DEVICE_BRAND","IntegratedDevices","compileCustomMonitor","customDeviceError","normalizeBleUuid","MIN_STUCK_TIMEOUT_MS","MAX_STUCK_TIMEOUT_MS","HEX_BYTES","assertIdentity","spec","id","trim","String","builtIn","Object","values","find","name","toLowerCase","compileNameMatch","nameMatch","RegExp","global","sticky","exact","replace","assertStuckTimeout","timeout","stuckDataTimeoutMs","Number","isInteger","compileWrite","path","write","undefined","commandHex","test","uuid","mainCommandUuid","defineCustomDevice","stuckDataTimeout","Array","isArray","services","length","fields","Map","frames","seenCharacteristics","Set","mainServices","map","service","serviceIndex","monitor","monitorUuids","monitorIndex","monitorPath","characteristic","frame","has","add","set","writeUuid"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/define-custom-device.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,wCAAqC;AAMzE,SAASC,iBAAiB,QAAQ,mCAAgC;AAGlE,SAASC,oBAAoB,QAAQ,6BAA0B;AAC/D,SAASC,iBAAiB,QAAQ,0BAAuB;AACzD,SAASC,gBAAgB,QAAQ,yBAAsB;AAEvD,MAAMC,oBAAoB,GAAG,KAAK;;AAElC;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,GAAGD,IAAI,CAACC,EAAE,CAACC,IAAI,CAAC,CAAC,GAAG,EAAE;EAE7D,IAAI,CAACD,EAAE,EAAE;IACP,MAAMP,iBAAiB,CAACS,MAAM,CAACH,IAAI,EAAEC,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC;EACtE;EAEA,MAAMG,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACd,iBAAiB,CAAC,CAACe,IAAI,CAClDC,IAAI,IAAKA,IAAI,CAACC,WAAW,CAAC,CAAC,KAAKR,EAAE,CAACQ,WAAW,CAAC,CAClD,CAAC;EAED,IAAIL,OAAO,EAAE;IACX,MAAMV,iBAAiB,CACrBO,EAAE,EACF,IAAI,EACJ,sCAAsCG,OAAO,GAC/C,CAAC;EAC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ACxBD,IAAI;IACJW,SAAS;IACT8B,YAAY;IACZV,gBAAgB;IAChBK,MAAM;IACNE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { customDeviceError } from "./custom-device-error.js";
|
|
4
|
+
const BASE_UUID_SUFFIX = "-0000-1000-8000-00805f9b34fb";
|
|
5
|
+
const SHORT = /^[0-9a-f]{4}$/;
|
|
6
|
+
const MEDIUM = /^[0-9a-f]{8}$/;
|
|
7
|
+
const FULL = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Accepts a 16-bit, 32-bit or 128-bit UUID and returns the 128-bit form, because that is
|
|
11
|
+
* what react-native-ble-plx reports back on a notification and what the parsing model is
|
|
12
|
+
* matched against.
|
|
13
|
+
*/
|
|
14
|
+
export const normalizeBleUuid = (id, path, value) => {
|
|
15
|
+
const raw = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
16
|
+
if (SHORT.test(raw)) {
|
|
17
|
+
return `0000${raw}${BASE_UUID_SUFFIX}`;
|
|
18
|
+
}
|
|
19
|
+
if (MEDIUM.test(raw)) {
|
|
20
|
+
return `${raw}${BASE_UUID_SUFFIX}`;
|
|
21
|
+
}
|
|
22
|
+
if (FULL.test(raw)) {
|
|
23
|
+
return raw;
|
|
24
|
+
}
|
|
25
|
+
throw customDeviceError(id, path, `is "${String(value)}", which is not a 16-bit, 32-bit or 128-bit Bluetooth UUID`);
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=normalize-ble-uuid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["customDeviceError","BASE_UUID_SUFFIX","SHORT","MEDIUM","FULL","normalizeBleUuid","id","path","value","raw","trim","toLowerCase","test","String"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/normalize-ble-uuid.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,0BAAuB;AAEzD,MAAMC,gBAAgB,GAAG,8BAA8B;AACvD,MAAMC,KAAK,GAAG,eAAe;AAC7B,MAAMC,MAAM,GAAG,eAAe;AAE9B,MAAMC,IAAI,GACR,gEAAgE;;AAElE;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGA,CAC9BC,EAAU,EACVC,IAAY,EACZC,KAAc,KACH;EACX,MAAMC,GAAG,GAAG,OAAOD,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAACE,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAG,EAAE;EAEvE,IAAIT,KAAK,CAACU,IAAI,CAACH,GAAG,CAAC,EAAE;IACnB,OAAO,OAAOA,GAAG,GAAGR,gBAAgB,EAAE;EACxC;EAEA,IAAIE,MAAM,CAACS,IAAI,CAACH,GAAG,CAAC,EAAE;IACpB,OAAO,GAAGA,GAAG,GAAGR,gBAAgB,EAAE;EACpC;EAEA,IAAIG,IAAI,CAACQ,IAAI,CAACH,GAAG,CAAC,EAAE;IAClB,OAAOA,GAAG;EACZ;EAEA,MAAMT,iBAAiB,CACrBM,EAAE,EACFC,IAAI,EACJ,OAAOM,MAAM,CAACL,KAAK,CAAC,4DACtB,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -2,28 +2,55 @@
|
|
|
2
2
|
|
|
3
3
|
import { integratedDevicesMap } from "../constants/integrated-devices-map.js";
|
|
4
4
|
import { IntegratedDevices } from "../types/integrated-devices.js";
|
|
5
|
+
import { isCustomDeviceDefinition } from "../utils/is-custom-device-definition.js";
|
|
5
6
|
import { BC01Device } from "./devices/bc01/bc01.device.js";
|
|
6
7
|
import { BP2Device } from "./devices/bp2/bp2.device.js";
|
|
8
|
+
import { CustomDevice } from "./devices/custom/custom.device.js";
|
|
7
9
|
import { F4Device } from "./devices/f4/f4.device.js";
|
|
8
10
|
import { SPO2Device } from "./devices/spo/spo2.device.js";
|
|
11
|
+
const collectCustomDevices = acceptedDevices => {
|
|
12
|
+
const customDevices = new Map();
|
|
13
|
+
const matchers = new Set();
|
|
14
|
+
acceptedDevices.forEach((entry, index) => {
|
|
15
|
+
if (typeof entry === "string") {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!isCustomDeviceDefinition(entry)) {
|
|
19
|
+
throw new Error(`acceptedDevices[${index}] is not a device registered with defineCustomDevice`);
|
|
20
|
+
}
|
|
21
|
+
if (customDevices.has(entry.id)) {
|
|
22
|
+
throw new Error(`acceptedDevices[${index}] registers the custom device "${entry.id}" twice`);
|
|
23
|
+
}
|
|
24
|
+
if (matchers.has(entry.nameMatch.source)) {
|
|
25
|
+
throw new Error(`acceptedDevices[${index}] ("${entry.id}") matches the same advertised name as an earlier custom device, so one would silently shadow the other`);
|
|
26
|
+
}
|
|
27
|
+
customDevices.set(entry.id, entry);
|
|
28
|
+
matchers.add(entry.nameMatch.source);
|
|
29
|
+
});
|
|
30
|
+
return customDevices;
|
|
31
|
+
};
|
|
9
32
|
export class DeviceCreator {
|
|
10
33
|
deviceNameCache = new Map();
|
|
11
34
|
CACHE_MAX_SIZE = 100;
|
|
12
35
|
constructor(acceptedDeviceNames) {
|
|
13
36
|
this.acceptedDeviceNames = acceptedDeviceNames;
|
|
37
|
+
this.customDevices = collectCustomDevices(acceptedDeviceNames);
|
|
14
38
|
}
|
|
15
39
|
getDeviceName = foundName => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return;
|
|
40
|
+
if (!foundName) {
|
|
41
|
+
return undefined;
|
|
19
42
|
}
|
|
20
|
-
if (
|
|
21
|
-
return;
|
|
43
|
+
if (this.deviceNameCache.has(foundName)) {
|
|
44
|
+
return this.deviceNameCache.get(foundName) ?? undefined;
|
|
22
45
|
}
|
|
23
|
-
|
|
46
|
+
const matched = this.matchDeviceName(foundName);
|
|
47
|
+
|
|
48
|
+
// Cache the result (store null for non-matches to avoid repeated tests)
|
|
49
|
+
this.cacheDeviceName(foundName, matched ?? null);
|
|
50
|
+
return matched;
|
|
24
51
|
};
|
|
25
52
|
createDevice(params) {
|
|
26
|
-
if (!params.deviceName.trim()) {
|
|
53
|
+
if (!String(params.deviceName ?? "").trim()) {
|
|
27
54
|
throw new Error("Device name is required");
|
|
28
55
|
}
|
|
29
56
|
if (!params.device) {
|
|
@@ -35,6 +62,11 @@ export class DeviceCreator {
|
|
|
35
62
|
if (!params.device.id) {
|
|
36
63
|
throw new Error("Device ID is required");
|
|
37
64
|
}
|
|
65
|
+
const custom = this.customDevices.get(params.deviceName);
|
|
66
|
+
if (custom) {
|
|
67
|
+
// @ts-expect-error - the caller asked for this custom device by its own id
|
|
68
|
+
return new CustomDevice(params.device, params, custom);
|
|
69
|
+
}
|
|
38
70
|
const deviceMap = {
|
|
39
71
|
[IntegratedDevices.BP2]: BP2Device,
|
|
40
72
|
[IntegratedDevices.F4]: F4Device,
|
|
@@ -52,29 +84,23 @@ export class DeviceCreator {
|
|
|
52
84
|
destroy = () => {
|
|
53
85
|
this.deviceNameCache.clear();
|
|
54
86
|
};
|
|
55
|
-
getIntegratedDeviceName = deviceName => {
|
|
56
|
-
if (!deviceName) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Check cache first
|
|
61
|
-
if (this.deviceNameCache.has(deviceName)) {
|
|
62
|
-
const cached = this.deviceNameCache.get(deviceName);
|
|
63
|
-
return cached ?? undefined;
|
|
64
|
-
}
|
|
65
87
|
|
|
66
|
-
|
|
67
|
-
|
|
88
|
+
/**
|
|
89
|
+
* A built-in device always wins over a declaration: its decoder is compiled and tested,
|
|
90
|
+
* and a declaration that happens to match the same advertised name must not displace it.
|
|
91
|
+
*/
|
|
92
|
+
matchDeviceName = deviceName => {
|
|
68
93
|
for (const [regex, deviceType] of integratedDevicesMap) {
|
|
69
|
-
if (regex.test(deviceName)) {
|
|
70
|
-
|
|
71
|
-
break; // Early return!
|
|
94
|
+
if (regex.test(deviceName) && this.acceptedDeviceNames.some(name => name === deviceType)) {
|
|
95
|
+
return deviceType;
|
|
72
96
|
}
|
|
73
97
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
for (const custom of this.customDevices.values()) {
|
|
99
|
+
if (custom.nameMatch.test(deviceName)) {
|
|
100
|
+
return custom.id;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
78
104
|
};
|
|
79
105
|
cacheDeviceName(deviceName, deviceType) {
|
|
80
106
|
// Implement simple LRU by clearing oldest entries when cache is full
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["integratedDevicesMap","IntegratedDevices","BC01Device","BP2Device","F4Device","SPO2Device","
|
|
1
|
+
{"version":3,"names":["integratedDevicesMap","IntegratedDevices","isCustomDeviceDefinition","BC01Device","BP2Device","CustomDevice","F4Device","SPO2Device","collectCustomDevices","acceptedDevices","customDevices","Map","matchers","Set","forEach","entry","index","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","deviceMap","BP2","F4","PC60WF","BC01","deviceClass","destroy","clear","regex","deviceType","test","some","values","size","firstKey","keys","next","value","delete"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/services/device-creator.ts"],"mappings":";;AAAA,SAASA,oBAAoB,QAAQ,wCAAqC;AAM1E,SAASC,iBAAiB,QAAQ,gCAA6B;AAC/D,SAASC,wBAAwB,QAAQ,yCAAsC;AAE/E,SAASC,UAAU,QAAQ,+BAA4B;AACvD,SAASC,SAAS,QAAQ,6BAA0B;AAEpD,SAASC,YAAY,QAAQ,mCAAgC;AAC7D,SAASC,QAAQ,QAAQ,2BAAwB;AACjD,SAASC,UAAU,QAAQ,8BAA2B;AAEtD,MAAMC,oBAAoB,GACxB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C,MAAM,CAACJ,QAAQ,CAAC;MACvC;IACF;IAEA,IAAI,CAACjC,eAAe,CAACH,GAAG,CAACiB,UAAU,EAAEc,UAAU,CAAC;EAClD;AACF","ignoreList":[]}
|
|
@@ -4,7 +4,16 @@ import { CaseType } from "../../types/case-type.js";
|
|
|
4
4
|
import { DeviceStatus } from "../../types/device-status.js";
|
|
5
5
|
import { parseMeasurement } from "../../utils/parse-measurement.js";
|
|
6
6
|
export class BTDataProcessor {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* One buffer per characteristic.
|
|
9
|
+
*
|
|
10
|
+
* A frame that is still incomplete stays buffered until the rest of it arrives, so a
|
|
11
|
+
* shared buffer would prepend one characteristic's leftover bytes to the next
|
|
12
|
+
* characteristic's notification. Every declared byte offset is absolute, so that frame
|
|
13
|
+
* would then be decoded at a shifted offset - a plausible wrong reading rather than an
|
|
14
|
+
* error. Keeping the buffers apart makes that impossible.
|
|
15
|
+
*/
|
|
16
|
+
buffers = new Map();
|
|
8
17
|
isMeasuring = false;
|
|
9
18
|
constructor(device, mainServices, stuckDataTimeoutDuration, callbacks) {
|
|
10
19
|
this.device = device;
|
|
@@ -12,16 +21,24 @@ export class BTDataProcessor {
|
|
|
12
21
|
this.stuckDataTimeoutDuration = stuckDataTimeoutDuration;
|
|
13
22
|
this.callbacks = callbacks;
|
|
14
23
|
}
|
|
24
|
+
get collectedValues() {
|
|
25
|
+
return this.buffers.get(this.currentUuid) ?? [];
|
|
26
|
+
}
|
|
27
|
+
currentUuid = "";
|
|
15
28
|
destroy = () => {
|
|
16
|
-
this.
|
|
29
|
+
this.buffers.clear();
|
|
30
|
+
this.currentUuid = "";
|
|
17
31
|
this.isMeasuring = false;
|
|
18
32
|
clearTimeout(this.stuckDataTimeout);
|
|
19
33
|
this.stuckDataTimeout = undefined;
|
|
20
34
|
};
|
|
21
35
|
processData = (uuid, hexValue) => {
|
|
22
|
-
this.
|
|
36
|
+
this.currentUuid = String(uuid ?? "").toLowerCase();
|
|
37
|
+
const buffer = this.buffers.get(this.currentUuid) ?? [];
|
|
38
|
+
buffer.push(...hexValue);
|
|
39
|
+
this.buffers.set(this.currentUuid, buffer);
|
|
23
40
|
this.startStuckTimeout();
|
|
24
|
-
const isValid = this.callbacks.validatePackage(
|
|
41
|
+
const isValid = this.callbacks.validatePackage(buffer, uuid);
|
|
25
42
|
if (!isValid) {
|
|
26
43
|
return;
|
|
27
44
|
}
|
|
@@ -111,7 +128,7 @@ export class BTDataProcessor {
|
|
|
111
128
|
}
|
|
112
129
|
}
|
|
113
130
|
resetDataAndSendCommandToDevice = () => {
|
|
114
|
-
this.
|
|
131
|
+
this.buffers.set(this.currentUuid, []);
|
|
115
132
|
this.callbacks.onSendCommandToDevice?.();
|
|
116
133
|
};
|
|
117
134
|
startStuckTimeout = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CaseType","DeviceStatus","parseMeasurement","BTDataProcessor","
|
|
1
|
+
{"version":3,"names":["CaseType","DeviceStatus","parseMeasurement","BTDataProcessor","buffers","Map","isMeasuring","constructor","device","mainServices","stuckDataTimeoutDuration","callbacks","collectedValues","get","currentUuid","destroy","clear","clearTimeout","stuckDataTimeout","undefined","processData","uuid","hexValue","String","toLowerCase","buffer","push","set","startStuckTimeout","isValid","validatePackage","data","extractData","resetDataAndSendCommandToDevice","dependentData","parsingCase","caseType","DEPENDENT","handleDependentResult","handleStatusChanges","parsingModel","findParsingModel","value","caseValuePosition","map","index","join","findParsingCase","parsedData","parseData","measurementTypeKey","mainService","characteristic","monitorUuids","find","e","caseValue","cases","successResult","STREAM","onStreamStart","onStatusChanged","MEASURING","OTHER","CONNECTED","skipConnectedChange","onResult","RESULT","onSendCommandToDevice","setTimeout","onError","Error","cause","message","cancelConnection"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/devices/bt-data-processor.ts"],"mappings":";;AAGA,SAASA,QAAQ,QAAQ,0BAAuB;AAEhD,SAASC,YAAY,QAAQ,8BAA2B;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EACnC,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["sentryLogger","DeviceStatus","BTConnectionHandler","BTDataProcessor","BTManagedDevice","constructor","device","deviceName","onError","onErrorCallback","onDeviceStatusChanged","onDeviceStatusChangedCallback","onResult","onResultCallback","onDeviceDisconnected","onDeviceDisconnectedCallback","deviceId","id","deviceData","name","localName","manufacturerData","sn","measurementTypes","status","measurementTypeKey","error","Error","message","caseType","_","data","diagramPoints","length","undefined","destroy","connectionHandler","dataProcessor","connect","getSupportedMeasurementTypeKeys","mainServices","onStatusChanged","bind","DISCONNECTED","onDataReceived","uuid","hexValue","processData","stuckDataTimeout","onStreamStart","validatePackage","parsedData","collectedValues","handleSuccessResult","onSendCommandToDevice","sendCommandToDevice","handleDependentResult","flatMap","service","monitorUuids","parsingModel","cases","map","c","filter","type","uniqueMeasurementTypes","Set","flat"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/devices/bt-managed-device.ts"],"mappings":";;AAGA,SAASA,YAAY,QAAQ,yCAAsC;
|
|
1
|
+
{"version":3,"names":["sentryLogger","DeviceStatus","BTConnectionHandler","BTDataProcessor","BTManagedDevice","constructor","device","deviceName","onError","onErrorCallback","onDeviceStatusChanged","onDeviceStatusChangedCallback","onResult","onResultCallback","onDeviceDisconnected","onDeviceDisconnectedCallback","deviceId","id","deviceData","name","localName","manufacturerData","sn","measurementTypes","status","measurementTypeKey","error","Error","message","caseType","_","data","diagramPoints","length","undefined","destroy","connectionHandler","dataProcessor","connect","getSupportedMeasurementTypeKeys","mainServices","onStatusChanged","bind","DISCONNECTED","onDataReceived","uuid","hexValue","processData","stuckDataTimeout","onStreamStart","validatePackage","parsedData","collectedValues","handleSuccessResult","onSendCommandToDevice","sendCommandToDevice","handleDependentResult","flatMap","service","monitorUuids","parsingModel","cases","map","c","filter","type","uniqueMeasurementTypes","Set","flat"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/devices/bt-managed-device.ts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,eAAe,KAAK;QACzC,IAAI;UACF,OAAO,IAAI,CAACC,mBAAmB,CAACX,IAAI,CAAC,IAAI,CAAC,CACxCS,UAAU,EACVC,eACF,CAAC;QACH,CAAC,CAAC,OAAO1B,KAAK,EAAE;UACd,IAAI,CAAClB,OAAO,EAAEkC,IAAI,CAAC,IAAI,CAAC,CAAChB,KAAyB,CAAC;QACrD;MACF,CAAC;MACD4B,qBAAqB,EACnB,IAAI,CAAClB,iBAAiB,EAAEmB,mBAAmB,EAAEb,IAAI,CAAC,IAAI,CAAC;MACzDlC,OAAO,EAAE,IAAI,CAACA,OAAO,EAAEkC,IAAI,CAAC,IAAI,CAAC;MACjCc,qBAAqB,EAAE,IAAI,CAACA,qBAAqB,EAAEd,IAAI,CAAC,IAAI;IAC9D,CACF,CAAC;IAED,MAAM,IAAI,CAACN,iBAAiB,CAACE,OAAO,CAAC,CAAC;EACxC,CAAC;EAEOC,+BAA+B,GAAGA,CAAA,KAA4B;IACpE,MAAMhB,gBAAgB,GAAG,IAAI,CAACiB,YAAY,CACvCiB,OAAO,CAAEC,OAAO,IAAK;MACpB,OAAOA,OAAO,CAACC,YAAY,CAACF,OAAO,CAChCZ,IAAI,IACHA,IAAI,CAACe,YAAY,CAACC,KAAK,CAACC,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACtC,kBAAkB,CAAC,IAAI,EAChE,CAAC;IACH,CAAC,CAAC,CACDuC,MAAM,CAAEC,IAAI,IAAKA,IAAI,KAAK/B,SAAS,CAAC;IAEvC,MAAMgC,sBAAsB,GAAG,CAAC,GAAG,IAAIC,GAAG,CAAC5C,gBAAgB,CAAC6C,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpE,OAAOF,sBAAsB;EAC/B,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CaseType } from "../../../types/case-type.js";
|
|
4
|
+
import { createFrameValidator } from "../../../utils/create-frame-validator.js";
|
|
5
|
+
import { BTManagedDevice } from "../bt-managed-device.js";
|
|
6
|
+
const RESERVED_KEYS = ["measurementTypeKey", "caseType"];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Runs a device registered with defineCustomDevice.
|
|
10
|
+
*
|
|
11
|
+
* Everything specific to the device is data: the services and characteristics it exposes,
|
|
12
|
+
* how a complete frame is recognised, which frame carries which reading, and how each byte
|
|
13
|
+
* range becomes a number. What is left here is the safety net - a reading is reported only
|
|
14
|
+
* when every property the declaration named decoded to a finite number inside the range the
|
|
15
|
+
* catalog accepts. Anything else is reported through onError and no measurement is emitted.
|
|
16
|
+
*/
|
|
17
|
+
export class CustomDevice extends BTManagedDevice {
|
|
18
|
+
validators = new Map();
|
|
19
|
+
constructor(device, params, definition) {
|
|
20
|
+
super(device, params);
|
|
21
|
+
this.definition = definition;
|
|
22
|
+
this.mainServices = definition.mainServices;
|
|
23
|
+
this.stuckDataTimeout = definition.stuckDataTimeout;
|
|
24
|
+
definition.frames.forEach((frame, uuid) => {
|
|
25
|
+
this.validators.set(uuid, createFrameValidator(frame));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
validatePackage = (pkg, uuid) => {
|
|
29
|
+
const validate = this.validators.get(String(uuid ?? "").toLowerCase());
|
|
30
|
+
if (!validate) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return validate(pkg);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Every declared "result" frame arrives here, whether or not the device streamed first.
|
|
38
|
+
* The reading is checked and reported, and the frame is then handed back as OTHER so the
|
|
39
|
+
* processor returns the device to CONNECTED without reporting it a second time.
|
|
40
|
+
*/
|
|
41
|
+
handleDependentResult = data => {
|
|
42
|
+
try {
|
|
43
|
+
this.report(data.parsedData);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
this.onError?.(error);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
...data,
|
|
49
|
+
parsingCase: {
|
|
50
|
+
...data.parsingCase,
|
|
51
|
+
caseType: CaseType.OTHER
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Stream frames reach this while the device is measuring. They carry no fields, and the
|
|
58
|
+
* readings themselves are reported from handleDependentResult, so there is nothing to do.
|
|
59
|
+
*/
|
|
60
|
+
handleSuccessResult() {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
report(parsedData) {
|
|
64
|
+
const measurementTypeKey = parsedData.measurementTypeKey;
|
|
65
|
+
if (!measurementTypeKey) {
|
|
66
|
+
this.fail("a result frame carries no measurement type", parsedData);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const names = Object.keys(parsedData).filter(key => !RESERVED_KEYS.includes(key));
|
|
70
|
+
if (names.length === 0) {
|
|
71
|
+
this.fail("a result frame decoded no properties", parsedData);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const rejection = names.map(name => this.reject(measurementTypeKey, name, parsedData[name])).find(message => message !== undefined);
|
|
75
|
+
if (rejection) {
|
|
76
|
+
this.fail(rejection, parsedData);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this.onResult?.(parsedData);
|
|
80
|
+
}
|
|
81
|
+
reject(measurementTypeKey, name, value) {
|
|
82
|
+
const field = this.definition.fields.get(`${measurementTypeKey}:${name}`);
|
|
83
|
+
if (!field) {
|
|
84
|
+
return `decoded "${name}", which is not declared for ${measurementTypeKey}`;
|
|
85
|
+
}
|
|
86
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
87
|
+
return `could not decode ${name}; the frame was shorter than the declaration expects`;
|
|
88
|
+
}
|
|
89
|
+
if (value < field.min || value > field.max) {
|
|
90
|
+
return `decoded ${name} = ${value} ${field.unit}, outside the accepted range ${field.min}-${field.max} ${field.unit}`;
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
fail(reason, parsedData) {
|
|
95
|
+
this.onError?.(new Error(`Custom device "${this.definition.id}": ${reason}. The reading was discarded (decoded ${JSON.stringify(parsedData)}).`));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=custom.device.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CaseType","createFrameValidator","BTManagedDevice","RESERVED_KEYS","CustomDevice","validators","Map","constructor","device","params","definition","mainServices","stuckDataTimeout","frames","forEach","frame","uuid","set","validatePackage","pkg","validate","get","String","toLowerCase","handleDependentResult","data","report","parsedData","error","onError","parsingCase","caseType","OTHER","handleSuccessResult","measurementTypeKey","fail","names","Object","keys","filter","key","includes","length","rejection","map","name","reject","find","message","undefined","onResult","value","field","fields","Number","isFinite","min","max","unit","reason","Error","id","JSON","stringify"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/custom/custom.device.ts"],"mappings":";;AAEA,SAASA,QAAQ,QAAQ,6BAA0B;AAQnD,SAASC,oBAAoB,QAAQ,0CAAuC;AAC5E,SAASC,eAAe,QAAQ,yBAAsB;AAKtD,MAAMC,aAAa,GAAG,CAAC,oBAAoB,EAAE,UAAU,CAAC;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,SAASF,eAAe,CAAiB;EAM/CG,UAAU,GAAG,IAAIC,GAAG,CAAqC,CAAC;EAE3EC,WAAWA,CACTC,MAAc,EACdC,MAA0C,EAC1CC,UAAkC,EAClC;IACA,KAAK,CAACF,MAAM,EAAEC,MAAM,CAAC;IAErB,IAAI,CAACC,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,YAAY,GAAGD,UAAU,CAACC,YAAY;IAC3C,IAAI,CAACC,gBAAgB,GAAGF,UAAU,CAACE,gBAAgB;IAEnDF,UAAU,CAACG,MAAM,CAACC,OAAO,CAAC,CAACC,KAAK,EAAEC,IAAI,KAAK;MACzC,IAAI,CAACX,UAA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AACC,SAAS,CAACpC,UAAU,CAAC,IACpH,CACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/accepted-device.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/compiled-custom-field.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/custom-byte-order.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/custom-case-kind.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/custom-case-spec.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CUSTOM_DEVICE_BRAND"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/custom-device-definition.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,qCAAkC;;AAQtE;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/custom-device-id.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/custom-device-spec.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/custom-field-encoding.ts"],"mappings":"","ignoreList":[]}
|