@mentra/bluetooth-sdk 3.4.0-dev.999 → 3.5.0-dev.1238
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/README.md +33 -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 +76 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +27 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +98 -120
- 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 +24 -9
- package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +170 -23
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +13 -316
- 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/SGCManager.kt +6 -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/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/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 +98 -1
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +42 -7
- 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/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 +6 -0
- package/build/index.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +66 -14
- 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/DeviceManager.swift +43 -22
- package/ios/Source/GeneratedChangelogCatalog.swift +2 -1
- package/ios/Source/GeneratedReleaseMetadata.swift +6 -6
- package/ios/Source/MentraBluetoothSDK.swift +27 -15
- 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/BluetoothAvailability.swift +15 -5
- package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +5 -0
- package/ios/Source/sgcs/MentraLive.swift +173 -42
- package/ios/Source/sgcs/Nimo.swift +39 -272
- package/ios/Source/sgcs/NimoCanvasCoordinator.swift +9 -38
- package/ios/Source/sgcs/NimoCanvasSession.swift +0 -1
- package/ios/Source/sgcs/SGCManager.swift +6 -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/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/PcmStreamTests.swift +299 -0
- package/ios/Tests/SpeechActivityTests.swift +238 -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 +102 -1
- package/src/_private/BluetoothSdkModule.ts +45 -7
- package/src/generated/changelogCatalog.ts +5 -1
- package/src/generated/releaseMetadata.ts +6 -6
- package/src/index.ts +12 -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/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -274
- 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/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
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
|
|
@@ -664,7 +666,7 @@ Engine coordinator:
|
|
|
664
666
|
|
|
665
667
|
Release CI embeds an immutable manifest URL and checksum into every published
|
|
666
668
|
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
|
|
669
|
+
package with its exact manifest and, for beta and stable releases, its OTA bundle. A completed release is available at
|
|
668
670
|
`https://github.com/Mentra-Community/MentraOS/releases/tag/mentra-v<releaseIdentity>`
|
|
669
671
|
and contains `mentra-release-<releaseIdentity>.json`, which records the exact
|
|
670
672
|
package coordinates, asset URLs, sizes, checksums, and build provenance.
|
|
@@ -679,10 +681,11 @@ Android/iOS OTA contract or infrastructure beneath a coordinator. React Native
|
|
|
679
681
|
application pages should render Mentra Engine's semantic controller state
|
|
680
682
|
instead of sequencing raw events.
|
|
681
683
|
|
|
682
|
-
Each
|
|
683
|
-
|
|
684
|
-
and
|
|
685
|
-
|
|
684
|
+
Each beta release publishes a portable OTA bundle; development releases do not.
|
|
685
|
+
A stable release publishes byte-identical copies of the promoted beta's OTA
|
|
686
|
+
manifest and bundle under its own names, so always resolve the bundle
|
|
687
|
+
coordinate and URL from `mentra-release-<releaseIdentity>.json` rather than
|
|
688
|
+
constructing a filename. The selected archive contains
|
|
686
689
|
`version.template.json`, every referenced ASG/MTK/BES artifact, `SHA256SUMS`,
|
|
687
690
|
and a dependency-free configuration script. After unpacking it, generate the
|
|
688
691
|
final manifest for its exact hosting URL:
|
|
@@ -865,10 +868,28 @@ MentraOS repo root:
|
|
|
865
868
|
./scripts/check-android-compile.sh bluetooth-sdk
|
|
866
869
|
```
|
|
867
870
|
|
|
868
|
-
The
|
|
869
|
-
|
|
870
|
-
`
|
|
871
|
-
|
|
871
|
+
The check script prepares `mobile/android` and uses its Gradle wrapper with
|
|
872
|
+
`-PmentraPublicSdk=true`, matching the CI release workflow's public SDK
|
|
873
|
+
dependency mode. Inside an Expo app, the `android/` folder in this package is
|
|
874
|
+
included by autolinking as `:mentra-bluetooth-sdk`.
|
|
875
|
+
|
|
876
|
+
A plain Android app can also build the native SDK from a MentraOS checkout,
|
|
877
|
+
without publishing it to Maven local, through a Gradle composite build. In the
|
|
878
|
+
app's `settings.gradle.kts`:
|
|
879
|
+
|
|
880
|
+
```kotlin
|
|
881
|
+
includeBuild("/path/to/MentraOS/mobile/modules/bluetooth-sdk/android") {
|
|
882
|
+
dependencySubstitution {
|
|
883
|
+
substitute(module("com.mentraglass:bluetooth-sdk")).using(project(":"))
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
The app keeps its `com.mentraglass:bluetooth-sdk` dependency; Gradle replaces it
|
|
889
|
+
with the source build. This standalone build has the same dependencies as the
|
|
890
|
+
Maven Central artifact (`-PmentraPublicSdk=true` is its default) and leaves out
|
|
891
|
+
the Expo adapter classes, which need an Expo host. It needs the Android NDK for
|
|
892
|
+
`lc3Lib`.
|
|
872
893
|
|
|
873
894
|
For bare native iOS or macOS apps, use the public SwiftPM repository:
|
|
874
895
|
|
|
@@ -878,7 +899,7 @@ https://github.com/Mentra-Community/mentra-bluetooth-sdk-ios.git
|
|
|
878
899
|
|
|
879
900
|
Select a coordinated SDK version that includes your target platform, then add
|
|
880
901
|
the `MentraBluetoothSDK` product to your app target. Native macOS support is new
|
|
881
|
-
on `dev`; use the local
|
|
902
|
+
on `dev`; use the local package below until a supporting release is published.
|
|
882
903
|
|
|
883
904
|
For local SDK development, add this package folder directly in Xcode:
|
|
884
905
|
|
|
@@ -894,7 +915,8 @@ permission/audio-input capability for host microphone capture and network-server
|
|
|
894
915
|
capability for local SDK servers. macOS uses CoreAudio instead of
|
|
895
916
|
`AVAudioSession`; it does not provide iOS background modes or ANCS relay. See
|
|
896
917
|
[the macOS integration guide](../../../mintlify-docs/bluetooth-sdk/macos.mdx)
|
|
897
|
-
and the
|
|
918
|
+
and the [`examples/bluetooth/macos`](../../../examples/bluetooth/macos/README.md) and
|
|
919
|
+
[`examples/bluetooth/react-native-macos`](../../../examples/bluetooth/react-native-macos/README.md) hosts.
|
|
898
920
|
|
|
899
921
|
Maintainers publishing the public SwiftPM mirror should follow
|
|
900
922
|
[RELEASING_IOS_SPM.md](./RELEASING_IOS_SPM.md).
|
package/android/build.gradle
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
185
|
-
apply
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
//
|
|
190
|
-
//
|
|
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
|
-
|
|
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
|
-
//
|
|
282
|
-
//
|
|
283
|
-
//
|
|
284
|
-
//
|
|
285
|
-
// 2.
|
|
286
|
-
//
|
|
287
|
-
dependencies.add(publicMavenSdk ? 'compileOnly' : 'implementation', '
|
|
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
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
//
|
|
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 {
|
package/android/settings.gradle
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
project
|
|
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,9 @@ object BluetoothSdkDefaults {
|
|
|
5
5
|
const val VOICE_ACTIVITY_DETECTION_ENABLED = false
|
|
6
6
|
const val LOUDNESS_GATE_ENABLED = true
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Must match the firmware default (on). Re-pushed on connect, so a false
|
|
10
|
+
* value here would silently turn it off on every pair the app touches.
|
|
11
|
+
*/
|
|
12
|
+
const val AUTO_POWER_OFF_ENABLED = true
|
|
10
13
|
}
|
|
@@ -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",
|
|
@@ -567,6 +574,12 @@ class BluetoothSdkModule : Module() {
|
|
|
567
574
|
sdk?.startScan(DeviceModel.fromDeviceType(model))
|
|
568
575
|
}
|
|
569
576
|
|
|
577
|
+
SdkAsyncFunction("getBondedGlasses") { ->
|
|
578
|
+
com.mentra.bluetoothsdk.sgcs.MentraLive.soleBondedMentraLive(Bridge.getContext())?.let {
|
|
579
|
+
mapOf("name" to (it.name ?: ""), "address" to it.address)
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
570
583
|
SdkAsyncFunction("getScanDiagnostic") { model: String ->
|
|
571
584
|
sdk?.connectedDeviceScanDiagnostic(DeviceModel.fromDeviceType(model))?.let {
|
|
572
585
|
mapOf("code" to it.code, "message" to it.message)
|
|
@@ -626,6 +639,10 @@ class BluetoothSdkModule : Module() {
|
|
|
626
639
|
requireSdk().sendIncidentId(incidentId, apiBaseUrl)
|
|
627
640
|
}
|
|
628
641
|
|
|
642
|
+
SdkCoroutineFunction("sendBesCrashReported") { incidentKey: String, reportId: String ->
|
|
643
|
+
requireSdk().sendBesCrashReported(incidentKey, reportId)
|
|
644
|
+
}
|
|
645
|
+
|
|
629
646
|
// MARK: - Native Notification Centre
|
|
630
647
|
|
|
631
648
|
// Public controls use the SDK facade; phone payload delivery uses DeviceManager.
|
|
@@ -885,13 +902,42 @@ class BluetoothSdkModule : Module() {
|
|
|
885
902
|
sdk?.setMicSourcePin(source)
|
|
886
903
|
}
|
|
887
904
|
|
|
888
|
-
//
|
|
889
|
-
//
|
|
890
|
-
//
|
|
905
|
+
// MARK: - On-device voice
|
|
906
|
+
//
|
|
907
|
+
// Everything that can wait on a model load or a worker runs on Dispatchers.IO,
|
|
908
|
+
// never on the shared Expo AsyncFunctionQueue, which every other native call
|
|
909
|
+
// (and every miniapp) waits behind.
|
|
910
|
+
|
|
911
|
+
AsyncFunction("setWakeWordDetection") Coroutine { enabled: Boolean, modelDir: String? ->
|
|
912
|
+
withContext(Dispatchers.IO) {
|
|
913
|
+
com.mentra.bluetoothsdk.stt.WakeWordDetector.configure(enabled, modelDir)
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// Lock-free: never waits on a model load.
|
|
918
|
+
AsyncFunction("isSttModelLoaded") { path: String ->
|
|
919
|
+
deviceManager?.isSttModelLoaded(path) ?: false
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// Resolves with the final text, "" when nothing was pending, or null when no
|
|
923
|
+
// streaming model is active, the model can't finalize early, or after 3 s.
|
|
924
|
+
AsyncFunction("finishTranscription") Coroutine { ->
|
|
925
|
+
withContext(Dispatchers.IO) { deviceManager?.finishTranscription() }
|
|
926
|
+
}
|
|
927
|
+
|
|
891
928
|
AsyncFunction("restartTranscriber") Coroutine { ->
|
|
892
929
|
withContext(Dispatchers.IO) { deviceManager?.restartTranscriber() }
|
|
893
930
|
}
|
|
894
931
|
|
|
932
|
+
AsyncFunction("setSpeechActivityDetection") Coroutine { enabled: Boolean, options: Map<String, Any?>? ->
|
|
933
|
+
val minSilenceMs =
|
|
934
|
+
(options?.get("minSilenceMs") as? Number)?.toInt()
|
|
935
|
+
?: com.mentra.bluetoothsdk.stt.SpeechActivityEngine.DEFAULT_MIN_SILENCE_MS
|
|
936
|
+
withContext(Dispatchers.IO) {
|
|
937
|
+
com.mentra.bluetoothsdk.stt.SpeechActivityDetector.configure(enabled, minSilenceMs)
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
895
941
|
// MARK: - Audio Playback Monitoring
|
|
896
942
|
|
|
897
943
|
SdkAsyncFunction("setOwnAppAudioPlaying") { playing: Boolean ->
|
|
@@ -933,6 +979,33 @@ class BluetoothSdkModule : Module() {
|
|
|
933
979
|
PcmStreamManager.abort(streamId)
|
|
934
980
|
}
|
|
935
981
|
|
|
982
|
+
// Native HTTP GET of raw s16le mono PCM, played as it arrives. Blocks a
|
|
983
|
+
// Dispatchers.IO thread (never the shared queue) until the body has played.
|
|
984
|
+
AsyncFunction("pcmStreamPlayUrl") Coroutine {
|
|
985
|
+
streamId: String,
|
|
986
|
+
url: String,
|
|
987
|
+
sampleRate: Int,
|
|
988
|
+
volume: Double,
|
|
989
|
+
jitterMs: Int?,
|
|
990
|
+
->
|
|
991
|
+
withContext(Dispatchers.IO) {
|
|
992
|
+
try {
|
|
993
|
+
mapOf(
|
|
994
|
+
"durationMs" to
|
|
995
|
+
PcmStreamManager.playUrl(
|
|
996
|
+
streamId,
|
|
997
|
+
url,
|
|
998
|
+
sampleRate,
|
|
999
|
+
volume.toFloat(),
|
|
1000
|
+
jitterMs,
|
|
1001
|
+
)
|
|
1002
|
+
)
|
|
1003
|
+
} catch (error: com.mentra.bluetoothsdk.utils.audio.PcmUrlPlaybackException) {
|
|
1004
|
+
throw CodedException(error.code, error.message ?: error.code, error)
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
936
1009
|
// *Blocking on Dispatchers.IO, not the shared AsyncFunctionQueue: these wait on
|
|
937
1010
|
// a CountDownLatch (up to 5s) for a BLE round-trip, which would otherwise stall
|
|
938
1011
|
// every other native call queued behind them.
|
|
@@ -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) {
|