@mentra/bluetooth-sdk 3.3.0-dev.943 → 3.4.0-dev.1003
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 +61 -0
- package/README.md +78 -0
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +274 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +13 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +8 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +79 -8
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +21 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +1 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +6 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +22 -4
- package/android/src/main/java/com/mentra/bluetoothsdk/TouchGesture.kt +19 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/connection/ConnectionModels.kt +5 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/GlassesAudioSetupPolicy.kt +64 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +832 -134
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +227 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisement.kt +19 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingReadinessPolicy.kt +94 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateMachine.kt +411 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateStore.kt +124 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +337 -39
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +8 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasEncoder.kt +8 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +1 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/status/DeviceStatus.kt +50 -0
- package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +16 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/DeviceManagerOwnerLossTest.kt +146 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/GlassesStatusAudioSetupTest.kt +51 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/GlassesStatusClassicAudioTest.kt +2 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/TouchGestureCommandTest.kt +112 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/WifiAdbPeerIntentTest.kt +19 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/GlassesAudioSetupPolicyTest.kt +65 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveAudioSetupReadinessTest.kt +231 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicyTest.kt +368 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisementParserTest.kt +20 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingReadinessPolicyTest.kt +136 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateMachineTest.kt +346 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +564 -1
- package/build/BluetoothSdk.types.d.ts +110 -2
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +6 -2
- 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/changelogCatalog.d.ts +3 -0
- package/build/generated/changelogCatalog.d.ts.map +1 -1
- package/build/generated/changelogCatalog.js +4 -0
- package/build/generated/changelogCatalog.js.map +1 -1
- package/build/generated/releaseMetadata.js +6 -6
- 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 +4 -0
- package/build/index.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +24 -4
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/Bridge.swift +11 -3
- package/ios/Source/DeviceManager.swift +103 -7
- package/ios/Source/DeviceStore.swift +27 -0
- package/ios/Source/GeneratedChangelogCatalog.swift +1 -0
- package/ios/Source/GeneratedReleaseMetadata.swift +6 -6
- package/ios/Source/MentraBluetoothSDK.swift +41 -7
- package/ios/Source/TouchGesture.swift +13 -0
- package/ios/Source/errors/BluetoothSdkError.swift +5 -1
- package/ios/Source/events/BluetoothEvents.swift +4 -0
- package/ios/Source/internal/BleTraceLogger.swift +9 -6
- package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +181 -0
- package/ios/Source/sgcs/MentraLive.swift +1196 -173
- package/ios/Source/sgcs/MentraLivePairingAdvertisement.swift +260 -1
- package/ios/Source/sgcs/MentraLivePairingStateMachine.swift +385 -0
- package/ios/Source/sgcs/MentraLivePairingStateStore.swift +121 -0
- package/ios/Source/sgcs/Nimo.swift +278 -38
- package/ios/Source/sgcs/NimoCanvasCoordinator.swift +77 -18
- package/ios/Source/sgcs/NimoCanvasSession.swift +1 -0
- package/ios/Source/sgcs/NimoMacResourceTransport.swift +217 -0
- package/ios/Source/sgcs/NimoResourceFixture.swift +384 -0
- package/ios/Source/sgcs/NimoResourceSession.swift +406 -0
- package/ios/Source/sgcs/SGCManager.swift +7 -0
- package/ios/Source/sgcs/Simulated.swift +2 -0
- package/ios/Source/status/DeviceStatus.swift +35 -0
- package/ios/Source/types/DeviceModels.swift +8 -1
- package/ios/Source/utils/AudioSessionMonitor.swift +158 -5
- package/ios/Tests/BluetoothAudioRouteTests.swift +82 -0
- package/ios/Tests/DeviceManagerReconnectTests.swift +75 -2
- package/ios/Tests/GlassesAudioSetupPolicyTests.swift +191 -0
- package/ios/Tests/MentraLiveAudioSetupTests.swift +215 -0
- package/ios/Tests/MentraLiveConnectionOptionsTests.swift +55 -0
- package/ios/Tests/MentraLivePairingAdvertisementTests.swift +327 -0
- package/ios/Tests/MentraLivePairingStateMachineTests.swift +402 -0
- package/ios/Tests/MentraLiveSessionReadinessTests.swift +328 -26
- package/ios/Tests/NimoCanvasTransportTests.swift +147 -0
- package/ios/Tests/NimoResourceSessionTests.swift +476 -0
- package/ios/Tests/TouchGestureCommandTests.swift +87 -0
- package/ios/Tests/WifiAdbDispatchTests.swift +118 -0
- package/package.json +3 -2
- package/src/BluetoothSdk.types.ts +115 -1
- package/src/_private/BluetoothSdkModule.ts +7 -1
- package/src/generated/changelogCatalog.ts +4 -0
- package/src/generated/releaseMetadata.ts +6 -6
- package/src/index.ts +12 -0
|
@@ -85,6 +85,8 @@ struct ViewState {
|
|
|
85
85
|
// Check if device is paired (don't activate to preserve A2DP music playback)
|
|
86
86
|
let isPaired = AudioSessionMonitor.isDevicePaired(devicePattern: audioDevicePattern)
|
|
87
87
|
|
|
88
|
+
publishClassicAudioProfiles(devicePattern: audioDevicePattern)
|
|
89
|
+
|
|
88
90
|
if isPaired {
|
|
89
91
|
// Device is paired! Don't activate it - let PhoneMic.swift activate when recording starts
|
|
90
92
|
Bridge.log("Audio: Mentra Live is paired (preserving A2DP for music)")
|
|
@@ -98,6 +100,7 @@ struct ViewState {
|
|
|
98
100
|
AudioSessionMonitor.startMonitoring(devicePattern: audioDevicePattern) {
|
|
99
101
|
[weak self] (connected: Bool, _: String?) in
|
|
100
102
|
guard let self = self else { return }
|
|
103
|
+
self.publishClassicAudioProfiles(devicePattern: audioDevicePattern)
|
|
101
104
|
|
|
102
105
|
if connected {
|
|
103
106
|
Bridge.log("Audio: Device paired and connected")
|
|
@@ -133,6 +136,22 @@ struct ViewState {
|
|
|
133
136
|
set { DeviceStore.shared.apply("bluetooth", "default_wearable", newValue) }
|
|
134
137
|
}
|
|
135
138
|
|
|
139
|
+
/// Clears the retired pre-v4 owner-lost setting. The Mentra Live pairing state is native
|
|
140
|
+
/// (`MentraLivePairingStateStore`) and never rides the settings replay.
|
|
141
|
+
private func clearOwnerLost() {
|
|
142
|
+
guard DeviceStore.shared.get("bluetooth", "mentra_live_owner_lost") as? Bool == true else { return }
|
|
143
|
+
DeviceStore.shared.apply("bluetooth", "mentra_live_owner_lost", false)
|
|
144
|
+
Bridge.saveSetting("mentra_live_owner_lost", false)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/// The saved glasses' firmware is no longer known once they are forgotten. The next glasses
|
|
148
|
+
/// report it again with their first `pairing_info`.
|
|
149
|
+
private func clearSecureFirmware() {
|
|
150
|
+
guard DeviceStore.shared.get("bluetooth", "mentra_live_secure_firmware") as? Bool == true else { return }
|
|
151
|
+
DeviceStore.shared.apply("bluetooth", "mentra_live_secure_firmware", false)
|
|
152
|
+
Bridge.saveSetting("mentra_live_secure_firmware", false)
|
|
153
|
+
}
|
|
154
|
+
|
|
136
155
|
private var pendingWearable: String {
|
|
137
156
|
get { DeviceStore.shared.get("bluetooth", "pending_wearable") as? String ?? "" }
|
|
138
157
|
set { DeviceStore.shared.apply("bluetooth", "pending_wearable", newValue) }
|
|
@@ -253,6 +272,26 @@ struct ViewState {
|
|
|
253
272
|
set { DeviceStore.shared.apply("glasses", "bluetoothClassicConnected", newValue) }
|
|
254
273
|
}
|
|
255
274
|
|
|
275
|
+
/// An HFP input is available or a matching Bluetooth output is active.
|
|
276
|
+
private var glassesBluetoothClassicProfilesConnected: Bool {
|
|
277
|
+
get { DeviceStore.shared.get("glasses", "bluetoothClassicProfilesConnected") as? Bool ?? false }
|
|
278
|
+
set { DeviceStore.shared.apply("glasses", "bluetoothClassicProfilesConnected", newValue) }
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/// A matching Bluetooth output is the active audio route.
|
|
282
|
+
private var glassesBluetoothAudioRouted: Bool {
|
|
283
|
+
get { DeviceStore.shared.get("glasses", "bluetoothAudioRouted") as? Bool ?? false }
|
|
284
|
+
set { DeviceStore.shared.apply("glasses", "bluetoothAudioRouted", newValue) }
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
#if !os(macOS)
|
|
288
|
+
private func publishClassicAudioProfiles(devicePattern: String) {
|
|
289
|
+
let profiles = AudioSessionMonitor.observeProfiles(devicePattern: devicePattern)
|
|
290
|
+
glassesBluetoothClassicProfilesConnected = profiles.profilesConnected
|
|
291
|
+
glassesBluetoothAudioRouted = profiles.audioRouted
|
|
292
|
+
}
|
|
293
|
+
#endif
|
|
294
|
+
|
|
256
295
|
private var micRanking: [String] {
|
|
257
296
|
get {
|
|
258
297
|
DeviceStore.shared.get("bluetooth", "micRanking") as? [String] ?? MicMap.map["auto"]!
|
|
@@ -708,6 +747,7 @@ struct ViewState {
|
|
|
708
747
|
// MARK: - Auxiliary Commands
|
|
709
748
|
|
|
710
749
|
func initSGC(_ wearable: String) {
|
|
750
|
+
guard NimoResourceFixture.shared.allowsManager(wearable) else { return }
|
|
711
751
|
Bridge.log("Initializing manager for wearable: \(wearable)")
|
|
712
752
|
if sgc != nil && sgc?.type != wearable {
|
|
713
753
|
Bridge.log("MAN: Manager already initialized, cleaning up previous sgc")
|
|
@@ -942,17 +982,23 @@ struct ViewState {
|
|
|
942
982
|
|
|
943
983
|
if audioDevicePattern.isEmpty || audioDevicePattern == DeviceTypes.SIMULATED {
|
|
944
984
|
glassesBluetoothClassicConnected = false
|
|
985
|
+
glassesBluetoothClassicProfilesConnected = false
|
|
986
|
+
glassesBluetoothAudioRouted = false
|
|
945
987
|
Bridge.log("MAN: Audio device pattern is empty or simulated, returning")
|
|
946
988
|
return
|
|
947
989
|
}
|
|
948
990
|
|
|
949
991
|
#if os(macOS)
|
|
950
992
|
glassesBluetoothClassicConnected = AudioSessionMonitor.isAudioDeviceConnected(devicePattern: audioDevicePattern)
|
|
993
|
+
// macOS only sees active audio devices, so every fact collapses to the same value.
|
|
994
|
+
glassesBluetoothClassicProfilesConnected = glassesBluetoothClassicConnected
|
|
995
|
+
glassesBluetoothAudioRouted = glassesBluetoothClassicConnected
|
|
951
996
|
otherBtConnected = AudioSessionMonitor.isOtherAudioDeviceConnected(devicePattern: audioDevicePattern)
|
|
952
997
|
#else
|
|
953
998
|
// A connected HFP input remains eligible even while another output is
|
|
954
999
|
// selected. Inspect available inputs as well as the active A2DP route.
|
|
955
1000
|
glassesBluetoothClassicConnected = AudioSessionMonitor.isDevicePaired(devicePattern: audioDevicePattern)
|
|
1001
|
+
publishClassicAudioProfiles(devicePattern: audioDevicePattern)
|
|
956
1002
|
otherBtConnected = AudioSessionMonitor.isOtherAudioDeviceConnected(devicePattern: audioDevicePattern)
|
|
957
1003
|
#endif
|
|
958
1004
|
}
|
|
@@ -1540,6 +1586,15 @@ struct ViewState {
|
|
|
1540
1586
|
sgc?.sendHotspotState(enabled)
|
|
1541
1587
|
}
|
|
1542
1588
|
|
|
1589
|
+
func setWifiAdbState(_ enabled: Bool, expectedBluetoothMac: String?) throws {
|
|
1590
|
+
guard let expectedBluetoothMac else { setWifiAdbState(enabled); return }
|
|
1591
|
+
guard let live = sgc as? MentraLive else {
|
|
1592
|
+
throw BluetoothSdkError(code: "glasses_not_connected", message: "Mentra Live glasses are not connected.")
|
|
1593
|
+
}
|
|
1594
|
+
// Capture one driver; its own session identity guards the actual queue insertion.
|
|
1595
|
+
try live.sendWifiAdbState(enabled, expectedBluetoothMac: expectedBluetoothMac)
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1543
1598
|
func setWifiAdbState(_ enabled: Bool) {
|
|
1544
1599
|
Bridge.log("MAN: 🔧 Setting glasses Wi-Fi ADB state: \(enabled)")
|
|
1545
1600
|
sgc?.sendWifiAdbState(enabled)
|
|
@@ -1597,6 +1652,10 @@ struct ViewState {
|
|
|
1597
1652
|
try liveSgc().sendGalleryServerEnabled(requestId: requestId, enabled: enabled)
|
|
1598
1653
|
}
|
|
1599
1654
|
|
|
1655
|
+
func sendTouchGestureDefaultBehaviorEnabled(requestId: String, gesture: TouchGesture, enabled: Bool) throws {
|
|
1656
|
+
try liveSgc().sendTouchGestureDefaultBehaviorEnabled(requestId: requestId, gesture: gesture, enabled: enabled)
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1600
1659
|
func sendGalleryMode(requestId: String, enabled: Bool) throws {
|
|
1601
1660
|
try liveSgc().sendGalleryMode(requestId: requestId, active: enabled)
|
|
1602
1661
|
}
|
|
@@ -1845,6 +1904,7 @@ struct ViewState {
|
|
|
1845
1904
|
}
|
|
1846
1905
|
|
|
1847
1906
|
func connectDefault(requiresAncs: Bool = true) {
|
|
1907
|
+
guard NimoResourceFixture.shared.allowsManager(defaultWearable, name: deviceName) else { return }
|
|
1848
1908
|
if defaultWearable.isEmpty {
|
|
1849
1909
|
Bridge.log("MAN: No default wearable, returning")
|
|
1850
1910
|
return
|
|
@@ -1861,9 +1921,18 @@ struct ViewState {
|
|
|
1861
1921
|
}
|
|
1862
1922
|
initSGC(defaultWearable)
|
|
1863
1923
|
(sgc as? MentraLive)?.setRequiresAncs(requiresAncs)
|
|
1864
|
-
if let live = sgc as? MentraLive
|
|
1865
|
-
|
|
1866
|
-
|
|
1924
|
+
if let live = sgc as? MentraLive {
|
|
1925
|
+
let pairingState = MentraLivePairingStateStore.shared
|
|
1926
|
+
if pairingState.isRejected {
|
|
1927
|
+
Bridge.log("MAN: connectDefault skipped — Mentra Live pairing_rejected (Pair Again or forget)")
|
|
1928
|
+
return
|
|
1929
|
+
}
|
|
1930
|
+
if pairingState.isPaused {
|
|
1931
|
+
// The manager watches the advertisement and resumes on its own.
|
|
1932
|
+
Bridge.log("MAN: connectDefault deferred — Mentra Live pairing_mode")
|
|
1933
|
+
live.connectById(reconnectTarget)
|
|
1934
|
+
return
|
|
1935
|
+
}
|
|
1867
1936
|
}
|
|
1868
1937
|
searching = true
|
|
1869
1938
|
sgc?.connectById(reconnectTarget)
|
|
@@ -1885,24 +1954,26 @@ struct ViewState {
|
|
|
1885
1954
|
}
|
|
1886
1955
|
|
|
1887
1956
|
func connectByName(_ dName: String, requiresAncs: Bool = true) {
|
|
1888
|
-
Bridge.log("MAN: Connecting to wearable: \(dName)")
|
|
1889
1957
|
var name = dName
|
|
1890
1958
|
|
|
1891
1959
|
// use stored device name if available:
|
|
1892
1960
|
if dName.isEmpty && !deviceName.isEmpty {
|
|
1893
1961
|
name = deviceName
|
|
1894
1962
|
}
|
|
1963
|
+
Bridge.log("PAIRFLOW: connect_by_name requested=\(dName) resolved=\(name)")
|
|
1895
1964
|
|
|
1896
1965
|
if pendingWearable.isEmpty, defaultWearable.isEmpty {
|
|
1897
|
-
Bridge.log("
|
|
1966
|
+
Bridge.log("PAIRFLOW: connect_by_name abort reason=no_wearable")
|
|
1898
1967
|
return
|
|
1899
1968
|
}
|
|
1900
1969
|
|
|
1970
|
+
guard NimoResourceFixture.shared.allowsManager(pendingWearable.isEmpty ? defaultWearable : pendingWearable, name: name) else { return }
|
|
1901
1971
|
if pendingWearable.isEmpty, !defaultWearable.isEmpty {
|
|
1902
|
-
Bridge.log("
|
|
1972
|
+
Bridge.log("PAIRFLOW: connect_by_name pending=\(defaultWearable)")
|
|
1903
1973
|
pendingWearable = defaultWearable
|
|
1904
1974
|
}
|
|
1905
1975
|
|
|
1976
|
+
guard NimoResourceFixture.shared.allowsManager(pendingWearable, name: name) else { return }
|
|
1906
1977
|
// if the pending wearable is a controller, don't disconnect, use the controller manager to connect
|
|
1907
1978
|
if ControllerTypes.ALL.contains(pendingWearable) {
|
|
1908
1979
|
controller?.disconnect()
|
|
@@ -1910,9 +1981,28 @@ struct ViewState {
|
|
|
1910
1981
|
return
|
|
1911
1982
|
}
|
|
1912
1983
|
|
|
1984
|
+
// Only an existing Mentra Live manager is reused. Calling initSGC first would swap out a
|
|
1985
|
+
// manager of another model here, before the queued handoff below disposes of it.
|
|
1986
|
+
if pendingWearable.contains(DeviceTypes.LIVE), let live = sgc as? MentraLive, !live.isManagerKilled {
|
|
1987
|
+
// The pairing scan already found this peripheral. Destroying the
|
|
1988
|
+
// manager here drops it, and the glasses are no longer discoverable
|
|
1989
|
+
// after the BLE bond, so the replacement scan never sees them.
|
|
1990
|
+
Bridge.log("PAIRFLOW: connect_by_name decision=reuse_manager name=\(name)")
|
|
1991
|
+
searching = true
|
|
1992
|
+
pendingDeviceName = name
|
|
1993
|
+
live.setRequiresAncs(requiresAncs)
|
|
1994
|
+
live.connectById(name)
|
|
1995
|
+
return
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
Bridge.log("PAIRFLOW: connect_by_name decision=new_manager name=\(name)")
|
|
1999
|
+
let managerEntry = NimoResourceFixture.shared.beginManagerEntry(pendingWearable)
|
|
1913
2000
|
Task {
|
|
1914
|
-
|
|
2001
|
+
defer { NimoResourceFixture.shared.endManagerEntry(managerEntry) }
|
|
2002
|
+
guard NimoResourceFixture.shared.allowsManager(self.pendingWearable, name: name) else { return }
|
|
2003
|
+
if !NimoResourceFixture.shared.preserveScan(name) { disconnect(clearPendingConnection: false) }
|
|
1915
2004
|
try? await Task.sleep(nanoseconds: 100 * 1_000_000) // 100ms
|
|
2005
|
+
guard NimoResourceFixture.shared.allowsManager(self.pendingWearable, name: name) else { return }
|
|
1916
2006
|
self.searching = true
|
|
1917
2007
|
self.pendingDeviceName = name
|
|
1918
2008
|
|
|
@@ -1923,6 +2013,7 @@ struct ViewState {
|
|
|
1923
2013
|
}
|
|
1924
2014
|
|
|
1925
2015
|
func connectDevice(_ deviceModel: String, _ deviceName: String) {
|
|
2016
|
+
guard NimoResourceFixture.shared.allowsManager(deviceModel, name: deviceName) else { return }
|
|
1926
2017
|
Bridge.log("MAN: Connecting to device: \(deviceModel) \(deviceName)")
|
|
1927
2018
|
if DeviceTypes.ALL.contains(deviceModel) {
|
|
1928
2019
|
pendingWearable = deviceModel
|
|
@@ -1950,6 +2041,8 @@ struct ViewState {
|
|
|
1950
2041
|
#if os(macOS)
|
|
1951
2042
|
audioRouteObserver = nil
|
|
1952
2043
|
glassesBluetoothClassicConnected = false
|
|
2044
|
+
glassesBluetoothClassicProfilesConnected = false
|
|
2045
|
+
glassesBluetoothAudioRouted = false
|
|
1953
2046
|
otherBtConnected = false
|
|
1954
2047
|
#endif
|
|
1955
2048
|
sgc?.clearDisplay() // clear the screen
|
|
@@ -2026,6 +2119,9 @@ struct ViewState {
|
|
|
2026
2119
|
|
|
2027
2120
|
func forget() {
|
|
2028
2121
|
Bridge.log("MAN: Forgetting smart glasses")
|
|
2122
|
+
MentraLivePairingStateStore.shared.update("forget") { $0.onForget() }
|
|
2123
|
+
clearOwnerLost()
|
|
2124
|
+
clearSecureFirmware()
|
|
2029
2125
|
// Call forget first to stop timers/handlers/reconnect logic
|
|
2030
2126
|
sgc?.forget()
|
|
2031
2127
|
disconnect()
|
|
@@ -31,6 +31,8 @@ class DeviceStore {
|
|
|
31
31
|
store.set("glasses", "micEnabled", false)
|
|
32
32
|
store.set("glasses", "voiceActivityDetectionEnabled", BluetoothSdkDefaults.voiceActivityDetectionEnabled)
|
|
33
33
|
store.set("glasses", "bluetoothClassicConnected", false)
|
|
34
|
+
store.set("glasses", "bluetoothClassicProfilesConnected", false)
|
|
35
|
+
store.set("glasses", "bluetoothAudioRouted", false)
|
|
34
36
|
store.set("glasses", "caseRemoved", true)
|
|
35
37
|
store.set("glasses", "caseOpen", true)
|
|
36
38
|
store.set("glasses", "caseCharging", false)
|
|
@@ -59,6 +61,7 @@ class DeviceStore {
|
|
|
59
61
|
store.set("glasses", "signalStrength", -1)
|
|
60
62
|
store.set("glasses", "signalStrengthUpdatedAt", 0)
|
|
61
63
|
store.set("glasses", "ringSignalStrength", -1)
|
|
64
|
+
store.set("glasses", "audioSetup", GlassesAudioSetupState.idle.toMap())
|
|
62
65
|
|
|
63
66
|
// CORE STATE:
|
|
64
67
|
store.set("bluetooth", "systemMicUnavailable", false)
|
|
@@ -144,10 +147,34 @@ class DeviceStore {
|
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
|
|
150
|
+
/// Publishes `GlassesStatus.audioSetup` and `audio_setup_changed` when the state changed.
|
|
151
|
+
@discardableResult
|
|
152
|
+
func publishAudioSetup(_ state: GlassesAudioSetupState) -> Bool {
|
|
153
|
+
guard GlassesAudioSetupState(map: store.get("glasses", "audioSetup")) != state else { return false }
|
|
154
|
+
let map = state.toMap()
|
|
155
|
+
store.set("glasses", "audioSetup", map)
|
|
156
|
+
Bridge.sendTypedMessage("audio_setup_changed", body: ["state": map])
|
|
157
|
+
return true
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/// Glasses without a driver-specific audio rule report `not_applicable` while ready and
|
|
161
|
+
/// `idle` otherwise. Runs before readiness is stored, so the update that marks the glasses
|
|
162
|
+
/// ready already carries the matching `audioSetup`.
|
|
163
|
+
private func publishModelDefaultAudioSetup(_ category: String, _ key: String, _ value: Any) {
|
|
164
|
+
guard ObservableStore.normalizeCategory(category) == "glasses", key == "fullyBooted",
|
|
165
|
+
let ready = value as? Bool,
|
|
166
|
+
DeviceManager.shared.sgc?.publishesAudioSetup != true
|
|
167
|
+
else { return }
|
|
168
|
+
publishAudioSetup(.modelDefault(ready: ready))
|
|
169
|
+
}
|
|
170
|
+
|
|
147
171
|
/// Apply changes with side effects
|
|
148
172
|
func apply(_ category: String, _ key: String, _ value: Any) {
|
|
149
173
|
let oldValue = store.get(category, key)
|
|
150
174
|
let storeWouldSkipSet = store.wouldSkipSet(category, key, value)
|
|
175
|
+
if !storeWouldSkipSet {
|
|
176
|
+
publishModelDefaultAudioSetup(category, key, value)
|
|
177
|
+
}
|
|
151
178
|
store.set(category, key, value)
|
|
152
179
|
if storeWouldSkipSet {
|
|
153
180
|
return
|
|
@@ -2,6 +2,7 @@ import Foundation
|
|
|
2
2
|
|
|
3
3
|
/// Generated from /changelogs. Do not edit directly.
|
|
4
4
|
let generatedReleaseChangelogs: [ReleaseChangelog] = [
|
|
5
|
+
ReleaseChangelog(version: "3.4.0", markdown: "This release is under active development. User-facing changes will be documented as they land."),
|
|
5
6
|
ReleaseChangelog(version: "3.3.0", markdown: "This release is under active development. User-facing changes will be documented as they land."),
|
|
6
7
|
ReleaseChangelog(version: "3.2.1", markdown: "- **Livestreamer:** \"Stream Here\" now works without a Wi-Fi network. Improved stream startup and connection reliability.\n- **Photos and gallery:** More reliable photo capture and gallery syncing.\n- **Mentra AI:** Reliability improvements and bug fixes.\n- **Miniapps:** Smoother transitions, with back buttons and gestures that take you to the previous screen inside a miniapp.\n- **Pairing and connections:** Improved G1 pairing and G2 background reconnection.\n- **Glasses updates:** Fixed repeated update checks and improved recovery after interrupted updates.\n- **Mentra Maps:** Bug fixes.\n- **NIMO:** Improved text and map layouts.\n- **Self-hosting:** Connect the Mentra App to your own self-hosted Mentra backend."),
|
|
7
8
|
ReleaseChangelog(version: "3.2.0", markdown: "- Improved glasses connectivity and Wi-Fi setup.\n\n- Breaking Bluetooth SDK change: `forgetWifiNetwork(ssid)` now returns `WifiForgetResult` instead of `WifiStatusChangeEvent`. Migrate status-only consumers to the semantic `outcome`; the requested network remains `ssid`, while optional post-command connectivity is reported by `connected`, `currentSsid`, and `localIp`."),
|
|
@@ -2,10 +2,10 @@ import Foundation
|
|
|
2
2
|
|
|
3
3
|
/// Generated by release CI. Do not edit in a release checkout.
|
|
4
4
|
enum GeneratedReleaseMetadata {
|
|
5
|
-
static let familyBaseVersion = "3.
|
|
6
|
-
static let releaseIdentity = "3.
|
|
7
|
-
static let releaseSetId = "mentra-3.
|
|
8
|
-
static let sourceCommit = "
|
|
9
|
-
static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.
|
|
10
|
-
static let otaManifestSha256 = "
|
|
5
|
+
static let familyBaseVersion = "3.4.0"
|
|
6
|
+
static let releaseIdentity = "3.4.0-dev.1003"
|
|
7
|
+
static let releaseSetId = "mentra-3.4.0-dev.1003"
|
|
8
|
+
static let sourceCommit = "48d4c36700cb3f509f2bf831113d4f1344a8aaca"
|
|
9
|
+
static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-dev.1003.json"
|
|
10
|
+
static let otaManifestSha256 = "cbd66999c0e1d5827a3202c9fc8ecfed3746e48ac6f2b03b68248c8d15b90498"
|
|
11
11
|
}
|
|
@@ -322,6 +322,7 @@ public final class MentraBluetoothSDK {
|
|
|
322
322
|
|
|
323
323
|
public init(configuration: MentraBluetoothSDKConfiguration = .default) {
|
|
324
324
|
self.configuration = configuration
|
|
325
|
+
NimoResourceFixture.shared.start()
|
|
325
326
|
// Once per process: apps may create the SDK more than once.
|
|
326
327
|
if !Self.didWarnMissingBackgroundMode, !Self.supportsBackgroundReconnect {
|
|
327
328
|
Self.didWarnMissingBackgroundMode = true
|
|
@@ -463,6 +464,10 @@ public final class MentraBluetoothSDK {
|
|
|
463
464
|
}
|
|
464
465
|
|
|
465
466
|
public func startScan(model: DeviceModel) throws {
|
|
467
|
+
NimoResourceFixture.shared.start()
|
|
468
|
+
guard NimoResourceFixture.shared.allowsManager(model.deviceType) else {
|
|
469
|
+
throw BluetoothSdkError(code: "nimo_capture_required", message: "The original NIMO fixture capture must be armed before scanning.")
|
|
470
|
+
}
|
|
466
471
|
if model != .simulated {
|
|
467
472
|
try BluetoothAvailability.shared.requirePoweredOn(operation: "scan for glasses")
|
|
468
473
|
}
|
|
@@ -533,6 +538,10 @@ public final class MentraBluetoothSDK {
|
|
|
533
538
|
}
|
|
534
539
|
|
|
535
540
|
public func connect(to device: Device, options: ConnectOptions = ConnectOptions()) throws {
|
|
541
|
+
NimoResourceFixture.shared.start()
|
|
542
|
+
guard NimoResourceFixture.shared.allowsManager(device.model.deviceType, name: device.name) else {
|
|
543
|
+
throw BluetoothSdkError(code: "nimo_capture_required", message: "The original NIMO fixture capture must be armed before connection.")
|
|
544
|
+
}
|
|
536
545
|
clearBluetoothRestoreIntent()
|
|
537
546
|
if device.model != .simulated {
|
|
538
547
|
try BluetoothAvailability.shared.requirePoweredOn(operation: "connect to glasses")
|
|
@@ -540,14 +549,18 @@ public final class MentraBluetoothSDK {
|
|
|
540
549
|
let isController = ControllerTypes.ALL.contains(device.model.deviceType)
|
|
541
550
|
if !isController {
|
|
542
551
|
requiresAncsForBluetoothRestore = options.requiresAncs
|
|
552
|
+
MentraLive.enableTransportBridging = options.enableTransportBridging
|
|
543
553
|
}
|
|
544
554
|
if options.cancelExistingConnectionAttempt {
|
|
545
555
|
if isController {
|
|
546
556
|
DeviceManager.shared.disconnectController()
|
|
547
|
-
} else {
|
|
557
|
+
} else if !NimoResourceFixture.shared.preserveScan(device.name) {
|
|
548
558
|
cancelConnectionAttempt()
|
|
549
559
|
}
|
|
550
560
|
}
|
|
561
|
+
if !isController {
|
|
562
|
+
MentraLive.clearStaleIosBondPrompt()
|
|
563
|
+
}
|
|
551
564
|
if options.saveAsDefault && !isController {
|
|
552
565
|
setDefaultDevice(device)
|
|
553
566
|
} else if !isController {
|
|
@@ -566,16 +579,21 @@ public final class MentraBluetoothSDK {
|
|
|
566
579
|
public func connectDefault(options: ConnectOptions = ConnectOptions()) throws {
|
|
567
580
|
clearBluetoothRestoreIntent()
|
|
568
581
|
requiresAncsForBluetoothRestore = options.requiresAncs
|
|
582
|
+
MentraLive.enableTransportBridging = options.enableTransportBridging
|
|
569
583
|
guard let device = currentDefaultDevice() else {
|
|
570
584
|
throw BluetoothSdkError(
|
|
571
585
|
code: "default_device_missing",
|
|
572
586
|
message: "Set a default glasses device before calling connectDefault."
|
|
573
587
|
)
|
|
574
588
|
}
|
|
589
|
+
NimoResourceFixture.shared.start()
|
|
590
|
+
guard NimoResourceFixture.shared.allowsManager(device.model.deviceType, name: device.name) else {
|
|
591
|
+
throw BluetoothSdkError(code: "nimo_capture_required", message: "The original NIMO fixture capture must be armed before connection.")
|
|
592
|
+
}
|
|
575
593
|
if device.model != .simulated {
|
|
576
594
|
try BluetoothAvailability.shared.requirePoweredOn(operation: "connect to glasses")
|
|
577
595
|
}
|
|
578
|
-
if options.cancelExistingConnectionAttempt {
|
|
596
|
+
if options.cancelExistingConnectionAttempt && !NimoResourceFixture.shared.preserveScan(device.name) {
|
|
579
597
|
cancelConnectionAttempt()
|
|
580
598
|
}
|
|
581
599
|
DeviceManager.shared.connectDefault(requiresAncs: options.requiresAncs)
|
|
@@ -704,6 +722,17 @@ public final class MentraBluetoothSDK {
|
|
|
704
722
|
)
|
|
705
723
|
}
|
|
706
724
|
|
|
725
|
+
/// Disable a stock action while retaining touch events. Reset by BES on BLE disconnect.
|
|
726
|
+
public func setTouchGestureDefaultBehaviorEnabled(_ gesture: TouchGesture, enabled: Bool) async throws -> SettingsAckEvent {
|
|
727
|
+
try await performSettingsCommand(
|
|
728
|
+
setting: "touch_gesture_default",
|
|
729
|
+
updateStore: { _ in },
|
|
730
|
+
send: { requestId in
|
|
731
|
+
try DeviceManager.shared.sendTouchGestureDefaultBehaviorEnabled(requestId: requestId, gesture: gesture, enabled: enabled)
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
}
|
|
735
|
+
|
|
707
736
|
public func setGalleryModeEnabled(_ enabled: Bool) async throws -> SettingsAckEvent {
|
|
708
737
|
try await performSettingsCommand(
|
|
709
738
|
setting: "gallery_mode",
|
|
@@ -1174,8 +1203,12 @@ public final class MentraBluetoothSDK {
|
|
|
1174
1203
|
/// Fire-and-forget Mentra Live Wi-Fi ADB toggle. Glasses do not ack this
|
|
1175
1204
|
/// command, so there is no pending-response wait (unlike hotspot / Wi-Fi forget).
|
|
1176
1205
|
public func setWifiAdbState(enabled: Bool) async throws {
|
|
1206
|
+
try await setWifiAdbState(enabled: enabled, expectedBluetoothMac: nil)
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
public func setWifiAdbState(enabled: Bool, expectedBluetoothMac: String?) async throws {
|
|
1177
1210
|
try requireGlassesConnected(operation: "toggle Wi-Fi ADB")
|
|
1178
|
-
DeviceManager.shared.setWifiAdbState(enabled)
|
|
1211
|
+
try DeviceManager.shared.setWifiAdbState(enabled, expectedBluetoothMac: expectedBluetoothMac)
|
|
1179
1212
|
}
|
|
1180
1213
|
|
|
1181
1214
|
func setSystemTime(timestampMs: Int64) {
|
|
@@ -2694,9 +2727,9 @@ public final class MentraBluetoothSDK {
|
|
|
2694
2727
|
let event = GalleryStatusEvent(values: data)
|
|
2695
2728
|
pendingGalleryStatus?.resolve(event)
|
|
2696
2729
|
delegate?.mentraBluetoothSDK(self, didReceive: .raw(name: "gallery_status", values: event.values))
|
|
2697
|
-
case "pairing_info":
|
|
2698
|
-
delegate?.mentraBluetoothSDK(self, didReceive: .raw(name:
|
|
2699
|
-
case "entering_pairing_mode", "owner_replaced":
|
|
2730
|
+
case "pairing_info", "pairing_state_changed", "audio_setup_changed":
|
|
2731
|
+
delegate?.mentraBluetoothSDK(self, didReceive: .raw(name: eventName, values: data))
|
|
2732
|
+
case "entering_pairing_mode", "pairing_mode_ended", "owner_replaced":
|
|
2700
2733
|
delegate?.mentraBluetoothSDK(self, didReceive: .raw(name: eventName, values: data))
|
|
2701
2734
|
case "photo_response":
|
|
2702
2735
|
let event = PhotoResponseEvent(values: data)
|
|
@@ -2792,7 +2825,8 @@ public final class MentraBluetoothSDK {
|
|
|
2792
2825
|
self,
|
|
2793
2826
|
didFail: BluetoothSdkError(
|
|
2794
2827
|
code: "pair_failure",
|
|
2795
|
-
message: data["error"] as? String ?? data.description
|
|
2828
|
+
message: data["error"] as? String ?? data.description,
|
|
2829
|
+
failureCode: data["code"] as? String
|
|
2796
2830
|
)
|
|
2797
2831
|
)
|
|
2798
2832
|
default:
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// Mentra Live touchpad gestures, using the public touch_event names.
|
|
4
|
+
public enum TouchGesture: String, CaseIterable, Sendable {
|
|
5
|
+
case singleTap = "single_tap"
|
|
6
|
+
case doubleTap = "double_tap"
|
|
7
|
+
case tripleTap = "triple_tap"
|
|
8
|
+
case longPress = "long_press"
|
|
9
|
+
case forwardSwipe = "forward_swipe"
|
|
10
|
+
case backwardSwipe = "backward_swipe"
|
|
11
|
+
case upSwipe = "up_swipe"
|
|
12
|
+
case downSwipe = "down_swipe"
|
|
13
|
+
}
|
|
@@ -3,10 +3,14 @@ import Foundation
|
|
|
3
3
|
public struct BluetoothSdkError: Error, LocalizedError, CustomStringConvertible {
|
|
4
4
|
public let code: String
|
|
5
5
|
public let message: String
|
|
6
|
+
/// Machine-readable reason a `pair_failure` carries (`pair_failure.code`), such as
|
|
7
|
+
/// `ios_forget_pairing`. Nil for other errors.
|
|
8
|
+
public let failureCode: String?
|
|
6
9
|
|
|
7
|
-
public init(code: String, message: String) {
|
|
10
|
+
public init(code: String, message: String, failureCode: String? = nil) {
|
|
8
11
|
self.code = code
|
|
9
12
|
self.message = message
|
|
13
|
+
self.failureCode = failureCode
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
public var errorDescription: String? {
|
|
@@ -174,6 +174,10 @@ public struct SettingsAckEvent: CustomStringConvertible {
|
|
|
174
174
|
stringValue(values, "requestId") ?? ""
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
public var gesture: TouchGesture? {
|
|
178
|
+
stringValue(values, "gesture").flatMap(TouchGesture.init(rawValue:))
|
|
179
|
+
}
|
|
180
|
+
|
|
177
181
|
public var setting: String {
|
|
178
182
|
stringValue(values, "setting") ?? ""
|
|
179
183
|
}
|
|
@@ -17,7 +17,8 @@ enum BleTraceLogger {
|
|
|
17
17
|
bytes: Int? = nil,
|
|
18
18
|
sourceFile: String = #fileID,
|
|
19
19
|
sourceFunction: String = #function,
|
|
20
|
-
sourceLine: Int = #line
|
|
20
|
+
sourceLine: Int = #line,
|
|
21
|
+
forwardToBridge: Bool = true
|
|
21
22
|
) {
|
|
22
23
|
guard let payload else {
|
|
23
24
|
emit(format(
|
|
@@ -27,7 +28,7 @@ enum BleTraceLogger {
|
|
|
27
28
|
type: "null",
|
|
28
29
|
bytes: bytes,
|
|
29
30
|
payload: "null"
|
|
30
|
-
))
|
|
31
|
+
), forwardToBridge: forwardToBridge)
|
|
31
32
|
return
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -39,7 +40,7 @@ enum BleTraceLogger {
|
|
|
39
40
|
type: extractType(from: payload),
|
|
40
41
|
bytes: bytes,
|
|
41
42
|
payload: jsonString(sanitized)
|
|
42
|
-
))
|
|
43
|
+
), forwardToBridge: forwardToBridge)
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
static func logMap(
|
|
@@ -50,7 +51,8 @@ enum BleTraceLogger {
|
|
|
50
51
|
bytes: Int? = nil,
|
|
51
52
|
sourceFile: String = #fileID,
|
|
52
53
|
sourceFunction: String = #function,
|
|
53
|
-
sourceLine: Int = #line
|
|
54
|
+
sourceLine: Int = #line,
|
|
55
|
+
forwardToBridge: Bool = true
|
|
54
56
|
) {
|
|
55
57
|
let sanitized = sanitizeDictionary(payload)
|
|
56
58
|
emit(format(
|
|
@@ -60,7 +62,7 @@ enum BleTraceLogger {
|
|
|
60
62
|
type: type ?? extractType(from: sanitized),
|
|
61
63
|
bytes: bytes,
|
|
62
64
|
payload: jsonString(sanitized)
|
|
63
|
-
))
|
|
65
|
+
), forwardToBridge: forwardToBridge)
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
static func logLifecycle(component: String, event: String, extra: [String: Any] = [:]) {
|
|
@@ -82,8 +84,9 @@ enum BleTraceLogger {
|
|
|
82
84
|
logMap(direction: "phone_app", layer: "app_lifecycle", type: event, payload: payload)
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
private static func emit(_ line: String) {
|
|
87
|
+
private static func emit(_ line: String, forwardToBridge: Bool = true) {
|
|
86
88
|
os_log("%{public}@", log: log, type: .info, line)
|
|
89
|
+
guard forwardToBridge else { return }
|
|
87
90
|
// Log events are excluded from tracing in Bridge, so forwarding a trace
|
|
88
91
|
// cannot recursively generate another trace.
|
|
89
92
|
Bridge.sendTypedMessage("log", body: ["message": line])
|