@ovok/native 1.16.1-dev.2135 → 1.16.1-dev.2139
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 +1 -0
- package/lib/commonjs/modules/bt-management/components/bt-provider-child-wrapper.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/runtime-context.js.map +1 -1
- package/lib/commonjs/modules/bt-management/index.js +12 -0
- package/lib/commonjs/modules/bt-management/index.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/bt-manager.js +50 -0
- package/lib/commonjs/modules/bt-management/services/bt-manager.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js +3 -0
- package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-command-writer.js +4 -2
- package/lib/commonjs/modules/bt-management/services/devices/bt-command-writer.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js +97 -28
- package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-current-time.js +59 -0
- package/lib/commonjs/modules/bt-management/services/devices/bt-current-time.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/bt-device-information.js +18 -37
- package/lib/commonjs/modules/bt-management/services/devices/bt-device-information.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +12 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-notification-readiness.js +68 -0
- package/lib/commonjs/modules/bt-management/services/devices/bt-notification-readiness.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/bt-pairing-retry.js +70 -0
- package/lib/commonjs/modules/bt-management/services/devices/bt-pairing-retry.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js +14 -0
- package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-details.js +77 -0
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-details.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-frame.js +49 -0
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-frame.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-racp.js +89 -0
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-racp.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose.js +35 -42
- package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/record-cursor.js +70 -0
- package/lib/commonjs/modules/bt-management/services/record-cursor.js.map +1 -0
- package/lib/commonjs/modules/bt-management/testing/fake-ble-manager.js +8 -0
- package/lib/commonjs/modules/bt-management/testing/fake-ble-manager.js.map +1 -1
- package/lib/commonjs/modules/bt-management/types/glucose-record-details.js +2 -0
- package/lib/commonjs/modules/bt-management/types/glucose-record-details.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/wait.js +10 -0
- package/lib/commonjs/modules/bt-management/utils/wait.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-link.js +41 -4
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-link.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/connections.js +4 -0
- package/lib/commonjs/modules/next/bluetooth/connections.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/driver.js +6 -0
- package/lib/commonjs/modules/next/bluetooth/driver.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/react-native/ovok-sink.js +12 -1
- package/lib/commonjs/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/readings.js +2 -1
- package/lib/commonjs/modules/next/bluetooth/readings.js.map +1 -1
- package/lib/module/modules/bt-management/components/bt-provider-child-wrapper.js +1 -0
- package/lib/module/modules/bt-management/components/bt-provider-child-wrapper.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/runtime-context.js.map +1 -1
- package/lib/module/modules/bt-management/index.js +1 -0
- package/lib/module/modules/bt-management/index.js.map +1 -1
- package/lib/module/modules/bt-management/services/bt-manager.js +50 -0
- package/lib/module/modules/bt-management/services/bt-manager.js.map +1 -1
- package/lib/module/modules/bt-management/services/custom/define-custom-device.js +3 -0
- package/lib/module/modules/bt-management/services/custom/define-custom-device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-command-writer.js +4 -2
- package/lib/module/modules/bt-management/services/devices/bt-command-writer.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js +97 -28
- package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-current-time.js +55 -0
- package/lib/module/modules/bt-management/services/devices/bt-current-time.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/bt-device-information.js +18 -37
- package/lib/module/modules/bt-management/services/devices/bt-device-information.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +13 -2
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-notification-readiness.js +65 -0
- package/lib/module/modules/bt-management/services/devices/bt-notification-readiness.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/bt-pairing-retry.js +65 -0
- package/lib/module/modules/bt-management/services/devices/bt-pairing-retry.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/custom/custom.device.js +14 -0
- package/lib/module/modules/bt-management/services/devices/custom/custom.device.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-details.js +72 -0
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-details.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-frame.js +40 -0
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-frame.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-racp.js +85 -0
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-racp.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose.js +25 -32
- package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose.js.map +1 -1
- package/lib/module/modules/bt-management/services/record-cursor.js +66 -0
- package/lib/module/modules/bt-management/services/record-cursor.js.map +1 -0
- package/lib/module/modules/bt-management/testing/fake-ble-manager.js +8 -0
- package/lib/module/modules/bt-management/testing/fake-ble-manager.js.map +1 -1
- package/lib/module/modules/bt-management/types/custom-device-definition.js +4 -0
- package/lib/module/modules/bt-management/types/custom-device-definition.js.map +1 -1
- package/lib/module/modules/bt-management/types/glucose-record-details.js +2 -0
- package/lib/module/modules/bt-management/types/glucose-record-details.js.map +1 -0
- package/lib/module/modules/bt-management/utils/wait.js +5 -0
- package/lib/module/modules/bt-management/utils/wait.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-link.js +41 -4
- package/lib/module/modules/next/bluetooth/ble-plx/ble-link.js.map +1 -1
- package/lib/module/modules/next/bluetooth/connections.js +4 -0
- package/lib/module/modules/next/bluetooth/connections.js.map +1 -1
- package/lib/module/modules/next/bluetooth/driver.js +6 -0
- package/lib/module/modules/next/bluetooth/driver.js.map +1 -1
- package/lib/module/modules/next/bluetooth/react-native/ovok-sink.js +12 -1
- package/lib/module/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -1
- package/lib/module/modules/next/bluetooth/readings.js +2 -1
- package/lib/module/modules/next/bluetooth/readings.js.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-sign-in.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/runtime-context.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/runtime-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts +1 -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 +20 -0
- 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/define-custom-device.d.ts +2 -1
- 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/devices/bt-command-writer.d.ts +3 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-command-writer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +14 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-current-time.d.ts +11 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-current-time.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-device-information.d.ts +2 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-device-information.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts +9 -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/bt-notification-readiness.d.ts +15 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-notification-readiness.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-pairing-retry.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-pairing-retry.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom.device.d.ts +2 -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/standard-gatt/standard-gatt.glucose-details.d.ts +7 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-details.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-frame.d.ts +16 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-frame.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-racp.d.ts +8 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-racp.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/record-cursor.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/record-cursor.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/testing/fake-ble-manager.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts +6 -2
- package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/create-device-params.d.ts +3 -0
- 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-device-definition.d.ts +14 -1
- 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/glucose-record-details.d.ts +33 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/glucose-record-details.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/wait.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/wait.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/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/connections.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/driver.d.ts +6 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/driver.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/link.d.ts +12 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/link.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/snapshot.d.ts +4 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/snapshot.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/hooks/use-sign-in.d.ts +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/runtime-context.d.ts +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/runtime-context.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/index.d.ts +1 -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 +20 -0
- 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/define-custom-device.d.ts +2 -1
- 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/devices/bt-command-writer.d.ts +3 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-command-writer.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +14 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-current-time.d.ts +11 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-current-time.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-device-information.d.ts +2 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-device-information.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts +9 -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/bt-notification-readiness.d.ts +15 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-notification-readiness.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-pairing-retry.d.ts +21 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-pairing-retry.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom.device.d.ts +2 -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/standard-gatt/standard-gatt.glucose-details.d.ts +7 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-details.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-frame.d.ts +16 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-frame.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-racp.d.ts +8 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose-racp.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/record-cursor.d.ts +21 -0
- package/lib/typescript/module/src/modules/bt-management/services/record-cursor.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/testing/fake-ble-manager.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts +6 -2
- package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/create-device-params.d.ts +3 -0
- 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-device-definition.d.ts +14 -1
- 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/glucose-record-details.d.ts +33 -0
- package/lib/typescript/module/src/modules/bt-management/types/glucose-record-details.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/wait.d.ts +3 -0
- package/lib/typescript/module/src/modules/bt-management/utils/wait.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/data-sync/services/managers/sync-progress-manager.d.ts +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/connections.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/driver.d.ts +6 -1
- package/lib/typescript/module/src/modules/next/bluetooth/driver.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/link.d.ts +12 -1
- package/lib/typescript/module/src/modules/next/bluetooth/link.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/snapshot.d.ts +4 -1
- package/lib/typescript/module/src/modules/next/bluetooth/snapshot.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose.js
CHANGED
|
@@ -6,18 +6,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.standardGlucoseDevice = exports.recordedAtFromGlucoseFrame = void 0;
|
|
7
7
|
var _next = require("@ovok/core/next");
|
|
8
8
|
var _bytesToHex = require("../../../utils/bytes-to-hex.js");
|
|
9
|
-
var _sigUuid = require("../../../utils/sig-uuid.js");
|
|
10
9
|
var _defineCustomDevice = require("../../custom/define-custom-device.js");
|
|
10
|
+
var _standardGattGlucoseDetails = require("./standard-gatt.glucose-details.js");
|
|
11
|
+
var _standardGattGlucoseFrame = require("./standard-gatt.glucose-frame.js");
|
|
12
|
+
var _standardGattGlucoseRacp = require("./standard-gatt.glucose-racp.js");
|
|
11
13
|
var _standardGattProfile = require("./standard-gatt.profile.js");
|
|
12
14
|
/**
|
|
13
15
|
* Glucose Service 0x1808: Glucose Measurement 0x2A18 and the Record Access Control Point
|
|
14
16
|
* 0x2A52.
|
|
15
17
|
*
|
|
16
18
|
* A glucose meter does not push its readings. The collector enables indications on the
|
|
17
|
-
* control point
|
|
18
|
-
*
|
|
19
|
-
* (`
|
|
20
|
-
*
|
|
19
|
+
* control point and writes a request for the stored records: those after the newest one it
|
|
20
|
+
* has read (`01 03 01 nn nn`) when the manager has a `recordCursorStorage`, otherwise all of
|
|
21
|
+
* them (`01 01`). The meter answers with one Glucose Measurement per record followed by a
|
|
22
|
+
* control-point response (`06 00 01 xx`). The SDK's stable result identity, which covers the
|
|
23
|
+
* record's sequence number, keeps a record seen twice from becoming a second reading.
|
|
21
24
|
*
|
|
22
25
|
* Glucose Measurement layout: flags, sequence number (2), base time (7), time offset (2,
|
|
23
26
|
* flag bit 0), concentration SFLOAT (2) and type/sample-location (1) (bit 1), sensor status
|
|
@@ -27,41 +30,33 @@ const MG_PER_DL_PER_KG_PER_L = 100_000;
|
|
|
27
30
|
|
|
28
31
|
/** One mol/L of glucose (180.16 g/mol) is 18,016 mg/dL. */
|
|
29
32
|
const MG_PER_DL_PER_MOL_PER_L = 18_016;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const BASE_TIME_INDEX = 3;
|
|
34
|
-
const TIME_OFFSET_INDEX = 10;
|
|
33
|
+
|
|
34
|
+
/** One decimal reads a mmol/L result (0.1 mmol/L is 1.8 mg/dL) back as the meter showed it. */
|
|
35
|
+
const MG_PER_DL_DECIMALS = 1;
|
|
35
36
|
|
|
36
37
|
/** Type 0xA and sample location 0x4 both mean a control-solution test, not a patient sample. */
|
|
37
38
|
const CONTROL_SOLUTION_TYPE = 0x0a;
|
|
38
39
|
const CONTROL_SOLUTION_LOCATION = 0x04;
|
|
39
|
-
const REPORT_ALL_STORED_RECORDS = "0101";
|
|
40
|
-
const concentrationIndex = flags => flags & FLAG_TIME_OFFSET ? TIME_OFFSET_INDEX + 2 : TIME_OFFSET_INDEX;
|
|
41
40
|
|
|
42
41
|
/** Bits 5-7 are reserved; a meter that sets one still sends a readable record. */
|
|
43
42
|
const ALL_FLAGS = Array.from({
|
|
44
43
|
length: 256
|
|
45
44
|
}, (_, flags) => flags);
|
|
46
45
|
const glucoseField = flags => {
|
|
47
|
-
const index = concentrationIndex(flags);
|
|
46
|
+
const index = (0, _standardGattGlucoseFrame.concentrationIndex)(flags);
|
|
48
47
|
return {
|
|
49
48
|
...(0, _standardGattProfile.littleEndian)("bloodGlucose", [index, index + 1], "mg/dL", "sfloat"),
|
|
50
|
-
scale: flags & FLAG_MOL_PER_L ? MG_PER_DL_PER_MOL_PER_L : MG_PER_DL_PER_KG_PER_L,
|
|
51
|
-
decimals:
|
|
49
|
+
scale: flags & _standardGattGlucoseFrame.FLAG_MOL_PER_L ? MG_PER_DL_PER_MOL_PER_L : MG_PER_DL_PER_KG_PER_L,
|
|
50
|
+
decimals: MG_PER_DL_DECIMALS
|
|
52
51
|
};
|
|
53
52
|
};
|
|
54
|
-
const byte = (frame, index) => {
|
|
55
|
-
const value = Number.parseInt(frame[index] ?? "", 16);
|
|
56
|
-
return Number.isInteger(value) ? value : undefined;
|
|
57
|
-
};
|
|
58
53
|
|
|
59
54
|
/** The record's own time: the base time plus its offset in minutes, read as phone-local. */
|
|
60
55
|
const recordedAtFromGlucoseFrame = frame => {
|
|
61
56
|
const parts = Array.from({
|
|
62
57
|
length: 7
|
|
63
|
-
}, (_, i) => byte(frame, BASE_TIME_INDEX + i));
|
|
64
|
-
const flags = byte(frame, 0);
|
|
58
|
+
}, (_, i) => (0, _standardGattGlucoseFrame.byte)(frame, _standardGattGlucoseFrame.BASE_TIME_INDEX + i));
|
|
59
|
+
const flags = (0, _standardGattGlucoseFrame.byte)(frame, 0);
|
|
65
60
|
if (flags === undefined || parts.some(part => part === undefined)) {
|
|
66
61
|
return undefined;
|
|
67
62
|
}
|
|
@@ -73,9 +68,9 @@ const recordedAtFromGlucoseFrame = frame => {
|
|
|
73
68
|
if (recordedAt.getFullYear() !== year || recordedAt.getMonth() !== month - 1 || recordedAt.getDate() !== day || recordedAt.getHours() !== hour || recordedAt.getMinutes() !== minute || recordedAt.getSeconds() !== second) {
|
|
74
69
|
return undefined;
|
|
75
70
|
}
|
|
76
|
-
if (flags & FLAG_TIME_OFFSET) {
|
|
77
|
-
const low = byte(frame, TIME_OFFSET_INDEX);
|
|
78
|
-
const high = byte(frame, TIME_OFFSET_INDEX + 1);
|
|
71
|
+
if (flags & _standardGattGlucoseFrame.FLAG_TIME_OFFSET) {
|
|
72
|
+
const low = (0, _standardGattGlucoseFrame.byte)(frame, _standardGattGlucoseFrame.TIME_OFFSET_INDEX);
|
|
73
|
+
const high = (0, _standardGattGlucoseFrame.byte)(frame, _standardGattGlucoseFrame.TIME_OFFSET_INDEX + 1);
|
|
79
74
|
if (low === undefined || high === undefined) {
|
|
80
75
|
return undefined;
|
|
81
76
|
}
|
|
@@ -86,8 +81,7 @@ const recordedAtFromGlucoseFrame = frame => {
|
|
|
86
81
|
};
|
|
87
82
|
exports.recordedAtFromGlucoseFrame = recordedAtFromGlucoseFrame;
|
|
88
83
|
const isControlSolution = frame => {
|
|
89
|
-
const
|
|
90
|
-
const typeAndLocation = byte(frame, concentrationIndex(flags) + 2);
|
|
84
|
+
const typeAndLocation = (0, _standardGattGlucoseFrame.typeAndLocationFromGlucoseFrame)(frame);
|
|
91
85
|
return typeAndLocation !== undefined && ((typeAndLocation & 0x0f) === CONTROL_SOLUTION_TYPE || typeAndLocation >> 4 === CONTROL_SOLUTION_LOCATION);
|
|
92
86
|
};
|
|
93
87
|
|
|
@@ -99,26 +93,26 @@ const standardGlucoseDevice = params => (0, _defineCustomDevice.defineCustomDevi
|
|
|
99
93
|
oneReadingPerConnection: params.oneReadingPerConnection,
|
|
100
94
|
stuckDataTimeoutMs: params.stuckDataTimeoutMs ?? 60_000,
|
|
101
95
|
services: [{
|
|
102
|
-
uuid:
|
|
96
|
+
uuid: _standardGattGlucoseRacp.GLUCOSE_SERVICE_UUID,
|
|
103
97
|
monitor: [{
|
|
104
|
-
uuid:
|
|
98
|
+
uuid: _standardGattGlucoseRacp.GLUCOSE_MEASUREMENT_UUID,
|
|
105
99
|
frame: {
|
|
106
|
-
minLengthBytes: TIME_OFFSET_INDEX
|
|
100
|
+
minLengthBytes: _standardGattGlucoseFrame.TIME_OFFSET_INDEX
|
|
107
101
|
},
|
|
108
102
|
caseSelectorBytes: [0],
|
|
109
|
-
cases: ALL_FLAGS.map(flags => flags & FLAG_CONCENTRATION ? {
|
|
103
|
+
cases: ALL_FLAGS.map(flags => flags & _standardGattGlucoseFrame.FLAG_CONCENTRATION ? {
|
|
110
104
|
selector: (0, _bytesToHex.byteToHex)(flags),
|
|
111
105
|
kind: "result",
|
|
112
106
|
measurementTypeKey: _next.MeasurementTypeKey.bloodGlucose,
|
|
113
107
|
fields: [glucoseField(flags)],
|
|
114
|
-
minLengthBytes: concentrationIndex(flags) + 3
|
|
108
|
+
minLengthBytes: (0, _standardGattGlucoseFrame.concentrationIndex)(flags) + 3
|
|
115
109
|
} : {
|
|
116
110
|
selector: (0, _bytesToHex.byteToHex)(flags),
|
|
117
111
|
kind: "idle",
|
|
118
112
|
description: "A record without a concentration"
|
|
119
113
|
})
|
|
120
114
|
}, {
|
|
121
|
-
uuid:
|
|
115
|
+
uuid: _standardGattGlucoseRacp.RECORD_ACCESS_CONTROL_POINT_UUID,
|
|
122
116
|
frame: {
|
|
123
117
|
minLengthBytes: 2
|
|
124
118
|
},
|
|
@@ -132,23 +126,22 @@ const standardGlucoseDevice = params => (0, _defineCustomDevice.defineCustomDevi
|
|
|
132
126
|
kind: "idle",
|
|
133
127
|
description: "Record access response"
|
|
134
128
|
}]
|
|
135
|
-
}]
|
|
136
|
-
write: {
|
|
137
|
-
uuid: (0, _sigUuid.sigUuid)("2a52"),
|
|
138
|
-
commandHex: REPORT_ALL_STORED_RECORDS,
|
|
139
|
-
when: "connect"
|
|
140
|
-
}
|
|
129
|
+
}]
|
|
141
130
|
}]
|
|
142
131
|
}, {
|
|
132
|
+
createCommandSequencer: _standardGattGlucoseRacp.createGlucoseSequencer,
|
|
143
133
|
decorateReading: (reading, frame, recordOffset) => {
|
|
144
|
-
if (frame && isControlSolution(frame)) {
|
|
134
|
+
if (frame && (isControlSolution(frame) || (0, _standardGattGlucoseDetails.hasUnusableSensorStatus)(frame))) {
|
|
145
135
|
return null;
|
|
146
136
|
}
|
|
147
137
|
const recordedAt = frame ? recordedAtFromGlucoseFrame(frame) : undefined;
|
|
148
|
-
const decorated =
|
|
138
|
+
const decorated = {
|
|
149
139
|
...reading,
|
|
150
|
-
|
|
151
|
-
|
|
140
|
+
...(frame && (0, _standardGattGlucoseDetails.glucoseRecordDetails)(frame)),
|
|
141
|
+
...(recordedAt && {
|
|
142
|
+
recordedAt
|
|
143
|
+
})
|
|
144
|
+
};
|
|
152
145
|
return params.decorateReading ? params.decorateReading(decorated, frame, recordOffset) : decorated;
|
|
153
146
|
}
|
|
154
147
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_next","require","_bytesToHex","
|
|
1
|
+
{"version":3,"names":["_next","require","_bytesToHex","_defineCustomDevice","_standardGattGlucoseDetails","_standardGattGlucoseFrame","_standardGattGlucoseRacp","_standardGattProfile","MG_PER_DL_PER_KG_PER_L","MG_PER_DL_PER_MOL_PER_L","MG_PER_DL_DECIMALS","CONTROL_SOLUTION_TYPE","CONTROL_SOLUTION_LOCATION","ALL_FLAGS","Array","from","length","_","flags","glucoseField","index","concentrationIndex","littleEndian","scale","FLAG_MOL_PER_L","decimals","recordedAtFromGlucoseFrame","frame","parts","i","byte","BASE_TIME_INDEX","undefined","some","part","yearLow","yearHigh","month","day","hour","minute","second","year","recordedAt","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","FLAG_TIME_OFFSET","low","TIME_OFFSET_INDEX","high","offsetMinutes","setMinutes","exports","isControlSolution","typeAndLocation","typeAndLocationFromGlucoseFrame","standardGlucoseDevice","params","defineCustomDevice","id","MeasurementTypeKey","bloodGlucose","nameMatch","matchByService","oneReadingPerConnection","stuckDataTimeoutMs","services","uuid","GLUCOSE_SERVICE_UUID","monitor","GLUCOSE_MEASUREMENT_UUID","minLengthBytes","caseSelectorBytes","cases","map","FLAG_CONCENTRATION","selector","byteToHex","kind","measurementTypeKey","fields","description","RECORD_ACCESS_CONTROL_POINT_UUID","createCommandSequencer","createGlucoseSequencer","decorateReading","reading","recordOffset","hasUnusableSensorStatus","decorated","glucoseRecordDetails"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/standard-gatt/standard-gatt.glucose.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEA,IAAAG,2BAAA,GAAAH,OAAA;AAIA,IAAAI,yBAAA,GAAAJ,OAAA;AAUA,IAAAK,wBAAA,GAAAL,OAAA;AAMA,IAAAM,oBAAA,GAAAN,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMO,sBAAsB,GAAG,OAAO;;AAEtC;AACA,MAAMC,uBAAuB,GAAG,MAAM;;AAEtC;AACA,MAAMC,kBAAkB,GAAG,CAAC;;AAE5B;AACA,MAAMC,qBAAqB,GAAG,IAAI;AAClC,MAAMC,yBAAyB,GAAG,IAAI;;AAEtC;AACA,MAAMC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;EAAEC,MAAM,EAAE;AAAI,CAAC,EAAE,CAACC,CAAC,EAAEC,KAAK,KAAKA,KAAK,CAAC;AAElE,MAAMC,YAAY,GAAID,KAAa,IAAsB;EACvD,MAAME,KAAK,GAAG,IAAAC,4CAAkB,EAACH,KAAK,CAAC;EAEvC,OAAO;IACL,GAAG,IAAAI,iCAAY,EAAC,cAAc,EAAE,CAACF,KAAK,EAAEA,KAAK,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC;IACtEG,KAAK,EACHL,KAAK,GAAGM,wCAAc,GAAGf,uBAAuB,GAAGD,sBAAsB;IAC3EiB,QAAQ,EAAEf;EACZ,CAAC;AACH,CAAC;;AAED;AACA,MAAMgB,0BAA0B,GAAIC,KAAwB,IAAu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,CAAC;MACzC,IAAIgB,UAAU,IAAI;QAAEA;MAAW,CAAC;IAClC,CAAC;IAED,OAAOmB,MAAM,CAAC4B,eAAe,GACzB5B,MAAM,CAAC4B,eAAe,CAACI,SAAS,EAAEnE,KAAK,EAAEiE,YAAY,CAAC,GACtDE,SAAS;EACf;AACF,CACF,CAAC;AAACrC,OAAA,CAAAI,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RecordCursor = void 0;
|
|
7
|
+
var _sentryLogger = require("../../helpers/utils/sentry-logger.js");
|
|
8
|
+
var _bluetoothError = require("../types/bluetooth-error.js");
|
|
9
|
+
const parseCursor = stored => {
|
|
10
|
+
const parsed = Number.parseInt(stored ?? "", 10);
|
|
11
|
+
return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : undefined;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The number of the newest stored record read from one device, kept in `storage` so the next
|
|
16
|
+
* connection asks the device for newer records only. Without storage it forgets on disconnect.
|
|
17
|
+
*/
|
|
18
|
+
class RecordCursor {
|
|
19
|
+
writing = false;
|
|
20
|
+
changedWhileWriting = false;
|
|
21
|
+
constructor(storage, key) {
|
|
22
|
+
this.storage = storage;
|
|
23
|
+
this.key = key;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** What an earlier connection stored; nothing, an unreadable value or a failing store gives `undefined`. */
|
|
27
|
+
load = async () => {
|
|
28
|
+
try {
|
|
29
|
+
this.newest = parseCursor(await this.storage?.getItem(this.key));
|
|
30
|
+
} catch (error) {
|
|
31
|
+
(0, _sentryLogger.sentryLogger)("error", "RECORD_CURSOR: Could not read the stored cursor", {
|
|
32
|
+
errorCode: (0, _bluetoothError.toBluetoothError)(error).code
|
|
33
|
+
});
|
|
34
|
+
this.newest = undefined;
|
|
35
|
+
}
|
|
36
|
+
return this.newest;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** Remembers a record number that is newer than any seen; writes to the store are coalesced. */
|
|
40
|
+
advance = recordNumber => {
|
|
41
|
+
if (this.newest !== undefined && recordNumber <= this.newest) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.newest = recordNumber;
|
|
45
|
+
void this.persist();
|
|
46
|
+
};
|
|
47
|
+
persist = async () => {
|
|
48
|
+
if (this.writing) {
|
|
49
|
+
this.changedWhileWriting = true;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.writing = true;
|
|
53
|
+
do {
|
|
54
|
+
this.changedWhileWriting = false;
|
|
55
|
+
await this.store();
|
|
56
|
+
} while (this.changedWhileWriting);
|
|
57
|
+
this.writing = false;
|
|
58
|
+
};
|
|
59
|
+
store = async () => {
|
|
60
|
+
try {
|
|
61
|
+
await this.storage?.setItem(this.key, String(this.newest));
|
|
62
|
+
} catch (error) {
|
|
63
|
+
(0, _sentryLogger.sentryLogger)("error", "RECORD_CURSOR: Could not store the cursor", {
|
|
64
|
+
errorCode: (0, _bluetoothError.toBluetoothError)(error).code
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
exports.RecordCursor = RecordCursor;
|
|
70
|
+
//# sourceMappingURL=record-cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_sentryLogger","require","_bluetoothError","parseCursor","stored","parsed","Number","parseInt","isSafeInteger","undefined","RecordCursor","writing","changedWhileWriting","constructor","storage","key","load","newest","getItem","error","sentryLogger","errorCode","toBluetoothError","code","advance","recordNumber","persist","store","setItem","String","exports"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/services/record-cursor.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAEA,MAA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AE/B;IACF;IAEA,IAAI,CAACD,OAAO,GAAG,IAAI;IAEnB,GAAG;MACD,IAAI,CAACC,mBAAmB,GAAG,KAAK;MAChC,MAAM,IAAI,CAACe,KAAK,CAAC,CAAC;IACpB,CAAC,QAAQ,IAAI,CAACf,mBAAmB;IAEjC,IAAI,CAACD,OAAO,GAAG,KAAK;EACtB,CAAC;EAEOgB,KAAK,GAAG,MAAAA,CAAA,KAA2B;IACzC,IAAI;MACF,MAAM,IAAI,CAACb,OAAO,EAAEc,OAAO,CAAC,IAAI,CAACb,GAAG,EAAEc,MAAM,CAAC,IAAI,CAACZ,MAAM,CAAC,CAAC;IAC5D,CAAC,CAAC,OAAOE,KAAK,EAAE;MACd,IAAAC,0BAAY,EAAC,OAAO,EAAE,2CAA2C,EAAE;QACjEC,SAAS,EAAE,IAAAC,gCAAgB,EAACH,KAAK,CAAC,CAACI;MACrC,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAACO,OAAA,CAAApB,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createFakeBleManager = exports.createFakeBleDevice = void 0;
|
|
7
|
+
var _buffer = require("buffer");
|
|
7
8
|
var _reactNativeBlePlx = require("react-native-ble-plx");
|
|
8
9
|
/* eslint-disable import/group-exports */
|
|
9
10
|
|
|
@@ -16,6 +17,8 @@ var _reactNativeBlePlx = require("react-native-ble-plx");
|
|
|
16
17
|
/** A deterministic BLE manager for hook and scan integration tests. No hardware is used. */
|
|
17
18
|
|
|
18
19
|
const characteristicKey = (serviceUuid, characteristicUuid) => `${serviceUuid}/${characteristicUuid}`;
|
|
20
|
+
const NOTIFICATIONS_ENABLED = _buffer.Buffer.from([0x01, 0x00]).toString("base64");
|
|
21
|
+
const NOTIFICATIONS_DISABLED = _buffer.Buffer.from([0x00, 0x00]).toString("base64");
|
|
19
22
|
|
|
20
23
|
/** Creates a GATT-capable fake device for connection and notification tests. */
|
|
21
24
|
const createFakeBleDevice = ({
|
|
@@ -30,6 +33,7 @@ const createFakeBleDevice = ({
|
|
|
30
33
|
let connected = false;
|
|
31
34
|
let currentMtu = mtu;
|
|
32
35
|
const values = new Map(Object.entries(characteristics));
|
|
36
|
+
const monitoredKeys = new Set();
|
|
33
37
|
const disconnectedCallbacks = new Set();
|
|
34
38
|
const notificationCallbacks = new Map();
|
|
35
39
|
const fake = {
|
|
@@ -65,8 +69,12 @@ const createFakeBleDevice = ({
|
|
|
65
69
|
readCharacteristicForService: async (serviceUuid, characteristicUuid) => ({
|
|
66
70
|
value: values.get(characteristicKey(serviceUuid, characteristicUuid)) ?? null
|
|
67
71
|
}),
|
|
72
|
+
readDescriptorForService: async (serviceUuid, characteristicUuid) => ({
|
|
73
|
+
value: monitoredKeys.has(characteristicKey(serviceUuid, characteristicUuid)) ? NOTIFICATIONS_ENABLED : NOTIFICATIONS_DISABLED
|
|
74
|
+
}),
|
|
68
75
|
monitorCharacteristicForService: (serviceUuid, characteristicUuid, callback) => {
|
|
69
76
|
const key = characteristicKey(serviceUuid, characteristicUuid);
|
|
77
|
+
monitoredKeys.add(key);
|
|
70
78
|
const callbacks = notificationCallbacks.get(key) ?? new Set();
|
|
71
79
|
callbacks.add(callback);
|
|
72
80
|
notificationCallbacks.set(key, callbacks);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_buffer","require","_reactNativeBlePlx","characteristicKey","serviceUuid","characteristicUuid","NOTIFICATIONS_ENABLED","Buffer","from","toString","NOTIFICATIONS_DISABLED","createFakeBleDevice","id","name","localName","manufacturerData","serviceUUIDs","mtu","characteristics","connected","currentMtu","values","Map","Object","entries","monitoredKeys","Set","disconnectedCallbacks","notificationCallbacks","fake","isConnected","connect","cancelConnection","forEach","callback","discoverAllServicesAndCharacteristics","onDisconnected","add","remove","delete","requestMTU","requestedMtu","readCharacteristicForService","value","get","readDescriptorForService","has","monitorCharacteristicForService","key","callbacks","set","writeCharacteristicWithResponseForService","writeCharacteristicWithoutResponseForService","device","emitCharacteristic","characteristic","uuid","disconnect","exports","createFakeBleManager","state","State","PoweredOn","devices","currentState","scanCallback","stateCallbacks","scannedServiceUUIDs","manager","onStateChange","emitCurrentState","startDeviceScan","_options","stopDeviceScan","undefined","createDevice","emitDevice","emitError","error","setState","nextState","getScannedServiceUUIDs"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/testing/fake-ble-manager.ts"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,kBAAA,GAAAD,OAAA;AAJA;;AAMA;;AAyBA;;AAiBA;;AAUA;;AAyBA,MAAME,iBAAiB,GAAGA,CAACC,WAAmB,EAAEC,kBAA0B,KACxE,GAAGD,WAAW,IAAIC,kBAAkB,EAAE;AAExC,MAAMC,qBAAqB,GAAGC,cAAM,CAACC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAACC,QAAQ,CAAC,QAAQ,CAAC;AAC1E,MAAMC,sBAAsB,GAAGH,cAAM,CAACC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAACC,QAAQ,CAAC,QAAQ,CAAC;;AAE3E;AACO,MAAME,mBAAmB,GAAGA,CAAC;EAClCC,EAAE;EACFC,IAAI,GAAGD,EAAE;EACTE,SAAS,GAAGD,IAAI;EAChBE,gBAAgB,GAAG,EAAE;EACrBC,YAAY,GAAG,EAAE;EACjBC,GAAG,GAAG,EAAE;EACRC,eAAe,GAAG,CAAC;AACC,CAAC,KAAoB;EACzC,IAAIC,SAAS,GAAG,KAAK;EACrB,IAAIC,UAAU,GAAGH,GAAG;EACpB,MAAMI,MAAM,GAAG,IAAIC,GAAG,CAACC,MAAM,CAACC,OAAO,CAACN,eAAe,CAAC,CAAC;EACvD,MAAMO,aAAa,GAAG,IAAIC,GAAG,CAAS,CAAC;EACvC,MAAMC,qBAAq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B,YAAY,GAAGgB,SAAS;MACxBd,cAAc,CAACjC,OAAO,CAAEC,QAAQ,IAAKA,QAAQ,CAAC8C,SAAS,CAAC,CAAC;IAC3D,CAAC;IACDC,sBAAsB,EAAEA,CAAA,KAAMd,mBAAmB;IACjDM,cAAc,EAAEA,CAAA,KAAML,OAAO,CAACK,cAAc,CAAC;EAC/C,CAAC;AACH,CAAC;AAACf,OAAA,CAAAC,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/bt-management/types/glucose-record-details.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.wait = void 0;
|
|
7
|
+
/** Resolves after `milliseconds`. */
|
|
8
|
+
const wait = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
9
|
+
exports.wait = wait;
|
|
10
|
+
//# sourceMappingURL=wait.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["wait","milliseconds","Promise","resolve","setTimeout","exports"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/utils/wait.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,IAAI,GAAIC,YAAoB,IACvC,IAAIC,OAAO,CAAEC,OAAO,IAAKC,UAAU,CAACD,OAAO,EAAEF,YAAY,CAAC,CAAC;AAACI,OAAA,CAAAL,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.openBleLink = openBleLink;
|
|
7
|
+
var _btDeviceInformation = require("../../../bt-management/services/devices/bt-device-information.js");
|
|
8
|
+
var _btNotificationReadiness = require("../../../bt-management/services/devices/bt-notification-readiness.js");
|
|
9
|
+
var _btPairingRetry = require("../../../bt-management/services/devices/bt-pairing-retry.js");
|
|
7
10
|
var _sentryLogger = require("../../../helpers/utils/sentry-logger.js");
|
|
8
11
|
var _channel = require("../channel.js");
|
|
9
12
|
var _bleErrors = require("./ble-errors.js");
|
|
@@ -54,13 +57,33 @@ async function connectWithRetries(device, signal) {
|
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|
|
60
|
+
|
|
61
|
+
/** Reads the standard Device Information strings; `undefined` when the device has none. */
|
|
62
|
+
async function readInformation(device, pairing) {
|
|
63
|
+
let information;
|
|
64
|
+
await (0, _btDeviceInformation.readDeviceInformation)(device, ({
|
|
65
|
+
manufacturerName,
|
|
66
|
+
model,
|
|
67
|
+
serialNumber
|
|
68
|
+
}) => {
|
|
69
|
+
information = {
|
|
70
|
+
manufacturerName,
|
|
71
|
+
model,
|
|
72
|
+
serialNumber
|
|
73
|
+
};
|
|
74
|
+
}, pairing.run);
|
|
75
|
+
return information;
|
|
76
|
+
}
|
|
57
77
|
class BleLink {
|
|
58
78
|
channels = new Set();
|
|
79
|
+
notificationsPending = new Set();
|
|
59
80
|
ended = false;
|
|
60
81
|
closeOnAbort = () => void this.close();
|
|
61
|
-
constructor(device, signal) {
|
|
82
|
+
constructor(device, signal, pairing, deviceInformation) {
|
|
62
83
|
this.device = device;
|
|
63
84
|
this.signal = signal;
|
|
85
|
+
this.pairing = pairing;
|
|
86
|
+
this.deviceInformation = deviceInformation;
|
|
64
87
|
this.disconnected = device.onDisconnected(() => this.endAll());
|
|
65
88
|
signal.addEventListener("abort", this.closeOnAbort, {
|
|
66
89
|
once: true
|
|
@@ -79,13 +102,15 @@ class BleLink {
|
|
|
79
102
|
}
|
|
80
103
|
});
|
|
81
104
|
this.channels.add(channel);
|
|
105
|
+
this.awaitNotifications(service, characteristic);
|
|
82
106
|
if (this.ended) {
|
|
83
107
|
channel.end();
|
|
84
108
|
}
|
|
85
109
|
return channel;
|
|
86
110
|
}
|
|
87
111
|
async write(service, characteristic, bytes) {
|
|
88
|
-
await this.
|
|
112
|
+
await Promise.all(this.notificationsPending);
|
|
113
|
+
await this.pairing.run(() => this.device.writeCharacteristicWithResponseForService(service, characteristic, toBase64(bytes)));
|
|
89
114
|
}
|
|
90
115
|
async close() {
|
|
91
116
|
this.signal.removeEventListener("abort", this.closeOnAbort);
|
|
@@ -93,6 +118,15 @@ class BleLink {
|
|
|
93
118
|
this.disconnected.remove();
|
|
94
119
|
await this.device.cancelConnection().catch(() => undefined);
|
|
95
120
|
}
|
|
121
|
+
|
|
122
|
+
/** A write waits for these, because a device may refuse a command until its notifications are on. */
|
|
123
|
+
awaitNotifications(serviceUuid, characteristicUuid) {
|
|
124
|
+
const enabled = (0, _btNotificationReadiness.awaitNotificationsEnabled)(this.device, [{
|
|
125
|
+
serviceUuid,
|
|
126
|
+
characteristicUuid
|
|
127
|
+
}]).finally(() => this.notificationsPending.delete(enabled));
|
|
128
|
+
this.notificationsPending.add(enabled);
|
|
129
|
+
}
|
|
96
130
|
endOrFail(channel, error) {
|
|
97
131
|
if (ENDS_THE_LINK.has(error.errorCode)) {
|
|
98
132
|
channel.end();
|
|
@@ -106,13 +140,16 @@ class BleLink {
|
|
|
106
140
|
}
|
|
107
141
|
}
|
|
108
142
|
|
|
109
|
-
/** Connects (retrying with backoff) and
|
|
143
|
+
/** Connects (retrying with backoff), discovers services and reads Device Information; aborting `signal` closes the link. */
|
|
110
144
|
async function openBleLink(device, signal) {
|
|
111
145
|
await connectWithRetries(device, signal).catch(error => {
|
|
112
146
|
throw (0, _bleErrors.fromBleError)(error);
|
|
113
147
|
});
|
|
148
|
+
const pairing = new _btPairingRetry.BTPairingRetry(device, () => (0, _sentryLogger.sentryLogger)("info", "BLUETOOTH: Waiting for the user to pair the device"));
|
|
149
|
+
let information;
|
|
114
150
|
try {
|
|
115
151
|
await device.discoverAllServicesAndCharacteristics();
|
|
152
|
+
information = await readInformation(device, pairing);
|
|
116
153
|
if (signal.aborted) {
|
|
117
154
|
throw abortReason(signal);
|
|
118
155
|
}
|
|
@@ -120,6 +157,6 @@ async function openBleLink(device, signal) {
|
|
|
120
157
|
await device.cancelConnection().catch(() => undefined);
|
|
121
158
|
throw (0, _bleErrors.fromBleError)(error);
|
|
122
159
|
}
|
|
123
|
-
return new BleLink(device, signal);
|
|
160
|
+
return new BleLink(device, signal, pairing, information);
|
|
124
161
|
}
|
|
125
162
|
//# sourceMappingURL=ble-link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_btDeviceInformation","require","_btNotificationReadiness","_btPairingRetry","_sentryLogger","_channel","_bleErrors","CONNECT_ATTEMPTS","FIRST_RETRY_DELAY_MS","MAX_RETRY_DELAY_MS","ENDS_THE_LINK","Set","toBytes","base64","Uint8Array","from","atob","char","charCodeAt","toBase64","bytes","btoa","String","fromCharCode","retryDelay","attempt","Math","min","abortReason","signal","reason","Error","wait","ms","Promise","resolve","reject","aborted","clearTimeout","timer","setTimeout","removeEventListener","addEventListener","once","connectWithRetries","device","isConnected","connect","error","sentryLogger","errorCode","fromBleError","code","attempts","readInformation","pairing","information","readDeviceInformation","manufacturerName","model","serialNumber","run","BleLink","channels","notificationsPending","ended","closeOnAbort","close","constructor","deviceInformation","disconnected","onDisconnected","endAll","subscribe","service","characteristic","channel","Channel","subscription","remove","delete","monitorCharacteristicForService","value","endOrFail","push","add","awaitNotifications","end","write","all","writeCharacteristicWithResponseForService","cancelConnection","catch","undefined","serviceUuid","characteristicUuid","enabled","awaitNotificationsEnabled","finally","has","fail","forEach","openBleLink","BTPairingRetry","discoverAllServicesAndCharacteristics"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/ble-link.ts"],"mappings":";;;;;;AAEA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,G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AC,IAAAjD,uBAAY,EAACH,KAAK,CAAC,CAAC;IACnC;EACF;EAEQwB,MAAMA,CAAA,EAAS;IACrB,IAAI,CAACP,KAAK,GAAG,IAAI;IACjB,CAAC,GAAG,IAAI,CAACF,QAAQ,CAAC,CAACsC,OAAO,CAAEzB,OAAO,IAAKA,OAAO,CAACW,GAAG,CAAC,CAAC,CAAC;EACxD;AACF;;AAEA;AACA,eAAee,WAAWA,CAACzD,MAAc,EAAEhB,MAAmB,EAAiB;EAC7E,MAAMe,kBAAkB,CAACC,MAAM,EAAEhB,MAAM,CAAC,CAAC+D,KAAK,CAAE5C,KAAc,IAAK;IACjE,MAAM,IAAAG,uBAAY,EAACH,KAAK,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMO,OAAO,GAAG,IAAIgD,8BAAc,CAAC1D,MAAM,EAAE,MACzC,IAAAI,0BAAY,EAAC,MAAM,EAAE,oDAAoD,CAAC,CAAC;EAE7E,IAAIO,WAA0C;EAE9C,IAAI;IACF,MAAMX,MAAM,CAAC2D,qCAAqC,CAAC,CAAC;IACpDhD,WAAW,GAAG,MAAMF,eAAe,CAACT,MAAM,EAAEU,OAAO,CAAC;IACpD,IAAI1B,MAAM,CAACQ,OAAO,EAAE;MAClB,MAAMT,WAAW,CAACC,MAAM,CAAC;IAC3B;EACF,CAAC,CAAC,OAAOmB,KAAK,EAAE;IACd,MAAMH,MAAM,CAAC8C,gBAAgB,CAAC,CAAC,CAACC,KAAK,CAAC,MAAMC,SAAS,CAAC;IACtD,MAAM,IAAA1C,uBAAY,EAACH,KAAK,CAAC;EAC3B;EAEA,OAAO,IAAIc,OAAO,CAACjB,MAAM,EAAEhB,MAAM,EAAE0B,OAAO,EAAEC,WAAW,CAAC;AAC1D","ignoreList":[]}
|
|
@@ -94,6 +94,10 @@ class Connections {
|
|
|
94
94
|
this.store.updateDevice(id, {
|
|
95
95
|
connection: event.status
|
|
96
96
|
});
|
|
97
|
+
} else if (event.kind === "information") {
|
|
98
|
+
this.store.updateDevice(id, {
|
|
99
|
+
information: event.information
|
|
100
|
+
});
|
|
97
101
|
} else if (event.kind === "reading") {
|
|
98
102
|
const device = this.store.device(id);
|
|
99
103
|
if (device) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_errors","require","_resultPolicy","endedBeforeConnecting","BluetoothError","Connections","sessions","Map","constructor","store","readings","policy","onEnded","isActive","id","has","connect","peripheral","driver","current","get","controller","signal","aborted","ended","start","connected","disconnect","session","abort","disconnectAll","Promise","all","keys","map","AbortController","markConnected","undefined","failConnecting","resolve","reject","updateDevice","connection","error","run","then","catch","failure","asBluetoothError","finally","delete","set","event","keepReadings","apply","kind","status","device","receive","reading","exports"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/connections.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAMA,MAAME,qBAAqB,GAAGA,CAAA,KAC5B,IAAIC,sBAAc,CAAC,mBAAmB,EAAE,6CAA6C,CAAC;;AAExF;AACA,MAAMC,WAAW,CAAC;EACCC,QAAQ,GAAG,IAAIC,GAAG,CAAkB,CAAC;EAE/CC,WAAWA,CACCC,KAAoB,EACpBC,QAAoB,EACpBC,MAAoB,EACpBC,OAA6B,EAC9C;IAAA,KAJiBH,KAAoB,GAApBA,KAAoB;IAAA,KACpBC,QAAoB,GAApBA,QAAoB;IAAA,KACpBC,MAAoB,GAApBA,MAAoB;IAAA,KACpBC,OAA6B,GAA7BA,OAA6B;EAC7C;EAEIC,QAAQA,CAACC,EAAU,EAAW;IACnC,OAAO,IAAI,CAACR,QAAQ,CAACS,GAAG,CAACD,EAAE,CAAC;EAC9B;;EAEA;EACA,MAAaE,OAAOA,CAACC,UAAsB,EAAEC,MAAc,EAAiB;IAC1E,MAAMC,OAAO,GAAG,IAAI,CAACb,QAAQ,CAACc,GAAG,CAACH,UAAU,CAACH,EAAE,CAAC;IAEhD,IAAIK,OAAO,EAAEE,UA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sC,KAAK,EAAE1B,SAAS,CAAC;IAC7C;EACF;EAEQ4B,KAAKA,CAACxC,EAAU,EAAEsC,KAAkB,EAAE1B,SAAqB,EAAQ;IACzE,IAAI0B,KAAK,CAACG,IAAI,KAAK,QAAQ,EAAE;MAC3B,IAAIH,KAAK,CAACI,MAAM,KAAK,cAAc,EAAE;QACnC9B,SAAS,CAAC,CAAC;MACb;MACA,IAAI,CAACjB,KAAK,CAACgC,YAAY,CAAC3B,EAAE,EAAE;QAAE4B,UAAU,EAAEU,KAAK,CAACI;MAAO,CAAC,CAAC;IAC3D,CAAC,MAAM,IAAIJ,KAAK,CAACG,IAAI,KAAK,SAAS,EAAE;MACnC,
|
|
1
|
+
{"version":3,"names":["_errors","require","_resultPolicy","endedBeforeConnecting","BluetoothError","Connections","sessions","Map","constructor","store","readings","policy","onEnded","isActive","id","has","connect","peripheral","driver","current","get","controller","signal","aborted","ended","start","connected","disconnect","session","abort","disconnectAll","Promise","all","keys","map","AbortController","markConnected","undefined","failConnecting","resolve","reject","updateDevice","connection","error","run","then","catch","failure","asBluetoothError","finally","delete","set","event","keepReadings","apply","kind","status","information","device","receive","reading","exports"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/connections.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAMA,MAAME,qBAAqB,GAAGA,CAAA,KAC5B,IAAIC,sBAAc,CAAC,mBAAmB,EAAE,6CAA6C,CAAC;;AAExF;AACA,MAAMC,WAAW,CAAC;EACCC,QAAQ,GAAG,IAAIC,GAAG,CAAkB,CAAC;EAE/CC,WAAWA,CACCC,KAAoB,EACpBC,QAAoB,EACpBC,MAAoB,EACpBC,OAA6B,EAC9C;IAAA,KAJiBH,KAAoB,GAApBA,KAAoB;IAAA,KACpBC,QAAoB,GAApBA,QAAoB;IAAA,KACpBC,MAAoB,GAApBA,MAAoB;IAAA,KACpBC,OAA6B,GAA7BA,OAA6B;EAC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AACF;AAACkB,OAAA,CAAAxD,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -33,6 +33,12 @@ const gattDriver = (key, protocol) => async function* (peripheral, signal) {
|
|
|
33
33
|
kind: "status",
|
|
34
34
|
status: "connected"
|
|
35
35
|
};
|
|
36
|
+
if (link.deviceInformation) {
|
|
37
|
+
yield {
|
|
38
|
+
kind: "information",
|
|
39
|
+
information: link.deviceInformation
|
|
40
|
+
};
|
|
41
|
+
}
|
|
36
42
|
for await (const reading of protocol(link)) {
|
|
37
43
|
yield {
|
|
38
44
|
kind: "reading",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_stableHash","require","isTimestamped","reading","temporal","recordedAt","start","end","some","value","Date","exports","readingId","key","peripheral","stableHash","id","gattDriver","protocol","signal","link","openLink","kind","status","close"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/driver.ts"],"mappings":";;;;;;AAIA,IAAAA,WAAA,GAAAC,OAAA;AAGA;;
|
|
1
|
+
{"version":3,"names":["_stableHash","require","isTimestamped","reading","temporal","recordedAt","start","end","some","value","Date","exports","readingId","key","peripheral","stableHash","id","gattDriver","protocol","signal","link","openLink","kind","status","deviceInformation","information","close"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/driver.ts"],"mappings":";;;;;;AAIA,IAAAA,WAAA,GAAAC,OAAA;AAGA;;AAsCA;;AAGA;;AAGA;AACA,MAAMC,aAAa,GAAIC,OAAoB,IAAc;EACvD,MAAMC,QAAQ,GAAGD,OAAmE;EAEpF,OAAO,CAACC,QAAQ,CAACC,UAAU,EAAED,QAAQ,CAACE,KAAK,EAAEF,QAAQ,CAACG,GAAG,CAAC,CAACC,IAAI,CAAEC,KAAK,IAAKA,KAAK,YAAYC,IAAI,CAAC;AACnG,CAAC;;AAED;AAAAC,OAAA,CAAAT,aAAA,GAAAA,aAAA;AACA,MAAMU,SAAS,GAAGA,CAACC,GAAW,EAAEC,UAAsB,EAAEX,OAAoB,KAC1ED,aAAa,CAACC,OAAO,CAAC,GAAG,QAAQ,IAAAY,sBAAU,EAAC;EAAEF,GAAG;EAAEC,UAAU,EAAEA,UAAU,CAACE,EAAE;EAAEb;AAAQ,CAAC,CAAC,EAAE,GAAG,IAAI;;AAEnG;AACA,MAAMc,UAAU,GAAGA,CAACJ,GAAW,EAAEK,QAAwB,KACvD,iBAAiBJ,UAAU,EAAEK,MAAM,EAAE;EACnC,MAAMC,IAAI,GAAG,MAAMN,UAAU,CAACO,QAAQ,CAACF,MAAM,CAAC;EAE9C,IAAI;IACF,MAAM;MAAEG,IAAI,EAAE,QAAQ;MAAEC,MAAM,EAAE;IAAY,CAAC;IAC7C,IAAIH,IAAI,CAACI,iBAAiB,EAAE;MAC1B,MAAM;QAAEF,IAAI,EAAE,aAAa;QAAEG,WAAW,EAAEL,IAAI,CAACI;MAAkB,CAAC;IACpE;IACA,WAAW,MAAMrB,OAAO,IAAIe,QAAQ,CAACE,IAAI,CAAC,EAAE;MAC1C,MAAM;QAAEE,IAAI,EAAE,SAAS;QAAEN,EAAE,EAAEJ,SAAS,CAACC,GAAG,EAAEC,UAAU,EAAEX,OAAO,CAAC;QAAEA;MAAQ,CAAC;IAC7E;IACA,MAAM;MAAEmB,IAAI,EAAE,QAAQ;MAAEC,MAAM,EAAE;IAAe,CAAC;EAClD,CAAC,SAAS;IACR,MAAMH,IAAI,CAACM,KAAK,CAAC,CAAC;EACpB;AACF,CAAC;AAACf,OAAA,CAAAM,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -4,6 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ovokReadingSink = void 0;
|
|
7
|
+
/** The time the device took the reading, when it reported one. */
|
|
8
|
+
const recordedAtOf = measurement => {
|
|
9
|
+
const {
|
|
10
|
+
recordedAt
|
|
11
|
+
} = measurement;
|
|
12
|
+
return recordedAt instanceof Date && !Number.isNaN(recordedAt.getTime()) ? recordedAt : undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
7
15
|
/** Saves readings for the signed-in account through the `Ovok` measurements API. */
|
|
8
16
|
const ovokReadingSink = client => ({
|
|
9
17
|
save: async ({
|
|
@@ -14,12 +22,15 @@ const ovokReadingSink = client => ({
|
|
|
14
22
|
const result = await client.measurements.save({
|
|
15
23
|
measurement,
|
|
16
24
|
sourceId: id,
|
|
25
|
+
effectiveDateTime: recordedAtOf(measurement),
|
|
17
26
|
device: {
|
|
18
27
|
id: device.id,
|
|
19
28
|
name: device.key,
|
|
20
29
|
localName: device.name,
|
|
21
30
|
manufacturerData: "",
|
|
22
|
-
|
|
31
|
+
manufacturerName: device.information?.manufacturerName,
|
|
32
|
+
model: device.information?.model,
|
|
33
|
+
sn: device.information?.serialNumber ?? ""
|
|
23
34
|
}
|
|
24
35
|
});
|
|
25
36
|
return result.status === "saved" ? {
|