@mentra/bluetooth-sdk 3.2.0-dev.193 → 3.2.0-dev.195
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 +11 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- 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.map +1 -1
- package/build/_private/BluetoothSdkModule.js +1 -0
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/react/useGlassesConnection.d.ts +5 -0
- package/build/react/useGlassesConnection.d.ts.map +1 -1
- package/build/react/useGlassesConnection.js +2 -2
- package/build/react/useGlassesConnection.js.map +1 -1
- package/build/react/useMentraBluetooth.d.ts +5 -0
- 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 +2 -2
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/DeviceManager.swift +4 -2
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/ios/Source/MentraBluetoothSDK.swift +10 -3
- package/ios/Source/sgcs/MentraLive.swift +20 -3
- package/ios/Source/types/DeviceModels.swift +9 -1
- package/ios/Tests/MentraLiveConnectionOptionsTests.swift +30 -0
- package/package.json +1 -1
- package/src/BluetoothSdk.types.ts +7 -0
- package/src/_private/BluetoothSdkModule.ts +1 -0
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/react/useGlassesConnection.ts +7 -2
- package/src/react/useMentraBluetooth.ts +6 -0
|
@@ -169,9 +169,17 @@ public struct Device: Identifiable, Equatable, CustomStringConvertible {
|
|
|
169
169
|
public struct ConnectOptions {
|
|
170
170
|
public let saveAsDefault: Bool
|
|
171
171
|
public let cancelExistingConnectionAttempt: Bool
|
|
172
|
+
/// Mentra Live on iOS only. Whether CoreBluetooth should require ANCS
|
|
173
|
+
/// authorization while establishing the connection.
|
|
174
|
+
public let requiresAncs: Bool
|
|
172
175
|
|
|
173
|
-
public init(
|
|
176
|
+
public init(
|
|
177
|
+
saveAsDefault: Bool = true,
|
|
178
|
+
cancelExistingConnectionAttempt: Bool = true,
|
|
179
|
+
requiresAncs: Bool = true
|
|
180
|
+
) {
|
|
174
181
|
self.saveAsDefault = saveAsDefault
|
|
175
182
|
self.cancelExistingConnectionAttempt = cancelExistingConnectionAttempt
|
|
183
|
+
self.requiresAncs = requiresAncs
|
|
176
184
|
}
|
|
177
185
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import CoreBluetooth
|
|
2
|
+
@testable import MentraBluetoothSDK
|
|
3
|
+
import XCTest
|
|
4
|
+
|
|
5
|
+
final class MentraLiveConnectionOptionsTests: XCTestCase {
|
|
6
|
+
func testConnectOptionsRequireAncsByDefault() {
|
|
7
|
+
XCTAssertTrue(ConnectOptions().requiresAncs)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
func testConnectOptionsCanDisableAncsRequirement() {
|
|
11
|
+
XCTAssertFalse(ConnectOptions(requiresAncs: false).requiresAncs)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#if os(macOS)
|
|
15
|
+
func testCoreBluetoothOptionsOmitAncsOnMacOS() {
|
|
16
|
+
XCTAssertNil(MentraLiveConnectionOptions.coreBluetoothOptions(requiresAncs: true))
|
|
17
|
+
}
|
|
18
|
+
#else
|
|
19
|
+
func testCoreBluetoothOptionsRequireAncsWhenEnabled() {
|
|
20
|
+
let options = MentraLiveConnectionOptions.coreBluetoothOptions(requiresAncs: true)
|
|
21
|
+
|
|
22
|
+
XCTAssertEqual(options?.count, 1)
|
|
23
|
+
XCTAssertEqual(options?[CBConnectPeripheralOptionRequiresANCS] as? Bool, true)
|
|
24
|
+
}
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
func testCoreBluetoothOptionsAreOmittedWhenAncsIsDisabled() {
|
|
28
|
+
XCTAssertNil(MentraLiveConnectionOptions.coreBluetoothOptions(requiresAncs: false))
|
|
29
|
+
}
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1485,6 +1485,13 @@ export interface Device {
|
|
|
1485
1485
|
export interface ConnectOptions {
|
|
1486
1486
|
saveAsDefault?: boolean
|
|
1487
1487
|
cancelExistingConnectionAttempt?: boolean
|
|
1488
|
+
/**
|
|
1489
|
+
* iOS Mentra Live only. When true, CoreBluetooth requires ANCS authorization
|
|
1490
|
+
* as part of the connection. Set false when the app does not use notification
|
|
1491
|
+
* relay and must avoid the system ANCS authorization flow. Defaults to true.
|
|
1492
|
+
* Android accepts this option as a no-op.
|
|
1493
|
+
*/
|
|
1494
|
+
requiresAncs?: boolean
|
|
1488
1495
|
}
|
|
1489
1496
|
|
|
1490
1497
|
export type ScanResultsCallback = (devices: Device[]) => void
|
|
@@ -295,6 +295,7 @@ installNativeLogConsole(NativeBluetoothSdkModule, Platform.OS)
|
|
|
295
295
|
const DEFAULT_CONNECT_OPTIONS: Required<ConnectOptions> = {
|
|
296
296
|
saveAsDefault: true,
|
|
297
297
|
cancelExistingConnectionAttempt: true,
|
|
298
|
+
requiresAncs: true,
|
|
298
299
|
}
|
|
299
300
|
|
|
300
301
|
const DEFAULT_SCAN_TIMEOUT_MS = 15_000
|
|
@@ -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.195",
|
|
16
|
+
"releaseSetId": "mentra-3.2.0-dev.195",
|
|
17
|
+
"sourceCommit": "321202ca96ec1852be19a7230ebcc3593fe87e54",
|
|
18
|
+
"otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.2.0/mentra-live-ota-3.2.0-dev.195.json",
|
|
19
|
+
"otaManifestSha256": "70f26063b2c281b9b046965f6f6d7ca22f8b53242c6c5be02030c5a04c7115e4"
|
|
20
20
|
})
|
|
@@ -22,6 +22,11 @@ export type UseGlassesConnectionOptions = {
|
|
|
22
22
|
autoConnectDefault?: boolean
|
|
23
23
|
defaultDeviceStorage?: DefaultDeviceStorage
|
|
24
24
|
onError?: (error: unknown) => void
|
|
25
|
+
/**
|
|
26
|
+
* Whether iOS should require ANCS authorization when automatically connecting.
|
|
27
|
+
* Defaults to true. Android accepts this option as a no-op.
|
|
28
|
+
*/
|
|
29
|
+
requiresAncs?: boolean
|
|
25
30
|
scanModel?: DeviceModel
|
|
26
31
|
scanTimeoutMs?: number
|
|
27
32
|
}
|
|
@@ -117,8 +122,8 @@ export function useGlassesConnection(
|
|
|
117
122
|
}
|
|
118
123
|
|
|
119
124
|
autoConnectAttemptedRef.current = true
|
|
120
|
-
void connectDefault().catch(() => undefined)
|
|
121
|
-
}, [defaultDevice, options.autoConnectDefault, status.connected])
|
|
125
|
+
void connectDefault({requiresAncs: options.requiresAncs ?? true}).catch(() => undefined)
|
|
126
|
+
}, [defaultDevice, options.autoConnectDefault, options.requiresAncs, status.connected])
|
|
122
127
|
|
|
123
128
|
async function runConnectionAction<T>(
|
|
124
129
|
nextAction: Exclude<GlassesConnectionAction, "idle" | "scanning">,
|
|
@@ -121,6 +121,11 @@ export type UseMentraBluetoothOptions = {
|
|
|
121
121
|
defaultDeviceStorage?: DefaultDeviceStorage
|
|
122
122
|
defaultModel?: DeviceModel
|
|
123
123
|
onError?: (error: unknown) => void
|
|
124
|
+
/**
|
|
125
|
+
* Whether iOS should require ANCS authorization when automatically connecting.
|
|
126
|
+
* Defaults to true. Android accepts this option as a no-op.
|
|
127
|
+
*/
|
|
128
|
+
requiresAncs?: boolean
|
|
124
129
|
scanTimeoutMs?: number
|
|
125
130
|
}
|
|
126
131
|
|
|
@@ -269,6 +274,7 @@ export function useMentraBluetooth(options: UseMentraBluetoothOptions = {}): Men
|
|
|
269
274
|
autoConnectDefault: options.autoConnectDefault,
|
|
270
275
|
defaultDeviceStorage: options.defaultDeviceStorage,
|
|
271
276
|
onError: options.onError,
|
|
277
|
+
requiresAncs: options.requiresAncs,
|
|
272
278
|
scanModel: options.defaultModel ?? DeviceModels.MentraLive,
|
|
273
279
|
scanTimeoutMs: options.scanTimeoutMs,
|
|
274
280
|
})
|