@mentra/bluetooth-sdk 3.2.0-dev.177 → 3.2.0-dev.181
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/README.md +7 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +6 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/ConnectedDeviceMatcher.kt +69 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +57 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/OtaManifest.kt +6 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/connection/ConnectionModels.kt +38 -1
- package/android/src/test/java/com/mentra/bluetoothsdk/ConnectedDeviceMatcherTest.kt +161 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/OtaManifestDowngradeTest.kt +8 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/ScanCompletionTest.kt +87 -0
- package/build/BluetoothSdk.types.d.ts +7 -0
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +2 -1
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js +28 -49
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/_private/scanSession.d.ts +21 -0
- package/build/_private/scanSession.d.ts.map +1 -0
- package/build/_private/scanSession.js +75 -0
- package/build/_private/scanSession.js.map +1 -0
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/react/useBluetoothScan.d.ts +2 -1
- package/build/react/useBluetoothScan.d.ts.map +1 -1
- package/build/react/useBluetoothScan.js +13 -0
- package/build/react/useBluetoothScan.js.map +1 -1
- package/build/react/useMentraBluetooth.d.ts +2 -1
- package/build/react/useMentraBluetooth.d.ts.map +1 -1
- package/build/react/useMentraBluetooth.js +1 -0
- package/build/react/useMentraBluetooth.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +7 -0
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/ios/Source/MentraBluetoothSDK.swift +43 -2
- package/ios/Source/OtaManifest.swift +6 -5
- package/ios/Source/connection/ScanSession.swift +11 -0
- package/ios/Source/internal/BluetoothAvailability.swift +7 -0
- package/ios/Source/internal/ConnectedDeviceMatcher.swift +45 -0
- package/ios/Tests/ConnectedDeviceMatcherTests.swift +27 -0
- package/ios/Tests/OtaManifestDowngradeTests.swift +20 -0
- package/package.json +1 -1
- package/src/BluetoothSdk.types.ts +8 -0
- package/src/_private/BluetoothSdkModule.ts +39 -57
- package/src/_private/scanSession.ts +88 -0
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/index.ts +1 -0
- package/src/react/useBluetoothScan.ts +12 -1
- package/src/react/useMentraBluetooth.ts +2 -0
|
@@ -12,9 +12,9 @@ export interface BluetoothSdkReleaseMetadata {
|
|
|
12
12
|
export const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({
|
|
13
13
|
"schemaVersion": 1,
|
|
14
14
|
"familyBaseVersion": "3.2.0",
|
|
15
|
-
"releaseIdentity": "3.2.0-dev.
|
|
16
|
-
"releaseSetId": "mentra-3.2.0-dev.
|
|
17
|
-
"sourceCommit": "
|
|
18
|
-
"otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.2.0/mentra-live-ota-3.2.0-dev.
|
|
19
|
-
"otaManifestSha256": "
|
|
15
|
+
"releaseIdentity": "3.2.0-dev.181",
|
|
16
|
+
"releaseSetId": "mentra-3.2.0-dev.181",
|
|
17
|
+
"sourceCommit": "89a4792321ce95bd16aadd721bc3dbc20e338861",
|
|
18
|
+
"otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.2.0/mentra-live-ota-3.2.0-dev.181.json",
|
|
19
|
+
"otaManifestSha256": "d9a100cc81733d02848a86c7617eff154f4cd9d714d1d36407789aeebbf71251"
|
|
20
20
|
})
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {useEffect, useRef, useState} from "react"
|
|
2
2
|
|
|
3
3
|
import BluetoothSdk, {DeviceModels} from "../index"
|
|
4
|
-
import type {Device, DeviceModel} from "../BluetoothSdk.types"
|
|
4
|
+
import type {Device, DeviceModel, ScanDiagnostic} from "../BluetoothSdk.types"
|
|
5
5
|
|
|
6
6
|
export type BluetoothScanDedupe = "id" | "name" | ((device: Device) => string)
|
|
7
7
|
|
|
@@ -15,6 +15,7 @@ export type UseBluetoothScanOptions = {
|
|
|
15
15
|
export type BluetoothScanHookResult = {
|
|
16
16
|
clearResults: () => void
|
|
17
17
|
devices: Device[]
|
|
18
|
+
diagnostic: ScanDiagnostic | null
|
|
18
19
|
error: unknown | null
|
|
19
20
|
model: DeviceModel
|
|
20
21
|
scanning: boolean
|
|
@@ -61,6 +62,7 @@ function hasDevice(devices: Device[], selectedDevice: Device | null, dedupe: Blu
|
|
|
61
62
|
|
|
62
63
|
export function useBluetoothScan(options: UseBluetoothScanOptions = {}): BluetoothScanHookResult {
|
|
63
64
|
const [devices, setDevices] = useState<Device[]>([])
|
|
65
|
+
const [diagnostic, setDiagnostic] = useState<ScanDiagnostic | null>(null)
|
|
64
66
|
const [error, setError] = useState<unknown | null>(null)
|
|
65
67
|
const [model, setModelState] = useState<DeviceModel>(options.model ?? DeviceModels.MentraLive)
|
|
66
68
|
const [scanning, setScanning] = useState(false)
|
|
@@ -98,11 +100,13 @@ export function useBluetoothScan(options: UseBluetoothScanOptions = {}): Bluetoo
|
|
|
98
100
|
}, [])
|
|
99
101
|
|
|
100
102
|
function clearResults() {
|
|
103
|
+
setDiagnostic(null)
|
|
101
104
|
setDevices([])
|
|
102
105
|
selectDevice(null)
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
function setModel(nextModel: DeviceModel) {
|
|
109
|
+
if (scanningRef.current) void stopScan()
|
|
106
110
|
setModelState(nextModel)
|
|
107
111
|
clearResults()
|
|
108
112
|
}
|
|
@@ -116,6 +120,7 @@ export function useBluetoothScan(options: UseBluetoothScanOptions = {}): Bluetoo
|
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
setError(null)
|
|
123
|
+
setDiagnostic(null)
|
|
119
124
|
setScanning(true)
|
|
120
125
|
scanningRef.current = true
|
|
121
126
|
setDevices([])
|
|
@@ -124,10 +129,14 @@ export function useBluetoothScan(options: UseBluetoothScanOptions = {}): Bluetoo
|
|
|
124
129
|
try {
|
|
125
130
|
const nextDevices = await BluetoothSdk.scan(scanModel, {
|
|
126
131
|
...(timeoutMsRef.current == null ? {} : {timeoutMs: timeoutMsRef.current}),
|
|
132
|
+
onDiagnostic: (hint) => {
|
|
133
|
+
if (activeScanRef.current === scanId) setDiagnostic(hint)
|
|
134
|
+
},
|
|
127
135
|
onResults: (results) => {
|
|
128
136
|
if (activeScanRef.current !== scanId) {
|
|
129
137
|
return
|
|
130
138
|
}
|
|
139
|
+
if (results.length > 0) setDiagnostic(null)
|
|
131
140
|
setDevices(dedupeDevices(results, dedupeRef.current))
|
|
132
141
|
},
|
|
133
142
|
})
|
|
@@ -152,6 +161,7 @@ export function useBluetoothScan(options: UseBluetoothScanOptions = {}): Bluetoo
|
|
|
152
161
|
}
|
|
153
162
|
|
|
154
163
|
async function stopScan() {
|
|
164
|
+
setDiagnostic(null)
|
|
155
165
|
activeScanRef.current += 1
|
|
156
166
|
setScanning(false)
|
|
157
167
|
scanningRef.current = false
|
|
@@ -161,6 +171,7 @@ export function useBluetoothScan(options: UseBluetoothScanOptions = {}): Bluetoo
|
|
|
161
171
|
return {
|
|
162
172
|
clearResults,
|
|
163
173
|
devices,
|
|
174
|
+
diagnostic,
|
|
164
175
|
error,
|
|
165
176
|
model,
|
|
166
177
|
scanning,
|
|
@@ -106,6 +106,7 @@ export type ScanController = {
|
|
|
106
106
|
active: boolean
|
|
107
107
|
clear: () => void
|
|
108
108
|
devices: Device[]
|
|
109
|
+
diagnostic: GlassesConnectionHookResult["scan"]["diagnostic"]
|
|
109
110
|
error: unknown | null
|
|
110
111
|
model: DeviceModel
|
|
111
112
|
selectedDevice: Device | null
|
|
@@ -252,6 +253,7 @@ function scanController(connection: GlassesConnectionHookResult): ScanController
|
|
|
252
253
|
active: connection.scan.scanning,
|
|
253
254
|
clear: connection.scan.clearResults,
|
|
254
255
|
devices: connection.scan.devices,
|
|
256
|
+
diagnostic: connection.scan.diagnostic,
|
|
255
257
|
error: connection.scan.error,
|
|
256
258
|
model: connection.scan.model,
|
|
257
259
|
selectedDevice: connection.scan.selectedDevice,
|