@mentra/bluetooth-sdk 3.4.0-dev.999 → 3.4.1-beta.1409

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.
Files changed (216) hide show
  1. package/MIGRATION.md +16 -7
  2. package/README.md +41 -14
  3. package/android/build.gradle +60 -51
  4. package/android/gradle.properties +3 -0
  5. package/android/settings.gradle +47 -3
  6. package/android/src/main/assets/nimo/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
  7. package/android/src/main/java/com/mentra/bluetoothsdk/BesCrashReportWaiters.kt +68 -0
  8. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +5 -1
  9. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +77 -6
  10. package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +41 -0
  11. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +131 -122
  12. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +3 -2
  13. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +6 -6
  14. package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +31 -10
  15. package/android/src/main/java/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt +57 -196
  16. package/android/src/main/java/com/mentra/bluetoothsdk/OtaManifest.kt +1 -16
  17. package/android/src/main/java/com/mentra/bluetoothsdk/debug/BleTraceLogger.kt +10 -1
  18. package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
  19. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/Ipv4Prefix.kt +51 -0
  20. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/NetworkFacts.kt +81 -0
  21. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkError.kt +108 -0
  22. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadiness.kt +103 -0
  23. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpec.kt +44 -0
  24. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkState.kt +117 -0
  25. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedSoftApNetwork.kt +598 -0
  26. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/SoftApTrace.kt +143 -0
  27. package/android/src/main/java/com/mentra/bluetoothsdk/otaserver/MentraOtaServerModule.kt +0 -7
  28. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTracker.kt +15 -0
  29. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +308 -60
  30. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +14 -5
  31. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +210 -325
  32. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +0 -35
  33. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +2 -10
  34. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdater.kt +213 -0
  35. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocol.kt +112 -0
  36. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +6 -0
  37. package/android/src/main/java/com/mentra/bluetoothsdk/streaming/StreamModels.kt +17 -6
  38. package/android/src/main/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueue.kt +92 -0
  39. package/android/src/main/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHost.kt +169 -0
  40. package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +74 -115
  41. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +348 -357
  42. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetector.kt +211 -0
  43. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngine.kt +137 -0
  44. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SttTextFormatter.kt +52 -0
  45. package/android/src/main/java/com/mentra/bluetoothsdk/stt/WakeWordDetector.kt +235 -0
  46. package/android/src/main/java/com/mentra/bluetoothsdk/utils/AvifExifStripper.java +2 -2
  47. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +3 -3
  48. package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +11 -0
  49. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/AudioRouteWatcher.kt +120 -0
  50. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +181 -16
  51. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlayback.kt +177 -0
  52. package/android/src/test/java/com/mentra/bluetoothsdk/BesCrashReportWaitersTest.kt +112 -0
  53. package/android/src/test/java/com/mentra/bluetoothsdk/StreamRequestCaptureAudioTest.kt +23 -4
  54. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/Ipv4PrefixTest.kt +59 -0
  55. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/NetworkFactsTest.kt +59 -0
  56. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedLocalNetworkPermissionTest.kt +35 -0
  57. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkErrorTest.kt +85 -0
  58. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkLifecycleTest.kt +164 -0
  59. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadinessTest.kt +141 -0
  60. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpecTest.kt +56 -0
  61. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/SoftApTraceTest.kt +97 -0
  62. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/UnavailableRetryTest.kt +47 -0
  63. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTrackerTest.kt +26 -0
  64. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveGlassesReadyBurstTest.kt +141 -0
  65. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveIncidentDispatchTest.kt +183 -0
  66. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicyTest.kt +9 -3
  67. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveRgbLedResponseTest.kt +76 -0
  68. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinatorTest.kt +1 -56
  69. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSessionTest.kt +0 -22
  70. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareTargetTest.kt +15 -0
  71. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdaterTest.kt +76 -0
  72. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocolTest.kt +77 -0
  73. package/android/src/test/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNamingTest.kt +23 -0
  74. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoReadinessDriverTest.kt +31 -1
  75. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueueTest.kt +81 -0
  76. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHostTest.kt +216 -0
  77. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/STTToolsExtractionTest.kt +108 -0
  78. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetectorTest.kt +126 -0
  79. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngineTest.kt +245 -0
  80. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SttTextFormatterTest.kt +67 -0
  81. package/android/src/testDebug/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlaybackTest.kt +76 -0
  82. package/build/BluetoothSdk.types.d.ts +103 -5
  83. package/build/BluetoothSdk.types.d.ts.map +1 -1
  84. package/build/BluetoothSdk.types.js.map +1 -1
  85. package/build/_private/BluetoothSdkModule.d.ts +42 -8
  86. package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
  87. package/build/_private/BluetoothSdkModule.js +1 -0
  88. package/build/_private/BluetoothSdkModule.js.map +1 -1
  89. package/build/_private/MentraLocalNetworkModule.d.ts +1 -1
  90. package/build/_private/MentraLocalNetworkModule.d.ts.map +1 -1
  91. package/build/_private/MentraLocalNetworkModule.js.map +1 -1
  92. package/build/generated/changelogCatalog.d.ts +5 -2
  93. package/build/generated/changelogCatalog.d.ts.map +1 -1
  94. package/build/generated/changelogCatalog.js +6 -2
  95. package/build/generated/changelogCatalog.js.map +1 -1
  96. package/build/generated/releaseMetadata.js +6 -6
  97. package/build/generated/releaseMetadata.js.map +1 -1
  98. package/build/index.d.ts +1 -1
  99. package/build/index.d.ts.map +1 -1
  100. package/build/index.js +7 -1
  101. package/build/index.js.map +1 -1
  102. package/build/ota-server/MentraOtaServerModule.d.ts +0 -2
  103. package/build/ota-server/MentraOtaServerModule.d.ts.map +1 -1
  104. package/build/ota-server/MentraOtaServerModule.js.map +1 -1
  105. package/build/ota-server/MentraOtaServerModule.web.d.ts +0 -1
  106. package/build/ota-server/MentraOtaServerModule.web.d.ts.map +1 -1
  107. package/build/ota-server/MentraOtaServerModule.web.js +0 -3
  108. package/build/ota-server/MentraOtaServerModule.web.js.map +1 -1
  109. package/build/ota-transport/index.d.ts +3 -3
  110. package/build/ota-transport/index.d.ts.map +1 -1
  111. package/build/ota-transport/index.js +4 -4
  112. package/build/ota-transport/index.js.map +1 -1
  113. package/build/react/useGlassesConnection.d.ts +1 -1
  114. package/build/react/useGlassesConnection.d.ts.map +1 -1
  115. package/build/react/useGlassesConnection.js +3 -3
  116. package/build/react/useGlassesConnection.js.map +1 -1
  117. package/build/react/useMentraBluetooth.d.ts +1 -1
  118. package/build/react/useMentraBluetooth.d.ts.map +1 -1
  119. package/build/react/useMentraBluetooth.js +1 -1
  120. package/build/react/useMentraBluetooth.js.map +1 -1
  121. package/ios/BluetoothSdkModule.swift +73 -22
  122. package/ios/LocalIPv4.swift +0 -61
  123. package/ios/MentraBluetoothSDK.podspec +7 -1
  124. package/ios/MentraOtaServerModule.swift +0 -16
  125. package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
  126. package/ios/Resources/NimoFirmware/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
  127. package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
  128. package/ios/Source/BesCrashReportWaiters.swift +64 -0
  129. package/ios/Source/BluetoothSdkDefaults.swift +4 -4
  130. package/ios/Source/Bridge.swift +14 -0
  131. package/ios/Source/DeviceManager.swift +52 -22
  132. package/ios/Source/GeneratedChangelogCatalog.swift +3 -2
  133. package/ios/Source/GeneratedReleaseMetadata.swift +6 -6
  134. package/ios/Source/MentraBluetoothSDK.swift +35 -16
  135. package/ios/Source/OtaManifest.swift +1 -17
  136. package/ios/Source/audio/PcmStreamPlayer.swift +290 -57
  137. package/ios/Source/audio/PcmUrlPlayback.swift +231 -0
  138. package/ios/Source/audio/SpeechActivity.swift +277 -0
  139. package/ios/Source/events/BluetoothEvents.swift +41 -0
  140. package/ios/Source/internal/BleTraceLogger.swift +14 -1
  141. package/ios/Source/internal/BluetoothAvailability.swift +15 -5
  142. package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +5 -0
  143. package/ios/Source/sgcs/MentraLive.swift +207 -66
  144. package/ios/Source/sgcs/Nimo.swift +249 -276
  145. package/ios/Source/sgcs/NimoCanvasCoordinator.swift +9 -38
  146. package/ios/Source/sgcs/NimoCanvasSession.swift +0 -1
  147. package/ios/Source/sgcs/NimoFirmwareUpdater.swift +260 -0
  148. package/ios/Source/sgcs/NimoOtaProtocol.swift +159 -0
  149. package/ios/Source/sgcs/SGCManager.swift +6 -0
  150. package/ios/Source/streaming/StreamModels.swift +15 -6
  151. package/ios/Source/stt/STTTools.swift +13 -31
  152. package/ios/Source/stt/SherpaOnnxTranscriber.swift +204 -162
  153. package/ios/Source/stt/SileroSpeechActivity.swift +87 -0
  154. package/ios/Source/stt/WakeWordDetector.swift +145 -0
  155. package/ios/Source/utils/BoundedWait.swift +44 -0
  156. package/ios/Source/utils/DemandDrivenAudioWorker.swift +79 -0
  157. package/ios/Source/utils/SttModelTraits.swift +62 -0
  158. package/ios/Tests/BesCrashReportTests.swift +142 -0
  159. package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
  160. package/ios/Tests/DeviceManagerReconnectTests.swift +0 -71
  161. package/ios/Tests/GlassesAudioSetupPolicyTests.swift +9 -3
  162. package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
  163. package/ios/Tests/MentraLiveAudioSetupTests.swift +6 -12
  164. package/ios/Tests/MentraLiveCommandQueueTests.swift +35 -0
  165. package/ios/Tests/MentraLiveSessionReadinessTests.swift +179 -10
  166. package/ios/Tests/NimoCanvasTransportTests.swift +0 -89
  167. package/ios/Tests/NimoOtaProtocolTests.swift +78 -0
  168. package/ios/Tests/PcmStreamTests.swift +299 -0
  169. package/ios/Tests/SpeechActivityTests.swift +238 -0
  170. package/ios/Tests/StreamRequestTests.swift +18 -0
  171. package/ios/Tests/SttModelTraitsTests.swift +62 -0
  172. package/package.json +2 -2
  173. package/plugin/build/withAndroid.js +9 -11
  174. package/plugin/build/withKotlinVersion.d.ts +2 -0
  175. package/plugin/build/withKotlinVersion.js +46 -0
  176. package/src/BluetoothSdk.types.ts +107 -5
  177. package/src/_private/BluetoothSdkModule.ts +45 -8
  178. package/src/_private/MentraLocalNetworkModule.ts +5 -1
  179. package/src/generated/changelogCatalog.ts +6 -2
  180. package/src/generated/releaseMetadata.ts +6 -6
  181. package/src/index.ts +13 -1
  182. package/src/ota-server/MentraOtaServerModule.ts +0 -2
  183. package/src/ota-server/MentraOtaServerModule.web.ts +0 -4
  184. package/src/ota-transport/index.ts +4 -5
  185. package/src/react/useGlassesConnection.ts +4 -4
  186. package/src/react/useMentraBluetooth.ts +2 -2
  187. package/android/silero/LICENSE.md +0 -17
  188. package/android/silero/build.gradle +0 -50
  189. package/android/silero/proguard-rules.pro +0 -24
  190. package/android/silero/src/androidTest/assets/hello.wav +0 -0
  191. package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +0 -79
  192. package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +0 -160
  193. package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +0 -449
  194. package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +0 -15
  195. package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +0 -14
  196. package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +0 -12
  197. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +0 -47
  198. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +0 -41
  199. package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +0 -44
  200. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -368
  201. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocol.kt +0 -156
  202. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -274
  203. package/android/src/main/java/com/mentra/bluetoothsdk/ScopedNetworkReadiness.kt +0 -17
  204. package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +0 -229
  205. package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -20
  206. package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -16
  207. package/android/src/test/java/com/mentra/bluetoothsdk/ScopedNetworkReadinessTest.kt +0 -39
  208. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnosticsTest.kt +0 -287
  209. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt +0 -127
  210. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +0 -851
  211. package/ios/Source/sgcs/NimoMacResourceTransport.swift +0 -217
  212. package/ios/Source/sgcs/NimoResourceFixture.swift +0 -384
  213. package/ios/Source/sgcs/NimoResourceSession.swift +0 -406
  214. package/ios/Tests/NimoResourceSessionTests.swift +0 -476
  215. /package/android/{silero/src/main/assets/LICENSE → src/main/assets/vad/LICENSE.silero_vad} +0 -0
  216. /package/android/{silero/src/main/assets → src/main/assets/vad}/silero_vad.onnx +0 -0
@@ -78,6 +78,8 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
78
78
  "audio_disconnected",
79
79
  "save_setting",
80
80
  "local_transcription",
81
+ "wake_word",
82
+ "speech_activity",
81
83
  "phone_notification",
82
84
  "native_notification_status",
83
85
  "native_notification_delivery",
@@ -95,6 +97,7 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
95
97
  "ota_start_ack",
96
98
  "ota_status",
97
99
  "ar99_ota_status",
100
+ "bes_crash_detected",
98
101
  "send_command_to_ble",
99
102
  "receive_command_from_ble",
100
103
  "miniapp_selected",
@@ -165,12 +168,6 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
165
168
  await sdk.setDashboardContent(content)
166
169
  }
167
170
 
168
- // Fixed typed fixture protocol; native schema/launch/peer authority is
169
- // validated before effects. Ordinary launches return fixture-unavailable.
170
- AsyncFunction("nimoResourceSession") { (requestJSON: String) async throws -> String in
171
- try await NimoResourceFixtureBridge.execute(requestJSON)
172
- }
173
-
174
171
  // MARK: - Connection Commands
175
172
 
176
173
  AsyncFunction("connectDefault") {
@@ -191,12 +188,6 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
191
188
  }
192
189
  }
193
190
 
194
- AsyncFunction("clearDefaultDevice") {
195
- await MainActor.run {
196
- self.bluetoothSdk().clearDefaultDevice()
197
- }
198
- }
199
-
200
191
  AsyncFunction("connectWithOptions") { (device: [String: Any], options: [String: Any]) in
201
192
  try await MainActor.run {
202
193
  guard let target = Device(dictionary: device) else {
@@ -240,7 +231,7 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
240
231
  }
241
232
 
242
233
  AsyncFunction("unpair") {
243
- try await DeviceManager.shared.unpair()
234
+ try await self.bluetoothSdk().unpair()
244
235
  }
245
236
 
246
237
  AsyncFunction("forgetController") {
@@ -383,6 +374,11 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
383
374
  }
384
375
  }
385
376
 
377
+ AsyncFunction("sendBesCrashReported") { (incidentKey: String, reportId: String) in
378
+ let sdk = await MainActor.run { self.bluetoothSdk() }
379
+ try await sdk.sendBesCrashReported(incidentKey: incidentKey, reportId: reportId)
380
+ }
381
+
386
382
  AsyncFunction("configureNativeNotifications") { (values: [String: Any]) in
387
383
  try await MainActor.run {
388
384
  try self.bluetoothSdk().configureNativeNotifications(NativeNotificationConfig(
@@ -671,9 +667,14 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
671
667
 
672
668
  // MARK: - Version Info Commands
673
669
 
670
+ // The OTA check asks again after request_timeout, so the code has to reach JS intact.
674
671
  AsyncFunction("requestVersionInfo") {
675
672
  let sdk = await MainActor.run { self.bluetoothSdk() }
676
- return try await sdk.requestVersionInfo().dictionary
673
+ do {
674
+ return try await sdk.requestVersionInfo().dictionary
675
+ } catch let error as BluetoothSdkError {
676
+ throw codedBridgeError(error)
677
+ }
677
678
  }
678
679
 
679
680
  // MARK: - Power Control Commands
@@ -747,16 +748,16 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
747
748
 
748
749
  // MARK: - Live PCM output stream (miniapp speaker.createStream)
749
750
 
750
- // jitterMs is accepted for signature parity with Android and ignored: AVAudioEngine's
751
- // scheduled-buffer playout has no equivalent fixed track buffer to size, so there is no
752
- // knob here that would mean the same thing.
751
+ // jitterMs (default 500, 80-500 as on Android): playback starts once that much audio is
752
+ // queued, or on close, so a sound shorter than the cushion still plays.
753
753
  AsyncFunction("pcmStreamOpen") {
754
- (streamId: String, sampleRate: Int, channels: Int, volume: Double, _: Int?) async throws in
754
+ (streamId: String, sampleRate: Int, channels: Int, volume: Double, jitterMs: Int?) async throws in
755
755
  try PcmStreamManager.open(
756
756
  streamId: streamId,
757
757
  sampleRate: sampleRate,
758
758
  channels: channels,
759
- volume: Float(volume)
759
+ volume: Float(volume),
760
+ jitterMs: jitterMs
760
761
  )
761
762
  }
762
763
 
@@ -774,6 +775,19 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
774
775
  await PcmStreamManager.abort(streamId: streamId)
775
776
  }
776
777
 
778
+ // Native HTTP GET of raw s16le mono PCM, played as it downloads. Async, so the download
779
+ // and playback never hold Expo's shared module queue.
780
+ AsyncFunction("pcmStreamPlayUrl") {
781
+ (streamId: String, url: String, sampleRate: Int, volume: Double, jitterMs: Int?) async throws -> [String: Int64] in
782
+ try ["durationMs": await PcmStreamManager.playUrl(
783
+ streamId: streamId,
784
+ url: url,
785
+ sampleRate: sampleRate,
786
+ volume: Float(volume),
787
+ jitterMs: jitterMs
788
+ )]
789
+ }
790
+
777
791
  AsyncFunction("getGlassesMediaVolume") { () async throws -> [String: Any] in
778
792
  try await DeviceManager.shared.getGlassesMediaVolume()
779
793
  }
@@ -832,12 +846,47 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
832
846
  }
833
847
  }
834
848
 
835
- AsyncFunction("restartTranscriber") {
836
- await MainActor.run {
837
- DeviceManager.shared.restartTranscriber()
849
+ // Loads the keyword spotter from the Speech-page model directory; disabling releases it.
850
+ AsyncFunction("setWakeWordDetection") { (enabled: Bool, modelDir: String?) async throws in
851
+ #if !os(macOS)
852
+ try await WakeWordDetector.shared.configure(enabled: enabled, modelDir: modelDir)
853
+ #else
854
+ if enabled {
855
+ throw NSError(domain: "WakeWordDetector", code: 1,
856
+ userInfo: [NSLocalizedDescriptionKey: "Native wake-word detection is not available on macOS"])
857
+ }
858
+ #endif
859
+ }
860
+
861
+ AsyncFunction("isSttModelLoaded") { (path: String) async -> Bool in
862
+ await DeviceManager.shared.isSttModelLoaded(path)
863
+ }
864
+
865
+ // Final text after its local_transcription event was sent, or null. Never throws.
866
+ AsyncFunction("finishTranscription") { () async -> String? in
867
+ await DeviceManager.shared.finishTranscription()
868
+ }
869
+
870
+ AsyncFunction("restartTranscriber") { () async throws in
871
+ guard await DeviceManager.shared.restartTranscriber() else {
872
+ throw NSError(domain: "SherpaOnnxTranscriber", code: 2,
873
+ userInfo: [NSLocalizedDescriptionKey: "Could not load the speech model"])
838
874
  }
839
875
  }
840
876
 
877
+ // Phone-side Silero speech activity on microphone PCM; disabling releases the model.
878
+ AsyncFunction("setSpeechActivityDetection") { (enabled: Bool, options: [String: Any]?) async throws in
879
+ #if !os(macOS)
880
+ let minSilenceMs = (options?["minSilenceMs"] as? NSNumber)?.intValue
881
+ try await SpeechActivityMonitor.shared.setEnabled(enabled, minSilenceMs: minSilenceMs)
882
+ #else
883
+ if enabled {
884
+ throw NSError(domain: "SpeechActivity", code: 1,
885
+ userInfo: [NSLocalizedDescriptionKey: "Native speech activity detection is not available on macOS"])
886
+ }
887
+ #endif
888
+ }
889
+
841
890
  // MARK: - Display Commands
842
891
 
843
892
  AsyncFunction("clearDisplay") {
@@ -1008,6 +1057,8 @@ public class BluetoothSdkModule: Module, MentraBluetoothSDKDelegate {
1008
1057
  sendEvent("ota_start_ack", event.values)
1009
1058
  case let .otaStatus(event):
1010
1059
  sendEvent("ota_status", event.values)
1060
+ case let .besCrashDetected(event):
1061
+ sendEvent("bes_crash_detected", event.values)
1011
1062
  case let .settingsAck(event):
1012
1063
  sendEvent("settings_ack", event.values)
1013
1064
  case let .versionInfo(event):
@@ -5,54 +5,6 @@ import Foundation
5
5
  /// (photo upload receiver, hotspot-served OTA). Prefers WiFi-ish interfaces carrying RFC1918
6
6
  /// addresses — under a glasses-hotspot session en0 holds the 192.168.43.x client address.
7
7
  enum LocalIPv4 {
8
- /// Return the active Wi-Fi address only when it is on the glasses gateway's /24.
9
- /// iPhone Wi-Fi is `en0`; accepting AWDL, VPN, cellular, or another private
10
- /// interface can publish an endpoint that the glasses cannot reach.
11
- static func wifiIPv4Address(matchingGateway gateway: String) -> String? {
12
- guard let gatewayPrefix = subnet24Prefix(gateway) else {
13
- return nil
14
- }
15
-
16
- var interfaces: UnsafeMutablePointer<ifaddrs>?
17
- guard getifaddrs(&interfaces) == 0, let first = interfaces else {
18
- return nil
19
- }
20
- defer { freeifaddrs(interfaces) }
21
-
22
- var cursor: UnsafeMutablePointer<ifaddrs>? = first
23
- while let current = cursor {
24
- defer { cursor = current.pointee.ifa_next }
25
- let interface = current.pointee
26
- guard String(cString: interface.ifa_name) == "en0",
27
- let addressPointer = interface.ifa_addr,
28
- addressPointer.pointee.sa_family == UInt8(AF_INET),
29
- (interface.ifa_flags & UInt32(IFF_UP)) != 0
30
- else {
31
- continue
32
- }
33
-
34
- var address = addressPointer.pointee
35
- var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
36
- guard getnameinfo(
37
- &address,
38
- socklen_t(address.sa_len),
39
- &hostname,
40
- socklen_t(hostname.count),
41
- nil,
42
- 0,
43
- NI_NUMERICHOST
44
- ) == 0 else {
45
- continue
46
- }
47
-
48
- let ip = String(cString: hostname)
49
- if subnet24Prefix(ip) == gatewayPrefix {
50
- return ip
51
- }
52
- }
53
- return nil
54
- }
55
-
56
8
  static func bestLocalIPv4Address() -> String? {
57
9
  var interfaces: UnsafeMutablePointer<ifaddrs>?
58
10
  guard getifaddrs(&interfaces) == 0, let first = interfaces else {
@@ -134,17 +86,4 @@ enum LocalIPv4 {
134
86
  private static func isLinkLocalIPv4(_ ip: String) -> Bool {
135
87
  ip.hasPrefix("169.254.")
136
88
  }
137
-
138
- private static func subnet24Prefix(_ ip: String) -> String? {
139
- let parts = ip.split(separator: ".")
140
- guard parts.count == 4,
141
- parts.allSatisfy({ part in
142
- guard let value = Int(part) else { return false }
143
- return (0 ... 255).contains(value)
144
- })
145
- else {
146
- return nil
147
- }
148
- return parts.prefix(3).joined(separator: ".")
149
- }
150
89
  }
@@ -51,7 +51,13 @@ Pod::Spec.new do |s|
51
51
  s.ios.vendored_frameworks = 'Packages/SherpaOnnx/sherpa-onnx.xcframework'
52
52
 
53
53
  s.resource_bundles = {
54
- 'BluetoothSDKPrivacy' => ['Source/PrivacyInfo.xcprivacy']
54
+ 'BluetoothSDKPrivacy' => ['Source/PrivacyInfo.xcprivacy'],
55
+ # NIMO firmware the SGC installs when connected glasses report another version.
56
+ 'MentraNimoFirmware' => ['Resources/NimoFirmware/*.bin']
57
+ }
58
+ # Phone-side Silero speech activity runs through the iOS-only sherpa-onnx framework.
59
+ s.ios.resource_bundles = {
60
+ 'MentraSileroVad' => ['Resources/SileroVad/silero_vad.onnx']
55
61
  }
56
62
 
57
63
  native_source_files = [
@@ -31,10 +31,6 @@ public class MentraOtaServerModule: Module {
31
31
  self.stopOtaServerInternal()
32
32
  }
33
33
 
34
- AsyncFunction("waitForWifiAddress") { (gateway: String, timeoutMs: Int) -> String in
35
- try await self.waitForWifiAddress(gateway: gateway, timeoutMs: timeoutMs)
36
- }
37
-
38
34
  AsyncFunction("downloadArtifact") { (source: String, destination: String) in
39
35
  try await self.artifactDownloader.download(from: source, to: destination)
40
36
  }
@@ -97,18 +93,6 @@ public class MentraOtaServerModule: Module {
97
93
  )
98
94
  }
99
95
 
100
- private func waitForWifiAddress(gateway: String, timeoutMs: Int) async throws -> String {
101
- let deadline = Date().addingTimeInterval(Double(max(timeoutMs, 0)) / 1000.0)
102
- repeat {
103
- if let address = LocalIPv4.wifiIPv4Address(matchingGateway: gateway) {
104
- return address
105
- }
106
- try await Task.sleep(nanoseconds: 250_000_000)
107
- } while Date() < deadline
108
-
109
- throw OtaServerModuleError("The iPhone did not join the glasses hotspot subnet.")
110
- }
111
-
112
96
  private func stopOtaServerInternal() {
113
97
  serverLock.lock()
114
98
  defer { serverLock.unlock() }
@@ -329,6 +329,17 @@ class SherpaOnnxRecognizer {
329
329
  }
330
330
  }
331
331
 
332
+ /// Replace an ended stream while retaining the loaded recognizer/model.
333
+ @discardableResult
334
+ func recreateStream() -> Bool {
335
+ guard let replacement = SherpaOnnxCreateOnlineStream(recognizer) else { return false }
336
+ lock.lock()
337
+ SherpaOnnxDestroyOnlineStream(stream)
338
+ stream = replacement
339
+ lock.unlock()
340
+ return true
341
+ }
342
+
332
343
  /// Signal that no more audio samples would be available.
333
344
  /// After this call, you cannot call acceptWaveform() any more.
334
345
  func inputFinished() {
@@ -1000,9 +1011,10 @@ class SherpaOnnxVoiceActivityDetectorWrapper {
1000
1011
  /// A pointer to the underlying counterpart in C
1001
1012
  private let vad: OpaquePointer
1002
1013
 
1003
- init(config: UnsafePointer<SherpaOnnxVadModelConfig>, buffer_size_in_seconds: Float) {
1014
+ /// Returns nil when sherpa-onnx rejects the model instead of terminating the app.
1015
+ init?(config: UnsafePointer<SherpaOnnxVadModelConfig>, buffer_size_in_seconds: Float) {
1004
1016
  guard let vad = SherpaOnnxCreateVoiceActivityDetector(config, buffer_size_in_seconds) else {
1005
- fatalError("SherpaOnnxCreateVoiceActivityDetector returned nil")
1017
+ return nil
1006
1018
  }
1007
1019
  self.vad = vad
1008
1020
  }
@@ -1626,11 +1638,17 @@ class SherpaOnnxKeywordSpotterWrapper {
1626
1638
  let spotter: OpaquePointer!
1627
1639
  var stream: OpaquePointer!
1628
1640
 
1629
- init(
1641
+ /// Returns nil when sherpa-onnx rejects the model or keywords instead of crashing later.
1642
+ init?(
1630
1643
  config: UnsafePointer<SherpaOnnxKeywordSpotterConfig>!
1631
1644
  ) {
1632
- spotter = SherpaOnnxCreateKeywordSpotter(config)
1633
- stream = SherpaOnnxCreateKeywordStream(spotter)
1645
+ guard let spotter = SherpaOnnxCreateKeywordSpotter(config) else { return nil }
1646
+ guard let stream = SherpaOnnxCreateKeywordStream(spotter) else {
1647
+ SherpaOnnxDestroyKeywordSpotter(spotter)
1648
+ return nil
1649
+ }
1650
+ self.spotter = spotter
1651
+ self.stream = stream
1634
1652
  }
1635
1653
 
1636
1654
  deinit {
@@ -0,0 +1,64 @@
1
+ import Foundation
2
+
3
+ /// Correlates `bes_crash_reported` commands with the glasses' `bes_crash_reported_ack`.
4
+ ///
5
+ /// Each call owns one waiter keyed by (incidentKey, reportId), so concurrent reports for
6
+ /// different incidents, or a stale ack for an earlier reportId, never settle each other.
7
+ @MainActor
8
+ final class BesCrashReportWaiters {
9
+ @MainActor
10
+ private final class Waiter {
11
+ let incidentKey: String
12
+ let reportId: String
13
+ let pending: PendingResponse<Void>
14
+
15
+ init(incidentKey: String, reportId: String) {
16
+ self.incidentKey = incidentKey
17
+ self.reportId = reportId
18
+ pending = PendingResponse<Void>(operation: "bes_crash_reported for \(incidentKey)")
19
+ }
20
+ }
21
+
22
+ private var waiters: [Waiter] = []
23
+
24
+ /// Registers before `send` so an immediate ack cannot be missed.
25
+ func report(incidentKey: String, reportId: String, timeoutMs: Int, send: () throws -> Void) async throws {
26
+ let waiter = Waiter(incidentKey: incidentKey, reportId: reportId)
27
+ waiters.append(waiter)
28
+ defer { waiters.removeAll { $0 === waiter } }
29
+ try send()
30
+ try await waiter.pending.wait(timeoutMs: timeoutMs)
31
+ }
32
+
33
+ /// Settles the waiters this ack answers. `ok:true` must echo the reportId; an `ok:false`
34
+ /// without a reportId rejects every waiter for that incidentKey. Returns the number settled.
35
+ @discardableResult
36
+ func onAck(_ values: [String: Any]) -> Int {
37
+ guard let incidentKey = values["incidentKey"] as? String else { return 0 }
38
+ let reportId = (values["reportId"] as? String).flatMap { $0.isEmpty ? nil : $0 }
39
+ let ok = values["ok"] as? Bool == true
40
+ let matched = waiters.filter {
41
+ $0.incidentKey == incidentKey && ($0.reportId == reportId || (!ok && reportId == nil))
42
+ }
43
+ if ok {
44
+ for waiter in matched {
45
+ waiter.pending.resolve(())
46
+ }
47
+ } else {
48
+ let error = (values["error"] as? String).flatMap { $0.isEmpty ? nil : $0 } ?? "unknown_error"
49
+ for waiter in matched {
50
+ waiter.pending.reject(BluetoothSdkError(
51
+ code: "bes_crash_report_rejected",
52
+ message: "Glasses rejected bes_crash_reported for \(incidentKey): \(error)"
53
+ ))
54
+ }
55
+ }
56
+ return matched.count
57
+ }
58
+
59
+ func rejectAll(_ error: Error) {
60
+ for waiter in waiters {
61
+ waiter.pending.reject(error)
62
+ }
63
+ }
64
+ }
@@ -11,12 +11,12 @@ enum BluetoothSdkDefaults {
11
11
  static let voiceActivityDetectionEnabled = false
12
12
  static let loudnessGateEnabled = true
13
13
 
14
- /// Must stay true. The firmware defaults auto power-off on, and we re-push
15
- /// every Bluetooth setting on connect, so a false default here would
16
- /// silently disable it on every pair the app touches.
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
17
  static let autoPowerOffEnabled = false
18
18
  private static let infoSdkVersionKey = "MentraBluetoothSdkVersion"
19
- private static let swiftPackageSdkVersion = "3.4.0-dev.999"
19
+ private static let swiftPackageSdkVersion = "3.4.1-beta.1409"
20
20
  private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
21
21
 
22
22
  private static func normalizedSdkVersion(_ value: String?) -> String? {
@@ -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],
@@ -152,6 +152,14 @@ struct ViewState {
152
152
  Bridge.saveSetting("mentra_live_secure_firmware", false)
153
153
  }
154
154
 
155
+ /// Whether the forgotten glasses keep former owners' keys is learned again from the next
156
+ /// glasses' `pairing_info`.
157
+ private func clearFormerOwnerKeys() {
158
+ guard DeviceStore.shared.get("bluetooth", "mentra_live_former_owner_keys") as? Bool == true else { return }
159
+ DeviceStore.shared.apply("bluetooth", "mentra_live_former_owner_keys", false)
160
+ Bridge.saveSetting("mentra_live_former_owner_keys", false)
161
+ }
162
+
155
163
  private var pendingWearable: String {
156
164
  get { DeviceStore.shared.get("bluetooth", "pending_wearable") as? String ?? "" }
157
165
  set { DeviceStore.shared.apply("bluetooth", "pending_wearable", newValue) }
@@ -222,14 +230,6 @@ struct ViewState {
222
230
  set { DeviceStore.shared.apply("bluetooth", "sensing_enabled", newValue) }
223
231
  }
224
232
 
225
- /// Phone-side VAD gating switch. Default is OFF (VAD runs) so that the
226
- /// coordinator can drive per-utterance offline/online STT switching from
227
- /// `vad_status` events. Set to `true` only as an emergency kill-switch.
228
- private var bypassVad: Bool {
229
- get { DeviceStore.shared.get("bluetooth", "bypass_vad") as? Bool ?? false }
230
- set { DeviceStore.shared.apply("bluetooth", "bypass_vad", newValue) }
231
- }
232
-
233
233
  private var localSttFallbackActive: Bool {
234
234
  get { DeviceStore.shared.get("bluetooth", "local_stt_fallback_active") as? Bool ?? false }
235
235
  set { DeviceStore.shared.apply("bluetooth", "local_stt_fallback_active", newValue) }
@@ -558,6 +558,11 @@ struct ViewState {
558
558
  }
559
559
 
560
560
  func handlePcm(_ pcmData: Data) {
561
+ // The wake word, phone-side speech activity, and local STT all hear the same 16 kHz mono PCM.
562
+ #if !os(macOS) && (!SWIFT_PACKAGE || MENTRA_FEATURE_LOCAL_STT)
563
+ WakeWordDetector.shared.accept(pcmData)
564
+ SpeechActivityMonitor.shared.accept(pcmData)
565
+ #endif
561
566
  handleSendingPcm(pcmData)
562
567
 
563
568
  // Send PCM to local transcriber.
@@ -747,7 +752,6 @@ struct ViewState {
747
752
  // MARK: - Auxiliary Commands
748
753
 
749
754
  func initSGC(_ wearable: String) {
750
- guard NimoResourceFixture.shared.allowsManager(wearable) else { return }
751
755
  Bridge.log("Initializing manager for wearable: \(wearable)")
752
756
  if sgc != nil && sgc?.type != wearable {
753
757
  Bridge.log("MAN: Manager already initialized, cleaning up previous sgc")
@@ -1009,12 +1013,33 @@ struct ViewState {
1009
1013
  updateMicState()
1010
1014
  }
1011
1015
 
1012
- func restartTranscriber() {
1016
+ /// Whether on-device transcription currently has `path` loaded. Never waits for a load.
1017
+ func isSttModelLoaded(_ path: String) -> Bool {
1018
+ #if !os(macOS) && (!SWIFT_PACKAGE || MENTRA_FEATURE_LOCAL_STT)
1019
+ return transcriber.isModelLoaded(path)
1020
+ #else
1021
+ return false
1022
+ #endif
1023
+ }
1024
+
1025
+ /// Reload the selected model if on-device transcription is in demand. Returns false only
1026
+ /// when that reload failed; true once it loaded or when there is no demand.
1027
+ func restartTranscriber() async -> Bool {
1013
1028
  #if !os(macOS) && (!SWIFT_PACKAGE || MENTRA_FEATURE_LOCAL_STT)
1014
- Bridge.log("MAN: Restarting SherpaOnnxTranscriber via command")
1015
- transcriber.restart()
1029
+ Bridge.log("MAN: Restarting SherpaOnnxTranscriber via command")
1030
+ return await transcriber.restart()
1016
1031
  #else
1017
- Bridge.log("MAN: Local STT is not included in this SwiftPM build")
1032
+ Bridge.log("MAN: Local STT is not included in this SwiftPM build")
1033
+ return true
1034
+ #endif
1035
+ }
1036
+
1037
+ /// End the current on-device utterance. See `SherpaOnnxTranscriber.finishUtterance`.
1038
+ func finishTranscription() async -> String? {
1039
+ #if !os(macOS) && (!SWIFT_PACKAGE || MENTRA_FEATURE_LOCAL_STT)
1040
+ return await transcriber.finishUtterance()
1041
+ #else
1042
+ return nil
1018
1043
  #endif
1019
1044
  }
1020
1045
 
@@ -1572,6 +1597,13 @@ struct ViewState {
1572
1597
  try driver.sendIncidentId(incidentId, apiBaseUrl: apiBaseUrl)
1573
1598
  }
1574
1599
 
1600
+ func sendBesCrashReported(incidentKey: String, reportId: String) throws {
1601
+ guard let driver = sgc else {
1602
+ throw BluetoothSdkError(code: "glasses_not_connected", message: "Cannot report the BES crash because glasses are not connected.")
1603
+ }
1604
+ try driver.sendBesCrashReported(incidentKey: incidentKey, reportId: reportId)
1605
+ }
1606
+
1575
1607
  func sendWifiCredentials(_ ssid: String, _ password: String) {
1576
1608
  Bridge.log("MAN: Sending wifi credentials: \(ssid)")
1577
1609
  sgc?.sendWifiCredentials(ssid, password)
@@ -1904,7 +1936,6 @@ struct ViewState {
1904
1936
  }
1905
1937
 
1906
1938
  func connectDefault(requiresAncs: Bool = true) {
1907
- guard NimoResourceFixture.shared.allowsManager(defaultWearable, name: deviceName) else { return }
1908
1939
  if defaultWearable.isEmpty {
1909
1940
  Bridge.log("MAN: No default wearable, returning")
1910
1941
  return
@@ -1967,13 +1998,11 @@ struct ViewState {
1967
1998
  return
1968
1999
  }
1969
2000
 
1970
- guard NimoResourceFixture.shared.allowsManager(pendingWearable.isEmpty ? defaultWearable : pendingWearable, name: name) else { return }
1971
2001
  if pendingWearable.isEmpty, !defaultWearable.isEmpty {
1972
2002
  Bridge.log("PAIRFLOW: connect_by_name pending=\(defaultWearable)")
1973
2003
  pendingWearable = defaultWearable
1974
2004
  }
1975
2005
 
1976
- guard NimoResourceFixture.shared.allowsManager(pendingWearable, name: name) else { return }
1977
2006
  // if the pending wearable is a controller, don't disconnect, use the controller manager to connect
1978
2007
  if ControllerTypes.ALL.contains(pendingWearable) {
1979
2008
  controller?.disconnect()
@@ -1996,13 +2025,9 @@ struct ViewState {
1996
2025
  }
1997
2026
 
1998
2027
  Bridge.log("PAIRFLOW: connect_by_name decision=new_manager name=\(name)")
1999
- let managerEntry = NimoResourceFixture.shared.beginManagerEntry(pendingWearable)
2000
2028
  Task {
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) }
2029
+ disconnect(clearPendingConnection: false)
2004
2030
  try? await Task.sleep(nanoseconds: 100 * 1_000_000) // 100ms
2005
- guard NimoResourceFixture.shared.allowsManager(self.pendingWearable, name: name) else { return }
2006
2031
  self.searching = true
2007
2032
  self.pendingDeviceName = name
2008
2033
 
@@ -2013,7 +2038,6 @@ struct ViewState {
2013
2038
  }
2014
2039
 
2015
2040
  func connectDevice(_ deviceModel: String, _ deviceName: String) {
2016
- guard NimoResourceFixture.shared.allowsManager(deviceModel, name: deviceName) else { return }
2017
2041
  Bridge.log("MAN: Connecting to device: \(deviceModel) \(deviceName)")
2018
2042
  if DeviceTypes.ALL.contains(deviceModel) {
2019
2043
  pendingWearable = deviceModel
@@ -2122,6 +2146,12 @@ struct ViewState {
2122
2146
  MentraLivePairingStateStore.shared.update("forget") { $0.onForget() }
2123
2147
  clearOwnerLost()
2124
2148
  clearSecureFirmware()
2149
+ clearFormerOwnerKeys()
2150
+ // With no connection object, MentraLive.forget() can't run. Only clear Live's saved
2151
+ // identity when Live is the target: forgetting G1/G2 must not touch a Live unit's.
2152
+ if sgc == nil, defaultWearable.contains(DeviceTypes.LIVE) || pendingWearable.contains(DeviceTypes.LIVE) {
2153
+ MentraLive.clearSavedPeripheral()
2154
+ }
2125
2155
  // Call forget first to stop timers/handlers/reconnect logic
2126
2156
  sgc?.forget()
2127
2157
  disconnect()
@@ -2,8 +2,9 @@ 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."),
6
- ReleaseChangelog(version: "3.3.0", markdown: "This release is under active development. User-facing changes will be documented as they land."),
5
+ ReleaseChangelog(version: "3.4.1", markdown: "- **Pairing:** Pairing your glasses is simpler, with new voice prompts to guide you. Glasses paired before this update keep working with your current phone.\n- **Mentra Call:** Simpler call controls and a free first month.\n- **Miniapps:** Add miniapps from a link or QR code.\n- **Glasses updates:** Updates keep going when your phone switches networks, with clearer messages if something goes wrong.\n- **Photos and gallery:** More reliable photo syncing on iPhone. Your glasses now tell you when their storage is full.\n- **Livestreaming:** Smoother livestreams.\n- **Sound:** Music no longer stays off after a call.\n- **Notes:** Short conversations now get notes too.\n- **Reliability:** Fewer glasses crashes and disconnects."),
6
+ ReleaseChangelog(version: "3.4.0", markdown: "- **Pairing:** Pairing your glasses is simpler, with new voice prompts to guide you.\n- **Mentra Call:** Simpler call controls and a free first month.\n- **Miniapps:** Add miniapps from a link or QR code.\n- **Glasses updates:** Updates keep going when your phone switches networks, with clearer messages if something goes wrong.\n- **Photos and gallery:** More reliable photo syncing on iPhone. Your glasses now tell you when their storage is full.\n- **Livestreaming:** Smoother livestreams.\n- **Sound:** Better speaker sound on Mentra Live, and music no longer stays off after a call.\n- **Notes:** Short conversations now get notes too.\n- **Reliability:** Fewer glasses crashes and disconnects."),
7
+ ReleaseChangelog(version: "3.3.0", markdown: "- **Mentra Call:** Now available on iPhone, with a redesigned call screen and photo sharing during calls.\n- **Microphone:** Improved glasses microphone reliability, including after phone calls.\n- **Photos and gallery:** More reliable photo capture and gallery syncing.\n- **Glasses updates:** More reliable glasses updates, with clearer progress.\n- **Miniapps:** Miniapps now update automatically. Fixed miniapps getting stuck on loading screens.\n- **Mentra AI:** Reliability improvements and bug fixes.\n- **Notes:** Take photos with the glasses camera button, and add meeting and location details to your notes.\n- **Pairing and connections:** Improved glasses audio reconnection on Android.\n- **G1 and NIMO:** Improved text display, including accented letters.\n- **Android tablets:** The Mentra App now rotates to landscape."),
7
8
  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."),
8
9
  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`."),
9
10
  ReleaseChangelog(version: "3.1.1", markdown: "- Improved Google login on iOS.\n- Pairing no longer requires phone microphone access."),
@@ -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.4.0"
6
- static let releaseIdentity = "3.4.0-dev.999"
7
- static let releaseSetId = "mentra-3.4.0-dev.999"
8
- static let sourceCommit = "9a179e6cb8dfaebca82e4f69e6b7515130915cd8"
9
- static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-dev.999.json"
10
- static let otaManifestSha256 = "e4112d567b31e56cd8e56bca94a83bd82fdc82e56670d51a0280b9043433dce1"
5
+ static let familyBaseVersion = "3.4.1"
6
+ static let releaseIdentity = "3.4.1-beta.1409"
7
+ static let releaseSetId = "mentra-3.4.1-beta.1409"
8
+ static let sourceCommit = "0ac9bbe8869f3e269f43ca87f37382076eca8301"
9
+ static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.1/mentra-live-ota-3.4.1-beta.1409.json"
10
+ static let otaManifestSha256 = "c31a58bc0159c019e95a450eda8d546484210ca4ee39f1220951d2e3b2c5abaf"
11
11
  }