@mentra/bluetooth-sdk 3.4.0-dev.999 → 3.4.0

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 (215) hide show
  1. package/MIGRATION.md +16 -7
  2. package/README.md +40 -13
  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 +114 -122
  12. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +2 -2
  13. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
  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 +274 -56
  30. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +5 -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 +3 -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 +2 -2
  93. package/build/generated/changelogCatalog.js +2 -2
  94. package/build/generated/changelogCatalog.js.map +1 -1
  95. package/build/generated/releaseMetadata.js +5 -5
  96. package/build/generated/releaseMetadata.js.map +1 -1
  97. package/build/index.d.ts +1 -1
  98. package/build/index.d.ts.map +1 -1
  99. package/build/index.js +7 -1
  100. package/build/index.js.map +1 -1
  101. package/build/ota-server/MentraOtaServerModule.d.ts +0 -2
  102. package/build/ota-server/MentraOtaServerModule.d.ts.map +1 -1
  103. package/build/ota-server/MentraOtaServerModule.js.map +1 -1
  104. package/build/ota-server/MentraOtaServerModule.web.d.ts +0 -1
  105. package/build/ota-server/MentraOtaServerModule.web.d.ts.map +1 -1
  106. package/build/ota-server/MentraOtaServerModule.web.js +0 -3
  107. package/build/ota-server/MentraOtaServerModule.web.js.map +1 -1
  108. package/build/ota-transport/index.d.ts +3 -3
  109. package/build/ota-transport/index.d.ts.map +1 -1
  110. package/build/ota-transport/index.js +4 -4
  111. package/build/ota-transport/index.js.map +1 -1
  112. package/build/react/useGlassesConnection.d.ts +1 -1
  113. package/build/react/useGlassesConnection.d.ts.map +1 -1
  114. package/build/react/useGlassesConnection.js +3 -3
  115. package/build/react/useGlassesConnection.js.map +1 -1
  116. package/build/react/useMentraBluetooth.d.ts +1 -1
  117. package/build/react/useMentraBluetooth.d.ts.map +1 -1
  118. package/build/react/useMentraBluetooth.js +1 -1
  119. package/build/react/useMentraBluetooth.js.map +1 -1
  120. package/ios/BluetoothSdkModule.swift +73 -22
  121. package/ios/LocalIPv4.swift +0 -61
  122. package/ios/MentraBluetoothSDK.podspec +7 -1
  123. package/ios/MentraOtaServerModule.swift +0 -16
  124. package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
  125. package/ios/Resources/NimoFirmware/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
  126. package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
  127. package/ios/Source/BesCrashReportWaiters.swift +64 -0
  128. package/ios/Source/BluetoothSdkDefaults.swift +4 -4
  129. package/ios/Source/Bridge.swift +14 -0
  130. package/ios/Source/DeviceManager.swift +43 -22
  131. package/ios/Source/GeneratedChangelogCatalog.swift +2 -2
  132. package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
  133. package/ios/Source/MentraBluetoothSDK.swift +35 -16
  134. package/ios/Source/OtaManifest.swift +1 -17
  135. package/ios/Source/audio/PcmStreamPlayer.swift +290 -57
  136. package/ios/Source/audio/PcmUrlPlayback.swift +231 -0
  137. package/ios/Source/audio/SpeechActivity.swift +277 -0
  138. package/ios/Source/events/BluetoothEvents.swift +41 -0
  139. package/ios/Source/internal/BleTraceLogger.swift +14 -1
  140. package/ios/Source/internal/BluetoothAvailability.swift +15 -5
  141. package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +5 -0
  142. package/ios/Source/sgcs/MentraLive.swift +195 -66
  143. package/ios/Source/sgcs/Nimo.swift +249 -276
  144. package/ios/Source/sgcs/NimoCanvasCoordinator.swift +9 -38
  145. package/ios/Source/sgcs/NimoCanvasSession.swift +0 -1
  146. package/ios/Source/sgcs/NimoFirmwareUpdater.swift +260 -0
  147. package/ios/Source/sgcs/NimoOtaProtocol.swift +159 -0
  148. package/ios/Source/sgcs/SGCManager.swift +6 -0
  149. package/ios/Source/streaming/StreamModels.swift +15 -6
  150. package/ios/Source/stt/STTTools.swift +13 -31
  151. package/ios/Source/stt/SherpaOnnxTranscriber.swift +204 -162
  152. package/ios/Source/stt/SileroSpeechActivity.swift +87 -0
  153. package/ios/Source/stt/WakeWordDetector.swift +145 -0
  154. package/ios/Source/utils/BoundedWait.swift +44 -0
  155. package/ios/Source/utils/DemandDrivenAudioWorker.swift +79 -0
  156. package/ios/Source/utils/SttModelTraits.swift +62 -0
  157. package/ios/Tests/BesCrashReportTests.swift +142 -0
  158. package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
  159. package/ios/Tests/DeviceManagerReconnectTests.swift +0 -71
  160. package/ios/Tests/GlassesAudioSetupPolicyTests.swift +9 -3
  161. package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
  162. package/ios/Tests/MentraLiveAudioSetupTests.swift +6 -12
  163. package/ios/Tests/MentraLiveCommandQueueTests.swift +35 -0
  164. package/ios/Tests/MentraLiveSessionReadinessTests.swift +179 -10
  165. package/ios/Tests/NimoCanvasTransportTests.swift +0 -89
  166. package/ios/Tests/NimoOtaProtocolTests.swift +78 -0
  167. package/ios/Tests/PcmStreamTests.swift +299 -0
  168. package/ios/Tests/SpeechActivityTests.swift +238 -0
  169. package/ios/Tests/StreamRequestTests.swift +18 -0
  170. package/ios/Tests/SttModelTraitsTests.swift +62 -0
  171. package/package.json +2 -2
  172. package/plugin/build/withAndroid.js +9 -11
  173. package/plugin/build/withKotlinVersion.d.ts +2 -0
  174. package/plugin/build/withKotlinVersion.js +46 -0
  175. package/src/BluetoothSdk.types.ts +107 -5
  176. package/src/_private/BluetoothSdkModule.ts +45 -8
  177. package/src/_private/MentraLocalNetworkModule.ts +5 -1
  178. package/src/generated/changelogCatalog.ts +2 -2
  179. package/src/generated/releaseMetadata.ts +5 -5
  180. package/src/index.ts +13 -1
  181. package/src/ota-server/MentraOtaServerModule.ts +0 -2
  182. package/src/ota-server/MentraOtaServerModule.web.ts +0 -4
  183. package/src/ota-transport/index.ts +4 -5
  184. package/src/react/useGlassesConnection.ts +4 -4
  185. package/src/react/useMentraBluetooth.ts +2 -2
  186. package/android/silero/LICENSE.md +0 -17
  187. package/android/silero/build.gradle +0 -50
  188. package/android/silero/proguard-rules.pro +0 -24
  189. package/android/silero/src/androidTest/assets/hello.wav +0 -0
  190. package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +0 -79
  191. package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +0 -160
  192. package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +0 -449
  193. package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +0 -15
  194. package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +0 -14
  195. package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +0 -12
  196. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +0 -47
  197. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +0 -41
  198. package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +0 -44
  199. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -368
  200. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocol.kt +0 -156
  201. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -274
  202. package/android/src/main/java/com/mentra/bluetoothsdk/ScopedNetworkReadiness.kt +0 -17
  203. package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +0 -229
  204. package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -20
  205. package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -16
  206. package/android/src/test/java/com/mentra/bluetoothsdk/ScopedNetworkReadinessTest.kt +0 -39
  207. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnosticsTest.kt +0 -287
  208. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt +0 -127
  209. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +0 -851
  210. package/ios/Source/sgcs/NimoMacResourceTransport.swift +0 -217
  211. package/ios/Source/sgcs/NimoResourceFixture.swift +0 -384
  212. package/ios/Source/sgcs/NimoResourceSession.swift +0 -406
  213. package/ios/Tests/NimoResourceSessionTests.swift +0 -476
  214. /package/android/{silero/src/main/assets/LICENSE → src/main/assets/vad/LICENSE.silero_vad} +0 -0
  215. /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.0"
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],
@@ -222,14 +222,6 @@ struct ViewState {
222
222
  set { DeviceStore.shared.apply("bluetooth", "sensing_enabled", newValue) }
223
223
  }
224
224
 
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
225
  private var localSttFallbackActive: Bool {
234
226
  get { DeviceStore.shared.get("bluetooth", "local_stt_fallback_active") as? Bool ?? false }
235
227
  set { DeviceStore.shared.apply("bluetooth", "local_stt_fallback_active", newValue) }
@@ -558,6 +550,11 @@ struct ViewState {
558
550
  }
559
551
 
560
552
  func handlePcm(_ pcmData: Data) {
553
+ // The wake word, phone-side speech activity, and local STT all hear the same 16 kHz mono PCM.
554
+ #if !os(macOS) && (!SWIFT_PACKAGE || MENTRA_FEATURE_LOCAL_STT)
555
+ WakeWordDetector.shared.accept(pcmData)
556
+ SpeechActivityMonitor.shared.accept(pcmData)
557
+ #endif
561
558
  handleSendingPcm(pcmData)
562
559
 
563
560
  // Send PCM to local transcriber.
@@ -747,7 +744,6 @@ struct ViewState {
747
744
  // MARK: - Auxiliary Commands
748
745
 
749
746
  func initSGC(_ wearable: String) {
750
- guard NimoResourceFixture.shared.allowsManager(wearable) else { return }
751
747
  Bridge.log("Initializing manager for wearable: \(wearable)")
752
748
  if sgc != nil && sgc?.type != wearable {
753
749
  Bridge.log("MAN: Manager already initialized, cleaning up previous sgc")
@@ -1009,12 +1005,33 @@ struct ViewState {
1009
1005
  updateMicState()
1010
1006
  }
1011
1007
 
1012
- func restartTranscriber() {
1008
+ /// Whether on-device transcription currently has `path` loaded. Never waits for a load.
1009
+ func isSttModelLoaded(_ path: String) -> Bool {
1010
+ #if !os(macOS) && (!SWIFT_PACKAGE || MENTRA_FEATURE_LOCAL_STT)
1011
+ return transcriber.isModelLoaded(path)
1012
+ #else
1013
+ return false
1014
+ #endif
1015
+ }
1016
+
1017
+ /// Reload the selected model if on-device transcription is in demand. Returns false only
1018
+ /// when that reload failed; true once it loaded or when there is no demand.
1019
+ func restartTranscriber() async -> Bool {
1013
1020
  #if !os(macOS) && (!SWIFT_PACKAGE || MENTRA_FEATURE_LOCAL_STT)
1014
- Bridge.log("MAN: Restarting SherpaOnnxTranscriber via command")
1015
- transcriber.restart()
1021
+ Bridge.log("MAN: Restarting SherpaOnnxTranscriber via command")
1022
+ return await transcriber.restart()
1016
1023
  #else
1017
- Bridge.log("MAN: Local STT is not included in this SwiftPM build")
1024
+ Bridge.log("MAN: Local STT is not included in this SwiftPM build")
1025
+ return true
1026
+ #endif
1027
+ }
1028
+
1029
+ /// End the current on-device utterance. See `SherpaOnnxTranscriber.finishUtterance`.
1030
+ func finishTranscription() async -> String? {
1031
+ #if !os(macOS) && (!SWIFT_PACKAGE || MENTRA_FEATURE_LOCAL_STT)
1032
+ return await transcriber.finishUtterance()
1033
+ #else
1034
+ return nil
1018
1035
  #endif
1019
1036
  }
1020
1037
 
@@ -1572,6 +1589,13 @@ struct ViewState {
1572
1589
  try driver.sendIncidentId(incidentId, apiBaseUrl: apiBaseUrl)
1573
1590
  }
1574
1591
 
1592
+ func sendBesCrashReported(incidentKey: String, reportId: String) throws {
1593
+ guard let driver = sgc else {
1594
+ throw BluetoothSdkError(code: "glasses_not_connected", message: "Cannot report the BES crash because glasses are not connected.")
1595
+ }
1596
+ try driver.sendBesCrashReported(incidentKey: incidentKey, reportId: reportId)
1597
+ }
1598
+
1575
1599
  func sendWifiCredentials(_ ssid: String, _ password: String) {
1576
1600
  Bridge.log("MAN: Sending wifi credentials: \(ssid)")
1577
1601
  sgc?.sendWifiCredentials(ssid, password)
@@ -1904,7 +1928,6 @@ struct ViewState {
1904
1928
  }
1905
1929
 
1906
1930
  func connectDefault(requiresAncs: Bool = true) {
1907
- guard NimoResourceFixture.shared.allowsManager(defaultWearable, name: deviceName) else { return }
1908
1931
  if defaultWearable.isEmpty {
1909
1932
  Bridge.log("MAN: No default wearable, returning")
1910
1933
  return
@@ -1967,13 +1990,11 @@ struct ViewState {
1967
1990
  return
1968
1991
  }
1969
1992
 
1970
- guard NimoResourceFixture.shared.allowsManager(pendingWearable.isEmpty ? defaultWearable : pendingWearable, name: name) else { return }
1971
1993
  if pendingWearable.isEmpty, !defaultWearable.isEmpty {
1972
1994
  Bridge.log("PAIRFLOW: connect_by_name pending=\(defaultWearable)")
1973
1995
  pendingWearable = defaultWearable
1974
1996
  }
1975
1997
 
1976
- guard NimoResourceFixture.shared.allowsManager(pendingWearable, name: name) else { return }
1977
1998
  // if the pending wearable is a controller, don't disconnect, use the controller manager to connect
1978
1999
  if ControllerTypes.ALL.contains(pendingWearable) {
1979
2000
  controller?.disconnect()
@@ -1996,13 +2017,9 @@ struct ViewState {
1996
2017
  }
1997
2018
 
1998
2019
  Bridge.log("PAIRFLOW: connect_by_name decision=new_manager name=\(name)")
1999
- let managerEntry = NimoResourceFixture.shared.beginManagerEntry(pendingWearable)
2000
2020
  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) }
2021
+ disconnect(clearPendingConnection: false)
2004
2022
  try? await Task.sleep(nanoseconds: 100 * 1_000_000) // 100ms
2005
- guard NimoResourceFixture.shared.allowsManager(self.pendingWearable, name: name) else { return }
2006
2023
  self.searching = true
2007
2024
  self.pendingDeviceName = name
2008
2025
 
@@ -2013,7 +2030,6 @@ struct ViewState {
2013
2030
  }
2014
2031
 
2015
2032
  func connectDevice(_ deviceModel: String, _ deviceName: String) {
2016
- guard NimoResourceFixture.shared.allowsManager(deviceModel, name: deviceName) else { return }
2017
2033
  Bridge.log("MAN: Connecting to device: \(deviceModel) \(deviceName)")
2018
2034
  if DeviceTypes.ALL.contains(deviceModel) {
2019
2035
  pendingWearable = deviceModel
@@ -2122,6 +2138,11 @@ struct ViewState {
2122
2138
  MentraLivePairingStateStore.shared.update("forget") { $0.onForget() }
2123
2139
  clearOwnerLost()
2124
2140
  clearSecureFirmware()
2141
+ // With no connection object, MentraLive.forget() can't run. Only clear Live's saved
2142
+ // identity when Live is the target: forgetting G1/G2 must not touch a Live unit's.
2143
+ if sgc == nil, defaultWearable.contains(DeviceTypes.LIVE) || pendingWearable.contains(DeviceTypes.LIVE) {
2144
+ MentraLive.clearSavedPeripheral()
2145
+ }
2125
2146
  // Call forget first to stop timers/handlers/reconnect logic
2126
2147
  sgc?.forget()
2127
2148
  disconnect()
@@ -2,8 +2,8 @@ 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.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."),
6
+ 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
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."),
8
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`."),
9
9
  ReleaseChangelog(version: "3.1.1", markdown: "- Improved Google login on iOS.\n- Pairing no longer requires phone microphone access."),
@@ -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.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"
6
+ static let releaseIdentity = "3.4.0"
7
+ static let releaseSetId = "mentra-3.4.0"
8
+ static let sourceCommit = "7fb33495a2971401485fae59afc83fd4c185eca8"
9
+ static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1390.json"
10
+ static let otaManifestSha256 = "b2f3cbd2b7dcc5bfc26f3569e13ad93d44e1b1bfaba76d5219050755fa6df781"
11
11
  }