@mentra/bluetooth-sdk 3.4.0-dev.998 → 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.
- package/MIGRATION.md +16 -7
- package/README.md +40 -13
- package/android/build.gradle +60 -51
- package/android/gradle.properties +3 -0
- package/android/settings.gradle +47 -3
- package/android/src/main/assets/nimo/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BesCrashReportWaiters.kt +68 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +5 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +77 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +41 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +114 -122
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +2 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +31 -10
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt +57 -196
- package/android/src/main/java/com/mentra/bluetoothsdk/OtaManifest.kt +1 -16
- package/android/src/main/java/com/mentra/bluetoothsdk/debug/BleTraceLogger.kt +10 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/Ipv4Prefix.kt +51 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/NetworkFacts.kt +81 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkError.kt +108 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadiness.kt +103 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpec.kt +44 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkState.kt +117 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedSoftApNetwork.kt +598 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/SoftApTrace.kt +143 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/otaserver/MentraOtaServerModule.kt +0 -7
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTracker.kt +15 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +274 -56
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +210 -325
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +0 -35
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +2 -10
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdater.kt +213 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocol.kt +112 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +6 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/streaming/StreamModels.kt +17 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueue.kt +92 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHost.kt +169 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +74 -115
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +348 -357
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetector.kt +211 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngine.kt +137 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SttTextFormatter.kt +52 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/WakeWordDetector.kt +235 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/AvifExifStripper.java +2 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +3 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +11 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/AudioRouteWatcher.kt +120 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +181 -16
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlayback.kt +177 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/BesCrashReportWaitersTest.kt +112 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/StreamRequestCaptureAudioTest.kt +23 -4
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/Ipv4PrefixTest.kt +59 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/NetworkFactsTest.kt +59 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedLocalNetworkPermissionTest.kt +35 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkErrorTest.kt +85 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkLifecycleTest.kt +164 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadinessTest.kt +141 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpecTest.kt +56 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/SoftApTraceTest.kt +97 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/UnavailableRetryTest.kt +47 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTrackerTest.kt +26 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveGlassesReadyBurstTest.kt +141 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveIncidentDispatchTest.kt +183 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicyTest.kt +3 -3
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveRgbLedResponseTest.kt +76 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinatorTest.kt +1 -56
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSessionTest.kt +0 -22
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareTargetTest.kt +15 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdaterTest.kt +76 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocolTest.kt +77 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNamingTest.kt +23 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoReadinessDriverTest.kt +31 -1
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueueTest.kt +81 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHostTest.kt +216 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/STTToolsExtractionTest.kt +108 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetectorTest.kt +126 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngineTest.kt +245 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SttTextFormatterTest.kt +67 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlaybackTest.kt +76 -0
- package/build/BluetoothSdk.types.d.ts +103 -5
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +42 -8
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js +1 -0
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/_private/MentraLocalNetworkModule.d.ts +1 -1
- package/build/_private/MentraLocalNetworkModule.d.ts.map +1 -1
- package/build/_private/MentraLocalNetworkModule.js.map +1 -1
- package/build/generated/changelogCatalog.d.ts +2 -2
- package/build/generated/changelogCatalog.js +2 -2
- package/build/generated/changelogCatalog.js.map +1 -1
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/ota-server/MentraOtaServerModule.d.ts +0 -2
- package/build/ota-server/MentraOtaServerModule.d.ts.map +1 -1
- package/build/ota-server/MentraOtaServerModule.js.map +1 -1
- package/build/ota-server/MentraOtaServerModule.web.d.ts +0 -1
- package/build/ota-server/MentraOtaServerModule.web.d.ts.map +1 -1
- package/build/ota-server/MentraOtaServerModule.web.js +0 -3
- package/build/ota-server/MentraOtaServerModule.web.js.map +1 -1
- package/build/ota-transport/index.d.ts +3 -3
- package/build/ota-transport/index.d.ts.map +1 -1
- package/build/ota-transport/index.js +4 -4
- package/build/ota-transport/index.js.map +1 -1
- package/build/react/useGlassesConnection.d.ts +1 -1
- package/build/react/useGlassesConnection.d.ts.map +1 -1
- package/build/react/useGlassesConnection.js +3 -3
- package/build/react/useGlassesConnection.js.map +1 -1
- package/build/react/useMentraBluetooth.d.ts +1 -1
- package/build/react/useMentraBluetooth.d.ts.map +1 -1
- package/build/react/useMentraBluetooth.js +1 -1
- package/build/react/useMentraBluetooth.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +73 -22
- package/ios/LocalIPv4.swift +0 -61
- package/ios/MentraBluetoothSDK.podspec +7 -1
- package/ios/MentraOtaServerModule.swift +0 -16
- package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
- package/ios/Resources/NimoFirmware/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
- package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
- package/ios/Source/BesCrashReportWaiters.swift +64 -0
- package/ios/Source/BluetoothSdkDefaults.swift +4 -4
- package/ios/Source/Bridge.swift +14 -0
- package/ios/Source/DeviceManager.swift +43 -22
- package/ios/Source/GeneratedChangelogCatalog.swift +2 -2
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/ios/Source/MentraBluetoothSDK.swift +35 -16
- package/ios/Source/OtaManifest.swift +1 -17
- package/ios/Source/audio/PcmStreamPlayer.swift +290 -57
- package/ios/Source/audio/PcmUrlPlayback.swift +231 -0
- package/ios/Source/audio/SpeechActivity.swift +277 -0
- package/ios/Source/events/BluetoothEvents.swift +41 -0
- package/ios/Source/internal/BleTraceLogger.swift +14 -1
- package/ios/Source/internal/BluetoothAvailability.swift +15 -5
- package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +5 -0
- package/ios/Source/sgcs/MentraLive.swift +195 -66
- package/ios/Source/sgcs/Nimo.swift +249 -276
- package/ios/Source/sgcs/NimoCanvasCoordinator.swift +9 -38
- package/ios/Source/sgcs/NimoCanvasSession.swift +0 -1
- package/ios/Source/sgcs/NimoFirmwareUpdater.swift +260 -0
- package/ios/Source/sgcs/NimoOtaProtocol.swift +159 -0
- package/ios/Source/sgcs/SGCManager.swift +6 -0
- package/ios/Source/streaming/StreamModels.swift +15 -6
- package/ios/Source/stt/STTTools.swift +13 -31
- package/ios/Source/stt/SherpaOnnxTranscriber.swift +204 -162
- package/ios/Source/stt/SileroSpeechActivity.swift +87 -0
- package/ios/Source/stt/WakeWordDetector.swift +145 -0
- package/ios/Source/utils/BoundedWait.swift +44 -0
- package/ios/Source/utils/DemandDrivenAudioWorker.swift +79 -0
- package/ios/Source/utils/SttModelTraits.swift +62 -0
- package/ios/Tests/BesCrashReportTests.swift +142 -0
- package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
- package/ios/Tests/DeviceManagerReconnectTests.swift +0 -71
- package/ios/Tests/GlassesAudioSetupPolicyTests.swift +9 -3
- package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
- package/ios/Tests/MentraLiveAudioSetupTests.swift +6 -12
- package/ios/Tests/MentraLiveCommandQueueTests.swift +35 -0
- package/ios/Tests/MentraLiveSessionReadinessTests.swift +179 -10
- package/ios/Tests/NimoCanvasTransportTests.swift +0 -89
- package/ios/Tests/NimoOtaProtocolTests.swift +78 -0
- package/ios/Tests/PcmStreamTests.swift +299 -0
- package/ios/Tests/SpeechActivityTests.swift +238 -0
- package/ios/Tests/StreamRequestTests.swift +18 -0
- package/ios/Tests/SttModelTraitsTests.swift +62 -0
- package/package.json +2 -2
- package/plugin/build/withAndroid.js +9 -11
- package/plugin/build/withKotlinVersion.d.ts +2 -0
- package/plugin/build/withKotlinVersion.js +46 -0
- package/src/BluetoothSdk.types.ts +107 -5
- package/src/_private/BluetoothSdkModule.ts +45 -8
- package/src/_private/MentraLocalNetworkModule.ts +5 -1
- package/src/generated/changelogCatalog.ts +2 -2
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/index.ts +13 -1
- package/src/ota-server/MentraOtaServerModule.ts +0 -2
- package/src/ota-server/MentraOtaServerModule.web.ts +0 -4
- package/src/ota-transport/index.ts +4 -5
- package/src/react/useGlassesConnection.ts +4 -4
- package/src/react/useMentraBluetooth.ts +2 -2
- package/android/silero/LICENSE.md +0 -17
- package/android/silero/build.gradle +0 -50
- package/android/silero/proguard-rules.pro +0 -24
- package/android/silero/src/androidTest/assets/hello.wav +0 -0
- package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +0 -79
- package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +0 -160
- package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +0 -449
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +0 -15
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +0 -14
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +0 -12
- package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +0 -47
- package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +0 -41
- package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +0 -44
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -368
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocol.kt +0 -156
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -274
- package/android/src/main/java/com/mentra/bluetoothsdk/ScopedNetworkReadiness.kt +0 -17
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +0 -229
- package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -20
- package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -16
- package/android/src/test/java/com/mentra/bluetoothsdk/ScopedNetworkReadinessTest.kt +0 -39
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnosticsTest.kt +0 -287
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt +0 -127
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +0 -851
- package/ios/Source/sgcs/NimoMacResourceTransport.swift +0 -217
- package/ios/Source/sgcs/NimoResourceFixture.swift +0 -384
- package/ios/Source/sgcs/NimoResourceSession.swift +0 -406
- package/ios/Tests/NimoResourceSessionTests.swift +0 -476
- /package/android/{silero/src/main/assets/LICENSE → src/main/assets/vad/LICENSE.silero_vad} +0 -0
- /package/android/{silero/src/main/assets → src/main/assets/vad}/silero_vad.onnx +0 -0
|
@@ -255,6 +255,33 @@ public class Bridge private constructor() {
|
|
|
255
255
|
sendTypedMessage("speaking_status", body as Map<String, Any>)
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Send a phone-side speech activity transition from the on-device Silero detector.
|
|
260
|
+
* [silentForMs] is 0 while speaking; on a silence transition, how long it has been quiet.
|
|
261
|
+
*/
|
|
262
|
+
@JvmStatic
|
|
263
|
+
fun sendSpeechActivity(speaking: Boolean, silentForMs: Long) {
|
|
264
|
+
val body = HashMap<String, Any>()
|
|
265
|
+
body["speaking"] = speaking
|
|
266
|
+
body["silentForMs"] = silentForMs
|
|
267
|
+
body["timestamp"] = System.currentTimeMillis()
|
|
268
|
+
sendTypedMessage("speech_activity", body as Map<String, Any>)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Send on-device keyword spotter state or a detection. [kind] is "loading", "ready",
|
|
273
|
+
* "detected" or "error"; it describes only the wake-word model.
|
|
274
|
+
*/
|
|
275
|
+
@JvmStatic
|
|
276
|
+
fun sendWakeWord(kind: String, phrase: String, message: String? = null) {
|
|
277
|
+
val body = HashMap<String, Any>()
|
|
278
|
+
body["kind"] = kind
|
|
279
|
+
body["phrase"] = phrase
|
|
280
|
+
body["timestamp"] = System.currentTimeMillis()
|
|
281
|
+
if (message != null) body["message"] = message
|
|
282
|
+
sendTypedMessage("wake_word", body as Map<String, Any>)
|
|
283
|
+
}
|
|
284
|
+
|
|
258
285
|
/** Send battery status */
|
|
259
286
|
@JvmStatic
|
|
260
287
|
fun sendBatteryStatus(level: Int, charging: Boolean) {
|
|
@@ -309,6 +336,20 @@ public class Bridge private constructor() {
|
|
|
309
336
|
DeviceStore.set("bluetooth", "searchResults", uniqueResults)
|
|
310
337
|
}
|
|
311
338
|
|
|
339
|
+
/** Drop glasses from the search results, for example when their pairing window closed. */
|
|
340
|
+
@JvmStatic
|
|
341
|
+
fun removeDiscoveredDevice(deviceModel: String, deviceName: String) {
|
|
342
|
+
val searchResults =
|
|
343
|
+
DeviceStore.store.getCategory("bluetooth")["searchResults"] as? List<*> ?: return
|
|
344
|
+
val remaining =
|
|
345
|
+
searchResults.filterNot { result ->
|
|
346
|
+
val values = result as? Map<*, *>
|
|
347
|
+
values?.get("model") == deviceModel && values["name"] == deviceName
|
|
348
|
+
}
|
|
349
|
+
if (remaining.size == searchResults.size) return
|
|
350
|
+
DeviceStore.set("bluetooth", "searchResults", remaining)
|
|
351
|
+
}
|
|
352
|
+
|
|
312
353
|
private fun mergeStableSearchResults(
|
|
313
354
|
currentResults: List<Map<String, Any>>,
|
|
314
355
|
newResult: Map<String, Any>,
|
|
@@ -26,7 +26,6 @@ import com.mentra.bluetoothsdk.sgcs.MentraLive
|
|
|
26
26
|
import com.mentra.bluetoothsdk.sgcs.MentraLivePairingStateStore
|
|
27
27
|
import com.mentra.bluetoothsdk.sgcs.MentraNex
|
|
28
28
|
import com.mentra.bluetoothsdk.sgcs.Nimo
|
|
29
|
-
import com.mentra.bluetoothsdk.sgcs.NimoResourceDiagnostics
|
|
30
29
|
import com.mentra.bluetoothsdk.sgcs.SGCManager
|
|
31
30
|
import com.mentra.bluetoothsdk.sgcs.Simulated
|
|
32
31
|
import com.mentra.bluetoothsdk.utils.ControllerTypes
|
|
@@ -36,7 +35,11 @@ import com.mentra.bluetoothsdk.utils.MicSourcePin
|
|
|
36
35
|
import com.mentra.bluetoothsdk.utils.MicTypes
|
|
37
36
|
import com.mentra.bluetoothsdk.utils.PhoneAudioMonitor
|
|
38
37
|
import com.mentra.lc3Lib.Lc3Cpp
|
|
38
|
+
import com.mentra.bluetoothsdk.stt.OnDeviceRecognizerHost
|
|
39
|
+
import com.mentra.bluetoothsdk.stt.STTTools
|
|
39
40
|
import com.mentra.bluetoothsdk.stt.SherpaOnnxTranscriber
|
|
41
|
+
import com.mentra.bluetoothsdk.stt.SpeechActivityDetector
|
|
42
|
+
import com.mentra.bluetoothsdk.stt.WakeWordDetector
|
|
40
43
|
import kotlin.coroutines.resume
|
|
41
44
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
42
45
|
import kotlinx.coroutines.CoroutineScope
|
|
@@ -46,6 +49,7 @@ import kotlinx.coroutines.launch
|
|
|
46
49
|
import java.text.SimpleDateFormat
|
|
47
50
|
import java.util.*
|
|
48
51
|
import java.util.concurrent.CountDownLatch
|
|
52
|
+
import java.util.concurrent.ExecutionException
|
|
49
53
|
import java.util.concurrent.ExecutorService
|
|
50
54
|
import java.util.concurrent.Executors
|
|
51
55
|
import java.util.concurrent.TimeUnit
|
|
@@ -165,13 +169,6 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
165
169
|
get() = DeviceStore.store.get("bluetooth", "power_saving_mode") as? Boolean ?: false
|
|
166
170
|
set(value) = DeviceStore.apply("bluetooth", "power_saving_mode", value)
|
|
167
171
|
|
|
168
|
-
// Phone-side VAD gating switch. Default is OFF (VAD runs) so the
|
|
169
|
-
// coordinator can drive per-utterance offline/online STT switching from
|
|
170
|
-
// `vad_status` events. Set to `true` only as an emergency kill-switch.
|
|
171
|
-
private var bypassVad: Boolean
|
|
172
|
-
get() = DeviceStore.store.get("bluetooth", "bypass_vad") as? Boolean ?: false
|
|
173
|
-
set(value) = DeviceStore.apply("bluetooth", "bypass_vad", value)
|
|
174
|
-
|
|
175
172
|
private var localSttFallbackActive: Boolean
|
|
176
173
|
get() = DeviceStore.store.get("bluetooth", "local_stt_fallback_active") as? Boolean ?: false
|
|
177
174
|
set(value) = DeviceStore.apply("bluetooth", "local_stt_fallback_active", value)
|
|
@@ -284,13 +281,23 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
284
281
|
private var micReinitRunnable: Runnable? = null
|
|
285
282
|
private var systemMicAvailabilityRecheckRunnable: Runnable? = null
|
|
286
283
|
|
|
287
|
-
//
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
private
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
284
|
+
// STT: one recognizer, loaded only while on-device transcription is in demand. Models
|
|
285
|
+
// load on sttLoader (never on the audio thread or under a DeviceManager lock) and are
|
|
286
|
+
// swapped in afterwards; see OnDeviceRecognizerHost.
|
|
287
|
+
private val sttLoader: ExecutorService =
|
|
288
|
+
Executors.newSingleThreadExecutor { runnable ->
|
|
289
|
+
Thread(runnable, "SttModelLoader").apply { isDaemon = true }
|
|
290
|
+
}
|
|
291
|
+
private val transcription =
|
|
292
|
+
OnDeviceRecognizerHost(
|
|
293
|
+
selection = ::selectedSttModel,
|
|
294
|
+
loadModel = ::loadTranscriber,
|
|
295
|
+
pathMatches = { transcriber, path -> transcriber.isModelLoaded(path) },
|
|
296
|
+
// Returns at once; the model is released on its worker after queued audio.
|
|
297
|
+
release = { transcriber -> transcriber.shutdown() },
|
|
298
|
+
loader = sttLoader,
|
|
299
|
+
log = { message -> Bridge.log(message) },
|
|
300
|
+
)
|
|
294
301
|
|
|
295
302
|
// View states
|
|
296
303
|
private val viewStates = mutableListOf<ViewState>()
|
|
@@ -309,7 +316,6 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
309
316
|
initializeViewStates()
|
|
310
317
|
if (initializeHardware) {
|
|
311
318
|
initializeHardwareServices()
|
|
312
|
-
NimoResourceDiagnostics.start(Bridge.getContext())
|
|
313
319
|
}
|
|
314
320
|
}
|
|
315
321
|
|
|
@@ -336,30 +342,6 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
336
342
|
lc3DecoderPtr = 0
|
|
337
343
|
}
|
|
338
344
|
|
|
339
|
-
// Initialize phone-side Silero VAD. Used by handlePcm to gate audio
|
|
340
|
-
// fan-out and to drive per-utterance offline/online STT switching
|
|
341
|
-
// (see LocalSttFallbackCoordinator on the JS side). If a previous
|
|
342
|
-
// policy somehow exists (re-init on hot reload), stop it first to
|
|
343
|
-
// release the ONNX session.
|
|
344
|
-
try {
|
|
345
|
-
vadPolicy?.stop()
|
|
346
|
-
val ctx = Bridge.getContext()
|
|
347
|
-
val policy = com.mentra.bluetoothsdk.stt.VadGateSpeechPolicy(ctx)
|
|
348
|
-
policy.init(blockSizeSamples = 512)
|
|
349
|
-
policy.onSpeechStateChanged = { speaking ->
|
|
350
|
-
isSpeaking = speaking
|
|
351
|
-
Bridge.sendVoiceActivityDetectionStatus(speaking)
|
|
352
|
-
}
|
|
353
|
-
vadPolicy = policy
|
|
354
|
-
Bridge.log("VadGateSpeechPolicy initialized")
|
|
355
|
-
} catch (e: Exception) {
|
|
356
|
-
Bridge.log("Failed to initialize VadGateSpeechPolicy: ${e.message}")
|
|
357
|
-
vadPolicy = null
|
|
358
|
-
} catch (e: LinkageError) {
|
|
359
|
-
Bridge.log("Failed to initialize VadGateSpeechPolicy: ${e.message}")
|
|
360
|
-
vadPolicy = null
|
|
361
|
-
}
|
|
362
|
-
|
|
363
345
|
// Mic reinit check every 10 seconds
|
|
364
346
|
val micReinitR =
|
|
365
347
|
object : Runnable {
|
|
@@ -579,8 +561,9 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
579
561
|
Bridge.log(
|
|
580
562
|
"MAN: Bluetooth restored, attempting reconnect to: $deviceName"
|
|
581
563
|
)
|
|
564
|
+
// A disconnect during the delay still counts.
|
|
582
565
|
handler.postDelayed(
|
|
583
|
-
{ connectDefault() },
|
|
566
|
+
{ if (shouldReconnectAfterBluetoothOn()) connectDefault() },
|
|
584
567
|
2000
|
|
585
568
|
) // Small delay to let BT stack stabilize
|
|
586
569
|
}
|
|
@@ -966,22 +949,15 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
966
949
|
// #endregion
|
|
967
950
|
|
|
968
951
|
fun handlePcm(pcmData: ByteArray) {
|
|
969
|
-
// Audio always flows. The
|
|
970
|
-
//
|
|
971
|
-
//
|
|
972
|
-
//
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
// VADs server-side. VadGateSpeechPolicy is kept around because
|
|
976
|
-
// hardware-side VAD events from the glasses route through the same
|
|
977
|
-
// class to fire `vad_status` (a separate signal the cloud SDK
|
|
978
|
-
// surfaces as `session.audio.isSpeaking`).
|
|
952
|
+
// Audio always flows; nothing here gates it. The on-device consumers below only
|
|
953
|
+
// copy and queue on this (glasses or phone mic) audio thread: model loading and
|
|
954
|
+
// inference run on their own workers. The glasses' hardware voice detection
|
|
955
|
+
// (Mentra Live sr_vad -> speaking_status) is separate and unaffected.
|
|
956
|
+
WakeWordDetector.accept(pcmData)
|
|
957
|
+
SpeechActivityDetector.accept(pcmData)
|
|
979
958
|
handleSendingPcm(pcmData)
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
transcriber?.acceptAudio(pcmData)
|
|
983
|
-
}
|
|
984
|
-
}
|
|
959
|
+
// Non-null only while on-device transcription is in demand.
|
|
960
|
+
transcription.current?.acceptAudio(pcmData)
|
|
985
961
|
}
|
|
986
962
|
|
|
987
963
|
// turns a single mic on and turns off all other mics:
|
|
@@ -1382,7 +1358,6 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
1382
1358
|
// MARK: - Auxiliary Commands
|
|
1383
1359
|
|
|
1384
1360
|
fun initSGC(wearable: String) {
|
|
1385
|
-
if (!NimoResourceDiagnostics.allowManagerConnect(wearable)) return
|
|
1386
1361
|
Bridge.log("Initializing manager for wearable: $wearable")
|
|
1387
1362
|
if (sgc != null && sgc?.type != wearable) {
|
|
1388
1363
|
Bridge.log("MAN: Manager already initialized, cleaning up previous sgc")
|
|
@@ -1454,55 +1429,67 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
1454
1429
|
}
|
|
1455
1430
|
}
|
|
1456
1431
|
|
|
1432
|
+
/**
|
|
1433
|
+
* Finish the active recognizer's current utterance. Returns the final text once its
|
|
1434
|
+
* `local_transcription` event has been sent, `""` when nothing was pending, or null when
|
|
1435
|
+
* no streaming model is active, the loaded model can't finalize early, or the 3 s wait
|
|
1436
|
+
* expires. Never throws. Call from a background thread: the final event is delivered on
|
|
1437
|
+
* the main thread before this returns.
|
|
1438
|
+
*/
|
|
1439
|
+
fun finishTranscription(): String? =
|
|
1440
|
+
try {
|
|
1441
|
+
transcription.current?.finishUtterance()
|
|
1442
|
+
} catch (e: Exception) {
|
|
1443
|
+
Bridge.log("STT: finishTranscription failed: ${e.message}")
|
|
1444
|
+
null
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/** Whether the active recognizer has [path] loaded. Lock-free; never waits on a load. */
|
|
1448
|
+
fun isSttModelLoaded(path: String): Boolean = transcription.isLoaded(path)
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Load the selected speech model if on-device transcription is in demand, and wait until
|
|
1452
|
+
* it is loaded. Returns at once when there is no demand or the model is already loaded;
|
|
1453
|
+
* throws when loading fails. Call from a background thread.
|
|
1454
|
+
*/
|
|
1457
1455
|
fun restartTranscriber() {
|
|
1458
1456
|
Bridge.log("MAN: Restarting transcriber via command")
|
|
1459
|
-
|
|
1460
|
-
|
|
1457
|
+
try {
|
|
1458
|
+
transcription.restart().get()
|
|
1459
|
+
} catch (e: ExecutionException) {
|
|
1460
|
+
throw e.cause ?: e
|
|
1461
1461
|
}
|
|
1462
1462
|
}
|
|
1463
1463
|
|
|
1464
|
-
private fun
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1464
|
+
private fun selectedSttModel(): OnDeviceRecognizerHost.Selection? {
|
|
1465
|
+
val context =
|
|
1466
|
+
try {
|
|
1467
|
+
Bridge.getContext()
|
|
1468
|
+
} catch (_: IllegalStateException) {
|
|
1469
|
+
return null
|
|
1470
|
+
}
|
|
1471
|
+
val path = STTTools.getSttModelPath(context).takeIf { it.isNotBlank() } ?: return null
|
|
1472
|
+
return OnDeviceRecognizerHost.Selection(path, STTTools.getSttModelLanguage(context))
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
/** Runs on [sttLoader]. Throws when the model can't be loaded. */
|
|
1476
|
+
private fun loadTranscriber(selection: OnDeviceRecognizerHost.Selection): SherpaOnnxTranscriber {
|
|
1477
|
+
val next = SherpaOnnxTranscriber(Bridge.getContext(), selection.path, selection.language)
|
|
1478
|
+
next.setTranscriptListener(
|
|
1479
|
+
object : SherpaOnnxTranscriber.TranscriptListener {
|
|
1480
|
+
override fun onPartialResult(text: String, language: String) {
|
|
1481
|
+
Bridge.log("STT: Partial result: $text")
|
|
1482
|
+
Bridge.sendLocalTranscription(text, false, language)
|
|
1483
|
+
}
|
|
1479
1484
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
// output to match the rest of the pipeline (parity with iOS).
|
|
1484
|
-
val formatted = if (language == "en-US") text.lowercase() else text
|
|
1485
|
-
Bridge.sendLocalTranscription(formatted, true, language)
|
|
1486
|
-
}
|
|
1485
|
+
override fun onFinalResult(text: String, language: String) {
|
|
1486
|
+
Bridge.log("STT: Final result: $text")
|
|
1487
|
+
Bridge.sendLocalTranscription(text, true, language)
|
|
1487
1488
|
}
|
|
1488
|
-
)
|
|
1489
|
-
nextTranscriber.initialize()
|
|
1490
|
-
if (!nextTranscriber.isInitialized()) {
|
|
1491
|
-
Bridge.log("SherpaOnnxTranscriber initialize() returned without becoming ready")
|
|
1492
|
-
return false
|
|
1493
1489
|
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
} catch (e: Exception) {
|
|
1498
|
-
Bridge.log("Failed to initialize SherpaOnnxTranscriber: ${e.message}")
|
|
1499
|
-
transcriber = null
|
|
1500
|
-
false
|
|
1501
|
-
} catch (e: LinkageError) {
|
|
1502
|
-
Bridge.log("Failed to initialize SherpaOnnxTranscriber: ${e.message}")
|
|
1503
|
-
transcriber = null
|
|
1504
|
-
false
|
|
1505
|
-
}
|
|
1490
|
+
)
|
|
1491
|
+
next.load()
|
|
1492
|
+
return next
|
|
1506
1493
|
}
|
|
1507
1494
|
|
|
1508
1495
|
// MARK: - connection state management
|
|
@@ -2006,6 +1993,13 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2006
1993
|
driver.sendIncidentId(incidentId, apiBaseUrl)
|
|
2007
1994
|
}
|
|
2008
1995
|
|
|
1996
|
+
fun sendBesCrashReported(incidentKey: String, reportId: String) {
|
|
1997
|
+
val driver = sgc ?: throw BluetoothSdkException(
|
|
1998
|
+
"glasses_not_connected", "Cannot report the BES crash because glasses are not connected.",
|
|
1999
|
+
)
|
|
2000
|
+
driver.sendBesCrashReported(incidentKey, reportId)
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2009
2003
|
/** Push a notification into the glasses' own notification centre; rejects unsupported or disconnected devices. */
|
|
2010
2004
|
fun sendPhoneNotification(notification: Map<String, Any>) {
|
|
2011
2005
|
// Package only - never the notification text.
|
|
@@ -2304,14 +2298,9 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2304
2298
|
val willSendPcm = shouldSendPcm || shouldSendLc3
|
|
2305
2299
|
val willSendTranscript = shouldSendTranscript || localSttFallbackActive
|
|
2306
2300
|
val nextEnabled = willSendPcm || willSendTranscript
|
|
2307
|
-
//
|
|
2308
|
-
|
|
2309
|
-
// audio stops flowing.
|
|
2310
|
-
if (micEnabled && !nextEnabled) {
|
|
2311
|
-
vadPolicy?.microphoneStateChanged(false)
|
|
2312
|
-
}
|
|
2301
|
+
// Load the recognizer while on-device transcription is in demand; release it when not.
|
|
2302
|
+
transcription.setDemand(willSendTranscript)
|
|
2313
2303
|
micEnabled = nextEnabled
|
|
2314
|
-
vadBuffer.clear()
|
|
2315
2304
|
updateMicState()
|
|
2316
2305
|
}
|
|
2317
2306
|
|
|
@@ -2355,8 +2344,21 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2355
2344
|
sgc?.sendRgbLedControl(requestId, packageName, action, color, onDurationMs, offDurationMs, count)
|
|
2356
2345
|
}
|
|
2357
2346
|
|
|
2347
|
+
/**
|
|
2348
|
+
* The person disconnected the glasses outside the app, in Android's Bluetooth settings. Like
|
|
2349
|
+
* the app's Disconnect, nothing reconnects them until the person connects again.
|
|
2350
|
+
*/
|
|
2351
|
+
fun disconnectByUser() {
|
|
2352
|
+
Bridge.log("MAN: Glasses disconnected in Android's Bluetooth settings")
|
|
2353
|
+
DeviceStore.apply("bluetooth", "glasses_user_disconnected", true)
|
|
2354
|
+
Bridge.saveSetting("glasses_user_disconnected", true)
|
|
2355
|
+
disconnect()
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
/** Glasses the person disconnected in the app stay disconnected. */
|
|
2358
2359
|
internal fun shouldReconnectAfterBluetoothOn(): Boolean =
|
|
2359
|
-
defaultWearable.isNotEmpty() && deviceName.isNotEmpty()
|
|
2360
|
+
defaultWearable.isNotEmpty() && deviceName.isNotEmpty() &&
|
|
2361
|
+
DeviceStore.store.get("bluetooth", "glasses_user_disconnected") != true
|
|
2360
2362
|
|
|
2361
2363
|
/**
|
|
2362
2364
|
* A ready Mentra Live session. Only an explicit pair (a pending target) clears
|
|
@@ -2387,7 +2389,6 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2387
2389
|
}
|
|
2388
2390
|
|
|
2389
2391
|
fun connectDefault() {
|
|
2390
|
-
if (NimoResourceDiagnostics.dispatchCapturedEntry { connectDefault() }) return
|
|
2391
2392
|
if (defaultWearable.isEmpty()) {
|
|
2392
2393
|
Bridge.log("MAN: No default wearable, returning")
|
|
2393
2394
|
return
|
|
@@ -2409,7 +2410,6 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2409
2410
|
Bridge.log("MAN: connectDefault skipped — bluetooth runtime permissions not granted")
|
|
2410
2411
|
return
|
|
2411
2412
|
}
|
|
2412
|
-
if (!NimoResourceDiagnostics.allowManagerConnect(defaultWearable, reconnectTarget)) return
|
|
2413
2413
|
initSGC(defaultWearable)
|
|
2414
2414
|
val live = sgc as? MentraLive
|
|
2415
2415
|
if (live != null && MentraLivePairingStateStore.isRejected) {
|
|
@@ -2446,7 +2446,6 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2446
2446
|
}
|
|
2447
2447
|
|
|
2448
2448
|
fun connectByName(dName: String) {
|
|
2449
|
-
if (NimoResourceDiagnostics.dispatchCapturedEntry { connectByName(dName) }) return
|
|
2450
2449
|
Bridge.log("MAN: Connecting to wearable: $dName")
|
|
2451
2450
|
|
|
2452
2451
|
var name = dName
|
|
@@ -2461,7 +2460,6 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2461
2460
|
return
|
|
2462
2461
|
}
|
|
2463
2462
|
|
|
2464
|
-
if (!NimoResourceDiagnostics.allowManagerConnect(pendingWearable.ifEmpty { defaultWearable }, name)) return
|
|
2465
2463
|
if (pendingWearable.isEmpty() && !defaultWearable.isEmpty()) {
|
|
2466
2464
|
Bridge.log("MAN: No pending wearable, using default wearable")
|
|
2467
2465
|
pendingWearable = defaultWearable
|
|
@@ -2476,11 +2474,8 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2476
2474
|
return
|
|
2477
2475
|
}
|
|
2478
2476
|
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
disconnect(clearPendingIdentity = false)
|
|
2482
|
-
Thread.sleep(100)
|
|
2483
|
-
}
|
|
2477
|
+
disconnect(clearPendingIdentity = false)
|
|
2478
|
+
Thread.sleep(100)
|
|
2484
2479
|
searching = true
|
|
2485
2480
|
pendingDeviceName = name
|
|
2486
2481
|
|
|
@@ -2489,10 +2484,8 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2489
2484
|
}
|
|
2490
2485
|
|
|
2491
2486
|
fun connectDevice(deviceModel: String, deviceName: String) {
|
|
2492
|
-
if (NimoResourceDiagnostics.dispatchCapturedEntry { connectDevice(deviceModel, deviceName) }) return
|
|
2493
2487
|
Bridge.log("MAN: Connecting to device: $deviceModel $deviceName")
|
|
2494
2488
|
if (DeviceTypes.ALL.contains(deviceModel)) {
|
|
2495
|
-
if (!NimoResourceDiagnostics.allowManagerConnect(deviceModel, deviceName)) return
|
|
2496
2489
|
pendingWearable = deviceModel
|
|
2497
2490
|
initSGC(pendingWearable)
|
|
2498
2491
|
sgc?.connectById(deviceName)
|
|
@@ -2698,8 +2691,6 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2698
2691
|
}
|
|
2699
2692
|
|
|
2700
2693
|
fun findCompatibleDevices(deviceModel: String) {
|
|
2701
|
-
if (NimoResourceDiagnostics.dispatchCapturedEntry { findCompatibleDevices(deviceModel) }) return
|
|
2702
|
-
if (!NimoResourceDiagnostics.allowManagerConnect(deviceModel)) return
|
|
2703
2694
|
Bridge.log("MAN: Searching for compatible device names for: $deviceModel")
|
|
2704
2695
|
|
|
2705
2696
|
// reset the search results:
|
|
@@ -2739,9 +2730,10 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
|
|
|
2739
2730
|
systemMicAvailabilityRecheckRunnable?.let { mainHandler.removeCallbacks(it) }
|
|
2740
2731
|
systemMicAvailabilityRecheckRunnable = null
|
|
2741
2732
|
|
|
2742
|
-
//
|
|
2743
|
-
|
|
2744
|
-
|
|
2733
|
+
// Release on-device voice models (each on its own worker).
|
|
2734
|
+
transcription.setDemand(false)
|
|
2735
|
+
WakeWordDetector.shutdown()
|
|
2736
|
+
SpeechActivityDetector.shutdown()
|
|
2745
2737
|
|
|
2746
2738
|
// Clean up LC3 encoder/decoder (synchronized to prevent use-after-free
|
|
2747
2739
|
// if the recording thread is mid-encode/decode)
|
|
@@ -3,8 +3,8 @@ package com.mentra.bluetoothsdk
|
|
|
3
3
|
/** Generated from /changelogs. Do not edit directly. */
|
|
4
4
|
internal val GENERATED_RELEASE_CHANGELOGS: List<ReleaseChangelog> =
|
|
5
5
|
listOf(
|
|
6
|
-
ReleaseChangelog(version = "3.4.0", markdown = "
|
|
7
|
-
ReleaseChangelog(version = "3.3.0", markdown = "
|
|
6
|
+
ReleaseChangelog(version = "3.4.0", markdown = "- **Pairing:** Pairing your glasses is simpler, with new voice prompts to guide you.\n- **Mentra Call:** Simpler call controls and a free first month.\n- **Miniapps:** Add miniapps from a link or QR code.\n- **Glasses updates:** Updates keep going when your phone switches networks, with clearer messages if something goes wrong.\n- **Photos and gallery:** More reliable photo syncing on iPhone. Your glasses now tell you when their storage is full.\n- **Livestreaming:** Smoother livestreams.\n- **Sound:** Better speaker sound on Mentra Live, and music no longer stays off after a call.\n- **Notes:** Short conversations now get notes too.\n- **Reliability:** Fewer glasses crashes and disconnects."),
|
|
7
|
+
ReleaseChangelog(version = "3.3.0", markdown = "- **Mentra Call:** Now available on iPhone, with a redesigned call screen and photo sharing during calls.\n- **Microphone:** Improved glasses microphone reliability, including after phone calls.\n- **Photos and gallery:** More reliable photo capture and gallery syncing.\n- **Glasses updates:** More reliable glasses updates, with clearer progress.\n- **Miniapps:** Miniapps now update automatically. Fixed miniapps getting stuck on loading screens.\n- **Mentra AI:** Reliability improvements and bug fixes.\n- **Notes:** Take photos with the glasses camera button, and add meeting and location details to your notes.\n- **Pairing and connections:** Improved glasses audio reconnection on Android.\n- **G1 and NIMO:** Improved text display, including accented letters.\n- **Android tablets:** The Mentra App now rotates to landscape."),
|
|
8
8
|
ReleaseChangelog(version = "3.2.1", markdown = "- **Livestreamer:** \"Stream Here\" now works without a Wi-Fi network. Improved stream startup and connection reliability.\n- **Photos and gallery:** More reliable photo capture and gallery syncing.\n- **Mentra AI:** Reliability improvements and bug fixes.\n- **Miniapps:** Smoother transitions, with back buttons and gestures that take you to the previous screen inside a miniapp.\n- **Pairing and connections:** Improved G1 pairing and G2 background reconnection.\n- **Glasses updates:** Fixed repeated update checks and improved recovery after interrupted updates.\n- **Mentra Maps:** Bug fixes.\n- **NIMO:** Improved text and map layouts.\n- **Self-hosting:** Connect the Mentra App to your own self-hosted Mentra backend."),
|
|
9
9
|
ReleaseChangelog(version = "3.2.0", markdown = "- Improved glasses connectivity and Wi-Fi setup.\n\n- Breaking Bluetooth SDK change: `forgetWifiNetwork(ssid)` now returns `WifiForgetResult` instead of `WifiStatusChangeEvent`. Migrate status-only consumers to the semantic `outcome`; the requested network remains `ssid`, while optional post-command connectivity is reported by `connected`, `currentSsid`, and `localIp`."),
|
|
10
10
|
ReleaseChangelog(version = "3.1.1", markdown = "- Improved Google login on iOS.\n- Pairing no longer requires phone microphone access."),
|
|
@@ -3,9 +3,9 @@ package com.mentra.bluetoothsdk
|
|
|
3
3
|
/** Generated by release CI. Do not edit in a release checkout. */
|
|
4
4
|
internal object GeneratedReleaseMetadata {
|
|
5
5
|
const val FAMILY_BASE_VERSION: String = "3.4.0"
|
|
6
|
-
const val RELEASE_IDENTITY: String = "3.4.0
|
|
7
|
-
const val RELEASE_SET_ID: String = "mentra-3.4.0
|
|
8
|
-
const val SOURCE_COMMIT: String = "
|
|
9
|
-
const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-
|
|
10
|
-
const val OTA_MANIFEST_SHA256: String = "
|
|
6
|
+
const val RELEASE_IDENTITY: String = "3.4.0"
|
|
7
|
+
const val RELEASE_SET_ID: String = "mentra-3.4.0"
|
|
8
|
+
const val SOURCE_COMMIT: String = "7fb33495a2971401485fae59afc83fd4c185eca8"
|
|
9
|
+
const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1390.json"
|
|
10
|
+
const val OTA_MANIFEST_SHA256: String = "b2f3cbd2b7dcc5bfc26f3569e13ad93d44e1b1bfaba76d5219050755fa6df781"
|
|
11
11
|
}
|
|
@@ -10,7 +10,6 @@ import android.os.Handler
|
|
|
10
10
|
import android.os.Looper
|
|
11
11
|
import android.util.Log
|
|
12
12
|
import com.mentra.bluetoothsdk.sgcs.MentraLive
|
|
13
|
-
import com.mentra.bluetoothsdk.sgcs.NimoResourceDiagnostics
|
|
14
13
|
import com.mentra.bluetoothsdk.streaming.StreamSessionState
|
|
15
14
|
import com.mentra.bluetoothsdk.utils.ControllerTypes
|
|
16
15
|
import com.mentra.bluetoothsdk.utils.PhoneAudioMonitor
|
|
@@ -95,6 +94,7 @@ class MentraBluetoothSdk private constructor(
|
|
|
95
94
|
private var pendingHotspotStatus: PendingHotspotStatusRequest? = null
|
|
96
95
|
private val hotspotMutex = Mutex()
|
|
97
96
|
private var pendingVersionInfo: PendingVersionInfoRequest? = null
|
|
97
|
+
private val besCrashReports = BesCrashReportWaiters()
|
|
98
98
|
private val wifiSessionCapabilities = WifiSessionCapabilities()
|
|
99
99
|
@Volatile private var configuredOtaVersionUrl: String? = null
|
|
100
100
|
|
|
@@ -149,6 +149,7 @@ class MentraBluetoothSdk private constructor(
|
|
|
149
149
|
private const val VIDEO_UPLOAD_STOP_TIMEOUT_MS = 10 * 60 * 1000L
|
|
150
150
|
private const val STREAM_START_TIMEOUT_MS = 30_000L
|
|
151
151
|
private const val STREAM_STOP_TIMEOUT_MS = 15_000L
|
|
152
|
+
private const val BES_CRASH_REPORTED_TIMEOUT_MS = 10_000L
|
|
152
153
|
private const val OTA_BES_VERSION_WAIT_MS = 5_000L
|
|
153
154
|
private const val OTA_MTK_VERSION_WAIT_MS = 2_000L
|
|
154
155
|
private const val OTA_VERSION_POLL_MS = 100L
|
|
@@ -349,7 +350,7 @@ class MentraBluetoothSdk private constructor(
|
|
|
349
350
|
dispatchDefaultDeviceChanged()
|
|
350
351
|
}
|
|
351
352
|
|
|
352
|
-
fun clearDefaultDevice() {
|
|
353
|
+
private fun clearDefaultDevice() {
|
|
353
354
|
suppressDefaultDeviceEvents = true
|
|
354
355
|
try {
|
|
355
356
|
DeviceStore.apply(ObservableStore.BLUETOOTH_CATEGORY, "default_wearable", "")
|
|
@@ -366,8 +367,6 @@ class MentraBluetoothSdk private constructor(
|
|
|
366
367
|
}
|
|
367
368
|
|
|
368
369
|
fun startScan(model: DeviceModel) {
|
|
369
|
-
if (NimoResourceDiagnostics.dispatchCapturedEntry { startScan(model) }) return
|
|
370
|
-
if (!NimoResourceDiagnostics.allowManagerConnect(model.deviceType)) return
|
|
371
370
|
if (model != DeviceModel.SIMULATED) {
|
|
372
371
|
requireBluetoothReady("scan for glasses")
|
|
373
372
|
}
|
|
@@ -474,13 +473,11 @@ class MentraBluetoothSdk private constructor(
|
|
|
474
473
|
|
|
475
474
|
@JvmOverloads
|
|
476
475
|
fun connect(device: Device, options: ConnectOptions = ConnectOptions()) {
|
|
477
|
-
if (NimoResourceDiagnostics.dispatchCapturedEntry { connect(device, options) }) return
|
|
478
|
-
if (!NimoResourceDiagnostics.allowManagerConnect(device.model.deviceType, device.name)) return
|
|
479
476
|
if (device.model != DeviceModel.SIMULATED) {
|
|
480
477
|
requireBluetoothReady("connect to glasses")
|
|
481
478
|
}
|
|
482
479
|
val isController = ControllerTypes.ALL.contains(device.model.deviceType)
|
|
483
|
-
if (options.cancelExistingConnectionAttempt
|
|
480
|
+
if (options.cancelExistingConnectionAttempt) {
|
|
484
481
|
if (isController) {
|
|
485
482
|
deviceManager.disconnectController()
|
|
486
483
|
} else {
|
|
@@ -517,18 +514,16 @@ class MentraBluetoothSdk private constructor(
|
|
|
517
514
|
|
|
518
515
|
@JvmOverloads
|
|
519
516
|
fun connectDefault(options: ConnectOptions = ConnectOptions()) {
|
|
520
|
-
if (NimoResourceDiagnostics.dispatchCapturedEntry { connectDefault(options) }) return
|
|
521
517
|
val defaultDevice =
|
|
522
518
|
currentDefaultDevice()
|
|
523
519
|
?: throw BluetoothSdkException(
|
|
524
520
|
"default_device_missing",
|
|
525
521
|
"Set a default glasses device before calling connectDefault.",
|
|
526
522
|
)
|
|
527
|
-
if (!NimoResourceDiagnostics.allowManagerConnect(defaultDevice.model.deviceType, defaultDevice.name)) return
|
|
528
523
|
if (defaultDevice.model != DeviceModel.SIMULATED) {
|
|
529
524
|
requireBluetoothReady("connect to glasses")
|
|
530
525
|
}
|
|
531
|
-
if (options.cancelExistingConnectionAttempt
|
|
526
|
+
if (options.cancelExistingConnectionAttempt) {
|
|
532
527
|
cancelConnectionAttempt()
|
|
533
528
|
}
|
|
534
529
|
deviceManager.connectDefault()
|
|
@@ -559,6 +554,12 @@ class MentraBluetoothSdk private constructor(
|
|
|
559
554
|
deviceManager.forget()
|
|
560
555
|
}
|
|
561
556
|
|
|
557
|
+
/** Unpair the glasses: disconnect, forget the default device and, on Mentra Live, remove the phone's Bluetooth bond. */
|
|
558
|
+
suspend fun unpair() {
|
|
559
|
+
analytics.noteDisconnectRequested(BluetoothSdkAnalyticsTracker.DISCONNECT_FORGET)
|
|
560
|
+
deviceManager.unpair()
|
|
561
|
+
}
|
|
562
|
+
|
|
562
563
|
@JvmOverloads
|
|
563
564
|
fun displayText(text: String, x: Int = 0, y: Int = 0, size: Int = 24) {
|
|
564
565
|
displayText(DisplayTextRequest(text = text, x = x, y = y, size = size))
|
|
@@ -1684,6 +1685,14 @@ class MentraBluetoothSdk private constructor(
|
|
|
1684
1685
|
deviceManager.sendIncidentId(incidentId, apiBaseUrl)
|
|
1685
1686
|
}
|
|
1686
1687
|
|
|
1688
|
+
/** Resolves on the glasses' matching `ok:true` ack; throws on `ok:false`, disconnect or timeout. */
|
|
1689
|
+
internal suspend fun sendBesCrashReported(incidentKey: String, reportId: String) {
|
|
1690
|
+
requireGlassesConnected("report the BES crash")
|
|
1691
|
+
besCrashReports.await(incidentKey, reportId, BES_CRASH_REPORTED_TIMEOUT_MS) {
|
|
1692
|
+
deviceManager.sendBesCrashReported(incidentKey, reportId)
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1687
1696
|
override fun close() {
|
|
1688
1697
|
resetWifiProtocolSession("", "sdk_closed")
|
|
1689
1698
|
if (activityLifecycleCallbacksRegistered) {
|
|
@@ -1704,6 +1713,12 @@ class MentraBluetoothSdk private constructor(
|
|
|
1704
1713
|
"glasses" -> {
|
|
1705
1714
|
if (changes["connected"] == false) {
|
|
1706
1715
|
resetWifiProtocolSession("", "wifi_session_disconnected")
|
|
1716
|
+
besCrashReports.rejectAll(
|
|
1717
|
+
BluetoothSdkException(
|
|
1718
|
+
"glasses_not_connected",
|
|
1719
|
+
"Glasses disconnected before acknowledging bes_crash_reported.",
|
|
1720
|
+
)
|
|
1721
|
+
)
|
|
1707
1722
|
}
|
|
1708
1723
|
analytics.observeGlassesStatus(getRawGlassesStatus(), ::isPhoneBluetoothOff)
|
|
1709
1724
|
val state = getState()
|
|
@@ -2065,6 +2080,12 @@ class MentraBluetoothSdk private constructor(
|
|
|
2065
2080
|
}
|
|
2066
2081
|
dispatchToListeners { it.onOtaStatus(event) }
|
|
2067
2082
|
}
|
|
2083
|
+
"bes_crash_detected" -> {
|
|
2084
|
+
val event = BesCrashDetectedEvent(data + mapOf("type" to "bes_crash_detected"))
|
|
2085
|
+
dispatchToListeners { it.onBesCrashDetected(event) }
|
|
2086
|
+
}
|
|
2087
|
+
// Request-scoped: consumed by the waiting sendBesCrashReported call, never a listener event.
|
|
2088
|
+
"bes_crash_reported_ack" -> besCrashReports.onAck(data)
|
|
2068
2089
|
"mic_health" -> {
|
|
2069
2090
|
dispatchToListeners { it.onMicHealth(MicHealthEvent.fromMap(data)) }
|
|
2070
2091
|
}
|