@mentra/bluetooth-sdk 3.3.0-beta.994 → 3.3.0-beta.997

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.
@@ -3,7 +3,7 @@ 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.3.0", markdown = "This release is under active development. User-facing changes will be documented as they land."),
6
+ 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
7
  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
8
  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
9
  ReleaseChangelog(version = "3.1.1", markdown = "- Improved Google login on iOS.\n- Pairing no longer requires phone microphone access."),
@@ -3,9 +3,9 @@ package com.mentra.bluetoothsdk
3
3
  /** Generated by release CI. Do not edit in a release checkout. */
4
4
  internal object GeneratedReleaseMetadata {
5
5
  const val FAMILY_BASE_VERSION: String = "3.3.0"
6
- const val RELEASE_IDENTITY: String = "3.3.0-beta.994"
7
- const val RELEASE_SET_ID: String = "mentra-3.3.0-beta.994"
8
- const val SOURCE_COMMIT: String = "0eb1f0630182f3a45d38ea8a8029f5aa4fe1178e"
9
- const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.994.json"
10
- const val OTA_MANIFEST_SHA256: String = "13b9b10db8c9b4b75fdff820999e51eee7b90bc2e96edc099920f095c7f34618"
6
+ const val RELEASE_IDENTITY: String = "3.3.0-beta.997"
7
+ const val RELEASE_SET_ID: String = "mentra-3.3.0-beta.997"
8
+ const val SOURCE_COMMIT: String = "a502069a55ab0162dc7ada340a0b0041c82b05c3"
9
+ const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.997.json"
10
+ const val OTA_MANIFEST_SHA256: String = "b3b501d1db23fbd4f9a8cc20eb9a2b51f26be768a757aea8827bf51420f734ec"
11
11
  }
@@ -566,6 +566,13 @@ class MentraLive : SGCManager() {
566
566
  // the physical connection (never on heartbeat readiness flaps), so a first-seen sid
567
567
  // after an upgrade OTA is always detected as a restart.
568
568
  private var readinessCompletedThisBleSession = false
569
+ // Readiness exchange the phone is waiting on. Every phone_ready carries it until the
570
+ // matching glasses_ready arrives, so retries and the copies the BES buffers while the
571
+ // glasses boot are one exchange: the glasses reset their transport once for it and answer
572
+ // later copies without resetting. Both exchange fields are scoped to the BLE session.
573
+ private var pendingReadyId: String? = null
574
+ // `sid` of the glasses process whose glasses_ready this BLE session last handled.
575
+ private var readyGlassesSessionId: String? = null
569
576
  // Note: appVersion, buildNumber, deviceModel, androidVersion
570
577
  // are inherited from SGCManager parent class
571
578
 
@@ -1194,6 +1201,7 @@ class MentraLive : SGCManager() {
1194
1201
  if (state == ConnTypes.DISCONNECTED) {
1195
1202
  resetWireNegotiationState()
1196
1203
  resetPendingAckState()
1204
+ resetReadinessExchange()
1197
1205
  // Queued writes are session-bound: transmitting them into the NEXT session
1198
1206
  // (e.g. a stale handshake whose reply activates v2 before the new session
1199
1207
  // negotiated) is the bug class this clear removes. Higher layers re-send
@@ -1249,6 +1257,7 @@ class MentraLive : SGCManager() {
1249
1257
  DeviceStore.apply("glasses", "signalStrengthUpdatedAt", 0L)
1250
1258
  resetWireNegotiationState()
1251
1259
  resetPendingAckState()
1260
+ resetReadinessExchange()
1252
1261
  // The glasses reset mic and wear tuning on BLE disconnect, so the
1253
1262
  // next link must be allowed to send them again.
1254
1263
  lastSentMicTuningBody = null
@@ -4612,6 +4621,19 @@ class MentraLive : SGCManager() {
4612
4621
  Bridge.log("LIVE: Ignoring stale glasses_ready during pairing yield")
4613
4622
  return
4614
4623
  }
4624
+ val sid = json.optString("sid", "").takeIf { it.isNotEmpty() }
4625
+ val readyId = json.optString("readyId", "").takeIf { it.isNotEmpty() }
4626
+ if (readyId != null && isRepeatedGlassesReady(readyId, sid)) {
4627
+ Bridge.log(
4628
+ "LIVE: Ignoring repeated glasses_ready for readiness exchange $readyId - " +
4629
+ "the glasses did not reset for it"
4630
+ )
4631
+ return
4632
+ }
4633
+ if (readyId != null && readyId == pendingReadyId) {
4634
+ pendingReadyId = null
4635
+ }
4636
+ readyGlassesSessionId = sid
4615
4637
  Bridge.log("LIVE: 🎉 Received glasses_ready message - SOC is booted and ready!")
4616
4638
  pairingYieldAwaitingReclaim = false
4617
4639
  pairingYieldActive = false
@@ -4633,7 +4655,7 @@ class MentraLive : SGCManager() {
4633
4655
  // Record the session id BEFORE marking ready: an unsolicited glasses_ready
4634
4656
  // already runs this full remote-reset flow, so recording (not re-triggering)
4635
4657
  // is correct here; version_info detection covers the restart case.
4636
- glassesSessionId = json.optString("sid", "").takeIf { it.isNotEmpty() }
4658
+ glassesSessionId = sid
4637
4659
  streamControlVersion = json.optInt("streamControlVersion", 0)
4638
4660
  Bridge.sendTypedMessage(
4639
4661
  "wifi_protocol_session_ready",
@@ -9110,13 +9132,34 @@ class MentraLive : SGCManager() {
9110
9132
  wireHandshakeSentGeneration = -1
9111
9133
  }
9112
9134
 
9135
+ /**
9136
+ * A glasses_ready that echoes a readyId answers a phone_ready exchange. The answer to the
9137
+ * exchange the phone is waiting on, and any answer from a glasses process other than the one
9138
+ * this link last handled (an asg restart resets for every exchange it first sees), followed a
9139
+ * transport reset. Any other answer repeats an exchange that process already reset for, or one
9140
+ * superseded by the pending exchange, whose answer is still to come.
9141
+ */
9142
+ private fun isRepeatedGlassesReady(readyId: String, sid: String?): Boolean =
9143
+ readyId != pendingReadyId && sid == readyGlassesSessionId
9144
+
9145
+ private fun resetReadinessExchange() {
9146
+ pendingReadyId = null
9147
+ readyGlassesSessionId = null
9148
+ }
9149
+
9113
9150
  /** Sends phone_ready to (re)start the glasses-driven readiness flow. */
9114
9151
  private fun sendPhoneReady(reason: String) {
9115
- Bridge.log("LIVE: 📱 Sending phone_ready to glasses ($reason) - waiting for glasses_ready response")
9152
+ val readyId = pendingReadyId ?: UUID.randomUUID().toString()
9153
+ pendingReadyId = readyId
9154
+ Bridge.log(
9155
+ "LIVE: 📱 Sending phone_ready to glasses ($reason, exchange $readyId) - " +
9156
+ "waiting for glasses_ready response"
9157
+ )
9116
9158
  markPairingTiming("phone_ready_sent", "reason=$reason queueSize=${sendQueue.size}")
9117
9159
  val readyMsg = JSONObject()
9118
9160
  readyMsg.put("type", "phone_ready")
9119
9161
  readyMsg.put("timestamp", System.currentTimeMillis())
9162
+ readyMsg.put("readyId", readyId)
9120
9163
  sendJson(readyMsg, true)
9121
9164
  }
9122
9165
 
@@ -0,0 +1,137 @@
1
+ package com.mentra.bluetoothsdk.sgcs
2
+
3
+ import android.os.Looper
4
+ import androidx.test.core.app.ApplicationProvider
5
+ import com.mentra.bluetoothsdk.Bridge
6
+ import com.mentra.bluetoothsdk.utils.ConnTypes
7
+ import java.time.Duration
8
+ import org.json.JSONObject
9
+ import org.junit.Assert.assertEquals
10
+ import org.junit.Assert.assertNotEquals
11
+ import org.junit.Assert.assertNotNull
12
+ import org.junit.Test
13
+ import org.junit.runner.RunWith
14
+ import org.robolectric.RobolectricTestRunner
15
+ import org.robolectric.Shadows.shadowOf
16
+ import org.robolectric.annotation.Config
17
+ import org.robolectric.annotation.LooperMode
18
+
19
+ @RunWith(RobolectricTestRunner::class)
20
+ @Config(sdk = [33], shadows = [G1PairingTest.ShadowLc3Cpp::class], instrumentedPackages = ["com.mentra.lc3Lib"])
21
+ @LooperMode(LooperMode.Mode.PAUSED)
22
+ class MentraLiveGlassesReadyBurstTest {
23
+ @Test fun `buffered phone_ready copies are one exchange with one init`() = withLive { live, inits ->
24
+ // Two SOC-ready heartbeats while the glasses boot: one exchange, sent twice.
25
+ receive(live, socReady())
26
+ val readyId = pendingReadyId(live)
27
+ receive(live, socReady())
28
+ assertEquals(readyId, pendingReadyId(live))
29
+
30
+ // The glasses answer every buffered copy; only the first followed a reset.
31
+ repeat(7) { receive(live, glassesReady("booted", readyId)) }
32
+ assertEquals(1, inits())
33
+ }
34
+
35
+ @Test fun `answers to a superseded exchange are ignored until the pending one arrives`() = withLive { live, inits ->
36
+ receive(live, socReady())
37
+ val first = pendingReadyId(live)
38
+ receive(live, glassesReady("booted", first))
39
+ invoke(live, "sendPhoneReady", "readiness re-run")
40
+ val second = pendingReadyId(live)
41
+
42
+ // The same process already reset for the first exchange; the pending one is still to come.
43
+ receive(live, glassesReady("booted", first))
44
+ assertEquals(1, inits())
45
+ receive(live, glassesReady("booted", second))
46
+ assertEquals(2, inits())
47
+ }
48
+
49
+ @Test fun `an answer from another glasses process is handled with no exchange pending`() = withLive { live, inits ->
50
+ receive(live, socReady())
51
+ val readyId = pendingReadyId(live)
52
+ receive(live, glassesReady("booted", readyId))
53
+
54
+ // A restarted process reset its transport for this copy, so it is not a repeat.
55
+ receive(live, glassesReady("restarted", readyId))
56
+ assertEquals(2, inits())
57
+ }
58
+
59
+ @Test fun `a restarted process answering an older copy is handled and the pending exchange still counts`() = withLive { live, inits ->
60
+ receive(live, socReady())
61
+ val first = pendingReadyId(live)
62
+ receive(live, glassesReady("booted", first))
63
+ invoke(live, "sendPhoneReady", "glasses session changed")
64
+ val second = pendingReadyId(live)
65
+
66
+ // The restarted process reset for a buffered copy of the old exchange, then resets
67
+ // again for the pending one: both answers follow a reset.
68
+ receive(live, glassesReady("restarted", first))
69
+ assertEquals(2, inits())
70
+ receive(live, glassesReady("restarted", second))
71
+ assertEquals(3, inits())
72
+ receive(live, glassesReady("restarted", second))
73
+ assertEquals(3, inits())
74
+ }
75
+
76
+ @Test fun `the readiness exchange ends with the BLE session`() = withLive { live, _ ->
77
+ receive(live, socReady())
78
+ val first = pendingReadyId(live)
79
+ invoke(live, "updateConnectionState", ConnTypes.DISCONNECTED)
80
+
81
+ receive(live, socReady())
82
+ assertNotEquals(first, pendingReadyId(live))
83
+ }
84
+
85
+ @Test fun `glasses without readyId keep initializing on every answer`() = withLive { live, inits ->
86
+ receive(live, glassesReady("legacy", null))
87
+ receive(live, glassesReady("legacy", null))
88
+ assertEquals(2, inits())
89
+ }
90
+
91
+ /** Runs `body` on a fresh MentraLive, counting SOC inits (one version request each). */
92
+ private fun withLive(body: (MentraLive, () -> Int) -> Unit) {
93
+ Bridge.initialize(ApplicationProvider.getApplicationContext())
94
+ val live = MentraLive()
95
+ var inits = 0
96
+ val sink = Bridge.addEventSink { type, event ->
97
+ if (type == "log" && event["message"].toString().contains("Requesting version info from ASG client")) {
98
+ inits++
99
+ }
100
+ }
101
+ try {
102
+ body(live) { inits }
103
+ } finally {
104
+ Bridge.removeEventSink(sink)
105
+ live.destroy()
106
+ shadowOf(Looper.getMainLooper()).idleFor(Duration.ofSeconds(2))
107
+ }
108
+ }
109
+
110
+ private fun socReady() = JSONObject().put("C", "sr_hrt").put("B", JSONObject().put("ready", 1))
111
+
112
+ private fun glassesReady(sid: String, readyId: String?) = JSONObject().apply {
113
+ put("type", "glasses_ready")
114
+ put("sid", sid)
115
+ if (readyId != null) put("readyId", readyId)
116
+ }
117
+
118
+ private fun pendingReadyId(live: MentraLive): String {
119
+ val readyId = MentraLive::class.java.getDeclaredField("pendingReadyId")
120
+ .apply { isAccessible = true }
121
+ .get(live) as String?
122
+ assertNotNull("SOC ready should start a readiness exchange", readyId)
123
+ return readyId!!
124
+ }
125
+
126
+ private fun receive(live: MentraLive, json: JSONObject) {
127
+ MentraLive::class.java.getDeclaredMethod("processJsonMessage", JSONObject::class.java)
128
+ .apply { isAccessible = true }
129
+ .invoke(live, json)
130
+ }
131
+
132
+ private fun invoke(live: MentraLive, name: String, argument: String) {
133
+ MentraLive::class.java.getDeclaredMethod(name, String::class.java)
134
+ .apply { isAccessible = true }
135
+ .invoke(live, argument)
136
+ }
137
+ }
@@ -1,7 +1,7 @@
1
1
  /** Generated from /changelogs. Do not edit directly. */
2
2
  export declare const GENERATED_RELEASE_CHANGELOGS: readonly [{
3
3
  readonly version: "3.3.0";
4
- readonly markdown: "This release is under active development. User-facing changes will be documented as they land.";
4
+ readonly 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.";
5
5
  }, {
6
6
  readonly version: "3.2.1";
7
7
  readonly 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.";
@@ -2,7 +2,7 @@
2
2
  export const GENERATED_RELEASE_CHANGELOGS = Object.freeze([
3
3
  {
4
4
  "version": "3.3.0",
5
- "markdown": "This release is under active development. User-facing changes will be documented as they land."
5
+ "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."
6
6
  },
7
7
  {
8
8
  "version": "3.2.1",
@@ -1 +1 @@
1
- {"version":3,"file":"changelogCatalog.js","sourceRoot":"","sources":["../../src/generated/changelogCatalog.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CACzD;IACE;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,gGAAgG;KAC7G;IACD;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,wtBAAwtB;KACruB;IACD;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,qXAAqX;KAClY;IACD;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,wFAAwF;KACrG;IACD;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,mrCAAmrC;KAChsC;CACO,CACT,CAAA","sourcesContent":["/** Generated from /changelogs. Do not edit directly. */\nexport const GENERATED_RELEASE_CHANGELOGS = Object.freeze(\n[\n {\n \"version\": \"3.3.0\",\n \"markdown\": \"This release is under active development. User-facing changes will be documented as they land.\"\n },\n {\n \"version\": \"3.2.1\",\n \"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.\"\n },\n {\n \"version\": \"3.2.0\",\n \"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`.\"\n },\n {\n \"version\": \"3.1.1\",\n \"markdown\": \"- Improved Google login on iOS.\\n- Pairing no longer requires phone microphone access.\"\n },\n {\n \"version\": \"3.1.0\",\n \"markdown\": \"**Mentra App and glasses**\\n\\n- Improved glasses pairing and reconnection, including on iPad.\\n- Improved Android background reliability for captions and miniapps.\\n- Added Xingyi AR99 support.\\n- More reliable photo and video capture, with improved shutter sounds and privacy-light timing. Taking photos no longer interrupts your running miniapp.\\n- Added video thumbnails and smoother gallery browsing.\\n- Easier Mentra Live updates through your phone, with clearer progress and better recovery from interruptions.\\n\\n**Miniapp updates**\\n\\n- **Mentra AI:** Control whether photos are included with questions. Improved visual answers and connected-app follow-ups.\\n- **Captions:** Added offline transcription settings and top/bottom positioning on supported displays.\\n- **Translation:** Restored all 60 languages.\\n- **Mentra Maps:** Clearer directions on G1/G2, less display flickering, and improved Android offline routing.\\n- **Livestreamer:** More video-quality controls and custom streaming options, plus improved startup and sharing.\\n- **Merge:** Tap to expand an insight; swipe down or back to dismiss it.\\n- **Mentra Notes:** Smoother back navigation.\\n- **Recorder:** Fixed audio sharing.\"\n }\n] as const,\n)\n"]}
1
+ {"version":3,"file":"changelogCatalog.js","sourceRoot":"","sources":["../../src/generated/changelogCatalog.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CACzD;IACE;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,m0BAAm0B;KACh1B;IACD;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,wtBAAwtB;KACruB;IACD;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,qXAAqX;KAClY;IACD;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,wFAAwF;KACrG;IACD;QACE,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,mrCAAmrC;KAChsC;CACO,CACT,CAAA","sourcesContent":["/** Generated from /changelogs. Do not edit directly. */\nexport const GENERATED_RELEASE_CHANGELOGS = Object.freeze(\n[\n {\n \"version\": \"3.3.0\",\n \"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.\"\n },\n {\n \"version\": \"3.2.1\",\n \"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.\"\n },\n {\n \"version\": \"3.2.0\",\n \"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`.\"\n },\n {\n \"version\": \"3.1.1\",\n \"markdown\": \"- Improved Google login on iOS.\\n- Pairing no longer requires phone microphone access.\"\n },\n {\n \"version\": \"3.1.0\",\n \"markdown\": \"**Mentra App and glasses**\\n\\n- Improved glasses pairing and reconnection, including on iPad.\\n- Improved Android background reliability for captions and miniapps.\\n- Added Xingyi AR99 support.\\n- More reliable photo and video capture, with improved shutter sounds and privacy-light timing. Taking photos no longer interrupts your running miniapp.\\n- Added video thumbnails and smoother gallery browsing.\\n- Easier Mentra Live updates through your phone, with clearer progress and better recovery from interruptions.\\n\\n**Miniapp updates**\\n\\n- **Mentra AI:** Control whether photos are included with questions. Improved visual answers and connected-app follow-ups.\\n- **Captions:** Added offline transcription settings and top/bottom positioning on supported displays.\\n- **Translation:** Restored all 60 languages.\\n- **Mentra Maps:** Clearer directions on G1/G2, less display flickering, and improved Android offline routing.\\n- **Livestreamer:** More video-quality controls and custom streaming options, plus improved startup and sharing.\\n- **Merge:** Tap to expand an insight; swipe down or back to dismiss it.\\n- **Mentra Notes:** Smoother back navigation.\\n- **Recorder:** Fixed audio sharing.\"\n }\n] as const,\n)\n"]}
@@ -1,10 +1,10 @@
1
1
  export const BLUETOOTH_SDK_RELEASE_METADATA = Object.freeze({
2
2
  "schemaVersion": 1,
3
3
  "familyBaseVersion": "3.3.0",
4
- "releaseIdentity": "3.3.0-beta.994",
5
- "releaseSetId": "mentra-3.3.0-beta.994",
6
- "sourceCommit": "0eb1f0630182f3a45d38ea8a8029f5aa4fe1178e",
7
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.994.json",
8
- "otaManifestSha256": "13b9b10db8c9b4b75fdff820999e51eee7b90bc2e96edc099920f095c7f34618"
4
+ "releaseIdentity": "3.3.0-beta.997",
5
+ "releaseSetId": "mentra-3.3.0-beta.997",
6
+ "sourceCommit": "a502069a55ab0162dc7ada340a0b0041c82b05c3",
7
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.997.json",
8
+ "otaManifestSha256": "b3b501d1db23fbd4f9a8cc20eb9a2b51f26be768a757aea8827bf51420f734ec"
9
9
  });
10
10
  //# sourceMappingURL=releaseMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,8BAA8B,GAA0C,MAAM,CAAC,MAAM,CAAC;IACjG,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,gBAAgB;IACnC,cAAc,EAAE,uBAAuB;IACvC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,kIAAkI;IACpJ,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface BluetoothSdkReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.3.0\",\n \"releaseIdentity\": \"3.3.0-beta.994\",\n \"releaseSetId\": \"mentra-3.3.0-beta.994\",\n \"sourceCommit\": \"0eb1f0630182f3a45d38ea8a8029f5aa4fe1178e\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.994.json\",\n \"otaManifestSha256\": \"13b9b10db8c9b4b75fdff820999e51eee7b90bc2e96edc099920f095c7f34618\"\n})\n"]}
1
+ {"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,8BAA8B,GAA0C,MAAM,CAAC,MAAM,CAAC;IACjG,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,gBAAgB;IACnC,cAAc,EAAE,uBAAuB;IACvC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,kIAAkI;IACpJ,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface BluetoothSdkReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.3.0\",\n \"releaseIdentity\": \"3.3.0-beta.997\",\n \"releaseSetId\": \"mentra-3.3.0-beta.997\",\n \"sourceCommit\": \"a502069a55ab0162dc7ada340a0b0041c82b05c3\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.997.json\",\n \"otaManifestSha256\": \"b3b501d1db23fbd4f9a8cc20eb9a2b51f26be768a757aea8827bf51420f734ec\"\n})\n"]}
@@ -16,7 +16,7 @@ enum BluetoothSdkDefaults {
16
16
  /// silently disable it on every pair the app touches.
17
17
  static let autoPowerOffEnabled = false
18
18
  private static let infoSdkVersionKey = "MentraBluetoothSdkVersion"
19
- private static let swiftPackageSdkVersion = "3.3.0-beta.994"
19
+ private static let swiftPackageSdkVersion = "3.3.0-beta.997"
20
20
  private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
21
21
 
22
22
  private static func normalizedSdkVersion(_ value: String?) -> String? {
@@ -2,7 +2,7 @@ import Foundation
2
2
 
3
3
  /// Generated from /changelogs. Do not edit directly.
4
4
  let generatedReleaseChangelogs: [ReleaseChangelog] = [
5
- ReleaseChangelog(version: "3.3.0", markdown: "This release is under active development. User-facing changes will be documented as they land."),
5
+ 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."),
6
6
  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."),
7
7
  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`."),
8
8
  ReleaseChangelog(version: "3.1.1", markdown: "- Improved Google login on iOS.\n- Pairing no longer requires phone microphone access."),
@@ -3,9 +3,9 @@ import Foundation
3
3
  /// Generated by release CI. Do not edit in a release checkout.
4
4
  enum GeneratedReleaseMetadata {
5
5
  static let familyBaseVersion = "3.3.0"
6
- static let releaseIdentity = "3.3.0-beta.994"
7
- static let releaseSetId = "mentra-3.3.0-beta.994"
8
- static let sourceCommit = "0eb1f0630182f3a45d38ea8a8029f5aa4fe1178e"
9
- static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.994.json"
10
- static let otaManifestSha256 = "13b9b10db8c9b4b75fdff820999e51eee7b90bc2e96edc099920f095c7f34618"
6
+ static let releaseIdentity = "3.3.0-beta.997"
7
+ static let releaseSetId = "mentra-3.3.0-beta.997"
8
+ static let sourceCommit = "a502069a55ab0162dc7ada340a0b0041c82b05c3"
9
+ static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.997.json"
10
+ static let otaManifestSha256 = "b3b501d1db23fbd4f9a8cc20eb9a2b51f26be768a757aea8827bf51420f734ec"
11
11
  }
@@ -1345,6 +1345,7 @@ class MentraLive: NSObject, SGCManager {
1345
1345
  if state == ConnTypes.DISCONNECTED {
1346
1346
  resetPendingAckState(reason: "BLE session ended")
1347
1347
  resetWireNegotiationState()
1348
+ resetReadinessExchange()
1348
1349
  resetAncsRelayState()
1349
1350
  // Queued writes are session-bound: transmitting them into the NEXT session
1350
1351
  // (e.g. a stale handshake whose reply activates v2 before the new session
@@ -1603,6 +1604,13 @@ class MentraLive: NSObject, SGCManager {
1603
1604
  // the physical connection — so a first-seen sid after an upgrade OTA cannot be
1604
1605
  // mistaken for a fresh pairing just because a not-ready heartbeat slipped in first.
1605
1606
  private var readinessCompletedThisBleSession = false
1607
+ /// Readiness exchange the phone is waiting on. Every phone_ready carries it until the
1608
+ /// matching glasses_ready arrives, so retries and the copies the BES buffers while the
1609
+ /// glasses boot are one exchange: the glasses reset their transport once for it and answer
1610
+ /// later copies without resetting. Both exchange fields are scoped to the BLE session.
1611
+ private var pendingReadyId: String?
1612
+ /// `sid` of the glasses process whose glasses_ready this BLE session last handled.
1613
+ private var readyGlassesSessionId: String?
1606
1614
  private var globalMessageId = 0
1607
1615
  private var lastReceivedMessageId = 0
1608
1616
  private var bleWriteTraceSequence = 0
@@ -2193,6 +2201,17 @@ class MentraLive: NSObject, SGCManager {
2193
2201
  return commands.removeFirst()
2194
2202
  }
2195
2203
 
2204
+ /// Discards the run of writes from earlier wire-session generations at the head of
2205
+ /// the queue in one pass and dequeues the first current one. Stale writes are never
2206
+ /// sent, so they must not each cost a drain tick: a burst of epoch resets would
2207
+ /// otherwise park every current write behind seconds of dead entries.
2208
+ func dequeue(currentGeneration: Int) -> (command: PendingMessage?, staleIds: [String]) {
2209
+ let firstCurrent = commands.firstIndex { $0.generation == currentGeneration } ?? commands.endIndex
2210
+ let staleIds = commands[..<firstCurrent].map(\.id)
2211
+ commands.removeSubrange(..<firstCurrent)
2212
+ return (commands.isEmpty ? nil : commands.removeFirst(), staleIds)
2213
+ }
2214
+
2196
2215
  func removeAll() {
2197
2216
  commands.removeAll()
2198
2217
  }
@@ -2203,21 +2222,25 @@ class MentraLive: NSObject, SGCManager {
2203
2222
  guard let self else { return }
2204
2223
  while true {
2205
2224
  let pendingIsNil = await MainActor.run { self.pending == nil }
2206
- if pendingIsNil {
2207
- if let command = await self.commandQueue.dequeue() {
2208
- let currentGeneration = await MainActor.run { self.wireSessionGeneration }
2209
- if command.generation != currentGeneration {
2210
- Bridge.log("LIVE: Dropping stale queued write from a previous session epoch (id: \(command.id))")
2211
- } else {
2212
- await self.processSendQueue(command)
2213
- }
2214
- }
2225
+ if pendingIsNil, let command = await self.dequeueCurrentGenerationWrite() {
2226
+ await self.processSendQueue(command)
2215
2227
  }
2216
2228
  try? await Task.sleep(nanoseconds: 100_000_000) // 100ms
2217
2229
  }
2218
2230
  }
2219
2231
  }
2220
2232
 
2233
+ private func dequeueCurrentGenerationWrite() -> PendingMessage? {
2234
+ let next = commandQueue.dequeue(currentGeneration: wireSessionGeneration)
2235
+ if !next.staleIds.isEmpty {
2236
+ Bridge.log(
2237
+ "LIVE: Dropping \(next.staleIds.count) stale queued write(s) from a previous session epoch " +
2238
+ "(ids: \(next.staleIds.joined(separator: ", ")))"
2239
+ )
2240
+ }
2241
+ return next.command
2242
+ }
2243
+
2221
2244
  private func processSendQueue(_ message: PendingMessage) async {
2222
2245
  guard let peripheral = connectedPeripheral,
2223
2246
  let txChar = txCharacteristic
@@ -2802,6 +2825,16 @@ class MentraLive: NSObject, SGCManager {
2802
2825
  Bridge.log("LIVE: Ignoring stale glasses_ready during pairing yield")
2803
2826
  return
2804
2827
  }
2828
+ let sid = (json["sid"] as? String).flatMap { $0.isEmpty ? nil : $0 }
2829
+ let readyId = (json["readyId"] as? String).flatMap { $0.isEmpty ? nil : $0 }
2830
+ if let readyId, isRepeatedGlassesReady(readyId: readyId, sid: sid) {
2831
+ Bridge.log("LIVE: Ignoring repeated glasses_ready for readiness exchange \(readyId) - the glasses did not reset for it")
2832
+ return
2833
+ }
2834
+ if readyId != nil, readyId == pendingReadyId {
2835
+ pendingReadyId = nil
2836
+ }
2837
+ readyGlassesSessionId = sid
2805
2838
  // glasses_ready is a REMOTE wire-session reset: the glasses ran
2806
2839
  // onTransportReset() before sending it, so their side is back on legacy
2807
2840
  // framing regardless of what this side negotiated earlier. Start a fresh
@@ -2817,7 +2850,7 @@ class MentraLive: NSObject, SGCManager {
2817
2850
  // Record the session id BEFORE marking ready: an unsolicited glasses_ready
2818
2851
  // already runs this full remote-reset flow, so recording (not re-triggering)
2819
2852
  // is correct here; version_info detection covers the restart case.
2820
- glassesSessionId = (json["sid"] as? String).flatMap { $0.isEmpty ? nil : $0 }
2853
+ glassesSessionId = sid
2821
2854
  streamControlVersion = json["streamControlVersion"] as? Int ?? 0
2822
2855
  Bridge.sendTypedMessage(
2823
2856
  "wifi_protocol_session_ready",
@@ -3388,12 +3421,7 @@ class MentraLive: NSObject, SGCManager {
3388
3421
  // This prevents re-initialization on every heartbeat after initial connection
3389
3422
  // The ready flag is reset on disconnect/reconnect, so this won't prevent proper reconnection
3390
3423
  if !fullyBooted {
3391
- let readyMsg: [String: Any] = [
3392
- "type": "phone_ready",
3393
- "timestamp": Int64(Date().timeIntervalSince1970 * 1000),
3394
- ]
3395
- // Send it through our data channel
3396
- sendJson(readyMsg, wakeUp: true)
3424
+ sendPhoneReady(reason: "SOC ready")
3397
3425
  }
3398
3426
  }
3399
3427
  }
@@ -3944,6 +3972,20 @@ class MentraLive: NSObject, SGCManager {
3944
3972
 
3945
3973
  // MARK: - Message Handlers
3946
3974
 
3975
+ /// A glasses_ready that echoes a readyId answers a phone_ready exchange. The answer to the
3976
+ /// exchange the phone is waiting on, and any answer from a glasses process other than the
3977
+ /// one this link last handled (an asg restart resets for every exchange it first sees),
3978
+ /// followed a transport reset. Any other answer repeats an exchange that process already
3979
+ /// reset for, or one superseded by the pending exchange, whose answer is still to come.
3980
+ private func isRepeatedGlassesReady(readyId: String, sid: String?) -> Bool {
3981
+ readyId != pendingReadyId && sid == readyGlassesSessionId
3982
+ }
3983
+
3984
+ private func resetReadinessExchange() {
3985
+ pendingReadyId = nil
3986
+ readyGlassesSessionId = nil
3987
+ }
3988
+
3947
3989
  private func handleGlassesReady() {
3948
3990
  Bridge.log("LIVE: 🎉 Received glasses_ready message - SOC is booted and ready!")
3949
3991
 
@@ -5796,12 +5838,13 @@ class MentraLive: NSObject, SGCManager {
5796
5838
  )
5797
5839
  // requestReadyK900()
5798
5840
 
5799
- let readyMsg: [String: Any] = [
5800
- "type": "phone_ready",
5801
- "timestamp": Int64(Date().timeIntervalSince1970 * 1000),
5802
- ]
5803
- // Send it through our data channel
5804
- sendJson(readyMsg, wakeUp: true)
5841
+ // The timer fires on bluetoothQueue; the pending readiness exchange is main-actor state.
5842
+ // A tick queued just before glasses_ready stopped the loop must not start a new exchange.
5843
+ let check = self.readinessCheckCounter
5844
+ DispatchQueue.main.async { [weak self] in
5845
+ guard let self, self.readinessCheckDispatchTimer != nil else { return }
5846
+ self.sendPhoneReady(reason: "readiness check #\(check)")
5847
+ }
5805
5848
  }
5806
5849
 
5807
5850
  readinessCheckDispatchTimer!.resume()
@@ -6047,6 +6090,7 @@ class MentraLive: NSObject, SGCManager {
6047
6090
  // Stop all timers
6048
6091
  stopAllTimers()
6049
6092
  resetWireNegotiationState()
6093
+ resetReadinessExchange()
6050
6094
  commandQueue.removeAll() // stale writes die with the session
6051
6095
  closeL2capFileChannel()
6052
6096
 
@@ -6176,10 +6220,15 @@ extension MentraLive {
6176
6220
 
6177
6221
  /// Sends phone_ready to (re)start the glasses-driven readiness flow.
6178
6222
  private func sendPhoneReady(reason: String) {
6179
- Bridge.log("LIVE: 📱 Sending phone_ready to glasses (\(reason)) - waiting for glasses_ready response")
6223
+ let readyId = pendingReadyId ?? UUID().uuidString
6224
+ pendingReadyId = readyId
6225
+ Bridge.log(
6226
+ "LIVE: 📱 Sending phone_ready to glasses (\(reason), exchange \(readyId)) - waiting for glasses_ready response"
6227
+ )
6180
6228
  let readyMsg: [String: Any] = [
6181
6229
  "type": "phone_ready",
6182
6230
  "timestamp": Int64(Date().timeIntervalSince1970 * 1000),
6231
+ "readyId": readyId,
6183
6232
  ]
6184
6233
  sendJson(readyMsg, wakeUp: true)
6185
6234
  }
@@ -0,0 +1,35 @@
1
+ @testable import MentraBluetoothSDK
2
+ import XCTest
3
+
4
+ @MainActor
5
+ final class MentraLiveCommandQueueTests: XCTestCase {
6
+ func testStaleGenerationRunIsDiscardedInOnePassAheadOfTheCurrentWrite() {
7
+ let queue = MentraLive.CommandQueue()
8
+ for (id, generation) in [("1", 1), ("2", 1), ("3", 2), ("4", 3), ("5", 3)] {
9
+ _ = queue.enqueue(write(id, generation: generation))
10
+ }
11
+
12
+ let next = queue.dequeue(currentGeneration: 3)
13
+ XCTAssertEqual(next.command?.id, "4")
14
+ XCTAssertEqual(next.staleIds, ["1", "2", "3"])
15
+
16
+ let following = queue.dequeue(currentGeneration: 3)
17
+ XCTAssertEqual(following.command?.id, "5")
18
+ XCTAssertEqual(following.staleIds, [])
19
+ }
20
+
21
+ func testQueueOfOnlyStaleWritesDrainsToEmpty() {
22
+ let queue = MentraLive.CommandQueue()
23
+ _ = queue.enqueue(write("1", generation: 1))
24
+ _ = queue.enqueue(write("2", generation: 2))
25
+
26
+ let next = queue.dequeue(currentGeneration: 3)
27
+ XCTAssertNil(next.command)
28
+ XCTAssertEqual(next.staleIds, ["1", "2"])
29
+ XCTAssertNil(queue.dequeue())
30
+ }
31
+
32
+ private func write(_ id: String, generation: Int) -> MentraLive.PendingMessage {
33
+ MentraLive.PendingMessage(data: Data([1]), id: id, retries: 0, generation: generation)
34
+ }
35
+ }
@@ -8,6 +8,10 @@ private final class SessionReadinessTransport: MentraLive {
8
8
  override func sendJson(_ jsonOriginal: [String: Any], wakeUp: Bool, requireAck: Bool) {
9
9
  commands.append(jsonOriginal)
10
10
  }
11
+
12
+ func phoneReadyIds() -> [String] {
13
+ commands.filter { $0["type"] as? String == "phone_ready" }.compactMap { $0["readyId"] as? String }
14
+ }
11
15
  }
12
16
 
13
17
  @MainActor
@@ -143,6 +147,131 @@ final class MentraLiveSessionReadinessTests: XCTestCase {
143
147
  XCTAssertTrue(sdk.glassesStatus.fullyBooted)
144
148
  }
145
149
 
150
+ func testBufferedPhoneReadyCopiesAreOneExchangeWithOneInit() throws {
151
+ try withReadinessTransport { transport, receive, versionRequests in
152
+ // Two SOC-ready heartbeats while the glasses boot: one exchange, sent twice.
153
+ try receive(["C": "sr_hrt", "B": ["ready": 1]])
154
+ try receive(["C": "sr_hrt", "B": ["ready": 1]])
155
+ let readyIds = transport.phoneReadyIds()
156
+ XCTAssertEqual(readyIds.count, 2)
157
+ XCTAssertEqual(Set(readyIds).count, 1)
158
+ let readyId = try XCTUnwrap(readyIds.first)
159
+
160
+ // The glasses answer every buffered copy; only the first followed a reset.
161
+ for _ in 0 ..< 7 {
162
+ try receive(["type": "glasses_ready", "sid": "booted", "readyId": readyId])
163
+ }
164
+ XCTAssertEqual(versionRequests(), 1)
165
+ XCTAssertEqual(DeviceStore.shared.store.get("glasses", "fullyBooted") as? Bool, true)
166
+ }
167
+ }
168
+
169
+ func testRestartedGlassesProcessStartsANewExchangeAndIgnoresStaleAnswers() throws {
170
+ try withReadinessTransport { transport, receive, versionRequests in
171
+ try receive(["C": "sr_hrt", "B": ["ready": 1]])
172
+ let first = try XCTUnwrap(transport.phoneReadyIds().last)
173
+ try receive(["type": "glasses_ready", "sid": "booted", "readyId": first])
174
+
175
+ // asg restarted under the live link: a new exchange, and the old one's answers no
176
+ // longer count even though the new process will reset for its own.
177
+ try receive(["type": "version_info_1", "sid": "restarted", "build_number": "302010073"])
178
+ let second = try XCTUnwrap(transport.phoneReadyIds().last)
179
+ XCTAssertNotEqual(second, first)
180
+ try receive(["type": "glasses_ready", "sid": "booted", "readyId": first])
181
+ XCTAssertEqual(versionRequests(), 1)
182
+
183
+ try receive(["type": "glasses_ready", "sid": "restarted", "readyId": second])
184
+ XCTAssertEqual(versionRequests(), 2)
185
+ }
186
+ }
187
+
188
+ func testAnswerFromAnotherGlassesProcessIsHandledWithNoExchangePending() throws {
189
+ try withReadinessTransport { transport, receive, versionRequests in
190
+ try receive(["C": "sr_hrt", "B": ["ready": 1]])
191
+ let readyId = try XCTUnwrap(transport.phoneReadyIds().last)
192
+ try receive(["type": "glasses_ready", "sid": "booted", "readyId": readyId])
193
+
194
+ // A different process reset its transport for this copy, so it is not a repeat.
195
+ try receive(["type": "glasses_ready", "sid": "restarted", "readyId": readyId])
196
+ XCTAssertEqual(versionRequests(), 2)
197
+ }
198
+ }
199
+
200
+ func testRestartedProcessAnsweringAnOlderCopyIsHandledAndThePendingExchangeStillCounts() throws {
201
+ try withReadinessTransport { transport, receive, versionRequests in
202
+ try receive(["C": "sr_hrt", "B": ["ready": 1]])
203
+ let first = try XCTUnwrap(transport.phoneReadyIds().last)
204
+ try receive(["type": "glasses_ready", "sid": "booted", "readyId": first])
205
+ try receive(["type": "version_info_1", "sid": "restarted", "build_number": "302010073"])
206
+ let second = try XCTUnwrap(transport.phoneReadyIds().last)
207
+
208
+ // The restarted process reset for a buffered copy of the old exchange, then resets
209
+ // again for the pending one: both answers follow a reset.
210
+ try receive(["type": "glasses_ready", "sid": "restarted", "readyId": first])
211
+ XCTAssertEqual(versionRequests(), 2)
212
+ try receive(["type": "glasses_ready", "sid": "restarted", "readyId": second])
213
+ XCTAssertEqual(versionRequests(), 3)
214
+ try receive(["type": "glasses_ready", "sid": "restarted", "readyId": second])
215
+ XCTAssertEqual(versionRequests(), 3)
216
+ }
217
+ }
218
+
219
+ func testReadinessExchangeEndsWithTheBleSession() throws {
220
+ try withReadinessTransport { transport, receive, _ in
221
+ try receive(["C": "sr_hrt", "B": ["ready": 1]])
222
+ let first = try XCTUnwrap(transport.phoneReadyIds().last)
223
+ transport.cleanup()
224
+ DeviceStore.shared.store.set("glasses", "fullyBooted", false)
225
+
226
+ try receive(["C": "sr_hrt", "B": ["ready": 1]])
227
+ XCTAssertNotEqual(try XCTUnwrap(transport.phoneReadyIds().last), first)
228
+ }
229
+ }
230
+
231
+ func testGlassesWithoutReadyIdKeepInitializingOnEveryAnswer() throws {
232
+ try withReadinessTransport { _, receive, versionRequests in
233
+ try receive(["type": "glasses_ready", "sid": "legacy"])
234
+ try receive(["type": "glasses_ready", "sid": "legacy"])
235
+ XCTAssertEqual(versionRequests(), 2)
236
+ }
237
+ }
238
+
239
+ /// Runs `body` on a fresh transport whose glasses have not reported readiness yet.
240
+ private func withReadinessTransport(
241
+ _ body: (
242
+ SessionReadinessTransport,
243
+ ([String: Any]) throws -> Void,
244
+ () -> Int
245
+ ) throws -> Void
246
+ ) throws {
247
+ let store = DeviceStore.shared.store
248
+ let saved = ["bluetooth", "glasses"].map { ($0, store.getCategory($0)) }
249
+ let previous = DeviceManager.shared.sgc
250
+ let transport = SessionReadinessTransport()
251
+ DeviceManager.shared.sgc = transport
252
+ defer {
253
+ transport.cleanup()
254
+ DeviceManager.shared.sgc = previous
255
+ for (category, values) in saved {
256
+ for key in store.getCategory(category).keys where values[key] == nil {
257
+ store.remove(category, key)
258
+ }
259
+ for (key, value) in values {
260
+ store.set(category, key, value)
261
+ }
262
+ }
263
+ }
264
+ store.set("glasses", "fullyBooted", false)
265
+
266
+ func receive(_ value: [String: Any]) throws {
267
+ try transport.processReceivedData(JSONSerialization.data(withJSONObject: value))
268
+ }
269
+ func versionRequests() -> Int {
270
+ transport.commands.filter { $0["type"] as? String == "request_version" }.count
271
+ }
272
+ try body(transport, receive, versionRequests)
273
+ }
274
+
146
275
  func testInitialVersionChunkDoesNotStartAnExtraReadinessExchange() throws {
147
276
  let store = DeviceStore.shared.store
148
277
  let saved = store.getCategory("glasses")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/bluetooth-sdk",
3
- "version": "3.3.0-beta.994",
3
+ "version": "3.3.0-beta.997",
4
4
  "description": "SDK for communicating with smart glasses",
5
5
  "main": "build/index.js",
6
6
  "react-native": "src/index.ts",
@@ -114,7 +114,7 @@
114
114
  "registry": "https://registry.npmjs.org/"
115
115
  },
116
116
  "dependencies": {
117
- "@mentra/cloud-protocol": "3.3.0-beta.994"
117
+ "@mentra/cloud-protocol": "3.3.0-beta.997"
118
118
  },
119
119
  "devDependencies": {
120
120
  "@types/node": "^25.9.3",
@@ -3,7 +3,7 @@ export const GENERATED_RELEASE_CHANGELOGS = Object.freeze(
3
3
  [
4
4
  {
5
5
  "version": "3.3.0",
6
- "markdown": "This release is under active development. User-facing changes will be documented as they land."
6
+ "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
7
  },
8
8
  {
9
9
  "version": "3.2.1",
@@ -12,9 +12,9 @@ export interface BluetoothSdkReleaseMetadata {
12
12
  export const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({
13
13
  "schemaVersion": 1,
14
14
  "familyBaseVersion": "3.3.0",
15
- "releaseIdentity": "3.3.0-beta.994",
16
- "releaseSetId": "mentra-3.3.0-beta.994",
17
- "sourceCommit": "0eb1f0630182f3a45d38ea8a8029f5aa4fe1178e",
18
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.994.json",
19
- "otaManifestSha256": "13b9b10db8c9b4b75fdff820999e51eee7b90bc2e96edc099920f095c7f34618"
15
+ "releaseIdentity": "3.3.0-beta.997",
16
+ "releaseSetId": "mentra-3.3.0-beta.997",
17
+ "sourceCommit": "a502069a55ab0162dc7ada340a0b0041c82b05c3",
18
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.997.json",
19
+ "otaManifestSha256": "b3b501d1db23fbd4f9a8cc20eb9a2b51f26be768a757aea8827bf51420f734ec"
20
20
  })