@mentra/bluetooth-sdk 3.3.0 → 3.4.0-beta.1241
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 +80 -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 +85 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +35 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +154 -110
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +21 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +1 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +6 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +27 -2
- 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 +925 -155
- 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/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 +5 -1
- 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/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 +201 -1
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +43 -5
- 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 +3 -0
- package/build/generated/changelogCatalog.d.ts.map +1 -1
- package/build/generated/changelogCatalog.js +4 -0
- 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 +9 -0
- package/build/index.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +76 -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 +131 -18
- package/ios/Source/DeviceStore.swift +27 -0
- package/ios/Source/GeneratedChangelogCatalog.swift +1 -0
- package/ios/Source/GeneratedReleaseMetadata.swift +6 -6
- package/ios/Source/MentraBluetoothSDK.swift +40 -5
- 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 +41 -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 +1270 -189
- 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/MentraLiveConnectionOptionsTests.swift +55 -0
- package/ios/Tests/MentraLivePairingAdvertisementTests.swift +327 -0
- package/ios/Tests/MentraLivePairingStateMachineTests.swift +402 -0
- package/ios/Tests/MentraLiveSessionReadinessTests.swift +368 -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/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 +201 -1
- package/src/_private/BluetoothSdkModule.ts +47 -5
- package/src/generated/changelogCatalog.ts +4 -0
- package/src/generated/releaseMetadata.ts +6 -6
- package/src/index.ts +22 -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
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.stt
|
|
2
|
+
|
|
3
|
+
import java.io.File
|
|
4
|
+
import java.nio.file.Files
|
|
5
|
+
import org.junit.Assert.assertEquals
|
|
6
|
+
import org.junit.Test
|
|
7
|
+
|
|
8
|
+
class SttTextFormatterTest {
|
|
9
|
+
private val text = "Hello, Mentra! I'm in New York."
|
|
10
|
+
|
|
11
|
+
// Excerpts of real tokens.txt files.
|
|
12
|
+
private val originalZipformerTokens =
|
|
13
|
+
sequenceOf("<blk> 0", "<sos/eos> 1", "<unk> 2", "S 3", "▁THE 4", "▁A 5", "T 6", "'S 7")
|
|
14
|
+
private val krokoTokens =
|
|
15
|
+
sequenceOf("<blk> 0", "<unk> 1", "▁the 2", "▁I 3", "s 4", ", 5", ". 6", "▁New 7")
|
|
16
|
+
|
|
17
|
+
@Test
|
|
18
|
+
fun upperCaseOnlyVocabularyIsLowercased() {
|
|
19
|
+
val casing = SttTextFormatter.casingForTokens(originalZipformerTokens)
|
|
20
|
+
assertEquals(SttTextFormatter.Casing.LOWERCASE, casing)
|
|
21
|
+
assertEquals("hello mentra", SttTextFormatter.format("HELLO MENTRA", casing))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Test
|
|
25
|
+
fun mixedCaseVocabularyKeepsTheModelsText() {
|
|
26
|
+
val casing = SttTextFormatter.casingForTokens(krokoTokens)
|
|
27
|
+
assertEquals(SttTextFormatter.Casing.PRESERVE, casing)
|
|
28
|
+
assertEquals(text, SttTextFormatter.format(text, casing))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Test
|
|
32
|
+
fun specialTokensAloneDoNotDecide() {
|
|
33
|
+
// <blk>/<unk> contain lower-case letters but never reach the transcript.
|
|
34
|
+
assertEquals(
|
|
35
|
+
SttTextFormatter.Casing.LOWERCASE,
|
|
36
|
+
SttTextFormatter.casingForTokens(sequenceOf("<blk> 0", "<unk> 1", "▁HI 2", "<0x41> 3")),
|
|
37
|
+
)
|
|
38
|
+
assertEquals(
|
|
39
|
+
SttTextFormatter.Casing.PRESERVE,
|
|
40
|
+
SttTextFormatter.casingForTokens(sequenceOf("<blk> 0", "▁ 1", "1 2")),
|
|
41
|
+
)
|
|
42
|
+
// Tab-separated ids, as some tokens.txt files use.
|
|
43
|
+
assertEquals(
|
|
44
|
+
SttTextFormatter.Casing.LOWERCASE,
|
|
45
|
+
SttTextFormatter.casingForTokens(sequenceOf("<blk>\t0", "▁HELLO\t1")),
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Test
|
|
50
|
+
fun casingComesFromTheModelFilesNotTheFolderName() {
|
|
51
|
+
val root = Files.createTempDirectory("stt-format").toFile()
|
|
52
|
+
try {
|
|
53
|
+
// The original Zipformer under a folder named like Kroko still lowercases.
|
|
54
|
+
val misnamed = File(root, "en-kroko").apply { mkdirs() }
|
|
55
|
+
File(misnamed, "tokens.txt").writeText(originalZipformerTokens.joinToString("\n"))
|
|
56
|
+
assertEquals(SttTextFormatter.Casing.LOWERCASE, SttTextFormatter.casingForModel(misnamed))
|
|
57
|
+
|
|
58
|
+
val kroko = File(root, "en").apply { mkdirs() }
|
|
59
|
+
File(kroko, "tokens.txt").writeText(krokoTokens.joinToString("\n"))
|
|
60
|
+
assertEquals(SttTextFormatter.Casing.PRESERVE, SttTextFormatter.casingForModel(kroko))
|
|
61
|
+
|
|
62
|
+
assertEquals(SttTextFormatter.Casing.PRESERVE, SttTextFormatter.casingForModel(File(root, "missing")))
|
|
63
|
+
} finally {
|
|
64
|
+
root.deleteRecursively()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.utils.audio
|
|
2
|
+
|
|
3
|
+
import java.io.ByteArrayOutputStream
|
|
4
|
+
import java.io.InputStream
|
|
5
|
+
import org.junit.Assert.assertArrayEquals
|
|
6
|
+
import org.junit.Assert.assertEquals
|
|
7
|
+
import org.junit.Assert.assertFalse
|
|
8
|
+
import org.junit.Assert.assertNull
|
|
9
|
+
import org.junit.Assert.assertTrue
|
|
10
|
+
import org.junit.Test
|
|
11
|
+
import org.junit.runner.RunWith
|
|
12
|
+
import org.robolectric.RobolectricTestRunner
|
|
13
|
+
import org.robolectric.annotation.Config
|
|
14
|
+
|
|
15
|
+
@RunWith(RobolectricTestRunner::class)
|
|
16
|
+
@Config(sdk = [33])
|
|
17
|
+
class PcmUrlPlaybackTest {
|
|
18
|
+
@Test
|
|
19
|
+
fun carryKeepsSamplesWholeAcrossOddChunks() {
|
|
20
|
+
val carry = Pcm16ByteCarry()
|
|
21
|
+
assertNull(carry.push(byteArrayOf(1), 1))
|
|
22
|
+
assertTrue(carry.hasPendingByte)
|
|
23
|
+
assertArrayEquals(byteArrayOf(1, 2), carry.push(byteArrayOf(2, 3, 4, 5), 1))
|
|
24
|
+
assertFalse(carry.hasPendingByte)
|
|
25
|
+
assertArrayEquals(byteArrayOf(3, 4, 5, 6), carry.push(byteArrayOf(3, 4, 5, 6, 7), 5))
|
|
26
|
+
assertTrue(carry.hasPendingByte)
|
|
27
|
+
assertArrayEquals(byteArrayOf(7, 8, 9, 10), carry.push(byteArrayOf(8, 9, 10), 3))
|
|
28
|
+
assertFalse(carry.hasPendingByte)
|
|
29
|
+
assertNull(carry.push(byteArrayOf(), 0))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Test
|
|
33
|
+
fun compressedContentTypesAreRejectedAndRawTypesPlayed() {
|
|
34
|
+
for (type in listOf("audio/mpeg", "Audio/MPEG; charset=binary", "audio/mp3", "audio/aac", "audio/ogg", "audio/opus", "audio/webm")) {
|
|
35
|
+
assertTrue(type, PcmUrlPlayback.isCompressedAudio(type))
|
|
36
|
+
}
|
|
37
|
+
for (type in listOf(null, "", "audio/L16; rate=24000", "audio/pcm", "application/octet-stream")) {
|
|
38
|
+
assertFalse(type.toString(), PcmUrlPlayback.isCompressedAudio(type))
|
|
39
|
+
}
|
|
40
|
+
assertEquals("audio/mpeg", PcmUrlPlayback.mediaType(" Audio/MPEG ; q=1"))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Returns at most a scripted number of bytes per read, like a network body. */
|
|
44
|
+
private class TricklingStream(private val data: ByteArray, private val sizes: IntArray) : InputStream() {
|
|
45
|
+
private var pos = 0
|
|
46
|
+
private var call = 0
|
|
47
|
+
|
|
48
|
+
override fun read(): Int = if (pos < data.size) data[pos++].toInt() and 0xff else -1
|
|
49
|
+
|
|
50
|
+
override fun read(b: ByteArray, off: Int, len: Int): Int {
|
|
51
|
+
if (pos >= data.size) return -1
|
|
52
|
+
val n = minOf(len, sizes[call++ % sizes.size], data.size - pos)
|
|
53
|
+
System.arraycopy(data, pos, b, off, n)
|
|
54
|
+
pos += n
|
|
55
|
+
return n
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Test
|
|
60
|
+
fun pumpWritesEverySampleInOrderInEvenChunks() {
|
|
61
|
+
val body = ByteArray(10_001) { (it * 7).toByte() }
|
|
62
|
+
val written = ByteArrayOutputStream()
|
|
63
|
+
val chunkSizes = mutableListOf<Int>()
|
|
64
|
+
|
|
65
|
+
val total =
|
|
66
|
+
PcmUrlPlayback.pump(TricklingStream(body, intArrayOf(1, 333, 2, 4095, 7, 64))) { chunk ->
|
|
67
|
+
chunkSizes.add(chunk.size)
|
|
68
|
+
written.write(chunk)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// The final odd byte has no pair and is dropped; everything else arrives in order.
|
|
72
|
+
assertEquals(10_000L, total)
|
|
73
|
+
assertArrayEquals(body.copyOf(10_000), written.toByteArray())
|
|
74
|
+
assertTrue(chunkSizes.all { it > 0 && it % 2 == 0 })
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -69,6 +69,26 @@ export type GlassesMediaVolumeGetResult = {
|
|
|
69
69
|
export type GlassesMediaVolumeSetResult = {
|
|
70
70
|
statusCode: number;
|
|
71
71
|
};
|
|
72
|
+
/** On-device keyword spotter state and detections. Describes only the wake-word model. */
|
|
73
|
+
export type WakeWordEvent = {
|
|
74
|
+
kind: "loading" | "ready" | "detected" | "error";
|
|
75
|
+
phrase: string;
|
|
76
|
+
/** Unix epoch milliseconds. */
|
|
77
|
+
timestamp: number;
|
|
78
|
+
message?: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Phone-side speech activity from the on-device Silero detector
|
|
82
|
+
* ([setSpeechActivityDetection]). Sent on transitions only. A gap in incoming
|
|
83
|
+
* microphone audio counts as silence.
|
|
84
|
+
*/
|
|
85
|
+
export type SpeechActivityEvent = {
|
|
86
|
+
speaking: boolean;
|
|
87
|
+
/** 0 while speaking; on a silence transition, how long the audio has been silent. */
|
|
88
|
+
silentForMs: number;
|
|
89
|
+
/** Unix epoch milliseconds. */
|
|
90
|
+
timestamp: number;
|
|
91
|
+
};
|
|
72
92
|
export type LocalTranscriptionEvent = {
|
|
73
93
|
text: string;
|
|
74
94
|
isFinal?: boolean;
|
|
@@ -725,9 +745,73 @@ export type StreamKeepAliveRequest = {
|
|
|
725
745
|
streamId: string;
|
|
726
746
|
ackId: string;
|
|
727
747
|
};
|
|
748
|
+
/**
|
|
749
|
+
* Stable machine-readable `pair_failure` causes. Unknown native codes still typecheck.
|
|
750
|
+
* `ios_forget_pairing`: iOS holds a stale Bluetooth pairing for these glasses during an
|
|
751
|
+
* explicit attempt; the user must remove it in Settings > Bluetooth before pairing again.
|
|
752
|
+
*/
|
|
753
|
+
export type PairFailureCode = "ios_forget_pairing" | string;
|
|
728
754
|
export type PairFailureEvent = {
|
|
729
755
|
type: "pair_failure";
|
|
730
756
|
error: string;
|
|
757
|
+
/** Stable cause, when the SDK can classify the failure. */
|
|
758
|
+
code?: PairFailureCode;
|
|
759
|
+
};
|
|
760
|
+
/**
|
|
761
|
+
* Mentra Live pairing state, owned by the SDK.
|
|
762
|
+
* - `normal`: no pairing mode in effect; automatic reconnect is allowed.
|
|
763
|
+
* - `pairing_mode`: the glasses opened a pairing window. Automatic reconnect is paused until
|
|
764
|
+
* `endsAtMs` or until the glasses report the window ended. `windowId` identifies the
|
|
765
|
+
* window and survives a cold restart.
|
|
766
|
+
* - `pairing_rejected`: the glasses no longer accept this phone (another phone paired, or repeated
|
|
767
|
+
* authentication rejections on secure-pairing firmware). Reconnect has stopped. Render Pair Again.
|
|
768
|
+
*/
|
|
769
|
+
export type MentraLivePairingState = {
|
|
770
|
+
state: "normal";
|
|
771
|
+
} | {
|
|
772
|
+
state: "pairing_mode";
|
|
773
|
+
windowId: number;
|
|
774
|
+
endsAtMs: number;
|
|
775
|
+
} | {
|
|
776
|
+
state: "pairing_rejected";
|
|
777
|
+
};
|
|
778
|
+
export type PairingStateChangedEvent = {
|
|
779
|
+
state: MentraLivePairingState;
|
|
780
|
+
};
|
|
781
|
+
/**
|
|
782
|
+
* Whether the user has to do anything to get glasses audio working, decided by the SDK for
|
|
783
|
+
* every glasses model. Render it; do not add your own audio timers or platform checks.
|
|
784
|
+
*
|
|
785
|
+
* - `idle`: no glasses session.
|
|
786
|
+
* - `not_applicable`: no user step for audio. Android attaches Classic audio from the BLE bond,
|
|
787
|
+
* and glasses without Classic audio have nothing to set up.
|
|
788
|
+
* - `connecting`: the glasses are connected, audio is not, and the SDK still expects audio to
|
|
789
|
+
* come up on its own (for example iPhone audio derived from the BLE pair). After setup, Mentra
|
|
790
|
+
* Live firmware that reports `classic_link` reconnects audio itself and stays here.
|
|
791
|
+
* - `connected`: Classic audio (A2DP or HFP) to the glasses is up.
|
|
792
|
+
* - `needs_user`: audio did not come up on its own. Ask the user to connect the glasses in the
|
|
793
|
+
* system Bluetooth settings (iPhone: Settings > Bluetooth). The state moves to `connected`
|
|
794
|
+
* as soon as audio comes up.
|
|
795
|
+
*/
|
|
796
|
+
export type GlassesAudioSetupState = {
|
|
797
|
+
state: "idle";
|
|
798
|
+
} | {
|
|
799
|
+
state: "not_applicable";
|
|
800
|
+
} | {
|
|
801
|
+
state: "connecting";
|
|
802
|
+
} | {
|
|
803
|
+
state: "connected";
|
|
804
|
+
} | {
|
|
805
|
+
state: "needs_user";
|
|
806
|
+
action: "connect_in_settings";
|
|
807
|
+
};
|
|
808
|
+
export type AudioSetupChangedEvent = {
|
|
809
|
+
state: GlassesAudioSetupState;
|
|
810
|
+
};
|
|
811
|
+
export type PairingModeEndedReason = "paired" | "cancelled" | "timeout" | string;
|
|
812
|
+
export type PairingModeEndedEvent = {
|
|
813
|
+
reason: PairingModeEndedReason;
|
|
814
|
+
window_id?: number;
|
|
731
815
|
};
|
|
732
816
|
export type PairingInfoEvent = {
|
|
733
817
|
had_previous_bond: boolean;
|
|
@@ -735,11 +819,25 @@ export type PairingInfoEvent = {
|
|
|
735
819
|
classic_bond_ready?: boolean;
|
|
736
820
|
secure_pairing_capable?: boolean;
|
|
737
821
|
protocol_version?: number;
|
|
822
|
+
/** Present when the glasses build includes ownership transfer. */
|
|
823
|
+
ownership_transfer?: boolean;
|
|
824
|
+
/** True when the glasses derive Classic audio from the LE pair (CTKD), so audio should connect on its own. */
|
|
825
|
+
auto_audio?: boolean;
|
|
826
|
+
/** True only after a BLE bond committed the owner and the window closed. */
|
|
827
|
+
owner_committed?: boolean;
|
|
738
828
|
};
|
|
739
829
|
export type EnteringPairingModeEvent = {
|
|
740
830
|
window_ms: number;
|
|
831
|
+
/** Identifies this pairing window. Also carried in `pairing_mode_ended` and the advertisement. */
|
|
832
|
+
window_id?: number;
|
|
741
833
|
reason?: string;
|
|
834
|
+
/** The glasses kept their bonds when the window opened; they change only if another phone pairs. */
|
|
835
|
+
owner_retained?: boolean;
|
|
742
836
|
};
|
|
837
|
+
/**
|
|
838
|
+
* @deprecated No longer emitted. Observe `pairing_state_changed` (or `GlassesStatus.pairingState`)
|
|
839
|
+
* and render Pair Again for `pairing_rejected`.
|
|
840
|
+
*/
|
|
743
841
|
export type OwnerReplacedEvent = {
|
|
744
842
|
reason: string;
|
|
745
843
|
};
|
|
@@ -938,6 +1036,50 @@ export type OtaStatusEvent = {
|
|
|
938
1036
|
error_message?: string;
|
|
939
1037
|
};
|
|
940
1038
|
export type OtaQueryResult = OtaStatusEvent;
|
|
1039
|
+
/** Lifecycle of a BES crash incident bundle on Mentra Live glasses. */
|
|
1040
|
+
export type BesCrashIncidentState = "COLLECTING" | "STORED" | "REPORTED" | "UPLOADED" | "EVICTED";
|
|
1041
|
+
/** One incident bundle the glasses dropped to stay within their storage budget. */
|
|
1042
|
+
export type BesCrashEviction = {
|
|
1043
|
+
incidentKey: string;
|
|
1044
|
+
reason: string;
|
|
1045
|
+
bytes: number;
|
|
1046
|
+
ms: number;
|
|
1047
|
+
};
|
|
1048
|
+
/**
|
|
1049
|
+
* Glasses-side summary of a BES crash incident. Fields the glasses could not
|
|
1050
|
+
* determine (for example `dumpId` of a reset without a dump) may be absent or null.
|
|
1051
|
+
*/
|
|
1052
|
+
export type BesCrashSummary = {
|
|
1053
|
+
attribution: "match" | "older" | "unknown";
|
|
1054
|
+
dumpId?: string | null;
|
|
1055
|
+
bootId?: string | null;
|
|
1056
|
+
resetHw?: number | null;
|
|
1057
|
+
resetSw?: number | null;
|
|
1058
|
+
crashUnixMs?: number | null;
|
|
1059
|
+
coveredFromMs?: number | null;
|
|
1060
|
+
coveredToMs?: number | null;
|
|
1061
|
+
traceGaps: number;
|
|
1062
|
+
truncated: boolean;
|
|
1063
|
+
torn: boolean;
|
|
1064
|
+
tailCaptured: boolean;
|
|
1065
|
+
dumpGap: boolean;
|
|
1066
|
+
evictedCount: number;
|
|
1067
|
+
recentEvictions: BesCrashEviction[];
|
|
1068
|
+
};
|
|
1069
|
+
/**
|
|
1070
|
+
* Mentra Live stored a BES crash or unexpected-reset incident. Sent when the
|
|
1071
|
+
* incident becomes `STORED`, and again on every reconnect while it is `STORED`
|
|
1072
|
+
* or `REPORTED`, so handlers must be idempotent per `incidentKey`.
|
|
1073
|
+
*/
|
|
1074
|
+
export type BesCrashDetectedEvent = {
|
|
1075
|
+
type: "bes_crash_detected";
|
|
1076
|
+
incidentKey: string;
|
|
1077
|
+
reason: "bes_crash" | "bes_unexpected_reset";
|
|
1078
|
+
state: BesCrashIncidentState;
|
|
1079
|
+
/** Cloud report already recorded for this incident, or null before one is reported. */
|
|
1080
|
+
reportId: string | null;
|
|
1081
|
+
summary: BesCrashSummary;
|
|
1082
|
+
};
|
|
941
1083
|
/** Nex BLE protobuf trace (NexEventUtils); payload matches native Map keys. */
|
|
942
1084
|
export type BleCommandTraceEvent = {
|
|
943
1085
|
command: string;
|
|
@@ -968,6 +1110,8 @@ export type BluetoothSdkModuleEvents = {
|
|
|
968
1110
|
voice_activity_detection_status: (event: VoiceActivityDetectionStatusEvent) => void;
|
|
969
1111
|
speaking_status: (event: SpeakingStatusEvent) => void;
|
|
970
1112
|
battery_status: (event: BatteryStatusEvent) => void;
|
|
1113
|
+
wake_word: (event: WakeWordEvent) => void;
|
|
1114
|
+
speech_activity: (event: SpeechActivityEvent) => void;
|
|
971
1115
|
local_transcription: (event: LocalTranscriptionEvent) => void;
|
|
972
1116
|
native_notification_status: (event: NativeNotificationStatus) => void;
|
|
973
1117
|
native_notification_delivery: (event: NativeNotificationDelivery) => void;
|
|
@@ -1000,6 +1144,10 @@ export type BluetoothSdkModuleEvents = {
|
|
|
1000
1144
|
pair_failure: (event: PairFailureEvent) => void;
|
|
1001
1145
|
pairing_info: (event: PairingInfoEvent) => void;
|
|
1002
1146
|
entering_pairing_mode: (event: EnteringPairingModeEvent) => void;
|
|
1147
|
+
pairing_mode_ended: (event: PairingModeEndedEvent) => void;
|
|
1148
|
+
pairing_state_changed: (event: PairingStateChangedEvent) => void;
|
|
1149
|
+
audio_setup_changed: (event: AudioSetupChangedEvent) => void;
|
|
1150
|
+
/** @deprecated No longer emitted. Use `pairing_state_changed`. */
|
|
1003
1151
|
owner_replaced: (event: OwnerReplacedEvent) => void;
|
|
1004
1152
|
audio_pairing_needed: (event: AudioPairingNeededEvent) => void;
|
|
1005
1153
|
audio_connected: (event: AudioConnectedEvent) => void;
|
|
@@ -1017,6 +1165,7 @@ export type BluetoothSdkModuleEvents = {
|
|
|
1017
1165
|
ota_start_ack: (event: OtaStartAckEvent) => void;
|
|
1018
1166
|
ota_status: (event: OtaStatusEvent) => void;
|
|
1019
1167
|
ar99_ota_status: (event: Ar99OtaStatusEvent) => void;
|
|
1168
|
+
bes_crash_detected: (event: BesCrashDetectedEvent) => void;
|
|
1020
1169
|
version_info: (event: VersionInfoEvent) => void;
|
|
1021
1170
|
send_command_to_ble: (event: BleCommandTraceEvent) => void;
|
|
1022
1171
|
receive_command_from_ble: (event: BleCommandTraceEvent) => void;
|
|
@@ -1114,6 +1263,8 @@ export type BluetoothSdkEventMap = {
|
|
|
1114
1263
|
voice_activity_detection_status: VoiceActivityDetectionStatusEvent;
|
|
1115
1264
|
speaking_status: SpeakingStatusEvent;
|
|
1116
1265
|
battery_status: BatteryStatusEvent;
|
|
1266
|
+
wake_word: WakeWordEvent;
|
|
1267
|
+
speech_activity: SpeechActivityEvent;
|
|
1117
1268
|
local_transcription: LocalTranscriptionEvent;
|
|
1118
1269
|
wifi_status_change: WifiStatusChangeEvent;
|
|
1119
1270
|
wifi_scan_result: WifiScanResultEvent;
|
|
@@ -1140,6 +1291,10 @@ export type BluetoothSdkEventMap = {
|
|
|
1140
1291
|
pair_failure: PairFailureEvent;
|
|
1141
1292
|
pairing_info: PairingInfoEvent;
|
|
1142
1293
|
entering_pairing_mode: EnteringPairingModeEvent;
|
|
1294
|
+
pairing_mode_ended: PairingModeEndedEvent;
|
|
1295
|
+
pairing_state_changed: PairingStateChangedEvent;
|
|
1296
|
+
audio_setup_changed: AudioSetupChangedEvent;
|
|
1297
|
+
/** @deprecated No longer emitted. Use `pairing_state_changed`. */
|
|
1143
1298
|
owner_replaced: OwnerReplacedEvent;
|
|
1144
1299
|
audio_pairing_needed: AudioPairingNeededEvent;
|
|
1145
1300
|
audio_connected: AudioConnectedEvent;
|
|
@@ -1155,6 +1310,8 @@ export type BluetoothSdkEventMap = {
|
|
|
1155
1310
|
ota_start_ack: OtaStartAckEvent;
|
|
1156
1311
|
ota_status: OtaStatusEvent;
|
|
1157
1312
|
ar99_ota_status: Ar99OtaStatusEvent;
|
|
1313
|
+
/** Mentra Live stored a BES crash incident for the phone to report. */
|
|
1314
|
+
bes_crash_detected: BesCrashDetectedEvent;
|
|
1158
1315
|
version_info: VersionInfoEvent;
|
|
1159
1316
|
extraction_progress: ExtractionProgressEvent;
|
|
1160
1317
|
};
|
|
@@ -1209,7 +1366,9 @@ export interface BluetoothSdkPublicModule {
|
|
|
1209
1366
|
/** Set the glasses clock from the phone after an OTA clock-skew failure. */
|
|
1210
1367
|
setSystemTime(timestampMs: number): Promise<void>;
|
|
1211
1368
|
/** Enable or disable Wi-Fi ADB on Mentra Live (no-op on other devices). */
|
|
1212
|
-
|
|
1369
|
+
/** When supplied, binds native admission to this full MAC observed in the current BLE session.
|
|
1370
|
+
* Resolves on queue admission, without confirming glasses-side state. */
|
|
1371
|
+
setWifiAdbState(enabled: boolean, expectedBluetoothMac?: string): Promise<void>;
|
|
1213
1372
|
/**
|
|
1214
1373
|
* Persistently enable/disable unauthenticated HTTP gallery access on the glasses' Wi-Fi.
|
|
1215
1374
|
* Default off; survives reconnects/restarts until disabled. Only use on trusted networks.
|
|
@@ -1298,7 +1457,32 @@ export interface BluetoothSdkPublicModule {
|
|
|
1298
1457
|
checkSttModelAvailable(): Promise<boolean>;
|
|
1299
1458
|
validateSttModel(path: string): Promise<boolean>;
|
|
1300
1459
|
extractTarBz2(sourcePath: string, destinationPath: string): Promise<boolean>;
|
|
1460
|
+
/**
|
|
1461
|
+
* Start or stop on-device keyword spotting on microphone PCM. `modelDir` must contain
|
|
1462
|
+
* `encoder.int8.onnx`, `decoder.onnx`, `joiner.int8.onnx`, `tokens.txt` and `keywords.txt`;
|
|
1463
|
+
* it is required when enabling. Disabling releases the model.
|
|
1464
|
+
*/
|
|
1465
|
+
setWakeWordDetection(enabled: boolean, modelDir?: string | null): Promise<void>;
|
|
1466
|
+
/**
|
|
1467
|
+
* Finalize the active on-device recognizer's current utterance now. Resolves after the final
|
|
1468
|
+
* `local_transcription` event for it has been emitted, with that final text (empty when nothing
|
|
1469
|
+
* was pending). Resolves `null` when no streaming model is active or the loaded model can't
|
|
1470
|
+
* finalize early.
|
|
1471
|
+
*/
|
|
1472
|
+
finishTranscription(): Promise<string | null>;
|
|
1473
|
+
/**
|
|
1474
|
+
* Reload the selected speech model when on-device transcription is in demand. Resolves after
|
|
1475
|
+
* it is loaded; rejects when loading fails; resolves immediately when there is no demand.
|
|
1476
|
+
*/
|
|
1301
1477
|
restartTranscriber(): Promise<void>;
|
|
1478
|
+
/**
|
|
1479
|
+
* Start or stop the on-device Silero speech detector on microphone PCM. While enabled it emits
|
|
1480
|
+
* `speech_activity` transitions; `minSilenceMs` (default 300) is the quiet gap before a silence
|
|
1481
|
+
* transition. Disabling releases the model.
|
|
1482
|
+
*/
|
|
1483
|
+
setSpeechActivityDetection(enabled: boolean, options?: {
|
|
1484
|
+
minSilenceMs?: number;
|
|
1485
|
+
}): Promise<void>;
|
|
1302
1486
|
setTtsModelDetails(path: string, languageCode: string): Promise<void>;
|
|
1303
1487
|
getTtsModelPath(): Promise<string>;
|
|
1304
1488
|
getTtsModelLanguage(): Promise<string>;
|
|
@@ -1355,6 +1539,10 @@ export interface GlassesStatus {
|
|
|
1355
1539
|
micEnabled: boolean;
|
|
1356
1540
|
voiceActivityDetectionEnabled: boolean;
|
|
1357
1541
|
bluetoothClassicConnected: boolean;
|
|
1542
|
+
/** iOS: an HFP input is available or a matching Bluetooth output is active. Android: same as `bluetoothClassicConnected`. */
|
|
1543
|
+
bluetoothClassicProfilesConnected: boolean;
|
|
1544
|
+
/** iOS: a matching Bluetooth output is the active audio route. Android: same as `bluetoothClassicConnected`. */
|
|
1545
|
+
bluetoothAudioRouted: boolean;
|
|
1358
1546
|
signalStrength: number;
|
|
1359
1547
|
/** Milliseconds since epoch when signalStrength was last refreshed by the phone BLE stack. */
|
|
1360
1548
|
signalStrengthUpdatedAt: number;
|
|
@@ -1368,6 +1556,10 @@ export interface GlassesStatus {
|
|
|
1368
1556
|
leftMacAddress: string;
|
|
1369
1557
|
rightMacAddress: string;
|
|
1370
1558
|
buildNumber: string;
|
|
1559
|
+
/** Mentra Live pairing state owned by the SDK. Absent on other models. */
|
|
1560
|
+
pairingState?: MentraLivePairingState;
|
|
1561
|
+
/** Audio setup state owned by the SDK, on every model. See `GlassesAudioSetupState`. */
|
|
1562
|
+
audioSetup?: GlassesAudioSetupState;
|
|
1371
1563
|
/** Glasses System.currentTimeMillis() from last version_info (clock skew detection). */
|
|
1372
1564
|
systemTimeMs?: number;
|
|
1373
1565
|
otaVersionUrl: string;
|
|
@@ -1452,6 +1644,14 @@ export interface ConnectOptions {
|
|
|
1452
1644
|
* Android accepts this option as a no-op.
|
|
1453
1645
|
*/
|
|
1454
1646
|
requiresAncs?: boolean;
|
|
1647
|
+
/**
|
|
1648
|
+
* iOS Mentra Live only. When true, CoreBluetooth is asked to bring up the
|
|
1649
|
+
* Classic profiles (A2DP/HFP) after the BLE connection
|
|
1650
|
+
* (CBConnectPeripheralOptionEnableTransportBridgingKey). Defaults to true:
|
|
1651
|
+
* without it the pairing screen waits for an audio route that never appears.
|
|
1652
|
+
* Android accepts this option as a no-op.
|
|
1653
|
+
*/
|
|
1654
|
+
enableTransportBridging?: boolean;
|
|
1455
1655
|
}
|
|
1456
1656
|
export type ScanResultsCallback = (devices: Device[]) => void;
|
|
1457
1657
|
/** Advisory for an empty scan. System connection state does not identify an owning app. */
|