@mentra/bluetooth-sdk 3.3.0-dev.944 → 3.4.0-beta.1237
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +61 -0
- package/README.md +111 -11
- package/android/build.gradle +60 -51
- package/android/gradle.properties +3 -0
- package/android/settings.gradle +47 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/BesCrashReportWaiters.kt +68 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +5 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +89 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +35 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +159 -110
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +21 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +2 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +6 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +35 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/TouchGesture.kt +19 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/connection/ConnectionModels.kt +5 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/GlassesAudioSetupPolicy.kt +64 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +1002 -157
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +227 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisement.kt +19 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingReadinessPolicy.kt +94 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateMachine.kt +411 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateStore.kt +124 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +54 -59
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +5 -32
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasEncoder.kt +8 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +3 -10
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +6 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/status/DeviceStatus.kt +50 -0
- 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/DeviceManagerOwnerLossTest.kt +146 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/GlassesStatusAudioSetupTest.kt +51 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/GlassesStatusClassicAudioTest.kt +2 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/TouchGestureCommandTest.kt +112 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/WifiAdbPeerIntentTest.kt +19 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/GlassesAudioSetupPolicyTest.kt +65 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveAudioSetupReadinessTest.kt +231 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/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 +368 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisementParserTest.kt +20 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingReadinessPolicyTest.kt +136 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateMachineTest.kt +346 -0
- package/android/src/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/utils/IncidentLogBleRelayNamingTest.kt +23 -0
- 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 +207 -2
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +45 -6
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js +2 -0
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/generated/changelogCatalog.d.ts +4 -1
- package/build/generated/changelogCatalog.d.ts.map +1 -1
- package/build/generated/changelogCatalog.js +5 -1
- package/build/generated/changelogCatalog.js.map +1 -1
- package/build/generated/releaseMetadata.js +6 -6
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +10 -0
- package/build/index.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +84 -12
- package/ios/MentraBluetoothSDK.podspec +4 -0
- package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
- package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
- package/ios/Source/BesCrashReportWaiters.swift +64 -0
- package/ios/Source/BluetoothSdkDefaults.swift +2 -2
- package/ios/Source/Bridge.swift +11 -3
- package/ios/Source/DeviceManager.swift +135 -18
- package/ios/Source/DeviceStore.swift +27 -0
- package/ios/Source/GeneratedChangelogCatalog.swift +2 -1
- package/ios/Source/GeneratedReleaseMetadata.swift +6 -6
- package/ios/Source/MentraBluetoothSDK.swift +51 -5
- package/ios/Source/TouchGesture.swift +13 -0
- 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/errors/BluetoothSdkError.swift +5 -1
- package/ios/Source/events/BluetoothEvents.swift +45 -0
- package/ios/Source/internal/BleTraceLogger.swift +9 -6
- package/ios/Source/internal/BluetoothAvailability.swift +15 -5
- package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +186 -0
- package/ios/Source/sgcs/MentraLive.swift +1366 -212
- package/ios/Source/sgcs/MentraLivePairingAdvertisement.swift +260 -1
- package/ios/Source/sgcs/MentraLivePairingStateMachine.swift +385 -0
- package/ios/Source/sgcs/MentraLivePairingStateStore.swift +121 -0
- package/ios/Source/sgcs/Nimo.swift +10 -3
- package/ios/Source/sgcs/NimoCanvasCoordinator.swift +39 -9
- package/ios/Source/sgcs/SGCManager.swift +13 -0
- package/ios/Source/sgcs/Simulated.swift +2 -0
- package/ios/Source/status/DeviceStatus.swift +35 -0
- 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/types/DeviceModels.swift +8 -1
- package/ios/Source/utils/AudioSessionMonitor.swift +158 -5
- 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/BluetoothAudioRouteTests.swift +82 -0
- package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
- package/ios/Tests/DeviceManagerReconnectTests.swift +4 -2
- package/ios/Tests/GlassesAudioSetupPolicyTests.swift +197 -0
- package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
- package/ios/Tests/MentraLiveAudioSetupTests.swift +209 -0
- package/ios/Tests/MentraLiveCommandQueueTests.swift +35 -0
- package/ios/Tests/MentraLiveConnectionOptionsTests.swift +55 -0
- package/ios/Tests/MentraLivePairingAdvertisementTests.swift +327 -0
- package/ios/Tests/MentraLivePairingStateMachineTests.swift +402 -0
- package/ios/Tests/MentraLiveSessionReadinessTests.swift +497 -26
- package/ios/Tests/NimoCanvasTransportTests.swift +58 -0
- package/ios/Tests/PcmStreamTests.swift +299 -0
- package/ios/Tests/SpeechActivityTests.swift +238 -0
- package/ios/Tests/SttModelTraitsTests.swift +62 -0
- package/ios/Tests/TouchGestureCommandTests.swift +87 -0
- package/ios/Tests/WifiAdbDispatchTests.swift +118 -0
- package/package.json +3 -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 +216 -1
- package/src/_private/BluetoothSdkModule.ts +49 -5
- package/src/generated/changelogCatalog.ts +5 -1
- package/src/generated/releaseMetadata.ts +6 -6
- package/src/index.ts +24 -0
- 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/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/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 -288
- /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
|
@@ -2,6 +2,7 @@ package com.mentra.bluetoothsdk
|
|
|
2
2
|
|
|
3
3
|
import android.os.Handler
|
|
4
4
|
import android.os.Looper
|
|
5
|
+
import com.mentra.bluetoothsdk.sgcs.GlassesAudioSetupPolicy
|
|
5
6
|
import com.mentra.bluetoothsdk.utils.DeviceTypes
|
|
6
7
|
import com.mentra.bluetoothsdk.utils.ConnTypes
|
|
7
8
|
import com.mentra.bluetoothsdk.utils.MicMap
|
|
@@ -79,6 +80,8 @@ object DeviceStore {
|
|
|
79
80
|
store.set("glasses", "micEnabled", false)
|
|
80
81
|
store.set("glasses", "voiceActivityDetectionEnabled", BluetoothSdkDefaults.VOICE_ACTIVITY_DETECTION_ENABLED)
|
|
81
82
|
store.set("glasses", "bluetoothClassicConnected", false)
|
|
83
|
+
store.set("glasses", "bluetoothClassicProfilesConnected", false)
|
|
84
|
+
store.set("glasses", "bluetoothAudioRouted", false)
|
|
82
85
|
store.set("glasses", "caseRemoved", true)
|
|
83
86
|
store.set("glasses", "caseOpen", true)
|
|
84
87
|
store.set("glasses", "caseCharging", false)
|
|
@@ -167,6 +170,16 @@ object DeviceStore {
|
|
|
167
170
|
return store.get(category, key)
|
|
168
171
|
}
|
|
169
172
|
|
|
173
|
+
/**
|
|
174
|
+
* `GlassesStatus.audioSetup` follows readiness on every model ([GlassesAudioSetupPolicy]), so
|
|
175
|
+
* the snapshot that changed `fullyBooted` already carries the new state. Announce it like
|
|
176
|
+
* `pairing_state_changed`, only when it changed.
|
|
177
|
+
*/
|
|
178
|
+
private fun publishAudioSetupChange(wasReady: Boolean, ready: Boolean) {
|
|
179
|
+
val state = GlassesAudioSetupPolicy.change(wasReady, ready) ?: return
|
|
180
|
+
Bridge.sendTypedMessage("audio_setup_changed", mapOf("state" to state.toMap()))
|
|
181
|
+
}
|
|
182
|
+
|
|
170
183
|
fun set(category: String, key: String, value: Any) {
|
|
171
184
|
store.set(category, key, value)
|
|
172
185
|
}
|
|
@@ -175,12 +188,20 @@ object DeviceStore {
|
|
|
175
188
|
fun apply(category: String, key: String, value: Any) {
|
|
176
189
|
val oldValue = store.get(category, key)
|
|
177
190
|
store.set(category, key, value)
|
|
191
|
+
if (category == "glasses" && key == "bluetoothClassicConnected") {
|
|
192
|
+
// Android has no separate profile/route signal; keep both equal to the Classic audio state.
|
|
193
|
+
store.set(category, "bluetoothClassicProfilesConnected", value)
|
|
194
|
+
store.set(category, "bluetoothAudioRouted", value)
|
|
195
|
+
}
|
|
178
196
|
val skipped = observableStoreWouldHaveSkipped(oldValue, value)
|
|
179
197
|
val forceMicReset =
|
|
180
198
|
category == ObservableStore.BLUETOOTH_CATEGORY && key == "mic_tuning" && isMicTuningReset(value)
|
|
181
199
|
if (skipped && !forceMicReset) {
|
|
182
200
|
return
|
|
183
201
|
}
|
|
202
|
+
if (category == "glasses" && key == "fullyBooted" && value is Boolean) {
|
|
203
|
+
publishAudioSetupChange(oldValue as? Boolean ?: false, value)
|
|
204
|
+
}
|
|
184
205
|
|
|
185
206
|
// Trigger hardware updates based on setting changes
|
|
186
207
|
when (category to key) {
|
|
@@ -3,7 +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.
|
|
6
|
+
ReleaseChangelog(version = "3.4.0", markdown = "This release is under active development. User-facing changes will be documented as they land."),
|
|
7
|
+
ReleaseChangelog(version = "3.3.0", markdown = "- **Mentra Call:** Now available on iPhone, with a redesigned call screen and photo sharing during calls.\n- **Microphone:** Improved glasses microphone reliability, including after phone calls.\n- **Photos and gallery:** More reliable photo capture and gallery syncing.\n- **Glasses updates:** More reliable glasses updates, with clearer progress.\n- **Miniapps:** Miniapps now update automatically. Fixed miniapps getting stuck on loading screens.\n- **Mentra AI:** Reliability improvements and bug fixes.\n- **Notes:** Take photos with the glasses camera button, and add meeting and location details to your notes.\n- **Pairing and connections:** Improved glasses audio reconnection on Android.\n- **G1 and NIMO:** Improved text display, including accented letters.\n- **Android tablets:** The Mentra App now rotates to landscape."),
|
|
7
8
|
ReleaseChangelog(version = "3.2.1", markdown = "- **Livestreamer:** \"Stream Here\" now works without a Wi-Fi network. Improved stream startup and connection reliability.\n- **Photos and gallery:** More reliable photo capture and gallery syncing.\n- **Mentra AI:** Reliability improvements and bug fixes.\n- **Miniapps:** Smoother transitions, with back buttons and gestures that take you to the previous screen inside a miniapp.\n- **Pairing and connections:** Improved G1 pairing and G2 background reconnection.\n- **Glasses updates:** Fixed repeated update checks and improved recovery after interrupted updates.\n- **Mentra Maps:** Bug fixes.\n- **NIMO:** Improved text and map layouts.\n- **Self-hosting:** Connect the Mentra App to your own self-hosted Mentra backend."),
|
|
8
9
|
ReleaseChangelog(version = "3.2.0", markdown = "- Improved glasses connectivity and Wi-Fi setup.\n\n- Breaking Bluetooth SDK change: `forgetWifiNetwork(ssid)` now returns `WifiForgetResult` instead of `WifiStatusChangeEvent`. Migrate status-only consumers to the semantic `outcome`; the requested network remains `ssid`, while optional post-command connectivity is reported by `connected`, `currentSsid`, and `localIp`."),
|
|
9
10
|
ReleaseChangelog(version = "3.1.1", markdown = "- Improved Google login on iOS.\n- Pairing no longer requires phone microphone access."),
|
|
@@ -2,10 +2,10 @@ package com.mentra.bluetoothsdk
|
|
|
2
2
|
|
|
3
3
|
/** Generated by release CI. Do not edit in a release checkout. */
|
|
4
4
|
internal object GeneratedReleaseMetadata {
|
|
5
|
-
const val FAMILY_BASE_VERSION: String = "3.
|
|
6
|
-
const val RELEASE_IDENTITY: String = "3.
|
|
7
|
-
const val RELEASE_SET_ID: String = "mentra-3.
|
|
8
|
-
const val SOURCE_COMMIT: String = "
|
|
9
|
-
const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.
|
|
10
|
-
const val OTA_MANIFEST_SHA256: String = "
|
|
5
|
+
const val FAMILY_BASE_VERSION: String = "3.4.0"
|
|
6
|
+
const val RELEASE_IDENTITY: String = "3.4.0-beta.1237"
|
|
7
|
+
const val RELEASE_SET_ID: String = "mentra-3.4.0-beta.1237"
|
|
8
|
+
const val SOURCE_COMMIT: String = "ad9203eb7fe636f5a6a77510451d0a8da34b880c"
|
|
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.1237.json"
|
|
10
|
+
const val OTA_MANIFEST_SHA256: String = "57f73cac781224161574b4a862c6fb76f98aafd384876ef1b06f998797d5e67f"
|
|
11
11
|
}
|
|
@@ -9,6 +9,7 @@ import android.os.Bundle
|
|
|
9
9
|
import android.os.Handler
|
|
10
10
|
import android.os.Looper
|
|
11
11
|
import android.util.Log
|
|
12
|
+
import com.mentra.bluetoothsdk.sgcs.MentraLive
|
|
12
13
|
import com.mentra.bluetoothsdk.streaming.StreamSessionState
|
|
13
14
|
import com.mentra.bluetoothsdk.utils.ControllerTypes
|
|
14
15
|
import com.mentra.bluetoothsdk.utils.PhoneAudioMonitor
|
|
@@ -93,6 +94,7 @@ class MentraBluetoothSdk private constructor(
|
|
|
93
94
|
private var pendingHotspotStatus: PendingHotspotStatusRequest? = null
|
|
94
95
|
private val hotspotMutex = Mutex()
|
|
95
96
|
private var pendingVersionInfo: PendingVersionInfoRequest? = null
|
|
97
|
+
private val besCrashReports = BesCrashReportWaiters()
|
|
96
98
|
private val wifiSessionCapabilities = WifiSessionCapabilities()
|
|
97
99
|
@Volatile private var configuredOtaVersionUrl: String? = null
|
|
98
100
|
|
|
@@ -147,6 +149,7 @@ class MentraBluetoothSdk private constructor(
|
|
|
147
149
|
private const val VIDEO_UPLOAD_STOP_TIMEOUT_MS = 10 * 60 * 1000L
|
|
148
150
|
private const val STREAM_START_TIMEOUT_MS = 30_000L
|
|
149
151
|
private const val STREAM_STOP_TIMEOUT_MS = 15_000L
|
|
152
|
+
private const val BES_CRASH_REPORTED_TIMEOUT_MS = 10_000L
|
|
150
153
|
private const val OTA_BES_VERSION_WAIT_MS = 5_000L
|
|
151
154
|
private const val OTA_MTK_VERSION_WAIT_MS = 2_000L
|
|
152
155
|
private const val OTA_VERSION_POLL_MS = 100L
|
|
@@ -640,6 +643,14 @@ class MentraBluetoothSdk private constructor(
|
|
|
640
643
|
send = { requestId -> deviceManager.sendGalleryServerEnabled(requestId, enabled) },
|
|
641
644
|
)
|
|
642
645
|
|
|
646
|
+
/** Disable a stock action while retaining touch events. Reset by BES on BLE disconnect. */
|
|
647
|
+
suspend fun setTouchGestureDefaultBehaviorEnabled(gesture: TouchGesture, enabled: Boolean): SettingsAckEvent =
|
|
648
|
+
performSettingsCommand(
|
|
649
|
+
setting = "touch_gesture_default",
|
|
650
|
+
updateStore = {},
|
|
651
|
+
send = { requestId -> deviceManager.sendTouchGestureDefaultBehaviorEnabled(requestId, gesture, enabled) },
|
|
652
|
+
)
|
|
653
|
+
|
|
643
654
|
suspend fun setGalleryModeEnabled(enabled: Boolean): SettingsAckEvent =
|
|
644
655
|
performSettingsCommand(
|
|
645
656
|
setting = "gallery_mode",
|
|
@@ -1111,8 +1122,9 @@ class MentraBluetoothSdk private constructor(
|
|
|
1111
1122
|
}
|
|
1112
1123
|
}
|
|
1113
1124
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1125
|
+
@JvmOverloads
|
|
1126
|
+
fun setWifiAdbState(enabled: Boolean, expectedBluetoothMac: String? = null) {
|
|
1127
|
+
deviceManager.setWifiAdbState(enabled, expectedBluetoothMac)
|
|
1116
1128
|
}
|
|
1117
1129
|
|
|
1118
1130
|
fun setSystemTime(timestampMs: Long) {
|
|
@@ -1667,6 +1679,14 @@ class MentraBluetoothSdk private constructor(
|
|
|
1667
1679
|
deviceManager.sendIncidentId(incidentId, apiBaseUrl)
|
|
1668
1680
|
}
|
|
1669
1681
|
|
|
1682
|
+
/** Resolves on the glasses' matching `ok:true` ack; throws on `ok:false`, disconnect or timeout. */
|
|
1683
|
+
internal suspend fun sendBesCrashReported(incidentKey: String, reportId: String) {
|
|
1684
|
+
requireGlassesConnected("report the BES crash")
|
|
1685
|
+
besCrashReports.await(incidentKey, reportId, BES_CRASH_REPORTED_TIMEOUT_MS) {
|
|
1686
|
+
deviceManager.sendBesCrashReported(incidentKey, reportId)
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1670
1690
|
override fun close() {
|
|
1671
1691
|
resetWifiProtocolSession("", "sdk_closed")
|
|
1672
1692
|
if (activityLifecycleCallbacksRegistered) {
|
|
@@ -1687,6 +1707,12 @@ class MentraBluetoothSdk private constructor(
|
|
|
1687
1707
|
"glasses" -> {
|
|
1688
1708
|
if (changes["connected"] == false) {
|
|
1689
1709
|
resetWifiProtocolSession("", "wifi_session_disconnected")
|
|
1710
|
+
besCrashReports.rejectAll(
|
|
1711
|
+
BluetoothSdkException(
|
|
1712
|
+
"glasses_not_connected",
|
|
1713
|
+
"Glasses disconnected before acknowledging bes_crash_reported.",
|
|
1714
|
+
)
|
|
1715
|
+
)
|
|
1690
1716
|
}
|
|
1691
1717
|
analytics.observeGlassesStatus(getRawGlassesStatus(), ::isPhoneBluetoothOff)
|
|
1692
1718
|
val state = getState()
|
|
@@ -2048,6 +2074,12 @@ class MentraBluetoothSdk private constructor(
|
|
|
2048
2074
|
}
|
|
2049
2075
|
dispatchToListeners { it.onOtaStatus(event) }
|
|
2050
2076
|
}
|
|
2077
|
+
"bes_crash_detected" -> {
|
|
2078
|
+
val event = BesCrashDetectedEvent(data + mapOf("type" to "bes_crash_detected"))
|
|
2079
|
+
dispatchToListeners { it.onBesCrashDetected(event) }
|
|
2080
|
+
}
|
|
2081
|
+
// Request-scoped: consumed by the waiting sendBesCrashReported call, never a listener event.
|
|
2082
|
+
"bes_crash_reported_ack" -> besCrashReports.onAck(data)
|
|
2051
2083
|
"mic_health" -> {
|
|
2052
2084
|
dispatchToListeners { it.onMicHealth(MicHealthEvent.fromMap(data)) }
|
|
2053
2085
|
}
|
|
@@ -2094,6 +2126,7 @@ class MentraBluetoothSdk private constructor(
|
|
|
2094
2126
|
BluetoothError(
|
|
2095
2127
|
code = "pair_failure",
|
|
2096
2128
|
message = data["error"] as? String ?: data.toString(),
|
|
2129
|
+
failureCode = data["code"] as? String,
|
|
2097
2130
|
)
|
|
2098
2131
|
)
|
|
2099
2132
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk
|
|
2
|
+
|
|
3
|
+
/** Mentra Live touchpad gestures, using the public touch_event names. */
|
|
4
|
+
enum class TouchGesture(val wireName: String) {
|
|
5
|
+
SINGLE_TAP("single_tap"),
|
|
6
|
+
DOUBLE_TAP("double_tap"),
|
|
7
|
+
TRIPLE_TAP("triple_tap"),
|
|
8
|
+
LONG_PRESS("long_press"),
|
|
9
|
+
FORWARD_SWIPE("forward_swipe"),
|
|
10
|
+
BACKWARD_SWIPE("backward_swipe"),
|
|
11
|
+
UP_SWIPE("up_swipe"),
|
|
12
|
+
DOWN_SWIPE("down_swipe");
|
|
13
|
+
|
|
14
|
+
companion object {
|
|
15
|
+
fun fromWireName(value: String): TouchGesture =
|
|
16
|
+
entries.firstOrNull { it.wireName == value }
|
|
17
|
+
?: throw BluetoothSdkException("invalid_touch_gesture", "Unknown touch gesture: $value")
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -45,6 +45,11 @@ data class BluetoothError(
|
|
|
45
45
|
val code: String,
|
|
46
46
|
val message: String,
|
|
47
47
|
val cause: Throwable? = null,
|
|
48
|
+
/**
|
|
49
|
+
* Stable machine-readable cause within [code], when the SDK can classify it. For
|
|
50
|
+
* `pair_failure`: `ios_forget_pairing` (iOS only).
|
|
51
|
+
*/
|
|
52
|
+
val failureCode: String? = null,
|
|
48
53
|
)
|
|
49
54
|
|
|
50
55
|
enum class ScanStopReason {
|
|
@@ -106,6 +106,21 @@ data class OtaStatusEvent(
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/** Mentra Live stored a BES crash incident; [values] is the glasses message with JSON nulls omitted. */
|
|
110
|
+
data class BesCrashDetectedEvent(
|
|
111
|
+
val values: Map<String, Any>,
|
|
112
|
+
) {
|
|
113
|
+
val incidentKey: String get() = stringValue(values, "incidentKey").orEmpty()
|
|
114
|
+
val reason: String get() = stringValue(values, "reason").orEmpty()
|
|
115
|
+
val state: String get() = stringValue(values, "state").orEmpty()
|
|
116
|
+
val reportId: String? get() = stringValue(values, "reportId")?.takeIf { it.isNotEmpty() }
|
|
117
|
+
@Suppress("UNCHECKED_CAST")
|
|
118
|
+
val summary: Map<String, Any> get() = values["summary"] as? Map<String, Any> ?: emptyMap()
|
|
119
|
+
|
|
120
|
+
/** Event body for JavaScript; `reportId` is null rather than absent before a report exists. */
|
|
121
|
+
fun toEventMap(): Map<String, Any?> = values + ("reportId" to reportId)
|
|
122
|
+
}
|
|
123
|
+
|
|
109
124
|
data class OtaQueryResult(
|
|
110
125
|
val values: Map<String, Any>,
|
|
111
126
|
) {
|
|
@@ -170,6 +185,7 @@ interface MentraBluetoothSdkListener {
|
|
|
170
185
|
fun onKeepAliveAck(event: KeepAliveAckEvent) {}
|
|
171
186
|
fun onOtaStartAck(event: OtaStartAckEvent) {}
|
|
172
187
|
fun onOtaStatus(event: OtaStatusEvent) {}
|
|
188
|
+
fun onBesCrashDetected(event: BesCrashDetectedEvent) {}
|
|
173
189
|
fun onSettingsAck(event: SettingsAckEvent) {}
|
|
174
190
|
fun onVersionInfo(event: VersionInfoResult) {}
|
|
175
191
|
fun onMicPcm(event: MicPcmEvent) {}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.sgcs
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `GlassesStatus.audioSetup`: whether the user has to do anything to get glasses audio working.
|
|
5
|
+
* Native code encodes it as a map, `{"state": "idle"}` through
|
|
6
|
+
* `{"state": "needs_user", "action": "connect_in_settings"}`, the same shape as the TypeScript
|
|
7
|
+
* `GlassesAudioSetupState` and iOS.
|
|
8
|
+
*/
|
|
9
|
+
internal enum class GlassesAudioSetupState(val state: String, val action: String? = null) {
|
|
10
|
+
/** No glasses session. */
|
|
11
|
+
IDLE("idle"),
|
|
12
|
+
/** No user step for audio on this platform and glasses. */
|
|
13
|
+
NOT_APPLICABLE("not_applicable"),
|
|
14
|
+
/** The link is up, audio is not, and the SDK still expects audio to come up on its own. */
|
|
15
|
+
CONNECTING("connecting"),
|
|
16
|
+
/** Classic audio to these glasses is up. */
|
|
17
|
+
CONNECTED("connected"),
|
|
18
|
+
/** Audio did not come up on its own. The user connects it in system Bluetooth settings. */
|
|
19
|
+
NEEDS_USER("needs_user", "connect_in_settings");
|
|
20
|
+
|
|
21
|
+
fun toMap(): Map<String, Any> =
|
|
22
|
+
if (action == null) mapOf("state" to state) else mapOf("state" to state, "action" to action)
|
|
23
|
+
|
|
24
|
+
companion object {
|
|
25
|
+
fun fromMap(raw: Any?): GlassesAudioSetupState? {
|
|
26
|
+
val state = (raw as? Map<*, *>)?.get("state") as? String ?: return null
|
|
27
|
+
return values().firstOrNull { it.state == state }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The Android audio setup rule, for every glasses model including Mentra Live. Android attaches
|
|
34
|
+
* Classic audio from the BLE bond (CTKD on secure Mentra Live firmware, `createBond` on older
|
|
35
|
+
* firmware), and glasses without Classic audio have nothing to set up, so there is never a user
|
|
36
|
+
* step to offer: `not_applicable` while the glasses are ready, `idle` without a session. The
|
|
37
|
+
* shared status layer applies it, so the update that marks the glasses ready carries
|
|
38
|
+
* `not_applicable` with it. iOS keeps its timed Mentra Live rules in `GlassesAudioSetupPolicy.swift`.
|
|
39
|
+
*/
|
|
40
|
+
internal object GlassesAudioSetupPolicy {
|
|
41
|
+
fun state(ready: Boolean): GlassesAudioSetupState =
|
|
42
|
+
if (ready) GlassesAudioSetupState.NOT_APPLICABLE else GlassesAudioSetupState.IDLE
|
|
43
|
+
|
|
44
|
+
/** The state `audio_setup_changed` announces when readiness moves, or null when it is unchanged. */
|
|
45
|
+
fun change(wasReady: Boolean, ready: Boolean): GlassesAudioSetupState? {
|
|
46
|
+
val after = state(ready)
|
|
47
|
+
return if (state(wasReady) == after) null else after
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Mentra Live firmware `{"type":"classic_link","a2dp":<bool>,"hfp":<bool>}`: whether the phone's
|
|
53
|
+
* A2DP and HFP (service-level) links to the glasses are up. iOS feeds it into its audio setup
|
|
54
|
+
* rules; Android's `audioSetup` does not depend on it. A missing or malformed field reads false.
|
|
55
|
+
*/
|
|
56
|
+
internal data class MentraLiveClassicLink(val a2dp: Boolean, val hfp: Boolean) {
|
|
57
|
+
companion object {
|
|
58
|
+
fun parse(json: org.json.JSONObject): MentraLiveClassicLink =
|
|
59
|
+
MentraLiveClassicLink(
|
|
60
|
+
a2dp = json.optBoolean("a2dp", false),
|
|
61
|
+
hfp = json.optBoolean("hfp", false),
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
}
|