@ovok/native 1.16.1-dev.2118 → 1.16.1-dev.2129
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/android-bluetooth-foreground-service.js +3 -1
- package/lib/commonjs/modules/bt-management/components/android-bluetooth-foreground-service.js.map +1 -1
- package/lib/commonjs/modules/bt-management/components/bluetooth-device-picker.js +9 -141
- package/lib/commonjs/modules/bt-management/components/bluetooth-device-picker.js.map +1 -1
- package/lib/commonjs/modules/bt-management/components/device-picker-sheet.js +160 -0
- package/lib/commonjs/modules/bt-management/components/device-picker-sheet.js.map +1 -0
- package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-permission.js +2 -1
- package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-permission.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-measurements.js +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-measurements.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/utils/bluetooth-permission-list.js +19 -0
- package/lib/commonjs/modules/bt-management/utils/bluetooth-permission-list.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/result-identity.js +3 -25
- package/lib/commonjs/modules/bt-management/utils/result-identity.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/auto-connect.js +32 -0
- package/lib/commonjs/modules/next/bluetooth/auto-connect.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-errors.js +33 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-errors.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-link.js +125 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-link.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-scanner.js +75 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-scanner.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/built-in-devices.js +34 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/built-in-devices.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/legacy-driver.js +67 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/legacy-driver.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/connections.js +110 -0
- package/lib/commonjs/modules/next/bluetooth/connections.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/daily-total-day.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/devices.js +41 -0
- package/lib/commonjs/modules/next/bluetooth/devices.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/driver.js +24 -20
- package/lib/commonjs/modules/next/bluetooth/driver.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/errors.js +26 -0
- package/lib/commonjs/modules/next/bluetooth/errors.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/index.js +116 -11
- package/lib/commonjs/modules/next/bluetooth/index.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/link.js +0 -103
- package/lib/commonjs/modules/next/bluetooth/link.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/paired.js +50 -0
- package/lib/commonjs/modules/next/bluetooth/paired.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/permissions.js +2 -0
- package/lib/commonjs/modules/next/bluetooth/permissions.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react/bluetooth-device-picker.js +44 -0
- package/lib/commonjs/modules/next/bluetooth/react/bluetooth-device-picker.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react/context.js +54 -0
- package/lib/commonjs/modules/next/bluetooth/react/context.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react/hooks.js +86 -0
- package/lib/commonjs/modules/next/bluetooth/react/hooks.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/create-bluetooth-runtime.js +28 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/create-bluetooth-runtime.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/os-permissions.js +32 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/os-permissions.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/ovok-sink.js +32 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/readings.js +92 -0
- package/lib/commonjs/modules/next/bluetooth/readings.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/result-policy.js +6 -1
- package/lib/commonjs/modules/next/bluetooth/result-policy.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/runtime.js +223 -0
- package/lib/commonjs/modules/next/bluetooth/runtime.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/scan-loop.js +82 -0
- package/lib/commonjs/modules/next/bluetooth/scan-loop.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/sink.js +6 -0
- package/lib/commonjs/modules/next/bluetooth/sink.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/snapshot.js +6 -0
- package/lib/commonjs/modules/next/bluetooth/snapshot.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/stable-hash.js +33 -0
- package/lib/commonjs/modules/next/bluetooth/stable-hash.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/store.js +61 -0
- package/lib/commonjs/modules/next/bluetooth/store.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/transport.js +6 -0
- package/lib/commonjs/modules/next/bluetooth/transport.js.map +1 -0
- package/lib/module/modules/bt-management/components/android-bluetooth-foreground-service.js +3 -1
- package/lib/module/modules/bt-management/components/android-bluetooth-foreground-service.js.map +1 -1
- package/lib/module/modules/bt-management/components/bluetooth-device-picker.js +9 -141
- package/lib/module/modules/bt-management/components/bluetooth-device-picker.js.map +1 -1
- package/lib/module/modules/bt-management/components/device-picker-sheet.js +154 -0
- package/lib/module/modules/bt-management/components/device-picker-sheet.js.map +1 -0
- package/lib/module/modules/bt-management/hooks/use-bluetooth-permission.js +4 -3
- package/lib/module/modules/bt-management/hooks/use-bluetooth-permission.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-measurements.js +1 -1
- package/lib/module/modules/bt-management/hooks/use-measurements.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/module/modules/bt-management/utils/bluetooth-permission-list.js +14 -0
- package/lib/module/modules/bt-management/utils/bluetooth-permission-list.js.map +1 -0
- package/lib/module/modules/bt-management/utils/result-identity.js +3 -25
- package/lib/module/modules/bt-management/utils/result-identity.js.map +1 -1
- package/lib/module/modules/next/bluetooth/auto-connect.js +28 -0
- package/lib/module/modules/next/bluetooth/auto-connect.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-errors.js +28 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-errors.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-link.js +122 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-link.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-scanner.js +69 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-scanner.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/built-in-devices.js +31 -0
- package/lib/module/modules/next/bluetooth/ble-plx/built-in-devices.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/legacy-driver.js +63 -0
- package/lib/module/modules/next/bluetooth/ble-plx/legacy-driver.js.map +1 -0
- package/lib/module/modules/next/bluetooth/connections.js +106 -0
- package/lib/module/modules/next/bluetooth/connections.js.map +1 -0
- package/lib/module/modules/next/bluetooth/daily-total-day.js.map +1 -0
- package/lib/module/modules/next/bluetooth/devices.js +37 -0
- package/lib/module/modules/next/bluetooth/devices.js.map +1 -0
- package/lib/module/modules/next/bluetooth/driver.js +23 -20
- package/lib/module/modules/next/bluetooth/driver.js.map +1 -1
- package/lib/module/modules/next/bluetooth/errors.js +21 -0
- package/lib/module/modules/next/bluetooth/errors.js.map +1 -0
- package/lib/module/modules/next/bluetooth/index.js +21 -3
- package/lib/module/modules/next/bluetooth/index.js.map +1 -1
- package/lib/module/modules/next/bluetooth/link.js +0 -101
- package/lib/module/modules/next/bluetooth/link.js.map +1 -1
- package/lib/module/modules/next/bluetooth/paired.js +46 -0
- package/lib/module/modules/next/bluetooth/paired.js.map +1 -0
- package/lib/module/modules/next/bluetooth/permissions.js +2 -0
- package/lib/module/modules/next/bluetooth/permissions.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react/bluetooth-device-picker.js +39 -0
- package/lib/module/modules/next/bluetooth/react/bluetooth-device-picker.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react/context.js +48 -0
- package/lib/module/modules/next/bluetooth/react/context.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react/hooks.js +76 -0
- package/lib/module/modules/next/bluetooth/react/hooks.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react-native/create-bluetooth-runtime.js +25 -0
- package/lib/module/modules/next/bluetooth/react-native/create-bluetooth-runtime.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react-native/os-permissions.js +28 -0
- package/lib/module/modules/next/bluetooth/react-native/os-permissions.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react-native/ovok-sink.js +28 -0
- package/lib/module/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -0
- package/lib/module/modules/next/bluetooth/readings.js +88 -0
- package/lib/module/modules/next/bluetooth/readings.js.map +1 -0
- package/lib/module/modules/next/bluetooth/result-policy.js +6 -1
- package/lib/module/modules/next/bluetooth/result-policy.js.map +1 -1
- package/lib/module/modules/next/bluetooth/runtime.js +220 -0
- package/lib/module/modules/next/bluetooth/runtime.js.map +1 -0
- package/lib/module/modules/next/bluetooth/scan-loop.js +78 -0
- package/lib/module/modules/next/bluetooth/scan-loop.js.map +1 -0
- package/lib/module/modules/next/bluetooth/sink.js +4 -0
- package/lib/module/modules/next/bluetooth/sink.js.map +1 -0
- package/lib/module/modules/next/bluetooth/snapshot.js +4 -0
- package/lib/module/modules/next/bluetooth/snapshot.js.map +1 -0
- package/lib/module/modules/next/bluetooth/stable-hash.js +28 -0
- package/lib/module/modules/next/bluetooth/stable-hash.js.map +1 -0
- package/lib/module/modules/next/bluetooth/store.js +57 -0
- package/lib/module/modules/next/bluetooth/store.js.map +1 -0
- package/lib/module/modules/next/bluetooth/transport.js +4 -0
- package/lib/module/modules/next/bluetooth/transport.js.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/components/android-bluetooth-foreground-service.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bluetooth-device-picker.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bluetooth-device-picker.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/device-picker-sheet.d.ts +25 -0
- package/lib/typescript/commonjs/src/modules/bt-management/components/device-picker-sheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-measurements.d.ts.map +1 -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/utils/bluetooth-permission-list.d.ts +4 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/bluetooth-permission-list.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/result-identity.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/auto-connect.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/auto-connect.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts +4 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts +8 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/connections.d.ts +25 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/connections.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/daily-total-day.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/devices.d.ts +30 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/devices.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/driver.d.ts +21 -19
- package/lib/typescript/commonjs/src/modules/next/bluetooth/driver.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/errors.d.ts +17 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts +32 -3
- 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 +2 -4
- package/lib/typescript/commonjs/src/modules/next/bluetooth/link.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/paired.d.ts +18 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/paired.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/permissions.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/permissions.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts +35 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/context.d.ts +30 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/hooks.d.ts +47 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/os-permissions.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/os-permissions.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/ovok-sink.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/readings.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/readings.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/result-policy.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/result-policy.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/runtime.d.ts +87 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/runtime.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/scan-loop.d.ts +23 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/scan-loop.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/sink.d.ts +20 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/sink.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/snapshot.d.ts +69 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/snapshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/stable-hash.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/stable-hash.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/store.d.ts +16 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/transport.d.ts +31 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/transport.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/components/android-bluetooth-foreground-service.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bluetooth-device-picker.d.ts +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bluetooth-device-picker.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/device-picker-sheet.d.ts +25 -0
- package/lib/typescript/module/src/modules/bt-management/components/device-picker-sheet.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/use-measurements.d.ts.map +1 -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/utils/bluetooth-permission-list.d.ts +4 -0
- package/lib/typescript/module/src/modules/bt-management/utils/bluetooth-permission-list.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/result-identity.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/auto-connect.d.ts +10 -0
- package/lib/typescript/module/src/modules/next/bluetooth/auto-connect.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts +4 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts +10 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts +8 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/connections.d.ts +25 -0
- package/lib/typescript/module/src/modules/next/bluetooth/connections.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/daily-total-day.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/devices.d.ts +30 -0
- package/lib/typescript/module/src/modules/next/bluetooth/devices.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/driver.d.ts +21 -19
- package/lib/typescript/module/src/modules/next/bluetooth/driver.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/errors.d.ts +17 -0
- package/lib/typescript/module/src/modules/next/bluetooth/errors.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts +32 -3
- 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 +2 -4
- package/lib/typescript/module/src/modules/next/bluetooth/link.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/paired.d.ts +18 -0
- package/lib/typescript/module/src/modules/next/bluetooth/paired.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/permissions.d.ts +13 -0
- package/lib/typescript/module/src/modules/next/bluetooth/permissions.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts +35 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/context.d.ts +30 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/context.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/hooks.d.ts +47 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/hooks.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts +21 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/os-permissions.d.ts +5 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/os-permissions.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/ovok-sink.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/readings.d.ts +21 -0
- package/lib/typescript/module/src/modules/next/bluetooth/readings.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/result-policy.d.ts +3 -0
- package/lib/typescript/module/src/modules/next/bluetooth/result-policy.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/runtime.d.ts +87 -0
- package/lib/typescript/module/src/modules/next/bluetooth/runtime.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/scan-loop.d.ts +23 -0
- package/lib/typescript/module/src/modules/next/bluetooth/scan-loop.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/sink.d.ts +20 -0
- package/lib/typescript/module/src/modules/next/bluetooth/sink.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/snapshot.d.ts +69 -0
- package/lib/typescript/module/src/modules/next/bluetooth/snapshot.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/stable-hash.d.ts +3 -0
- package/lib/typescript/module/src/modules/next/bluetooth/stable-hash.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/store.d.ts +16 -0
- package/lib/typescript/module/src/modules/next/bluetooth/store.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/transport.d.ts +31 -0
- package/lib/typescript/module/src/modules/next/bluetooth/transport.d.ts.map +1 -0
- package/package.json +1 -1
- package/lib/commonjs/modules/bt-management/utils/daily-total-day.js.map +0 -1
- package/lib/commonjs/modules/next/bluetooth/drivers.js +0 -20
- package/lib/commonjs/modules/next/bluetooth/drivers.js.map +0 -1
- package/lib/commonjs/modules/next/bluetooth/legacy-driver.js +0 -55
- package/lib/commonjs/modules/next/bluetooth/legacy-driver.js.map +0 -1
- package/lib/module/modules/bt-management/utils/daily-total-day.js.map +0 -1
- package/lib/module/modules/next/bluetooth/drivers.js +0 -17
- package/lib/module/modules/next/bluetooth/drivers.js.map +0 -1
- package/lib/module/modules/next/bluetooth/legacy-driver.js +0 -51
- package/lib/module/modules/next/bluetooth/legacy-driver.js.map +0 -1
- package/lib/typescript/commonjs/src/modules/bt-management/utils/daily-total-day.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/drivers.d.ts +0 -7
- package/lib/typescript/commonjs/src/modules/next/bluetooth/drivers.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/legacy-driver.d.ts +0 -8
- package/lib/typescript/commonjs/src/modules/next/bluetooth/legacy-driver.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/bt-management/utils/daily-total-day.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/next/bluetooth/drivers.d.ts +0 -7
- package/lib/typescript/module/src/modules/next/bluetooth/drivers.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/next/bluetooth/legacy-driver.d.ts +0 -8
- package/lib/typescript/module/src/modules/next/bluetooth/legacy-driver.d.ts.map +0 -1
- /package/lib/commonjs/modules/{bt-management/utils → next/bluetooth}/daily-total-day.js +0 -0
- /package/lib/module/modules/{bt-management/utils → next/bluetooth}/daily-total-day.js +0 -0
- /package/lib/typescript/commonjs/src/modules/{bt-management/utils → next/bluetooth}/daily-total-day.d.ts +0 -0
- /package/lib/typescript/module/src/modules/{bt-management/utils → next/bluetooth}/daily-total-day.d.ts +0 -0
|
@@ -4,31 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.reviveResultDates = exports.createStableResultId = void 0;
|
|
7
|
+
var _stableHash = require("../../next/bluetooth/stable-hash.js");
|
|
7
8
|
/* eslint-disable import/group-exports */
|
|
8
9
|
|
|
9
|
-
const canonicalize = value => {
|
|
10
|
-
if (value instanceof Date) {
|
|
11
|
-
return value.toISOString();
|
|
12
|
-
}
|
|
13
|
-
if (Array.isArray(value)) {
|
|
14
|
-
return value.map(canonicalize);
|
|
15
|
-
}
|
|
16
|
-
if (value && typeof value === "object") {
|
|
17
|
-
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, canonicalize(nested)]));
|
|
18
|
-
}
|
|
19
|
-
return value;
|
|
20
|
-
};
|
|
21
|
-
const hash = value => {
|
|
22
|
-
let first = 0x811c9dc5;
|
|
23
|
-
let second = 0x01000193;
|
|
24
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
25
|
-
const code = value.charCodeAt(index);
|
|
26
|
-
first = Math.imul(first ^ code, 0x01000193);
|
|
27
|
-
second = Math.imul(second ^ code + index, 0x811c9dc5);
|
|
28
|
-
}
|
|
29
|
-
return `${(first >>> 0).toString(16).padStart(8, "0")}${(second >>> 0).toString(16).padStart(8, "0")}`;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
10
|
/**
|
|
33
11
|
* Creates an identity that is stable when a device sends its stored history again.
|
|
34
12
|
* Recording IDs, timestamps and indexes are retained in the canonical payload; transient
|
|
@@ -36,11 +14,11 @@ const hash = value => {
|
|
|
36
14
|
*/
|
|
37
15
|
const createStableResultId = (deviceData, data) => {
|
|
38
16
|
const deviceIdentity = deviceData.sn || deviceData.manufacturerData || deviceData.model || deviceData.name || deviceData.id;
|
|
39
|
-
return `ovok:${
|
|
17
|
+
return `ovok:${(0, _stableHash.stableHash)({
|
|
40
18
|
device: deviceIdentity,
|
|
41
19
|
name: deviceData.name,
|
|
42
20
|
data
|
|
43
|
-
})
|
|
21
|
+
})}`;
|
|
44
22
|
};
|
|
45
23
|
|
|
46
24
|
/** Converts the ISO date strings of `recordedAt`, `start` and `end` fields back to `Date`s, recursively. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_stableHash","require","createStableResultId","deviceData","data","deviceIdentity","sn","manufacturerData","model","name","id","stableHash","device","exports","reviveResultDates","value","revive","current","key","includes","date","Date","Number","isNaN","getTime","Array","isArray","map","item","Object","fromEntries","entries","childKey","childValue"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/utils/result-identity.ts"],"mappings":";;;;;;AAIA,IAAAA,WAAA,GAAAC,OAAA;AAJA;;AAOA;AACA;AACA;AACA;AACA;AACO,MAAMC,oBAAoB,GAAGA,CAClCC,UAAsB,EACtBC,IAAiB,KACN;EACX,MAAMC,cAAc,GAClBF,UAAU,CAACG,EAAE,IACbH,UAAU,CAACI,gBAAgB,IAC3BJ,UAAU,CAACK,KAAK,IAChBL,UAAU,CAACM,IAAI,IACfN,UAAU,CAACO,EAAE;EAEf,OAAO,QAAQ,IAAAC,sBAAU,EAAC;IACxBC,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
|
6
|
+
exports.AutoConnectBackoff = void 0;
|
|
7
|
+
const FIRST_RETRY_DELAY_MS = 2_000;
|
|
8
|
+
const MAX_RETRY_DELAY_MS = 60_000;
|
|
9
|
+
|
|
10
|
+
/** When a paired device that keeps failing may be connected automatically again. */
|
|
11
|
+
class AutoConnectBackoff {
|
|
12
|
+
failures = new Map();
|
|
13
|
+
allows(id, now = Date.now()) {
|
|
14
|
+
return (this.failures.get(id)?.notBefore ?? 0) <= now;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Records a failure; returns how long until the next automatic attempt. */
|
|
18
|
+
failed(id, now = Date.now()) {
|
|
19
|
+
const count = (this.failures.get(id)?.count ?? 0) + 1;
|
|
20
|
+
const delay = Math.min(FIRST_RETRY_DELAY_MS * 2 ** (count - 1), MAX_RETRY_DELAY_MS);
|
|
21
|
+
this.failures.set(id, {
|
|
22
|
+
count,
|
|
23
|
+
notBefore: now + delay
|
|
24
|
+
});
|
|
25
|
+
return delay;
|
|
26
|
+
}
|
|
27
|
+
succeeded(id) {
|
|
28
|
+
this.failures.delete(id);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.AutoConnectBackoff = AutoConnectBackoff;
|
|
32
|
+
//# sourceMappingURL=auto-connect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FIRST_RETRY_DELAY_MS","MAX_RETRY_DELAY_MS","AutoConnectBackoff","failures","Map","allows","id","now","Date","get","notBefore","failed","count","delay","Math","min","set","succeeded","delete","exports"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/auto-connect.ts"],"mappings":";;;;;;AAAA,MAAMA,oBAAoB,GAAG,KAAK;AAClC,MAAMC,kBAAkB,GAAG,MAAM;;AAEjC;AACA,MAAMC,kBAAkB,CAAC;EACNC,QAAQ,GAAG,IAAIC,GAAG,CAA+C,CAAC;EAE5EC,MAAMA,CAACC,EAAU,EAAEC,GAAG,GAAGC,IAAI,CAACD,GAAG,CAAC,CAAC,EAAW;IACnD,OAAO,CAAC,IAAI,CAACJ,QAAQ,CAACM,GAAG,CAACH,EAAE,CAAC,EAAEI,SAAS,IAAI,CAAC,KAAKH,GAAG;EACvD;;EAEA;EACOI,MAAMA,CAACL,EAAU,EAAEC,GAAG,GAAGC,IAAI,CAACD,GAAG,CAAC,CAAC,EAAU;IAClD,MAAMK,KAAK,GAAG,CAAC,IAAI,CAACT,QAAQ,CAACM,GAAG,CAACH,EAAE,CAAC,EAAEM,KAAK,IAAI,CAAC,IAAI,CAAC;IACrD,MAAMC,KAAK,GAAGC,IAAI,CAACC,GAAG,CAACf,oBAAoB,GAAG,CAAC,KAAKY,KAAK,GAAG,CAAC,CAAC,EAAEX,kBAAkB,CAAC;IAEnF,IAAI,CAACE,QAAQ,CAACa,GAAG,CAACV,EAAE,EAAE;MAAEM,KAAK;MAAEF,SAAS,EAAEH,GAAG,GAAGM;IAAM,CAAC,CAAC;IAExD,OAAOA,KAAK;EACd;EAEOI,SAASA,CAACX,EAAU,EAAQ;IACjC,IAAI,CAACH,QAAQ,CAACe,MAAM,CAACZ,EAAE,CAAC;EAC1B;AACF;AAACa,OAAA,CAAAjB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fromBleError = void 0;
|
|
7
|
+
var _bluetoothError = require("../../../bt-management/types/bluetooth-error.js");
|
|
8
|
+
var _errors = require("../errors.js");
|
|
9
|
+
const CODES = {
|
|
10
|
+
[_bluetoothError.BluetoothErrorCode.UNKNOWN]: "unknown",
|
|
11
|
+
[_bluetoothError.BluetoothErrorCode.PERMISSION_DENIED]: "permission-denied",
|
|
12
|
+
[_bluetoothError.BluetoothErrorCode.UNSUPPORTED]: "unsupported",
|
|
13
|
+
[_bluetoothError.BluetoothErrorCode.POWERED_OFF]: "powered-off",
|
|
14
|
+
[_bluetoothError.BluetoothErrorCode.SCAN_FAILED]: "scan-failed",
|
|
15
|
+
[_bluetoothError.BluetoothErrorCode.CONNECTION_FAILED]: "connection-failed",
|
|
16
|
+
[_bluetoothError.BluetoothErrorCode.PAIRING_REQUIRED]: "pairing-required",
|
|
17
|
+
[_bluetoothError.BluetoothErrorCode.DISCOVERY_FAILED]: "discovery-failed",
|
|
18
|
+
[_bluetoothError.BluetoothErrorCode.DEVICE_ERROR]: "device-error",
|
|
19
|
+
[_bluetoothError.BluetoothErrorCode.FRAME_INVALID]: "frame-invalid",
|
|
20
|
+
[_bluetoothError.BluetoothErrorCode.MEASUREMENT_FAILED]: "measurement-failed",
|
|
21
|
+
[_bluetoothError.BluetoothErrorCode.BACKGROUND_SYNC]: "unknown"
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Classifies a `react-native-ble-plx` or legacy device error as a `BluetoothError`. */
|
|
25
|
+
const fromBleError = error => {
|
|
26
|
+
if (error instanceof _errors.BluetoothError) {
|
|
27
|
+
return error;
|
|
28
|
+
}
|
|
29
|
+
const legacy = (0, _bluetoothError.toBluetoothError)(error);
|
|
30
|
+
return new _errors.BluetoothError(CODES[legacy.code], legacy.message, error);
|
|
31
|
+
};
|
|
32
|
+
exports.fromBleError = fromBleError;
|
|
33
|
+
//# sourceMappingURL=ble-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_bluetoothError","require","_errors","CODES","LegacyCode","UNKNOWN","PERMISSION_DENIED","UNSUPPORTED","POWERED_OFF","SCAN_FAILED","CONNECTION_FAILED","PAIRING_REQUIRED","DISCOVERY_FAILED","DEVICE_ERROR","FRAME_INVALID","MEASUREMENT_FAILED","BACKGROUND_SYNC","fromBleError","error","BluetoothError","legacy","toBluetoothError","code","message","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/ble-errors.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,KAA6C,GAAG;EACpD,CAACC,kCAAU,CAACC,OAAO,GAAG,SAAS;EAC/B,CAACD,kCAAU,CAACE,iBAAiB,GAAG,mBAAmB;EACnD,CAACF,kCAAU,CAACG,WAAW,GAAG,aAAa;EACvC,CAACH,kCAAU,CAACI,WAAW,GAAG,aAAa;EACvC,CAACJ,kCAAU,CAACK,WAAW,GAAG,aAAa;EACvC,CAACL,kCAAU,CAACM,iBAAiB,GAAG,mBAAmB;EACnD,CAACN,kCAAU,CAACO,gBAAgB,GAAG,kBAAkB;EACjD,CAACP,kCAAU,CAACQ,gBAAgB,GAAG,kBAAkB;EACjD,CAACR,kCAAU,CAACS,YAAY,GAAG,cAAc;EACzC,CAACT,kCAAU,CAACU,aAAa,GAAG,eAAe;EAC3C,CAACV,kCAAU,CAACW,kBAAkB,GAAG,oBAAoB;EACrD,CAACX,kCAAU,CAACY,eAAe,GAAG;AAChC,CAAC;;AAED;AACO,MAAMC,YAAY,GAAIC,KAAc,IAAqB;EAC9D,IAAIA,KAAK,YAAYC,sBAAc,EAAE;IACnC,OAAOD,KAAK;EACd;EAEA,MAAME,MAAM,GAAG,IAAAC,gCAAgB,EAACH,KAAK,CAAC;EAEtC,OAAO,IAAIC,sBAAc,CAAChB,KAAK,CAACiB,MAAM,CAACE,IAAI,CAAC,EAAEF,MAAM,CAACG,OAAO,EAAEL,KAAK,CAAC;AACtE,CAAC;AAACM,OAAA,CAAAP,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.openBleLink = openBleLink;
|
|
7
|
+
var _sentryLogger = require("../../../helpers/utils/sentry-logger.js");
|
|
8
|
+
var _channel = require("../channel.js");
|
|
9
|
+
var _bleErrors = require("./ble-errors.js");
|
|
10
|
+
const CONNECT_ATTEMPTS = 5;
|
|
11
|
+
const FIRST_RETRY_DELAY_MS = 1000;
|
|
12
|
+
const MAX_RETRY_DELAY_MS = 5000;
|
|
13
|
+
|
|
14
|
+
/** BleErrorCode.OperationCancelled and DeviceDisconnected; the enum is not available at runtime. */
|
|
15
|
+
const ENDS_THE_LINK = new Set([2, 201]);
|
|
16
|
+
const toBytes = base64 => Uint8Array.from(atob(base64), char => char.charCodeAt(0));
|
|
17
|
+
const toBase64 = bytes => btoa(String.fromCharCode(...bytes));
|
|
18
|
+
const retryDelay = attempt => Math.min(FIRST_RETRY_DELAY_MS * 2 ** (attempt - 1), MAX_RETRY_DELAY_MS);
|
|
19
|
+
const abortReason = signal => signal.reason ?? new Error("The Bluetooth connection was cancelled");
|
|
20
|
+
|
|
21
|
+
/** Waits `ms`, or rejects as soon as `signal` aborts so a cancelled retry does not linger. */
|
|
22
|
+
const wait = (ms, signal) => new Promise((resolve, reject) => {
|
|
23
|
+
const aborted = () => {
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
reject(abortReason(signal));
|
|
26
|
+
};
|
|
27
|
+
const timer = setTimeout(() => {
|
|
28
|
+
signal.removeEventListener("abort", aborted);
|
|
29
|
+
resolve();
|
|
30
|
+
}, ms);
|
|
31
|
+
signal.addEventListener("abort", aborted, {
|
|
32
|
+
once: true
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
async function connectWithRetries(device, signal) {
|
|
36
|
+
for (let attempt = 1;; attempt += 1) {
|
|
37
|
+
if (signal.aborted) {
|
|
38
|
+
throw abortReason(signal);
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
if (!(await device.isConnected())) {
|
|
42
|
+
await device.connect();
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (attempt >= CONNECT_ATTEMPTS) {
|
|
47
|
+
(0, _sentryLogger.sentryLogger)("error", "BLUETOOTH: Connection failed", {
|
|
48
|
+
errorCode: (0, _bleErrors.fromBleError)(error).code,
|
|
49
|
+
attempts: attempt
|
|
50
|
+
});
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
await wait(retryDelay(attempt), signal);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
class BleLink {
|
|
58
|
+
channels = new Set();
|
|
59
|
+
ended = false;
|
|
60
|
+
closeOnAbort = () => void this.close();
|
|
61
|
+
constructor(device, signal) {
|
|
62
|
+
this.device = device;
|
|
63
|
+
this.signal = signal;
|
|
64
|
+
this.disconnected = device.onDisconnected(() => this.endAll());
|
|
65
|
+
signal.addEventListener("abort", this.closeOnAbort, {
|
|
66
|
+
once: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
subscribe(service, characteristic) {
|
|
70
|
+
const channel = new _channel.Channel(() => {
|
|
71
|
+
subscription.remove();
|
|
72
|
+
this.channels.delete(channel);
|
|
73
|
+
});
|
|
74
|
+
const subscription = this.device.monitorCharacteristicForService(service, characteristic, (error, value) => {
|
|
75
|
+
if (error) {
|
|
76
|
+
this.endOrFail(channel, error);
|
|
77
|
+
} else if (value?.value) {
|
|
78
|
+
channel.push(toBytes(value.value));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
this.channels.add(channel);
|
|
82
|
+
if (this.ended) {
|
|
83
|
+
channel.end();
|
|
84
|
+
}
|
|
85
|
+
return channel;
|
|
86
|
+
}
|
|
87
|
+
async write(service, characteristic, bytes) {
|
|
88
|
+
await this.device.writeCharacteristicWithResponseForService(service, characteristic, toBase64(bytes));
|
|
89
|
+
}
|
|
90
|
+
async close() {
|
|
91
|
+
this.signal.removeEventListener("abort", this.closeOnAbort);
|
|
92
|
+
this.endAll();
|
|
93
|
+
this.disconnected.remove();
|
|
94
|
+
await this.device.cancelConnection().catch(() => undefined);
|
|
95
|
+
}
|
|
96
|
+
endOrFail(channel, error) {
|
|
97
|
+
if (ENDS_THE_LINK.has(error.errorCode)) {
|
|
98
|
+
channel.end();
|
|
99
|
+
} else {
|
|
100
|
+
channel.fail((0, _bleErrors.fromBleError)(error));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
endAll() {
|
|
104
|
+
this.ended = true;
|
|
105
|
+
[...this.channels].forEach(channel => channel.end());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Connects (retrying with backoff) and discovers services; aborting `signal` closes the link. */
|
|
110
|
+
async function openBleLink(device, signal) {
|
|
111
|
+
await connectWithRetries(device, signal).catch(error => {
|
|
112
|
+
throw (0, _bleErrors.fromBleError)(error);
|
|
113
|
+
});
|
|
114
|
+
try {
|
|
115
|
+
await device.discoverAllServicesAndCharacteristics();
|
|
116
|
+
if (signal.aborted) {
|
|
117
|
+
throw abortReason(signal);
|
|
118
|
+
}
|
|
119
|
+
} catch (error) {
|
|
120
|
+
await device.cancelConnection().catch(() => undefined);
|
|
121
|
+
throw (0, _bleErrors.fromBleError)(error);
|
|
122
|
+
}
|
|
123
|
+
return new BleLink(device, signal);
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=ble-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_sentryLogger","require","_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","BleLink","channels","ended","closeOnAbort","close","constructor","disconnected","onDisconnected","endAll","subscribe","service","characteristic","channel","Channel","subscription","remove","delete","monitorCharacteristicForService","value","endOrFail","push","add","end","write","writeCharacteristicWithResponseForService","cancelConnection","catch","undefined","has","fail","forEach","openBleLink","discoverAllServicesAndCharacteristics"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/ble-link.ts"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AAEA,MAAMG,gBAAgB,GAAG,CAAC;AAC1B,MAAMC,oBAAoB,GAAG,IAAI;AACjC,MAAMC,kBAAkB,GAAG,IAAI;;AAE/B;AACA,MAAMC,aAAkC,GAAG,IAAIC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAE5D,MAAMC,OAAO,GAAIC,MAAc,IAAiBC,UAAU,CAACC,IAAI,CAACC,IAAI,CAACH,MAAM,CAAC,EAAGI,IAAI,IAAKA,IAAI,CAACC,UAAU,CAAC,CAAC,CAAC,CAAC;AAE3G,MAAMC,QAAQ,GAAIC,KAAiB,IAAaC,IAAI,CAACC,MAAM,CAACC,YAAY,CAAC,GAAGH,KAAK,CAAC,CAAC;AAEnF,MAAMI,UAAU,GAAIC,OAAe,IACjCC,IAAI,CAACC,GAAG,CAACnB,oBAAoB,GAAG,CAAC,KAAKiB,OAAO,GAAG,CAAC,CAAC,EAAEhB,kBAAkB,CAAC;AAEzE,MAAMmB,WAAW,GAAIC,MAAmB,IACtCA,MAAM,CAACC,MAAM,IAAI,IAAIC,KAAK,CAAC,wCAAwC,CAAC;;AAEtE;AACA,MAAMC,IAAI,GAAGA,CAACC,EAAU,EAAEJ,MAAmB,KAC3C,IAAIK,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;EAC/B,MAAMC,OAAO,GAAGA,CAAA,KAAM;IACpBC,YAAY,CAACC,KAAK,CAAC;IACnBH,MAAM,CAACR,WAAW,CAACC,MAAM,CAAC,CAAC;EAC7B,CAAC;EAED,MAAMU,KAAK,GAAGC,UAAU,CAAC,MAAM;IAC7BX,MAAM,CAACY,mBAAmB,CAAC,OAAO,EAAEJ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|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.blePeripheral = exports.bleManagerScanner = exports.bleDeviceOf = void 0;
|
|
7
|
+
var _reactNativeBlePlx = require("react-native-ble-plx");
|
|
8
|
+
var _bleErrors = require("./ble-errors.js");
|
|
9
|
+
var _bleLink = require("./ble-link.js");
|
|
10
|
+
const ADAPTER_STATES = {
|
|
11
|
+
[_reactNativeBlePlx.State.PoweredOn]: "on",
|
|
12
|
+
[_reactNativeBlePlx.State.PoweredOff]: "off",
|
|
13
|
+
[_reactNativeBlePlx.State.Unauthorized]: "unauthorized",
|
|
14
|
+
[_reactNativeBlePlx.State.Unsupported]: "unsupported"
|
|
15
|
+
};
|
|
16
|
+
const bleDevices = new WeakMap();
|
|
17
|
+
|
|
18
|
+
/** The `react-native-ble-plx` device behind a peripheral this adapter reported. */
|
|
19
|
+
const bleDeviceOf = peripheral => {
|
|
20
|
+
const device = bleDevices.get(peripheral);
|
|
21
|
+
if (!device) {
|
|
22
|
+
throw new Error("The peripheral was not found by bleManagerScanner");
|
|
23
|
+
}
|
|
24
|
+
return device;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** A `react-native-ble-plx` device as a peripheral. */
|
|
28
|
+
exports.bleDeviceOf = bleDeviceOf;
|
|
29
|
+
const blePeripheral = device => {
|
|
30
|
+
const peripheral = {
|
|
31
|
+
id: device.id,
|
|
32
|
+
advertisement: {
|
|
33
|
+
name: device.name?.trim() || device.localName?.trim() || "",
|
|
34
|
+
serviceUUIDs: device.serviceUUIDs ?? [],
|
|
35
|
+
manufacturerData: device.manufacturerData ?? null
|
|
36
|
+
},
|
|
37
|
+
openLink: signal => (0, _bleLink.openBleLink)(device, signal)
|
|
38
|
+
};
|
|
39
|
+
bleDevices.set(peripheral, device);
|
|
40
|
+
return peripheral;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** A scanner over a `react-native-ble-plx` `BleManager`. */
|
|
44
|
+
exports.blePeripheral = blePeripheral;
|
|
45
|
+
const bleManagerScanner = bleManager => ({
|
|
46
|
+
watchState: listener => {
|
|
47
|
+
const subscription = bleManager.onStateChange(state => listener(ADAPTER_STATES[state] ?? "unknown"), true);
|
|
48
|
+
return () => subscription.remove();
|
|
49
|
+
},
|
|
50
|
+
scan: (onFound, onError) => {
|
|
51
|
+
let active = true;
|
|
52
|
+
try {
|
|
53
|
+
bleManager.startDeviceScan(null, {
|
|
54
|
+
scanMode: _reactNativeBlePlx.ScanMode.Balanced
|
|
55
|
+
}, (error, device) => {
|
|
56
|
+
if (!active) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (error) {
|
|
60
|
+
onError((0, _bleErrors.fromBleError)(error));
|
|
61
|
+
} else if (device) {
|
|
62
|
+
onFound(blePeripheral(device));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
} catch (error) {
|
|
66
|
+
onError((0, _bleErrors.fromBleError)(error));
|
|
67
|
+
}
|
|
68
|
+
return () => {
|
|
69
|
+
active = false;
|
|
70
|
+
bleManager.stopDeviceScan();
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
exports.bleManagerScanner = bleManagerScanner;
|
|
75
|
+
//# sourceMappingURL=ble-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeBlePlx","require","_bleErrors","_bleLink","ADAPTER_STATES","State","PoweredOn","PoweredOff","Unauthorized","Unsupported","bleDevices","WeakMap","bleDeviceOf","peripheral","device","get","Error","exports","blePeripheral","id","advertisement","name","trim","localName","serviceUUIDs","manufacturerData","openLink","signal","openBleLink","set","bleManagerScanner","bleManager","watchState","listener","subscription","onStateChange","state","remove","scan","onFound","onError","active","startDeviceScan","scanMode","ScanMode","Balanced","error","fromBleError","stopDeviceScan"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-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AAA;AACA,MAAMY,iBAAiB,GAAIC,UAAsB,KAAwB;EACvEC,UAAU,EAAGC,QAAQ,IAAK;IACxB,MAAMC,YAAY,GAAGH,UAAU,CAACI,aAAa,CAAEC,KAAK,IAAKH,QAAQ,CAAC7B,cAAc,CAACgC,KAAK,CAAC,IAAI,SAAS,CAAC,EAAE,IAAI,CAAC;IAE5G,OAAO,MAAMF,YAAY,CAACG,MAAM,CAAC,CAAC;EACpC,CAAC;EACDC,IAAI,EAAEA,CAACC,OAAO,EAAEC,OAAO,KAAK;IAC1B,IAAIC,MAAM,GAAG,IAAI;IAEjB,IAAI;MACFV,UAAU,CAACW,eAAe,CAAC,IAAI,EAAE;QAAEC,QAAQ,EAAEC,2BAAQ,CAACC;MAAS,CAAC,EAAE,CAACC,KAAK,EAAEhC,MAAM,KAAK;QACnF,IAAI,CAAC2B,MAAM,EAAE;UACX;QACF;QACA,IAAIK,KAAK,EAAE;UACTN,OAAO,CAAC,IAAAO,uBAAY,EAACD,KAAK,CAAC,CAAC;QAC9B,CAAC,MAAM,IAAIhC,MAAM,EAAE;UACjByB,OAAO,CAACrB,aAAa,CAACJ,MAAM,CAAC,CAAC;QAChC;MACF,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOgC,KAAK,EAAE;MACdN,OAAO,CAAC,IAAAO,uBAAY,EAACD,KAAK,CAAC,CAAC;IAC9B;IAEA,OAAO,MAAM;MACXL,MAAM,GAAG,KAAK;MACdV,UAAU,CAACiB,cAAc,CAAC,CAAC;IAC7B,CAAC;EACH;AACF,CAAC,CAAC;AAAC/B,OAAA,CAAAa,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.builtInDevices = void 0;
|
|
7
|
+
var _resolveDeviceKey = require("../../../bt-management/core/resolve-device-key.js");
|
|
8
|
+
var _deviceCreator = require("../../../bt-management/services/device-creator.js");
|
|
9
|
+
var _driver = require("../driver.js");
|
|
10
|
+
var _sigProfiles = require("../sig-profiles.js");
|
|
11
|
+
var _legacyDriver = require("./legacy-driver.js");
|
|
12
|
+
/** Support for the SDK's integrated devices and `defineCustomDevice` declarations, over `react-native-ble-plx`. */
|
|
13
|
+
const builtInDevices = accepted => {
|
|
14
|
+
const creator = new _deviceCreator.DeviceCreator(accepted);
|
|
15
|
+
return {
|
|
16
|
+
match: ({
|
|
17
|
+
name,
|
|
18
|
+
serviceUUIDs,
|
|
19
|
+
manufacturerData
|
|
20
|
+
}) => {
|
|
21
|
+
const key = (0, _resolveDeviceKey.resolveDeviceKey)(accepted, name, serviceUUIDs, manufacturerData ?? undefined);
|
|
22
|
+
if (key === undefined) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const protocol = _sigProfiles.SIG_PROTOCOLS.get(key);
|
|
26
|
+
return {
|
|
27
|
+
key,
|
|
28
|
+
driver: protocol ? (0, _driver.gattDriver)(key, protocol) : (0, _legacyDriver.legacyDriver)(creator, key)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.builtInDevices = builtInDevices;
|
|
34
|
+
//# sourceMappingURL=built-in-devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_resolveDeviceKey","require","_deviceCreator","_driver","_sigProfiles","_legacyDriver","builtInDevices","accepted","creator","DeviceCreator","match","name","serviceUUIDs","manufacturerData","key","resolveDeviceKey","undefined","protocol","SIG_PROTOCOLS","get","driver","gattDriver","legacyDriver","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/built-in-devices.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEA,IAAAI,aAAA,GAAAJ,OAAA;AAEA;AACA,MAAMK,cAAc,GAAIC,QAAmC,IAAoB;EAC7E,MAAMC,OAAO,GAAG,IAAIC,4BAAa,CAACF,QAAQ,CAAC;EAE3C,OAAO;IACLG,KAAK,EAAEA,CAAC;MAAEC,IAAI;MAAEC,YAAY;MAAEC;IAAiB,CAAC,KAAK;MACnD,MAAMC,GAAG,GAAG,IAAAC,kCAAgB,EAACR,QAAQ,EAAEI,IAAI,EAAEC,YAAY,EAAEC,gBAAgB,IAAIG,SAAS,CAAC;MAEzF,IAAIF,GAAG,KAAKE,SAAS,EAAE;QACrB,OAAOA,SAAS;MAClB;MAEA,MAAMC,QAAQ,GAAGC,0BAAa,CAACC,GAAG,CAACL,GAAG,CAAC;MAEvC,OAAO;QAAEA,GAAG;QAAEM,MAAM,EAAEH,QAAQ,GAAG,IAAAI,kBAAU,EAACP,GAAG,EAAEG,QAAQ,CAAC,GAAG,IAAAK,0BAAY,EAACd,OAAO,EAAEM,GAAG;MAAE,CAAC;IAC3F;EACF,CAAC;AACH,CAAC;AAACS,OAAA,CAAAjB,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.legacyDriver = void 0;
|
|
7
|
+
var _deviceStatus = require("../../../bt-management/types/device-status.js");
|
|
8
|
+
var _channel = require("../channel.js");
|
|
9
|
+
var _driver = require("../driver.js");
|
|
10
|
+
var _bleErrors = require("./ble-errors.js");
|
|
11
|
+
var _bleScanner = require("./ble-scanner.js");
|
|
12
|
+
const STATUSES = {
|
|
13
|
+
[_deviceStatus.DeviceStatus.CONNECTED]: "connected",
|
|
14
|
+
[_deviceStatus.DeviceStatus.MEASURING]: "measuring",
|
|
15
|
+
[_deviceStatus.DeviceStatus.DISCONNECTED]: "disconnected"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Runs a device class from `@ovok/native/bt-management` until its protocol moves to a `DeviceProtocol`. */
|
|
19
|
+
const legacyDriver = (creator, deviceName) => (peripheral, signal) => {
|
|
20
|
+
const stop = () => events.end();
|
|
21
|
+
const events = new _channel.Channel(() => {
|
|
22
|
+
signal.removeEventListener("abort", stop);
|
|
23
|
+
void managed.disconnect();
|
|
24
|
+
});
|
|
25
|
+
const managed = creator.createDevice({
|
|
26
|
+
device: (0, _bleScanner.bleDeviceOf)(peripheral),
|
|
27
|
+
deviceName,
|
|
28
|
+
onResult: ({
|
|
29
|
+
id,
|
|
30
|
+
data
|
|
31
|
+
}) => {
|
|
32
|
+
const reading = data;
|
|
33
|
+
events.push({
|
|
34
|
+
kind: "reading",
|
|
35
|
+
id: (0, _driver.isTimestamped)(reading) ? id : null,
|
|
36
|
+
reading
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
onDeviceStatusChanged: ({
|
|
40
|
+
status
|
|
41
|
+
}) => {
|
|
42
|
+
const mapped = STATUSES[status];
|
|
43
|
+
if (mapped) {
|
|
44
|
+
events.push({
|
|
45
|
+
kind: "status",
|
|
46
|
+
status: mapped
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (status === _deviceStatus.DeviceStatus.DISCONNECTED) {
|
|
50
|
+
events.end();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
onError: ({
|
|
54
|
+
error
|
|
55
|
+
}) => events.push({
|
|
56
|
+
kind: "error",
|
|
57
|
+
error: (0, _bleErrors.fromBleError)(error)
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
signal.addEventListener("abort", stop, {
|
|
61
|
+
once: true
|
|
62
|
+
});
|
|
63
|
+
managed.connect().catch(error => events.fail((0, _bleErrors.fromBleError)(error)));
|
|
64
|
+
return events;
|
|
65
|
+
};
|
|
66
|
+
exports.legacyDriver = legacyDriver;
|
|
67
|
+
//# sourceMappingURL=legacy-driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_deviceStatus","require","_channel","_driver","_bleErrors","_bleScanner","STATUSES","DeviceStatus","CONNECTED","MEASURING","DISCONNECTED","legacyDriver","creator","deviceName","peripheral","signal","stop","events","end","Channel","removeEventListener","managed","disconnect","createDevice","device","bleDeviceOf","onResult","id","data","reading","push","kind","isTimestamped","onDeviceStatusChanged","status","mapped","onError","error","fromBleError","addEventListener","once","connect","catch","fail","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/legacy-driver.ts"],"mappings":";;;;;;AAKA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAEA,MAAMK,QAAmF,GAAG;EAC1F,CAACC,0BAAY,CAACC,SAAS,GAAG,WAAW;EACrC,CAACD,0BAAY,CAACE,SAAS,GAAG,WAAW;EACrC,CAACF,0BAAY,CAACG,YAAY,GAAG;AAC/B,CAAC;;AAED;AACA,MAAMC,YAAY,GAAGA,CAACC,OAAiD,EAAEC,UAAqB,KAC5F,CAACC,UAAU,EAAEC,MAAM,KAAK;EACtB,MAAMC,IAAI,GAAGA,CAAA,KAAMC,MAAM,CAACC,GAAG,CAAC,CAAC;EAE/B,MAAMD,MAAM,GAAG,IAAIE,gBAAO,CAAc,MAAM;IAC5CJ,MAAM,CAACK,mBAAmB,CAAC,OAAO,EAAEJ,IAAI,CAAC;IACzC,KAAKK,OAAO,CAACC,UAAU,CAAC,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMD,OAAO,GAAGT,OAAO,CAACW,YAAY,CAAC;IACnCC,MAAM,EAAE,IAAAC,uBAAW,EAACX,UAAU,CAAC;IAC/BD,UAAU;IACVa,QAAQ,EAAEA,CAAC;MAAEC,EAAE;MAAEC;IAAK,CAAC,KAAK;MAC1B,MAAMC,OAAO,GAAGD,IAAmB;MAEnCX,MAAM,CAACa,IAAI,CAAC;QAAEC,IAAI,EAAE,SAAS;QAAEJ,EAAE,EAAE,IAAAK,qBAAa,EAACH,OAAO,CAAC,GAAGF,EAAE,GAAG,IAAI;QAAEE;MAAQ,CAAC,CAAC;IACnF,CAAC;IACDI,qBAAqB,EAAEA,CAAC;MAAEC;IAAO,CAAC,KAAK;MACrC,MAAMC,MAAM,GAAG7B,QAAQ,CAAC4B,MAAM,CAAC;MAE/B,IAAIC,MAAM,EAAE;QACVlB,MAAM,CAACa,IAAI,CAAC;UAAEC,IAAI,EAAE,QAAQ;UAAEG,MAAM,EAAEC;QAAO,CAAC,CAAC;MACjD;MACA,IAAID,MAAM,KAAK3B,0BAAY,CAACG,YAAY,EAAE;QACxCO,MAAM,CAACC,GAAG,CAAC,CAAC;MACd;IACF,CAAC;IACDkB,OAAO,EAAEA,CAAC;MAAEC;IAAM,CAAC,KAAKpB,MAAM,CAACa,IAAI,CAAC;MAAEC,IAAI,EAAE,OAAO;MAAEM,KAAK,EAAE,IAAAC,uBAAY,EAACD,KAAK;IAAE,CAAC;EACnF,CAAC,CAAC;EAEFtB,MAAM,CAACwB,gBAAgB,CAAC,OAAO,EAAEvB,IAAI,EAAE;IAAEwB,IAAI,EAAE;EAAK,CAAC,CAAC;EACtDnB,OAAO,CAACoB,OAAO,CAAC,CAAC,CAACC,KAAK,CAAEL,KAAc,IAAKpB,MAAM,CAAC0B,IAAI,CAAC,IAAAL,uBAAY,EAACD,KAAK,CAAC,CAAC,CAAC;EAE7E,OAAOpB,MAAM;AACf,CAAC;AAAC2B,OAAA,CAAAjC,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Connections = void 0;
|
|
7
|
+
var _errors = require("./errors.js");
|
|
8
|
+
var _resultPolicy = require("./result-policy.js");
|
|
9
|
+
const endedBeforeConnecting = () => new _errors.BluetoothError("connection-failed", "The device disconnected before it connected");
|
|
10
|
+
|
|
11
|
+
/** One driver run per connected device, its events folded into the snapshot. */
|
|
12
|
+
class Connections {
|
|
13
|
+
sessions = new Map();
|
|
14
|
+
constructor(store, readings, policy, onEnded) {
|
|
15
|
+
this.store = store;
|
|
16
|
+
this.readings = readings;
|
|
17
|
+
this.policy = policy;
|
|
18
|
+
this.onEnded = onEnded;
|
|
19
|
+
}
|
|
20
|
+
isActive(id) {
|
|
21
|
+
return this.sessions.has(id);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Resolves once connected; joins a connection still opening or open, and waits out one being closed. */
|
|
25
|
+
async connect(peripheral, driver) {
|
|
26
|
+
const current = this.sessions.get(peripheral.id);
|
|
27
|
+
if (current?.controller.signal.aborted) {
|
|
28
|
+
await current.ended;
|
|
29
|
+
return this.connect(peripheral, driver);
|
|
30
|
+
}
|
|
31
|
+
return (current ?? this.start(peripheral, driver)).connected;
|
|
32
|
+
}
|
|
33
|
+
async disconnect(id) {
|
|
34
|
+
const session = this.sessions.get(id);
|
|
35
|
+
session?.controller.abort();
|
|
36
|
+
await session?.ended;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Disconnects every device; resolves once every connection has ended. */
|
|
40
|
+
async disconnectAll() {
|
|
41
|
+
await Promise.all([...this.sessions.keys()].map(id => this.disconnect(id)));
|
|
42
|
+
}
|
|
43
|
+
start(peripheral, driver) {
|
|
44
|
+
const {
|
|
45
|
+
id
|
|
46
|
+
} = peripheral;
|
|
47
|
+
const controller = new AbortController();
|
|
48
|
+
let markConnected = () => undefined;
|
|
49
|
+
let failConnecting = () => undefined;
|
|
50
|
+
const connected = new Promise((resolve, reject) => {
|
|
51
|
+
markConnected = resolve;
|
|
52
|
+
failConnecting = reject;
|
|
53
|
+
});
|
|
54
|
+
this.store.updateDevice(id, {
|
|
55
|
+
connection: "connecting",
|
|
56
|
+
error: null
|
|
57
|
+
});
|
|
58
|
+
const ended = this.run(peripheral, driver, controller.signal, () => markConnected()).then(() => {
|
|
59
|
+
this.store.updateDevice(id, {
|
|
60
|
+
connection: "disconnected"
|
|
61
|
+
});
|
|
62
|
+
failConnecting(endedBeforeConnecting());
|
|
63
|
+
}).catch(error => {
|
|
64
|
+
const failure = (0, _errors.asBluetoothError)(error, "connection-failed");
|
|
65
|
+
this.store.updateDevice(id, controller.signal.aborted ? {
|
|
66
|
+
connection: "disconnected"
|
|
67
|
+
} : {
|
|
68
|
+
connection: "failed",
|
|
69
|
+
error: failure
|
|
70
|
+
});
|
|
71
|
+
failConnecting(failure);
|
|
72
|
+
}).finally(() => {
|
|
73
|
+
this.sessions.delete(id);
|
|
74
|
+
this.onEnded(id);
|
|
75
|
+
});
|
|
76
|
+
const session = {
|
|
77
|
+
controller,
|
|
78
|
+
connected,
|
|
79
|
+
ended
|
|
80
|
+
};
|
|
81
|
+
this.sessions.set(id, session);
|
|
82
|
+
return session;
|
|
83
|
+
}
|
|
84
|
+
async run(peripheral, driver, signal, connected) {
|
|
85
|
+
for await (const event of (0, _resultPolicy.keepReadings)(driver(peripheral, signal), this.policy)) {
|
|
86
|
+
this.apply(peripheral.id, event, connected);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
apply(id, event, connected) {
|
|
90
|
+
if (event.kind === "status") {
|
|
91
|
+
if (event.status !== "disconnected") {
|
|
92
|
+
connected();
|
|
93
|
+
}
|
|
94
|
+
this.store.updateDevice(id, {
|
|
95
|
+
connection: event.status
|
|
96
|
+
});
|
|
97
|
+
} else if (event.kind === "reading") {
|
|
98
|
+
const device = this.store.device(id);
|
|
99
|
+
if (device) {
|
|
100
|
+
this.readings.receive(device, event.id, event.reading);
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
this.store.updateDevice(id, {
|
|
104
|
+
error: event.error
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.Connections = Connections;
|
|
110
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +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,UAAU,CAACC,MAAM,CAACC,OAAO,EAAE;M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C;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,MAAME,MAAM,GAAG,IAAI,CAAChD,KAAK,CAACgD,MAAM,CAAC3C,EAAE,CAAC;MAEpC,IAAI2C,MAAM,EAAE;QACV,IAAI,CAAC/C,QAAQ,CAACgD,OAAO,CAACD,MAAM,EAAEL,KAAK,CAACtC,EAAE,EAAEsC,KAAK,CAACO,OAAO,CAAC;MACxD;IACF,CAAC,MAAM;MACL,IAAI,CAAClD,KAAK,CAACgC,YAAY,CAAC3B,EAAE,EAAE;QAAE6B,KAAK,EAAES,KAAK,CAACT;MAAM,CAAC,CAAC;IACrD;EACF;AACF;AAACiB,OAAA,CAAAvD,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["dailyTotalDay","data","now","temporal","end","Date","getTime","day","start","recordedAt","toISOString","slice","undefined","exports"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/daily-total-day.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAGA,CAC3BC,IAAY,EACZC,GAAW,KACY;EACvB,MAAMC,QAAQ,GAAGF,IAAuD;EAExE,IAAIE,QAAQ,CAACC,GAAG,YAAYC,IAAI,IAAIF,QAAQ,CAACC,GAAG,CAACE,OAAO,CAAC,CAAC,GAAGJ,GAAG,EAAE;IAChE,OAAO,QAAQ;EACjB;EAEA,MAAMK,GAAG,GAAGJ,QAAQ,CAACC,GAAG,IAAID,QAAQ,CAACK,KAAK,IAAIL,QAAQ,CAACM,UAAU;EAEjE,OAAOF,GAAG,YAAYF,IAAI,GAAGE,GAAG,CAACG,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAGC,SAAS;AACzE,CAAC;AAACC,OAAA,CAAAb,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.matchDevice = exports.defineDevice = void 0;
|
|
7
|
+
var _driver = require("./driver.js");
|
|
8
|
+
/** A peripheral a support recognised: the device key its readings carry and the driver that runs it. */
|
|
9
|
+
|
|
10
|
+
/** Recognises peripherals by their advertisement. */
|
|
11
|
+
|
|
12
|
+
/** A device a third party adds: how to recognise it and the protocol that reads it. */
|
|
13
|
+
|
|
14
|
+
/** Support for one device a third party defines with its own protocol. */
|
|
15
|
+
const defineDevice = ({
|
|
16
|
+
key,
|
|
17
|
+
matches,
|
|
18
|
+
protocol
|
|
19
|
+
}) => {
|
|
20
|
+
const driver = (0, _driver.gattDriver)(key, protocol);
|
|
21
|
+
return {
|
|
22
|
+
match: advertisement => matches(advertisement) ? {
|
|
23
|
+
key,
|
|
24
|
+
driver
|
|
25
|
+
} : undefined
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** The first support's match for an advertisement. */
|
|
30
|
+
exports.defineDevice = defineDevice;
|
|
31
|
+
const matchDevice = (devices, advertisement) => {
|
|
32
|
+
for (const support of devices) {
|
|
33
|
+
const match = support.match(advertisement);
|
|
34
|
+
if (match) {
|
|
35
|
+
return match;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
};
|
|
40
|
+
exports.matchDevice = matchDevice;
|
|
41
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_driver","require","defineDevice","key","matches","protocol","driver","gattDriver","match","advertisement","undefined","exports","matchDevice","devices","support"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/devices.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGA;;AAUA;;AAOA;;AAaA;AACA,MAAMC,YAAY,GAAGA,CAAC;EAAEC,GAAG;EAAEC,OAAO;EAAEC;AAA2B,CAAC,KAAoB;EACpF,MAAMC,MAAM,GAAG,IAAAC,kBAAU,EAACJ,GAAG,EAAEE,QAAQ,CAAC;EAExC,OAAO;IAAEG,KAAK,EAAGC,aAAa,IAAML,OAAO,CAACK,aAAa,CAAC,GAAG;MAAEN,GAAG;MAAEG;IAAO,CAAC,GAAGI;EAAW,CAAC;AAC7F,CAAC;;AAED;AAAAC,OAAA,CAAAT,YAAA,GAAAA,YAAA;AACA,MAAMU,WAAW,GAAGA,CAACC,OAAiC,EAAEJ,aAA4B,KAA8B;EAChH,KAAK,MAAMK,OAAO,IAAID,OAAO,EAAE;IAC7B,MAAML,KAAK,GAAGM,OAAO,CAACN,KAAK,CAACC,aAAa,CAAC;IAE1C,IAAID,KAAK,EAAE;MACT,OAAOA,KAAK;IACd;EACF;EAEA,OAAOE,SAAS;AAClB,CAAC;AAACC,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
|