@mentra/bluetooth-sdk 3.5.0-dev.1291 → 3.5.0-dev.1308
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/MIGRATION.md +15 -6
- package/README.md +1 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +4 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +1 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +14 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +11 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +7 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTracker.kt +15 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +78 -26
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +5 -5
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTrackerTest.kt +26 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicyTest.kt +3 -3
- package/build/BluetoothSdk.types.d.ts +3 -1
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +0 -1
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- 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/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/react/useGlassesConnection.d.ts +1 -1
- package/build/react/useGlassesConnection.d.ts.map +1 -1
- package/build/react/useGlassesConnection.js +3 -3
- package/build/react/useGlassesConnection.js.map +1 -1
- package/build/react/useMentraBluetooth.d.ts +1 -1
- package/build/react/useMentraBluetooth.d.ts.map +1 -1
- package/build/react/useMentraBluetooth.js +1 -1
- package/build/react/useMentraBluetooth.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +1 -7
- package/ios/Source/BluetoothSdkDefaults.swift +5 -5
- package/ios/Source/Bridge.swift +14 -0
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/ios/Source/MentraBluetoothSDK.swift +8 -1
- package/ios/Source/sgcs/MentraLive.swift +15 -23
- package/package.json +2 -2
- package/src/BluetoothSdk.types.ts +3 -1
- package/src/_private/BluetoothSdkModule.ts +0 -1
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/index.ts +1 -1
- package/src/react/useGlassesConnection.ts +4 -4
- package/src/react/useMentraBluetooth.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMentraBluetooth.js","sourceRoot":"","sources":["../../src/react/useMentraBluetooth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAA;AAE9B,OAAO,YAAY,MAAM,UAAU,CAAA;AACnC,OAAO,EACL,wCAAwC,EACxC,YAAY,EACZ,+BAA+B,EAC/B,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,uBAAuB,CAAA;AAe9B,OAAO,EACL,oBAAoB,GAGrB,MAAM,wBAAwB,CAAA;AAwH/B,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1E,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AAC3E,CAAC;AAED,SAAS,YAAY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pC,QAAQ,EAAE,mBAAmB;QAC7B,OAAO,EAAE,UAAU,CAAC,eAAe,CAAC,kBAAkB,KAAK,KAAK;QAChE,KAAK,EAAE,gBAAgB;KACxB,CAAA;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,mBAAmB;QAC5C,kBAAkB,EAAE,UAAU,CAAC,kBAAkB;QACjD,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,cAAc,EAAE,UAAU,CAAC,cAAc;QACzC,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,KAAK,EAAE,gBAAgB,IAAI,UAAU,CAAC,KAAK;QAC3C,OAAO,EAAE,mBAAmB,CAAC,UAAU,CAAC,aAAa,CAAC;QACtD,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC;QAChC,GAAG,EAAE,aAAa,CAAC,UAAU,CAAC,eAAe,EAAE,UAAU,CAAC,aAAa,EAAE,WAAW,CAAC;QACrF,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;QAC7C,qBAAqB;QACrB,gCAAgC;KACjC,CAAA;AACH,CAAC","sourcesContent":["import {useState} from \"react\"\n\nimport BluetoothSdk from \"../index\"\nimport {\n DEFAULT_VOICE_ACTIVITY_DETECTION_ENABLED,\n DeviceModels,\n createDisconnectedGlassesStatus,\n isConnectedGlassesConnectionStatus,\n isReadyGlassesConnectionStatus,\n} from \"../BluetoothSdk.types\"\nimport type {\n ConnectOptions,\n Device,\n DeviceModel,\n GlassesConnectionStatus,\n HotspotStatus,\n PublicBluetoothStatus,\n PublicGlassesStatus,\n MicMode,\n SettingsAckSuccessEvent,\n WifiSearchResult,\n WifiStatus,\n} from \"../BluetoothSdk.types\"\n\nimport {\n useGlassesConnection,\n type DefaultDeviceStorage,\n type GlassesConnectionHookResult,\n} from \"./useGlassesConnection\"\n\nexport type BatteryState = {\n charging: boolean\n level: number | null\n}\n\nexport type ConnectedGlassesInfo = {\n appVersion?: string\n bluetoothName?: string\n buildNumber?: string\n color?: string\n deviceModel?: string\n firmwareVersion?: string\n serialNumber?: string\n style?: string\n}\n\nexport type FirmwareInfo = {\n appVersion?: string\n buildNumber?: string\n source:\n | \"app\"\n | \"bes\"\n | \"device\"\n | \"firmware\"\n | \"left\"\n | \"mtk\"\n | \"right\"\n | \"unknown\"\n version: string | null\n}\n\nexport type SignalState = {\n strengthDbm: number | null\n updatedAt: number | null\n}\n\nexport type GlassesRuntimeState =\n | {\n connected: false\n connection: Exclude<GlassesConnectionStatus, {state: \"connected\"}>\n ready: false\n }\n | {\n battery: BatteryState\n connected: true\n connection: Extract<GlassesConnectionStatus, {state: \"connected\"}>\n device: ConnectedGlassesInfo\n firmware: FirmwareInfo\n hotspot: HotspotStatus\n ready: boolean\n signal: SignalState\n voiceActivityDetectionEnabled: boolean\n wifi: WifiStatus\n }\n\nexport type GalleryModeState = {\n applying: boolean\n enabled: boolean\n error: unknown | null\n}\n\nexport type PhoneSdkRuntimeState = {\n currentMic: MicMode | null\n defaultDevice: Device | null\n galleryMode: GalleryModeState\n lastLog: string[]\n micRanking: MicMode[]\n otherBluetoothConnected: boolean\n searching: boolean\n searchingController: boolean\n systemMicUnavailable: boolean\n wifiScanResults: WifiSearchResult[]\n}\n\nexport type ScanController = {\n active: boolean\n clear: () => void\n devices: Device[]\n diagnostic: GlassesConnectionHookResult[\"scan\"][\"diagnostic\"]\n error: unknown | null\n model: DeviceModel\n selectedDevice: Device | null\n selectDevice: (device: Device | null) => void\n setModel: (model: DeviceModel) => void\n start: (model?: DeviceModel) => Promise<Device[]>\n stop: () => Promise<void>\n}\n\nexport type UseMentraBluetoothOptions = {\n autoConnectDefault?: boolean\n defaultDeviceStorage?: DefaultDeviceStorage\n defaultModel?: DeviceModel\n onError?: (error: unknown) => void\n /**\n * Whether iOS should require ANCS authorization when automatically connecting.\n * Defaults to true. Android accepts this option as a no-op.\n */\n requiresAncs?: boolean\n scanTimeoutMs?: number\n}\n\nexport type MentraBluetoothSession = {\n busy: boolean\n clearDefaultDevice: () => Promise<void>\n connect: (device?: Device, options?: ConnectOptions) => Promise<void>\n connectDefault: (options?: ConnectOptions) => Promise<void>\n defaultDevice: Device | null\n disconnect: () => Promise<void>\n error: unknown | null\n glasses: GlassesRuntimeState\n refresh: () => Promise<void>\n scan: ScanController\n sdk: PhoneSdkRuntimeState\n setDefaultDevice: (device: Device | null) => Promise<void>\n setGalleryModeEnabled: (enabled: boolean) => Promise<SettingsAckSuccessEvent>\n setVoiceActivityDetectionEnabled: (enabled: boolean) => Promise<void>\n}\n\nfunction stringValue(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length > 0 ? value : undefined\n}\n\nfunction numberValue(value: unknown): number | null {\n return typeof value === \"number\" && Number.isFinite(value) ? value : null\n}\n\nfunction firmwareInfo(status: Partial<PublicGlassesStatus>): FirmwareInfo {\n const firmwareSources = [\n [\"firmwareVersion\", \"firmware\"],\n [\"deviceFirmwareVersion\", \"device\"],\n [\"rightFirmwareVersion\", \"right\"],\n [\"leftFirmwareVersion\", \"left\"],\n [\"besFirmwareVersion\", \"bes\"],\n [\"mtkFirmwareVersion\", \"mtk\"],\n [\"appVersion\", \"app\"],\n ] as const\n\n for (const [key, source] of firmwareSources) {\n const value = stringValue((status as Record<string, unknown>)[key])\n if (value) {\n return {\n appVersion: stringValue(status.appVersion),\n buildNumber: stringValue(status.buildNumber),\n source,\n version: value,\n }\n }\n }\n\n return {\n appVersion: stringValue(status.appVersion),\n buildNumber: stringValue(status.buildNumber),\n source: \"unknown\",\n version: null,\n }\n}\n\nfunction batteryState(status: Partial<PublicGlassesStatus>): BatteryState {\n const level = typeof status.batteryLevel === \"number\" && status.batteryLevel >= 0 ? status.batteryLevel : null\n return {\n charging: status.charging ?? false,\n level,\n }\n}\n\nfunction connectedGlassesInfo(status: Partial<PublicGlassesStatus>): ConnectedGlassesInfo {\n return {\n appVersion: stringValue(status.appVersion),\n bluetoothName: stringValue(status.bluetoothName),\n buildNumber: stringValue(status.buildNumber),\n color: stringValue(status.color),\n deviceModel: stringValue(status.deviceModel),\n firmwareVersion: stringValue(status.firmwareVersion),\n serialNumber: stringValue(status.serialNumber),\n style: stringValue(status.style),\n }\n}\n\nfunction runtimeGlassesState(status: Partial<PublicGlassesStatus>): GlassesRuntimeState {\n const connection = status.connection ?? createDisconnectedGlassesStatus().connection ?? {state: \"disconnected\"}\n\n if (!isConnectedGlassesConnectionStatus(connection)) {\n return {\n connected: false,\n connection,\n ready: false,\n }\n }\n\n return {\n battery: batteryState(status),\n connected: true,\n connection,\n device: connectedGlassesInfo(status),\n firmware: firmwareInfo(status),\n hotspot: status.hotspot ?? {state: \"disabled\"},\n ready: isReadyGlassesConnectionStatus(connection),\n signal: {\n strengthDbm: numberValue((status as Record<string, unknown>).signalStrength),\n updatedAt: numberValue((status as Record<string, unknown>).signalStrengthUpdatedAt),\n },\n voiceActivityDetectionEnabled: status.voiceActivityDetectionEnabled ?? DEFAULT_VOICE_ACTIVITY_DETECTION_ENABLED,\n wifi: status.wifi ?? {state: \"disconnected\"},\n }\n}\n\nfunction phoneSdkState(\n status: Partial<PublicBluetoothStatus>,\n defaultDevice: Device | null,\n galleryMode: GalleryModeState,\n): PhoneSdkRuntimeState {\n return {\n currentMic: status.currentMic || null,\n defaultDevice,\n galleryMode,\n lastLog: status.lastLog ?? [],\n micRanking: status.micRanking ?? [],\n otherBluetoothConnected: status.otherBtConnected ?? false,\n searching: status.searching ?? false,\n searchingController: status.searchingController ?? false,\n systemMicUnavailable: status.systemMicUnavailable ?? false,\n wifiScanResults: status.wifiScanResults ?? [],\n }\n}\n\nfunction scanController(connection: GlassesConnectionHookResult): ScanController {\n return {\n active: connection.scan.scanning,\n clear: connection.scan.clearResults,\n devices: connection.scan.devices,\n diagnostic: connection.scan.diagnostic,\n error: connection.scan.error,\n model: connection.scan.model,\n selectedDevice: connection.scan.selectedDevice,\n selectDevice: connection.scan.selectDevice,\n setModel: connection.scan.setModel,\n start: connection.scan.startScan,\n stop: connection.scan.stopScan,\n }\n}\n\nexport function useMentraBluetooth(options: UseMentraBluetoothOptions = {}): MentraBluetoothSession {\n const connection = useGlassesConnection({\n autoConnectDefault: options.autoConnectDefault,\n defaultDeviceStorage: options.defaultDeviceStorage,\n onError: options.onError,\n requiresAncs: options.requiresAncs,\n scanModel: options.defaultModel ?? DeviceModels.MentraLive,\n scanTimeoutMs: options.scanTimeoutMs,\n })\n const [galleryModeApplying, setGalleryModeApplying] = useState(false)\n const [galleryModeError, setGalleryModeError] = useState<unknown | null>(null)\n\n async function setGalleryModeEnabled(enabled: boolean): Promise<SettingsAckSuccessEvent> {\n setGalleryModeApplying(true)\n setGalleryModeError(null)\n try {\n return await BluetoothSdk.setGalleryModeEnabled(enabled)\n } catch (error) {\n setGalleryModeError(error)\n options.onError?.(error)\n throw error\n } finally {\n setGalleryModeApplying(false)\n }\n }\n\n async function setVoiceActivityDetectionEnabled(enabled: boolean) {\n try {\n await BluetoothSdk.setVoiceActivityDetectionEnabled(enabled)\n } catch (error) {\n options.onError?.(error)\n throw error\n }\n }\n\n const galleryMode: GalleryModeState = {\n applying: galleryModeApplying,\n enabled: connection.bluetoothStatus.galleryModeEnabled !== false,\n error: galleryModeError,\n }\n\n return {\n busy: connection.busy || galleryModeApplying,\n clearDefaultDevice: connection.clearDefaultDevice,\n connect: connection.connect,\n connectDefault: connection.connectDefault,\n defaultDevice: connection.defaultDevice,\n disconnect: connection.disconnect,\n error: galleryModeError ?? connection.error,\n glasses: runtimeGlassesState(connection.glassesStatus),\n refresh: connection.refresh,\n scan: scanController(connection),\n sdk: phoneSdkState(connection.bluetoothStatus, connection.defaultDevice, galleryMode),\n setDefaultDevice: connection.setDefaultDevice,\n setGalleryModeEnabled,\n setVoiceActivityDetectionEnabled,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useMentraBluetooth.js","sourceRoot":"","sources":["../../src/react/useMentraBluetooth.ts"],"names":[],"mappings":"AAA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AAC,aAAa,EAAE,WAAW,CAAC;QACrF,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;QAC7C,qBAAqB;QACrB,gCAAgC;KACjC,CAAA;AACH,CAAC","sourcesContent":["import {useState} from \"react\"\n\nimport BluetoothSdk from \"../index\"\nimport {\n DEFAULT_VOICE_ACTIVITY_DETECTION_ENABLED,\n DeviceModels,\n createDisconnectedGlassesStatus,\n isConnectedGlassesConnectionStatus,\n isReadyGlassesConnectionStatus,\n} from \"../BluetoothSdk.types\"\nimport type {\n ConnectOptions,\n Device,\n DeviceModel,\n GlassesConnectionStatus,\n HotspotStatus,\n PublicBluetoothStatus,\n PublicGlassesStatus,\n MicMode,\n SettingsAckSuccessEvent,\n WifiSearchResult,\n WifiStatus,\n} from \"../BluetoothSdk.types\"\n\nimport {\n useGlassesConnection,\n type DefaultDeviceStorage,\n type GlassesConnectionHookResult,\n} from \"./useGlassesConnection\"\n\nexport type BatteryState = {\n charging: boolean\n level: number | null\n}\n\nexport type ConnectedGlassesInfo = {\n appVersion?: string\n bluetoothName?: string\n buildNumber?: string\n color?: string\n deviceModel?: string\n firmwareVersion?: string\n serialNumber?: string\n style?: string\n}\n\nexport type FirmwareInfo = {\n appVersion?: string\n buildNumber?: string\n source:\n | \"app\"\n | \"bes\"\n | \"device\"\n | \"firmware\"\n | \"left\"\n | \"mtk\"\n | \"right\"\n | \"unknown\"\n version: string | null\n}\n\nexport type SignalState = {\n strengthDbm: number | null\n updatedAt: number | null\n}\n\nexport type GlassesRuntimeState =\n | {\n connected: false\n connection: Exclude<GlassesConnectionStatus, {state: \"connected\"}>\n ready: false\n }\n | {\n battery: BatteryState\n connected: true\n connection: Extract<GlassesConnectionStatus, {state: \"connected\"}>\n device: ConnectedGlassesInfo\n firmware: FirmwareInfo\n hotspot: HotspotStatus\n ready: boolean\n signal: SignalState\n voiceActivityDetectionEnabled: boolean\n wifi: WifiStatus\n }\n\nexport type GalleryModeState = {\n applying: boolean\n enabled: boolean\n error: unknown | null\n}\n\nexport type PhoneSdkRuntimeState = {\n currentMic: MicMode | null\n defaultDevice: Device | null\n galleryMode: GalleryModeState\n lastLog: string[]\n micRanking: MicMode[]\n otherBluetoothConnected: boolean\n searching: boolean\n searchingController: boolean\n systemMicUnavailable: boolean\n wifiScanResults: WifiSearchResult[]\n}\n\nexport type ScanController = {\n active: boolean\n clear: () => void\n devices: Device[]\n diagnostic: GlassesConnectionHookResult[\"scan\"][\"diagnostic\"]\n error: unknown | null\n model: DeviceModel\n selectedDevice: Device | null\n selectDevice: (device: Device | null) => void\n setModel: (model: DeviceModel) => void\n start: (model?: DeviceModel) => Promise<Device[]>\n stop: () => Promise<void>\n}\n\nexport type UseMentraBluetoothOptions = {\n autoConnectDefault?: boolean\n defaultDeviceStorage?: DefaultDeviceStorage\n defaultModel?: DeviceModel\n onError?: (error: unknown) => void\n /**\n * Whether iOS should require ANCS authorization when automatically connecting.\n * Defaults to true. Android accepts this option as a no-op.\n */\n requiresAncs?: boolean\n scanTimeoutMs?: number\n}\n\nexport type MentraBluetoothSession = {\n busy: boolean\n unpair: () => Promise<void>\n connect: (device?: Device, options?: ConnectOptions) => Promise<void>\n connectDefault: (options?: ConnectOptions) => Promise<void>\n defaultDevice: Device | null\n disconnect: () => Promise<void>\n error: unknown | null\n glasses: GlassesRuntimeState\n refresh: () => Promise<void>\n scan: ScanController\n sdk: PhoneSdkRuntimeState\n setDefaultDevice: (device: Device | null) => Promise<void>\n setGalleryModeEnabled: (enabled: boolean) => Promise<SettingsAckSuccessEvent>\n setVoiceActivityDetectionEnabled: (enabled: boolean) => Promise<void>\n}\n\nfunction stringValue(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length > 0 ? value : undefined\n}\n\nfunction numberValue(value: unknown): number | null {\n return typeof value === \"number\" && Number.isFinite(value) ? value : null\n}\n\nfunction firmwareInfo(status: Partial<PublicGlassesStatus>): FirmwareInfo {\n const firmwareSources = [\n [\"firmwareVersion\", \"firmware\"],\n [\"deviceFirmwareVersion\", \"device\"],\n [\"rightFirmwareVersion\", \"right\"],\n [\"leftFirmwareVersion\", \"left\"],\n [\"besFirmwareVersion\", \"bes\"],\n [\"mtkFirmwareVersion\", \"mtk\"],\n [\"appVersion\", \"app\"],\n ] as const\n\n for (const [key, source] of firmwareSources) {\n const value = stringValue((status as Record<string, unknown>)[key])\n if (value) {\n return {\n appVersion: stringValue(status.appVersion),\n buildNumber: stringValue(status.buildNumber),\n source,\n version: value,\n }\n }\n }\n\n return {\n appVersion: stringValue(status.appVersion),\n buildNumber: stringValue(status.buildNumber),\n source: \"unknown\",\n version: null,\n }\n}\n\nfunction batteryState(status: Partial<PublicGlassesStatus>): BatteryState {\n const level = typeof status.batteryLevel === \"number\" && status.batteryLevel >= 0 ? status.batteryLevel : null\n return {\n charging: status.charging ?? false,\n level,\n }\n}\n\nfunction connectedGlassesInfo(status: Partial<PublicGlassesStatus>): ConnectedGlassesInfo {\n return {\n appVersion: stringValue(status.appVersion),\n bluetoothName: stringValue(status.bluetoothName),\n buildNumber: stringValue(status.buildNumber),\n color: stringValue(status.color),\n deviceModel: stringValue(status.deviceModel),\n firmwareVersion: stringValue(status.firmwareVersion),\n serialNumber: stringValue(status.serialNumber),\n style: stringValue(status.style),\n }\n}\n\nfunction runtimeGlassesState(status: Partial<PublicGlassesStatus>): GlassesRuntimeState {\n const connection = status.connection ?? createDisconnectedGlassesStatus().connection ?? {state: \"disconnected\"}\n\n if (!isConnectedGlassesConnectionStatus(connection)) {\n return {\n connected: false,\n connection,\n ready: false,\n }\n }\n\n return {\n battery: batteryState(status),\n connected: true,\n connection,\n device: connectedGlassesInfo(status),\n firmware: firmwareInfo(status),\n hotspot: status.hotspot ?? {state: \"disabled\"},\n ready: isReadyGlassesConnectionStatus(connection),\n signal: {\n strengthDbm: numberValue((status as Record<string, unknown>).signalStrength),\n updatedAt: numberValue((status as Record<string, unknown>).signalStrengthUpdatedAt),\n },\n voiceActivityDetectionEnabled: status.voiceActivityDetectionEnabled ?? DEFAULT_VOICE_ACTIVITY_DETECTION_ENABLED,\n wifi: status.wifi ?? {state: \"disconnected\"},\n }\n}\n\nfunction phoneSdkState(\n status: Partial<PublicBluetoothStatus>,\n defaultDevice: Device | null,\n galleryMode: GalleryModeState,\n): PhoneSdkRuntimeState {\n return {\n currentMic: status.currentMic || null,\n defaultDevice,\n galleryMode,\n lastLog: status.lastLog ?? [],\n micRanking: status.micRanking ?? [],\n otherBluetoothConnected: status.otherBtConnected ?? false,\n searching: status.searching ?? false,\n searchingController: status.searchingController ?? false,\n systemMicUnavailable: status.systemMicUnavailable ?? false,\n wifiScanResults: status.wifiScanResults ?? [],\n }\n}\n\nfunction scanController(connection: GlassesConnectionHookResult): ScanController {\n return {\n active: connection.scan.scanning,\n clear: connection.scan.clearResults,\n devices: connection.scan.devices,\n diagnostic: connection.scan.diagnostic,\n error: connection.scan.error,\n model: connection.scan.model,\n selectedDevice: connection.scan.selectedDevice,\n selectDevice: connection.scan.selectDevice,\n setModel: connection.scan.setModel,\n start: connection.scan.startScan,\n stop: connection.scan.stopScan,\n }\n}\n\nexport function useMentraBluetooth(options: UseMentraBluetoothOptions = {}): MentraBluetoothSession {\n const connection = useGlassesConnection({\n autoConnectDefault: options.autoConnectDefault,\n defaultDeviceStorage: options.defaultDeviceStorage,\n onError: options.onError,\n requiresAncs: options.requiresAncs,\n scanModel: options.defaultModel ?? DeviceModels.MentraLive,\n scanTimeoutMs: options.scanTimeoutMs,\n })\n const [galleryModeApplying, setGalleryModeApplying] = useState(false)\n const [galleryModeError, setGalleryModeError] = useState<unknown | null>(null)\n\n async function setGalleryModeEnabled(enabled: boolean): Promise<SettingsAckSuccessEvent> {\n setGalleryModeApplying(true)\n setGalleryModeError(null)\n try {\n return await BluetoothSdk.setGalleryModeEnabled(enabled)\n } catch (error) {\n setGalleryModeError(error)\n options.onError?.(error)\n throw error\n } finally {\n setGalleryModeApplying(false)\n }\n }\n\n async function setVoiceActivityDetectionEnabled(enabled: boolean) {\n try {\n await BluetoothSdk.setVoiceActivityDetectionEnabled(enabled)\n } catch (error) {\n options.onError?.(error)\n throw error\n }\n }\n\n const galleryMode: GalleryModeState = {\n applying: galleryModeApplying,\n enabled: connection.bluetoothStatus.galleryModeEnabled !== false,\n error: galleryModeError,\n }\n\n return {\n busy: connection.busy || galleryModeApplying,\n unpair: connection.unpair,\n connect: connection.connect,\n connectDefault: connection.connectDefault,\n defaultDevice: connection.defaultDevice,\n disconnect: connection.disconnect,\n error: galleryModeError ?? connection.error,\n glasses: runtimeGlassesState(connection.glassesStatus),\n refresh: connection.refresh,\n scan: scanController(connection),\n sdk: phoneSdkState(connection.bluetoothStatus, connection.defaultDevice, galleryMode),\n setDefaultDevice: connection.setDefaultDevice,\n setGalleryModeEnabled,\n setVoiceActivityDetectionEnabled,\n }\n}\n"]}
|
|
@@ -188,12 +188,6 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
AsyncFunction("clearDefaultDevice") {
|
|
192
|
-
await MainActor.run {
|
|
193
|
-
self.bluetoothSdk().clearDefaultDevice()
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
191
|
AsyncFunction("connectWithOptions") { (device: [String: Any], options: [String: Any]) in
|
|
198
192
|
try await MainActor.run {
|
|
199
193
|
guard let target = Device(dictionary: device) else {
|
|
@@ -237,7 +231,7 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
|
|
|
237
231
|
}
|
|
238
232
|
|
|
239
233
|
AsyncFunction("unpair") {
|
|
240
|
-
try await
|
|
234
|
+
try await self.bluetoothSdk().unpair()
|
|
241
235
|
}
|
|
242
236
|
|
|
243
237
|
AsyncFunction("forgetController") {
|
|
@@ -11,12 +11,12 @@ enum BluetoothSdkDefaults {
|
|
|
11
11
|
static let voiceActivityDetectionEnabled = false
|
|
12
12
|
static let loudnessGateEnabled = true
|
|
13
13
|
|
|
14
|
-
/// Must
|
|
15
|
-
///
|
|
16
|
-
///
|
|
17
|
-
static let autoPowerOffEnabled =
|
|
14
|
+
/// Must match the firmware and Mentra App default (off). We re-push every
|
|
15
|
+
/// Bluetooth setting on connect, so a true default here turns on the
|
|
16
|
+
/// 20-minute unworn power-off on every pair the app touches.
|
|
17
|
+
static let autoPowerOffEnabled = false
|
|
18
18
|
private static let infoSdkVersionKey = "MentraBluetoothSdkVersion"
|
|
19
|
-
private static let swiftPackageSdkVersion = "3.5.0-dev.
|
|
19
|
+
private static let swiftPackageSdkVersion = "3.5.0-dev.1308"
|
|
20
20
|
private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
|
|
21
21
|
|
|
22
22
|
private static func normalizedSdkVersion(_ value: String?) -> String? {
|
package/ios/Source/Bridge.swift
CHANGED
|
@@ -253,6 +253,20 @@ class Bridge {
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
/// Drops glasses from the search results, for example when their pairing window closed.
|
|
257
|
+
static func removeDiscoveredDevice(_ deviceModel: String, _ deviceName: String) {
|
|
258
|
+
Task {
|
|
259
|
+
await MainActor.run {
|
|
260
|
+
let searchResults = DeviceStore.shared.get("bluetooth", "searchResults") as? [[String: Any]] ?? []
|
|
261
|
+
let remaining = searchResults.filter {
|
|
262
|
+
!($0["model"] as? String == deviceModel && $0["name"] as? String == deviceName)
|
|
263
|
+
}
|
|
264
|
+
if remaining.count == searchResults.count { return }
|
|
265
|
+
DeviceStore.shared.set("bluetooth", "searchResults", remaining)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
256
270
|
private static func mergeStableSearchResults(
|
|
257
271
|
_ currentResults: [[String: Any]],
|
|
258
272
|
newResult: [String: Any],
|
|
@@ -3,9 +3,9 @@ import Foundation
|
|
|
3
3
|
/// Generated by release CI. Do not edit in a release checkout.
|
|
4
4
|
enum GeneratedReleaseMetadata {
|
|
5
5
|
static let familyBaseVersion = "3.5.0"
|
|
6
|
-
static let releaseIdentity = "3.5.0-dev.
|
|
7
|
-
static let releaseSetId = "mentra-3.5.0-dev.
|
|
8
|
-
static let sourceCommit = "
|
|
9
|
-
static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.
|
|
10
|
-
static let otaManifestSha256 = "
|
|
6
|
+
static let releaseIdentity = "3.5.0-dev.1308"
|
|
7
|
+
static let releaseSetId = "mentra-3.5.0-dev.1308"
|
|
8
|
+
static let sourceCommit = "6ad1a1d1cf362452478d58eb15db3293cdc760f3"
|
|
9
|
+
static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1308.json"
|
|
10
|
+
static let otaManifestSha256 = "abfc780248a6b1257a92eb978d3631a8c8d64837511c1da9216afdeca35e922b"
|
|
11
11
|
}
|
|
@@ -450,7 +450,7 @@ public final class MentraBluetoothSDK {
|
|
|
450
450
|
finishDefaultDeviceApply(generation: generation)
|
|
451
451
|
}
|
|
452
452
|
|
|
453
|
-
|
|
453
|
+
private func clearDefaultDevice() {
|
|
454
454
|
defaultDeviceApplyGeneration += 1
|
|
455
455
|
let generation = defaultDeviceApplyGeneration
|
|
456
456
|
suppressDefaultDeviceEvents = true
|
|
@@ -617,6 +617,13 @@ public final class MentraBluetoothSDK {
|
|
|
617
617
|
DeviceManager.shared.forget()
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
+
/// Unpair the glasses: disconnect, forget the default device and, on Mentra Live, remove the phone's Bluetooth bond.
|
|
621
|
+
public func unpair() async throws {
|
|
622
|
+
analytics.noteDisconnectRequested(BluetoothSdkAnalyticsTracker.disconnectForget)
|
|
623
|
+
clearBluetoothRestoreIntent()
|
|
624
|
+
try await DeviceManager.shared.unpair()
|
|
625
|
+
}
|
|
626
|
+
|
|
620
627
|
public func displayText(_ text: String, x: Int = 0, y: Int = 0, size: Int = 24) async throws {
|
|
621
628
|
try await displayText(DisplayTextRequest(text: text, x: x, y: y, size: size))
|
|
622
629
|
}
|
|
@@ -807,26 +807,8 @@ extension MentraLive: CBCentralManagerDelegate {
|
|
|
807
807
|
if !isReconnectTarget && advertisesPairingFlag(advertisementData)
|
|
808
808
|
&& !isPairingDiscoverable(advertisementData)
|
|
809
809
|
{
|
|
810
|
-
//
|
|
811
|
-
|
|
812
|
-
pairFlow(
|
|
813
|
-
"discover",
|
|
814
|
-
"name=\(name) id=\(peripheral.identifier.uuidString) saved=\(savedDeviceName ?? "-") pairingMode=false secure=true connect=false"
|
|
815
|
-
)
|
|
816
|
-
discoveredPeripherals[name] = peripheral
|
|
817
|
-
rememberPeripheral(peripheral, name: name)
|
|
818
|
-
if cacheAdvPairing(
|
|
819
|
-
name,
|
|
820
|
-
pairingMode: false,
|
|
821
|
-
pairingCode: nil,
|
|
822
|
-
securePairingCapable: true
|
|
823
|
-
) {
|
|
824
|
-
emitDiscoveredDeviceFromCache(
|
|
825
|
-
name,
|
|
826
|
-
identifier: peripheral.identifier.uuidString,
|
|
827
|
-
rssi: rssi?.intValue
|
|
828
|
-
)
|
|
829
|
-
}
|
|
810
|
+
// Only glasses that can pair now are listed; a closed window drops them.
|
|
811
|
+
unlistNotPairable(name)
|
|
830
812
|
return
|
|
831
813
|
}
|
|
832
814
|
|
|
@@ -852,11 +834,13 @@ extension MentraLive: CBCentralManagerDelegate {
|
|
|
852
834
|
discoveredPeripherals[name] = peripheral
|
|
853
835
|
rememberPeripheral(peripheral, name: name)
|
|
854
836
|
|
|
855
|
-
if !
|
|
837
|
+
if trailer.secureCapable && !trailer.pairingMode {
|
|
838
|
+
unlistNotPairable(name)
|
|
839
|
+
} else if !partialAdvertisement, cacheAdvPairing(
|
|
856
840
|
name,
|
|
857
841
|
// Field firmware has no pairing flag. Treat it as pairable so the
|
|
858
842
|
// new Mentra App can still find old glasses.
|
|
859
|
-
pairingMode:
|
|
843
|
+
pairingMode: true,
|
|
860
844
|
pairingCode: trailer.pairingCode,
|
|
861
845
|
securePairingCapable: trailer.secureCapable
|
|
862
846
|
) {
|
|
@@ -2963,7 +2947,7 @@ class MentraLive: NSObject, SGCManager {
|
|
|
2963
2947
|
|
|
2964
2948
|
// The choose-glasses scan has to hear a later advertisement when the glasses
|
|
2965
2949
|
// enter pairing mode. iOS reports each peripheral once unless duplicates are
|
|
2966
|
-
// allowed, so the
|
|
2950
|
+
// allowed, so the glasses would stay off the list. Reconnect scans stay
|
|
2967
2951
|
// duplicate-free so a saved glasses advertisement cannot start another connect.
|
|
2968
2952
|
let scanOptions: [String: Any] = [
|
|
2969
2953
|
CBCentralManagerScanOptionAllowDuplicatesKey: manualDiscoveryActive,
|
|
@@ -7223,6 +7207,14 @@ class MentraLive: NSObject, SGCManager {
|
|
|
7223
7207
|
return true
|
|
7224
7208
|
}
|
|
7225
7209
|
|
|
7210
|
+
/// Drops glasses that are not in pairing mode from the search results, once per change, so the
|
|
7211
|
+
/// next pairable advertisement lists them again.
|
|
7212
|
+
private func unlistNotPairable(_ name: String) {
|
|
7213
|
+
if cacheAdvPairing(name, pairingMode: false, pairingCode: nil, securePairingCapable: true) {
|
|
7214
|
+
Bridge.removeDiscoveredDevice("Mentra Live", name)
|
|
7215
|
+
}
|
|
7216
|
+
}
|
|
7217
|
+
|
|
7226
7218
|
private func emitDiscoveredDeviceFromCache(
|
|
7227
7219
|
_ name: String,
|
|
7228
7220
|
identifier: String = "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mentra/bluetooth-sdk",
|
|
3
|
-
"version": "3.5.0-dev.
|
|
3
|
+
"version": "3.5.0-dev.1308",
|
|
4
4
|
"description": "SDK for communicating with smart glasses",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"registry": "https://registry.npmjs.org/"
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
|
-
"@mentra/cloud-protocol": "3.5.0-dev.
|
|
118
|
+
"@mentra/cloud-protocol": "3.5.0-dev.1308"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@types/node": "^25.9.3",
|
|
@@ -1554,7 +1554,6 @@ export interface BluetoothSdkPublicModule {
|
|
|
1554
1554
|
|
|
1555
1555
|
getDefaultDevice(): Promise<Device | null>
|
|
1556
1556
|
setDefaultDevice(device: Device | null): Promise<void>
|
|
1557
|
-
clearDefaultDevice(): Promise<void>
|
|
1558
1557
|
|
|
1559
1558
|
startScan(model: DeviceModel): Promise<void>
|
|
1560
1559
|
stopScan(): Promise<void>
|
|
@@ -1565,6 +1564,9 @@ export interface BluetoothSdkPublicModule {
|
|
|
1565
1564
|
cancelConnectionAttempt(): Promise<void>
|
|
1566
1565
|
disconnect(): Promise<void>
|
|
1567
1566
|
forget(): Promise<void>
|
|
1567
|
+
/** Unpair the glasses: disconnect, forget them as the default device and, on Mentra Live, remove the phone's Bluetooth
|
|
1568
|
+
* bond, so the next pairing starts from pairing mode. */
|
|
1569
|
+
unpair(): Promise<void>
|
|
1568
1570
|
|
|
1569
1571
|
displayText(text: string, x?: number, y?: number, size?: number): Promise<void>
|
|
1570
1572
|
clearDisplay(): Promise<void>
|
|
@@ -96,7 +96,6 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
96
96
|
connectDefault(options?: ConnectOptions): Promise<void>
|
|
97
97
|
connectDefaultWithOptions(options: Required<ConnectOptions>): Promise<void>
|
|
98
98
|
setDefaultDevice(device: Device | null): Promise<void>
|
|
99
|
-
clearDefaultDevice(): Promise<void>
|
|
100
99
|
/** Android only: iOS cannot read its Bluetooth bonds. */
|
|
101
100
|
getBondedGlasses?: () => Promise<{name: string; address: string} | null>
|
|
102
101
|
getScanDiagnostic?: (model: DeviceModel) => Promise<ScanDiagnostic | null>
|
|
@@ -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.5.0",
|
|
15
|
-
"releaseIdentity": "3.5.0-dev.
|
|
16
|
-
"releaseSetId": "mentra-3.5.0-dev.
|
|
17
|
-
"sourceCommit": "
|
|
18
|
-
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.
|
|
19
|
-
"otaManifestSha256": "
|
|
15
|
+
"releaseIdentity": "3.5.0-dev.1308",
|
|
16
|
+
"releaseSetId": "mentra-3.5.0-dev.1308",
|
|
17
|
+
"sourceCommit": "6ad1a1d1cf362452478d58eb15db3293cdc760f3",
|
|
18
|
+
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1308.json",
|
|
19
|
+
"otaManifestSha256": "abfc780248a6b1257a92eb978d3631a8c8d64837511c1da9216afdeca35e922b"
|
|
20
20
|
})
|
package/src/index.ts
CHANGED
|
@@ -108,7 +108,6 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
|
108
108
|
PrivateBluetoothSdkModule.onBluetoothStatus(listener),
|
|
109
109
|
getDefaultDevice: bindPublicMethod("getDefaultDevice"),
|
|
110
110
|
setDefaultDevice: bindPublicMethod("setDefaultDevice"),
|
|
111
|
-
clearDefaultDevice: bindPublicMethod("clearDefaultDevice"),
|
|
112
111
|
startScan: bindPublicMethod("startScan"),
|
|
113
112
|
stopScan: bindPublicMethod("stopScan"),
|
|
114
113
|
scan: bindPublicMethod("scan") as BluetoothSdkPublicModule["scan"],
|
|
@@ -117,6 +116,7 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
|
117
116
|
cancelConnectionAttempt: bindPublicMethod("cancelConnectionAttempt"),
|
|
118
117
|
disconnect: bindPublicMethod("disconnect"),
|
|
119
118
|
forget: bindPublicMethod("forget"),
|
|
119
|
+
unpair: bindPublicMethod("unpair"),
|
|
120
120
|
displayText: bindPublicMethod("displayText"),
|
|
121
121
|
clearDisplay: bindPublicMethod("clearDisplay"),
|
|
122
122
|
setDashboardContent: bindPublicMethod("setDashboardContent"),
|
|
@@ -34,7 +34,7 @@ export type UseGlassesConnectionOptions = {
|
|
|
34
34
|
export type GlassesConnectionHookResult = BluetoothStatusHookResult & {
|
|
35
35
|
action: GlassesConnectionAction
|
|
36
36
|
busy: boolean
|
|
37
|
-
|
|
37
|
+
unpair: () => Promise<void>
|
|
38
38
|
connect: (device?: Device, options?: ConnectOptions) => Promise<void>
|
|
39
39
|
connectDefault: (options?: ConnectOptions) => Promise<void>
|
|
40
40
|
defaultDevice: Device | null
|
|
@@ -152,9 +152,9 @@ export function useGlassesConnection(
|
|
|
152
152
|
})
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
async function
|
|
155
|
+
async function unpair() {
|
|
156
156
|
await runConnectionAction("forgetting", async () => {
|
|
157
|
-
await BluetoothSdk.
|
|
157
|
+
await BluetoothSdk.unpair()
|
|
158
158
|
await defaultDeviceStorageRef.current?.save(null)
|
|
159
159
|
setDefaultDeviceState(null)
|
|
160
160
|
scan.selectDevice(null)
|
|
@@ -201,7 +201,7 @@ export function useGlassesConnection(
|
|
|
201
201
|
...status,
|
|
202
202
|
action: scan.scanning ? "scanning" : action,
|
|
203
203
|
busy,
|
|
204
|
-
|
|
204
|
+
unpair,
|
|
205
205
|
connect,
|
|
206
206
|
connectDefault,
|
|
207
207
|
defaultDevice,
|
|
@@ -131,7 +131,7 @@ export type UseMentraBluetoothOptions = {
|
|
|
131
131
|
|
|
132
132
|
export type MentraBluetoothSession = {
|
|
133
133
|
busy: boolean
|
|
134
|
-
|
|
134
|
+
unpair: () => Promise<void>
|
|
135
135
|
connect: (device?: Device, options?: ConnectOptions) => Promise<void>
|
|
136
136
|
connectDefault: (options?: ConnectOptions) => Promise<void>
|
|
137
137
|
defaultDevice: Device | null
|
|
@@ -312,7 +312,7 @@ export function useMentraBluetooth(options: UseMentraBluetoothOptions = {}): Men
|
|
|
312
312
|
|
|
313
313
|
return {
|
|
314
314
|
busy: connection.busy || galleryModeApplying,
|
|
315
|
-
|
|
315
|
+
unpair: connection.unpair,
|
|
316
316
|
connect: connection.connect,
|
|
317
317
|
connectDefault: connection.connectDefault,
|
|
318
318
|
defaultDevice: connection.defaultDevice,
|