@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
package/MIGRATION.md CHANGED
@@ -1,21 +1,30 @@
1
- # Bluetooth SDK migration: Mentra Live pairing state
1
+ # Bluetooth SDK migration
2
2
 
3
- This note covers the public pairing API in `@mentra/bluetooth-sdk` `3.3.0` relative to the published `3.2.1` package. `3.3.0` is the current release family in `package.json` and is not on npm yet.
3
+ Public API changes in `@mentra/bluetooth-sdk`, for apps upgrading from an earlier release.
4
4
 
5
- ## Version
5
+ ## `3.4.0`: `unpair()` replaces `clearDefaultDevice()`
6
+
7
+ - `clearDefaultDevice()` is removed, in TypeScript, Kotlin and Swift. It forgot the saved default device but left the phone bonded with the glasses, so the next pairing skipped pairing mode.
8
+ - Use `unpair()`: it disconnects, forgets the default device and, on Mentra Live, removes the phone's Bluetooth bond, so pairing again starts from pairing mode. `forget()` is unchanged.
9
+
10
+ ## `3.3.0`: Mentra Live pairing state
11
+
12
+ This covers the public pairing API change in `3.3.0`, for apps upgrading from `3.2`.
13
+
14
+ ### Version
6
15
 
7
16
  The SDK version is `package.json` `"version"`. The iOS podspec (`ios/MentraBluetoothSDK.podspec`) and the Android Gradle module (`android/build.gradle`) read that same value. Swift package metadata is injected from it at pack time.
8
17
 
9
- This repository keeps the Bluetooth SDK version aligned with the matching Mentra Live software release. It does not cut an independent major for a breaking SDK change. The break below ships in the unpublished `3.3.0` family. No further version bump was applied in this change. Integrators on `3.2.1` pick it up by moving to `3.3.0` when that release is published.
18
+ This repository keeps the Bluetooth SDK version aligned with the matching Mentra Live software release. It does not cut an independent major for a breaking SDK change. The break below shipped in `3.3.0`. Apps on `3.2.1` pick it up by moving to `3.3.0` or later.
10
19
 
11
- ## Removed
20
+ ### Removed
12
21
 
13
22
  - `confirmReplaceOwner()` is removed.
14
23
  - The `confirm_replace_owner_result` event and its types are removed.
15
24
  - `owner_replaced` is deprecated and is never emitted. Remove listeners. Use `pairing_state_changed` or `GlassesStatus.pairingState`.
16
25
  - `pairing_info` no longer includes `awaiting_confirm` or `retained_owner_link`.
17
26
 
18
- ## Added
27
+ ### Added
19
28
 
20
29
  `GlassesStatus.pairingState` (absent on models other than Mentra Live):
21
30
 
@@ -54,7 +63,7 @@ Other additions:
54
63
  - `pairing_info.auto_audio` is true when the glasses derive Classic audio from the LE pair (CTKD). The SDK already uses it for `audioSetup`.
55
64
  - `pair_failure.code` may be `"ios_forget_pairing"`: iOS holds a stale Bluetooth pairing for these glasses during an explicit attempt. The user must open Settings > Bluetooth, choose Forget This Device, then pair again. On Android and iOS native apps this arrives as the pairing-failure error's `failureCode`.
56
65
 
57
- ## Behavior
66
+ ### Behavior
58
67
 
59
68
  On supported Mentra Live firmware, three presses of the power button open one 120-second pairing window. The glasses speak a 4-character code. Three presses again cancel the window. After a timeout or a cancel, the phone that was already paired reconnects automatically. If another phone pairs, that previous phone gets `pairing_rejected`. Pairing readiness needs no app-side `pairing_info` wait: the SDK reports the glasses ready only after secure firmware commits the bond, and treats glasses that send no `pairing_info` within 5 seconds as older firmware.
60
69
 
package/README.md CHANGED
@@ -46,6 +46,8 @@ changes. Adding this JS package alone cannot reroute logs in an older binary.
46
46
  - React Native `0.72+`.
47
47
  - Expo `49+` when using Expo.
48
48
  - Android min SDK `28+`.
49
+ - Android source builds use Kotlin `2.3.0+`; the Expo config plugin selects it
50
+ automatically. The public Maven SDK still targets Kotlin 2.1 consumers.
49
51
  - iOS deployment target `15.1+`.
50
52
  - Native macOS deployment target `13+`. The Starter Kit's separate
51
53
  `react-native-macos` host requires macOS `14+` and a matching React Native / Expo
@@ -444,13 +446,18 @@ const discoveredDevice = await scanAndChooseDevice()
444
446
  await BluetoothSdk.connect(discoveredDevice)
445
447
  await saveDeviceToYourAppStorage(discoveredDevice)
446
448
 
447
- await BluetoothSdk.clearDefaultDevice()
449
+ await BluetoothSdk.unpair()
448
450
  await saveDeviceToYourAppStorage(null)
449
451
  ```
450
452
 
451
453
  ## Mentra Live pairing
452
454
 
453
- `confirmReplaceOwner()` and `confirm_replace_owner_result` are removed. `owner_replaced` is deprecated and is never emitted. The replacement is `GlassesStatus.pairingState`, also delivered as `pairing_state_changed`. Full steps are in [MIGRATION.md](./MIGRATION.md). The version stays `3.3.0` in `package.json` (podspec and Gradle read it). npm still publishes `3.2.1`.
455
+ React Native apps should use `MentraLivePairingFlow` or `useMentraLivePairing` from
456
+ `@mentra/engine/pairing`. They provide the same scan, bond adoption, connect, Pair
457
+ Audio and failure flow as the Mentra App. See
458
+ [Pair Mentra Live](https://docs.mentraglass.com/bluetooth-sdk/pairing).
459
+
460
+ `confirmReplaceOwner()` and `confirm_replace_owner_result` are removed. `owner_replaced` is deprecated and is never emitted. The replacement is `GlassesStatus.pairingState`, also delivered as `pairing_state_changed`. SDK `3.3.0` removed them; apps upgrading from `3.2` follow [MIGRATION.md](./MIGRATION.md).
454
461
 
455
462
  On supported Mentra Live firmware, three power-button presses open one 120-second window and the glasses speak a 4-character code. Three presses again cancel it. The phone that was already paired pauses automatic reconnect for that window plus a 30-second margin (`pairingState.endsAtMs`), then reconnects after `pairing_mode_ended` with `reason` `"timeout"` or `"cancelled"`. If the glasses stop accepting this phone (another phone paired, or repeated authentication rejections on secure-pairing firmware), this phone's state becomes `pairing_rejected`: reconnect stops, and the UI should show Pair Again. That state clears only after a successful explicit pair or `forget()`.
456
463
 
@@ -469,7 +476,7 @@ BluetoothSdk.addListener("pair_failure", (event) => {
469
476
  })
470
477
  ```
471
478
 
472
- `entering_pairing_mode` includes `window_id`. `pairing_info` includes `auto_audio` and no longer includes `awaiting_confirm` or `retained_owner_link`. Do not use the word "owner" in user-facing sample copy.
479
+ `entering_pairing_mode` includes `window_id`. `pairing_info` includes `auto_audio` and no longer includes `awaiting_confirm` or `retained_owner_link`. With `former_owner_keys: true` the glasses keep this phone's keys after another phone takes them over or this phone unpairs, and take it back in pairing mode with the pairing it has: the SDK keeps the phone's Bluetooth pairing on Android, and an iOS app need not send the person to forget the glasses in Settings after Unpair. Do not use the word "owner" in user-facing sample copy.
473
480
 
474
481
  ## Glasses audio setup
475
482
 
@@ -664,7 +671,7 @@ Engine coordinator:
664
671
 
665
672
  Release CI embeds an immutable manifest URL and checksum into every published
666
673
  SDK distribution. The completed coordinated release record correlates the SDK
667
- package with its exact manifest and OTA bundle. A completed release is available at
674
+ package with its exact manifest and, for beta and stable releases, its OTA bundle. A completed release is available at
668
675
  `https://github.com/Mentra-Community/MentraOS/releases/tag/mentra-v<releaseIdentity>`
669
676
  and contains `mentra-release-<releaseIdentity>.json`, which records the exact
670
677
  package coordinates, asset URLs, sizes, checksums, and build provenance.
@@ -679,10 +686,11 @@ Android/iOS OTA contract or infrastructure beneath a coordinator. React Native
679
686
  application pages should render Mentra Engine's semantic controller state
680
687
  instead of sequencing raw events.
681
688
 
682
- Each coordinated prerelease publishes a portable OTA bundle. Stable releases
683
- promote the exact beta-tested OTA bytes, so always resolve the bundle coordinate
684
- and URL from `mentra-release-<releaseIdentity>.json` rather than constructing a
685
- filename. The selected archive contains
689
+ Each beta release publishes a portable OTA bundle; development releases do not.
690
+ A stable release publishes byte-identical copies of the promoted beta's OTA
691
+ manifest and bundle under its own names, so always resolve the bundle
692
+ coordinate and URL from `mentra-release-<releaseIdentity>.json` rather than
693
+ constructing a filename. The selected archive contains
686
694
  `version.template.json`, every referenced ASG/MTK/BES artifact, `SHA256SUMS`,
687
695
  and a dependency-free configuration script. After unpacking it, generate the
688
696
  final manifest for its exact hosting URL:
@@ -865,10 +873,28 @@ MentraOS repo root:
865
873
  ./scripts/check-android-compile.sh bluetooth-sdk
866
874
  ```
867
875
 
868
- The `android/` folder in this package is source for the generated Expo Android
869
- project, not the local Gradle entrypoint. The check script prepares
870
- `mobile/android` and uses its Gradle wrapper with `-PmentraPublicSdk=true`,
871
- matching the CI release workflow's public SDK dependency mode.
876
+ The check script prepares `mobile/android` and uses its Gradle wrapper with
877
+ `-PmentraPublicSdk=true`, matching the CI release workflow's public SDK
878
+ dependency mode. Inside an Expo app, the `android/` folder in this package is
879
+ included by autolinking as `:mentra-bluetooth-sdk`.
880
+
881
+ A plain Android app can also build the native SDK from a MentraOS checkout,
882
+ without publishing it to Maven local, through a Gradle composite build. In the
883
+ app's `settings.gradle.kts`:
884
+
885
+ ```kotlin
886
+ includeBuild("/path/to/MentraOS/mobile/modules/bluetooth-sdk/android") {
887
+ dependencySubstitution {
888
+ substitute(module("com.mentraglass:bluetooth-sdk")).using(project(":"))
889
+ }
890
+ }
891
+ ```
892
+
893
+ The app keeps its `com.mentraglass:bluetooth-sdk` dependency; Gradle replaces it
894
+ with the source build. This standalone build has the same dependencies as the
895
+ Maven Central artifact (`-PmentraPublicSdk=true` is its default) and leaves out
896
+ the Expo adapter classes, which need an Expo host. It needs the Android NDK for
897
+ `lc3Lib`.
872
898
 
873
899
  For bare native iOS or macOS apps, use the public SwiftPM repository:
874
900
 
@@ -878,7 +904,7 @@ https://github.com/Mentra-Community/mentra-bluetooth-sdk-ios.git
878
904
 
879
905
  Select a coordinated SDK version that includes your target platform, then add
880
906
  the `MentraBluetoothSDK` product to your app target. Native macOS support is new
881
- on `dev`; use the local source override until a supporting release is published.
907
+ on `dev`; use the local package below until a supporting release is published.
882
908
 
883
909
  For local SDK development, add this package folder directly in Xcode:
884
910
 
@@ -894,7 +920,8 @@ permission/audio-input capability for host microphone capture and network-server
894
920
  capability for local SDK servers. macOS uses CoreAudio instead of
895
921
  `AVAudioSession`; it does not provide iOS background modes or ANCS relay. See
896
922
  [the macOS integration guide](../../../mintlify-docs/bluetooth-sdk/macos.mdx)
897
- and the Starter Kit's `examples/macos` and `examples/react-native-macos` hosts.
923
+ and the [`examples/bluetooth/macos`](../../../examples/bluetooth/macos/README.md) and
924
+ [`examples/bluetooth/react-native-macos`](../../../examples/bluetooth/react-native-macos/README.md) hosts.
898
925
 
899
926
  Maintainers publishing the public SwiftPM mirror should follow
900
927
  [RELEASING_IOS_SPM.md](./RELEASING_IOS_SPM.md).
@@ -8,7 +8,14 @@ apply plugin: 'signing'
8
8
  def packageJson = new JsonSlurper().parse(file("../package.json"))
9
9
  def mavenGroupId = 'com.mentraglass'
10
10
  def mavenPublishVersion = (findProperty('mentraMavenVersion') ?: System.getenv('MENTRA_MAVEN_VERSION') ?: packageJson.version).toString()
11
- def publicMavenSdk = (findProperty('mentraPublicSdk') ?: System.getenv('MENTRA_PUBLIC_SDK') ?: 'false').toString().toBoolean()
11
+ // Inside an Expo host such as the MentraOS app, autolinking provides
12
+ // :expo-modules-core. Without it, this directory is the root of a standalone
13
+ // build (settings.gradle), for example a composite build in a plain Android app.
14
+ // expo-modules-core has no prebuilt Android artifact to resolve instead, so a
15
+ // standalone build leaves out the Expo adapter classes and defaults to the
16
+ // public Maven artifact's dependency shape.
17
+ def standaloneBuild = findProject(':expo-modules-core') == null
18
+ def publicMavenSdk = (findProperty('mentraPublicSdk') ?: System.getenv('MENTRA_PUBLIC_SDK') ?: standaloneBuild.toString()).toString().toBoolean()
12
19
 
13
20
  // Download Sherpa-ONNX Android AAR from the upstream GitHub release and stage
14
21
  // it as a Maven artifact in a tiny on-disk repository under libs/maven/.
@@ -88,7 +95,7 @@ if (!sherpaOnnxAar.exists()) {
88
95
  }
89
96
 
90
97
  // Minimal POM so the Maven resolver is happy. No transitive deps — the AAR
91
- // ships its own native libs and we already pin onnxruntime separately below.
98
+ // ships its own native libs, including its own libonnxruntime.so.
92
99
  if (!sherpaOnnxPom.exists()) {
93
100
  sherpaOnnxPom.text = """<?xml version="1.0" encoding="UTF-8"?>
94
101
  <project xmlns="http://maven.apache.org/POM/4.0.0">
@@ -181,13 +188,38 @@ gradle.taskGraph.whenReady {
181
188
  }
182
189
  }
183
190
 
184
- def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
185
- apply from: expoModulesCorePlugin
186
- applyKotlinExpoModulesCorePlugin()
187
- useExpoPublishing()
191
+ if (standaloneBuild) {
192
+ apply plugin: 'kotlin-android'
193
+ // Java 17 bytecode, as in the MentraOS app build.
194
+ android {
195
+ compileOptions {
196
+ sourceCompatibility JavaVersion.VERSION_17
197
+ targetCompatibility JavaVersion.VERSION_17
198
+ }
199
+ }
200
+ kotlin {
201
+ compilerOptions {
202
+ jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
203
+ }
204
+ }
205
+ // Expo adapters, compiled only inside an Expo host (see expo-module.config.json).
206
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
207
+ exclude(
208
+ '**/com/mentra/bluetoothsdk/BluetoothSdkModule.kt',
209
+ '**/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt',
210
+ '**/com/mentra/bluetoothsdk/otaserver/MentraOtaServerModule.kt',
211
+ '**/com/mentra/bluetoothsdk/photoreceiver/MentraPhotoReceiverModule.kt'
212
+ )
213
+ }
214
+ } else {
215
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
216
+ apply from: expoModulesCorePlugin
217
+ applyKotlinExpoModulesCorePlugin()
218
+ useExpoPublishing()
219
+ }
188
220
 
189
- // Hosts that embed @mentra/crust compile with Kotlin 2.3 (its QuickJS library
190
- // requires it). Keep the public Maven artifact usable from Kotlin 2.1 builds:
221
+ // Source builds use Kotlin 2.3 for avif-coder (and Crust's QuickJS when present).
222
+ // Keep the public Maven artifact usable from Kotlin 2.1 builds:
191
223
  // 2.2 metadata (a 2.1 compiler reads one version ahead; 2.2 is also the lowest
192
224
  // language version that reads the 2.3 expo-modules-core classes compiled here),
193
225
  // 2.1 stdlib APIs, and a kotlin-stdlib 2.1.20 dependency in the POM.
@@ -225,6 +257,9 @@ if (useManagedAndroidSdkVersions) {
225
257
 
226
258
  android {
227
259
  namespace "com.mentra.bluetoothsdk"
260
+ buildFeatures {
261
+ buildConfig true
262
+ }
228
263
  defaultConfig {
229
264
  versionCode 1
230
265
  versionName project.version
@@ -255,7 +290,9 @@ android {
255
290
  dependencies {
256
291
  // Expo adapter class is compiled into the MentraOS module, but the bare SDK
257
292
  // artifact should not expose Expo as a runtime dependency.
258
- compileOnly project(':expo-modules-core')
293
+ if (!standaloneBuild) {
294
+ compileOnly project(':expo-modules-core')
295
+ }
259
296
 
260
297
  // Kotlin standard library (explicitly added for IDE support)
261
298
  // Version is managed by Expo modules, but explicit dependency helps IDE indexing
@@ -278,13 +315,15 @@ dependencies {
278
315
  implementation 'androidx.exifinterface:exifinterface:1.3.7'
279
316
 
280
317
  // AVIF decode for BLE photo fallback. Public Maven artifacts omit this
281
- // JitPack-only decoder from runtime metadata; Android 12+ can still use the
282
- // platform decoder, while MentraOS app builds keep HeifCoder for broader
283
- // fallback support.
284
- // Pinned to the JitPack 1.7.3 build (same as asg_client): the Maven Central
285
- // 2.2.x releases transitively pull kotlin-stdlib 2.3.0, which breaks this
286
- // project's Kotlin 2.1 compile of :expo.
287
- dependencies.add(publicMavenSdk ? 'compileOnly' : 'implementation', 'com.github.awxkee:avif-coder:1.7.3')
318
+ // decoder from runtime metadata; Android 12+ can still use the platform
319
+ // decoder, while MentraOS app builds keep Coder for broader fallback.
320
+ // 3.0.0 ships 16 KB-aligned libcoder.so (1.7.3 was 4 KB). Its POM depends
321
+ // on kotlin-stdlib 2.3.0. Exclude it to keep the public SDK's runtime
322
+ // dependencies on 2.1; the Expo plugin selects a 2.3 source compiler to
323
+ // read the decoder's metadata, independently of this stdlib exclusion.
324
+ dependencies.add(publicMavenSdk ? 'compileOnly' : 'implementation', 'io.github.awxkee:avif-coder:3.0.0') {
325
+ exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
326
+ }
288
327
 
289
328
  testImplementation 'junit:junit:4.13.2'
290
329
  testImplementation 'org.robolectric:robolectric:4.11.1'
@@ -308,28 +347,18 @@ dependencies {
308
347
  // Maven Central/Google repositories for normal SDK use.
309
348
  def optionalMentraOsIntegrationDependency = publicMavenSdk ? 'compileOnly' : 'implementation'
310
349
 
311
- // Sherpa-ONNX for local transcription. Jitpack's v1.13.2 build failed
312
- // upstream, so we stage the prebuilt AAR into libs/maven/ (see top of file)
313
- // and consume it as a Maven coord — AGP rejects raw files() .aar deps in
314
- // library modules.
350
+ // Sherpa-ONNX for on-device transcription, the wake word and Silero speech
351
+ // activity (com.k2fsa.sherpa.onnx.Vad, model in src/main/assets/vad/).
352
+ // Jitpack's v1.13.2 build failed upstream, so we stage the prebuilt AAR into
353
+ // libs/maven/ (see top of file) and consume it as a Maven coord — AGP rejects
354
+ // raw files() .aar deps in library modules.
315
355
  dependencies.add(optionalMentraOsIntegrationDependency, "${sherpaOnnxGroup}:${sherpaOnnxArtifact}:${sherpaOnnxVersion}@aar")
316
356
 
317
357
  if (!publicMavenSdk) {
318
- // Silero VAD — vendored source under silero/, wired as :silero
319
- // sub-project (see settings.gradle). This replaces the previous Jitpack AAR
320
- // (com.github.gkonovalov:android-vad:2.0.9) whose prebuilt JNI was bound to
321
- // an ORT version incompatible with the one bundled by sherpa-onnx, causing a
322
- // dlopen UnsatisfiedLinkError for OrtGetApiBase at VAD startup. By owning the
323
- // source we control both the Java API surface and the ORT version it links
324
- // against; today both consumers (Silero VAD and sherpa-onnx) load their own
325
- // libonnxruntime.so — see packagingOptions pickFirst above.
326
- implementation project(':silero')
327
-
328
358
  // Vuzix Z100
329
359
  implementation 'com.vuzix:ultralite-sdk-android:1.8'
330
360
  implementation 'com.squareup.picasso:picasso:2.8'
331
361
  } else {
332
- compileOnly project(':silero')
333
362
  compileOnly 'com.vuzix:ultralite-sdk-android:1.8'
334
363
  compileOnly 'com.squareup.picasso:picasso:2.8'
335
364
  }
@@ -338,26 +367,6 @@ dependencies {
338
367
  implementation 'com.google.protobuf:protobuf-java-util:4.32.0'
339
368
  }
340
369
 
341
- // Pin onnxruntime-android to 1.24.3 — the version sherpa-onnx 1.13.2 was built
342
- // against (its libonnxruntime.so exports OrtGetApiBase@@VERS_1.24.3). Matching
343
- // this lets the :silero VAD module share a single libonnxruntime.so with
344
- // sherpa-onnx, resolving the ELF symbol-versioning conflict that crashed VAD
345
- // startup on previous mismatched versions.
346
- configurations.all {
347
- resolutionStrategy {
348
- eachDependency { DependencyResolveDetails details ->
349
- if (details.requested.group == 'com.microsoft.onnxruntime') {
350
- details.useVersion '1.24.3'
351
- details.because('Match sherpa-onnx 1.13.2 ORT 1.24.3')
352
- }
353
- if (details.requested.name == 'onnxruntime-android') {
354
- details.useVersion '1.24.3'
355
- details.because('Match sherpa-onnx 1.13.2 ORT 1.24.3')
356
- }
357
- }
358
- }
359
- }
360
-
361
370
  afterEvaluate {
362
371
  publishing {
363
372
  publications {
@@ -0,0 +1,3 @@
1
+ # Used when this directory is the root of a standalone build (settings.gradle).
2
+ # Inside an Expo host, the host's own gradle.properties sets the same value.
3
+ android.useAndroidX=true
@@ -1,4 +1,48 @@
1
- include ':lc3Lib'
1
+ // Standalone build of the Bluetooth SDK's Android library, used when this
2
+ // directory is the root of a Gradle build: for example a plain Android app that
3
+ // consumes the SDK from source through a composite build,
4
+ // includeBuild("<MentraOS>/mobile/modules/bluetooth-sdk/android")
5
+ // with com.mentraglass:bluetooth-sdk substituted by project(":").
6
+ // The MentraOS app (an Expo host) ignores this file: Expo autolinking adds this
7
+ // directory as :mentra-bluetooth-sdk, and the SDK's config plugin adds :lc3Lib
8
+ // to the host's own settings.gradle.
9
+
10
+ gradle.rootProject { project ->
11
+ // Same versions as the MentraOS app's generated Android project. AGP refuses
12
+ // two versions in one composite build, so when this build is included in an
13
+ // app, use the AGP version on that app's root build classpath.
14
+ def androidGradlePluginVersion = '8.12.0'
15
+ def appGradle = gradle.parent
16
+ if (appGradle != null) {
17
+ try {
18
+ androidGradlePluginVersion = appGradle.rootProject.buildscript.classLoader
19
+ .loadClass('com.android.Version')
20
+ .getField('ANDROID_GRADLE_PLUGIN_VERSION')
21
+ .get(null)
22
+ } catch (ClassNotFoundException ignored) {
23
+ // The app does not load AGP in its root build; keep the default.
24
+ }
25
+ }
26
+
27
+ project.buildscript {
28
+ repositories {
29
+ google()
30
+ mavenCentral()
31
+ }
32
+ dependencies {
33
+ classpath "com.android.tools.build:gradle:${androidGradlePluginVersion}"
34
+ classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.0'
35
+ }
36
+ }
37
+ }
2
38
 
3
- include ':silero'
4
- project(':silero').projectDir = new File(rootDir, 'silero')
39
+ gradle.beforeProject { project ->
40
+ project.repositories {
41
+ google()
42
+ mavenCentral()
43
+ }
44
+ }
45
+
46
+ rootProject.name = 'mentra-bluetooth-sdk'
47
+
48
+ include ':lc3Lib'
@@ -0,0 +1,68 @@
1
+ package com.mentra.bluetoothsdk
2
+
3
+ import kotlinx.coroutines.CompletableDeferred
4
+ import kotlinx.coroutines.withTimeoutOrNull
5
+
6
+ /**
7
+ * Correlates `bes_crash_reported` commands with the glasses' `bes_crash_reported_ack`.
8
+ *
9
+ * Each call owns one waiter keyed by (incidentKey, reportId), so concurrent reports for
10
+ * different incidents, or a stale ack for an earlier reportId, never settle each other.
11
+ */
12
+ internal class BesCrashReportWaiters {
13
+ private class Waiter(val incidentKey: String, val reportId: String) {
14
+ val result = CompletableDeferred<Unit>()
15
+ }
16
+
17
+ private val waiters = mutableListOf<Waiter>()
18
+
19
+ /** Registers before [send] so an immediate ack cannot be missed. */
20
+ suspend fun await(incidentKey: String, reportId: String, timeoutMs: Long, send: () -> Unit) {
21
+ val waiter = Waiter(incidentKey, reportId)
22
+ synchronized(waiters) { waiters.add(waiter) }
23
+ try {
24
+ send()
25
+ withTimeoutOrNull(timeoutMs) { waiter.result.await() }
26
+ ?: throw BluetoothSdkException(
27
+ "request_timeout",
28
+ "bes_crash_reported for $incidentKey timed out waiting for the glasses ack.",
29
+ )
30
+ } finally {
31
+ synchronized(waiters) { waiters.remove(waiter) }
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Settles the waiters this ack answers. `ok:true` must echo the reportId; an `ok:false`
37
+ * without a reportId rejects every waiter for that incidentKey. Returns the number settled.
38
+ */
39
+ fun onAck(values: Map<String, Any>): Int {
40
+ val incidentKey = values["incidentKey"] as? String ?: return 0
41
+ val reportId = (values["reportId"] as? String)?.takeIf { it.isNotEmpty() }
42
+ val ok = values["ok"] == true
43
+ val matched = synchronized(waiters) {
44
+ waiters.filter {
45
+ it.incidentKey == incidentKey && (it.reportId == reportId || (!ok && reportId == null))
46
+ }
47
+ }
48
+ if (ok) {
49
+ matched.forEach { it.result.complete(Unit) }
50
+ } else {
51
+ val error = (values["error"] as? String)?.takeIf { it.isNotEmpty() } ?: "unknown_error"
52
+ matched.forEach {
53
+ it.result.completeExceptionally(
54
+ BluetoothSdkException(
55
+ "bes_crash_report_rejected",
56
+ "Glasses rejected bes_crash_reported for $incidentKey: $error",
57
+ )
58
+ )
59
+ }
60
+ }
61
+ return matched.size
62
+ }
63
+
64
+ fun rejectAll(error: Throwable) {
65
+ val snapshot = synchronized(waiters) { waiters.toList() }
66
+ snapshot.forEach { it.result.completeExceptionally(error) }
67
+ }
68
+ }
@@ -5,6 +5,10 @@ object BluetoothSdkDefaults {
5
5
  const val VOICE_ACTIVITY_DETECTION_ENABLED = false
6
6
  const val LOUDNESS_GATE_ENABLED = true
7
7
 
8
- /** Off until someone turns it on in Super Mode. Re-pushed on connect. */
8
+ /**
9
+ * Must match the firmware and Mentra App default (off). Re-pushed on
10
+ * connect, so a true value here turns on the 20-minute unworn power-off on
11
+ * every pair the app touches.
12
+ */
9
13
  const val AUTO_POWER_OFF_ENABLED = false
10
14
  }
@@ -271,6 +271,10 @@ class BluetoothSdkModule : Module() {
271
271
  sendEvent("ota_status", event.values)
272
272
  }
273
273
 
274
+ override fun onBesCrashDetected(event: BesCrashDetectedEvent) {
275
+ sendEvent("bes_crash_detected", event.toEventMap())
276
+ }
277
+
274
278
  override fun onSettingsAck(event: SettingsAckEvent) {
275
279
  sendEvent("settings_ack", event.values)
276
280
  }
@@ -351,6 +355,8 @@ class BluetoothSdkModule : Module() {
351
355
  "speaking_status",
352
356
  "battery_status",
353
357
  "local_transcription",
358
+ "wake_word",
359
+ "speech_activity",
354
360
  "wifi_status_change",
355
361
  "wifi_scan_result",
356
362
  "wifi_forget_result",
@@ -406,6 +412,7 @@ class BluetoothSdkModule : Module() {
406
412
  "ota_start_ack",
407
413
  "ota_status",
408
414
  "ar99_ota_status",
415
+ "bes_crash_detected",
409
416
  // Nex / BLE debug (NexEventUtils —Bridge.sendTypedMessage)
410
417
  "send_command_to_ble",
411
418
  "receive_command_from_ble",
@@ -539,8 +546,6 @@ class BluetoothSdkModule : Module() {
539
546
  sdk?.setDefaultDevice(device.toMentraDevice())
540
547
  }
541
548
 
542
- SdkAsyncFunction("clearDefaultDevice") { -> sdk?.clearDefaultDevice() }
543
-
544
549
  SdkAsyncFunction("connectWithOptions") { device: Map<String, Any>, options: Map<String, Any> ->
545
550
  sdk?.connect(
546
551
  device.toMentraDevice()
@@ -555,7 +560,7 @@ class BluetoothSdkModule : Module() {
555
560
 
556
561
  SdkAsyncFunction("forget") { -> sdk?.forget() }
557
562
 
558
- SdkCoroutineFunction("unpair") { -> deviceManager?.unpair() }
563
+ SdkCoroutineFunction("unpair") { -> sdk?.unpair() }
559
564
 
560
565
  AsyncFunction("connectDefaultController") { deviceManager?.connectDefaultController() }
561
566
 
@@ -567,6 +572,12 @@ class BluetoothSdkModule : Module() {
567
572
  sdk?.startScan(DeviceModel.fromDeviceType(model))
568
573
  }
569
574
 
575
+ SdkAsyncFunction("getBondedGlasses") { ->
576
+ com.mentra.bluetoothsdk.sgcs.MentraLive.soleBondedMentraLive(Bridge.getContext())?.let {
577
+ mapOf("name" to (it.name ?: ""), "address" to it.address)
578
+ }
579
+ }
580
+
570
581
  SdkAsyncFunction("getScanDiagnostic") { model: String ->
571
582
  sdk?.connectedDeviceScanDiagnostic(DeviceModel.fromDeviceType(model))?.let {
572
583
  mapOf("code" to it.code, "message" to it.message)
@@ -626,6 +637,10 @@ class BluetoothSdkModule : Module() {
626
637
  requireSdk().sendIncidentId(incidentId, apiBaseUrl)
627
638
  }
628
639
 
640
+ SdkCoroutineFunction("sendBesCrashReported") { incidentKey: String, reportId: String ->
641
+ requireSdk().sendBesCrashReported(incidentKey, reportId)
642
+ }
643
+
629
644
  // MARK: - Native Notification Centre
630
645
 
631
646
  // Public controls use the SDK facade; phone payload delivery uses DeviceManager.
@@ -885,13 +900,42 @@ class BluetoothSdkModule : Module() {
885
900
  sdk?.setMicSourcePin(source)
886
901
  }
887
902
 
888
- // Runs on Dispatchers.IO, not the shared Expo AsyncFunctionQueue: restart()
889
- // does a synchronous JNI model reload that would otherwise block every other
890
- // native call in the app until it completes.
903
+ // MARK: - On-device voice
904
+ //
905
+ // Everything that can wait on a model load or a worker runs on Dispatchers.IO,
906
+ // never on the shared Expo AsyncFunctionQueue, which every other native call
907
+ // (and every miniapp) waits behind.
908
+
909
+ AsyncFunction("setWakeWordDetection") Coroutine { enabled: Boolean, modelDir: String? ->
910
+ withContext(Dispatchers.IO) {
911
+ com.mentra.bluetoothsdk.stt.WakeWordDetector.configure(enabled, modelDir)
912
+ }
913
+ }
914
+
915
+ // Lock-free: never waits on a model load.
916
+ AsyncFunction("isSttModelLoaded") { path: String ->
917
+ deviceManager?.isSttModelLoaded(path) ?: false
918
+ }
919
+
920
+ // Resolves with the final text, "" when nothing was pending, or null when no
921
+ // streaming model is active, the model can't finalize early, or after 3 s.
922
+ AsyncFunction("finishTranscription") Coroutine { ->
923
+ withContext(Dispatchers.IO) { deviceManager?.finishTranscription() }
924
+ }
925
+
891
926
  AsyncFunction("restartTranscriber") Coroutine { ->
892
927
  withContext(Dispatchers.IO) { deviceManager?.restartTranscriber() }
893
928
  }
894
929
 
930
+ AsyncFunction("setSpeechActivityDetection") Coroutine { enabled: Boolean, options: Map<String, Any?>? ->
931
+ val minSilenceMs =
932
+ (options?.get("minSilenceMs") as? Number)?.toInt()
933
+ ?: com.mentra.bluetoothsdk.stt.SpeechActivityEngine.DEFAULT_MIN_SILENCE_MS
934
+ withContext(Dispatchers.IO) {
935
+ com.mentra.bluetoothsdk.stt.SpeechActivityDetector.configure(enabled, minSilenceMs)
936
+ }
937
+ }
938
+
895
939
  // MARK: - Audio Playback Monitoring
896
940
 
897
941
  SdkAsyncFunction("setOwnAppAudioPlaying") { playing: Boolean ->
@@ -933,6 +977,33 @@ class BluetoothSdkModule : Module() {
933
977
  PcmStreamManager.abort(streamId)
934
978
  }
935
979
 
980
+ // Native HTTP GET of raw s16le mono PCM, played as it arrives. Blocks a
981
+ // Dispatchers.IO thread (never the shared queue) until the body has played.
982
+ AsyncFunction("pcmStreamPlayUrl") Coroutine {
983
+ streamId: String,
984
+ url: String,
985
+ sampleRate: Int,
986
+ volume: Double,
987
+ jitterMs: Int?,
988
+ ->
989
+ withContext(Dispatchers.IO) {
990
+ try {
991
+ mapOf(
992
+ "durationMs" to
993
+ PcmStreamManager.playUrl(
994
+ streamId,
995
+ url,
996
+ sampleRate,
997
+ volume.toFloat(),
998
+ jitterMs,
999
+ )
1000
+ )
1001
+ } catch (error: com.mentra.bluetoothsdk.utils.audio.PcmUrlPlaybackException) {
1002
+ throw CodedException(error.code, error.message ?: error.code, error)
1003
+ }
1004
+ }
1005
+ }
1006
+
936
1007
  // *Blocking on Dispatchers.IO, not the shared AsyncFunctionQueue: these wait on
937
1008
  // a CountDownLatch (up to 5s) for a BLE round-trip, which would otherwise stall
938
1009
  // every other native call queued behind them.