@mentra/bluetooth-sdk 3.4.0-beta.1297 → 3.4.0-beta.1300

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.
@@ -336,6 +336,20 @@ public class Bridge private constructor() {
336
336
  DeviceStore.set("bluetooth", "searchResults", uniqueResults)
337
337
  }
338
338
 
339
+ /** Drop glasses from the search results, for example when their pairing window closed. */
340
+ @JvmStatic
341
+ fun removeDiscoveredDevice(deviceModel: String, deviceName: String) {
342
+ val searchResults =
343
+ DeviceStore.store.getCategory("bluetooth")["searchResults"] as? List<*> ?: return
344
+ val remaining =
345
+ searchResults.filterNot { result ->
346
+ val values = result as? Map<*, *>
347
+ values?.get("model") == deviceModel && values["name"] == deviceName
348
+ }
349
+ if (remaining.size == searchResults.size) return
350
+ DeviceStore.set("bluetooth", "searchResults", remaining)
351
+ }
352
+
339
353
  private fun mergeStableSearchResults(
340
354
  currentResults: List<Map<String, Any>>,
341
355
  newResult: Map<String, Any>,
@@ -2344,6 +2344,17 @@ class DeviceManager internal constructor(initializeHardware: Boolean) {
2344
2344
  sgc?.sendRgbLedControl(requestId, packageName, action, color, onDurationMs, offDurationMs, count)
2345
2345
  }
2346
2346
 
2347
+ /**
2348
+ * The person disconnected the glasses outside the app, in Android's Bluetooth settings. Like
2349
+ * the app's Disconnect, nothing reconnects them until the person connects again.
2350
+ */
2351
+ fun disconnectByUser() {
2352
+ Bridge.log("MAN: Glasses disconnected in Android's Bluetooth settings")
2353
+ DeviceStore.apply("bluetooth", "glasses_user_disconnected", true)
2354
+ Bridge.saveSetting("glasses_user_disconnected", true)
2355
+ disconnect()
2356
+ }
2357
+
2347
2358
  /** Glasses the person disconnected in the app stay disconnected. */
2348
2359
  internal fun shouldReconnectAfterBluetoothOn(): Boolean =
2349
2360
  defaultWearable.isNotEmpty() && deviceName.isNotEmpty() &&
@@ -3,9 +3,9 @@ package com.mentra.bluetoothsdk
3
3
  /** Generated by release CI. Do not edit in a release checkout. */
4
4
  internal object GeneratedReleaseMetadata {
5
5
  const val FAMILY_BASE_VERSION: String = "3.4.0"
6
- const val RELEASE_IDENTITY: String = "3.4.0-beta.1297"
7
- const val RELEASE_SET_ID: String = "mentra-3.4.0-beta.1297"
8
- const val SOURCE_COMMIT: String = "0380ba8fea16ed46215a90d762f595577994ec88"
9
- const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1297.json"
10
- const val OTA_MANIFEST_SHA256: String = "2144f4c7a33ec9bbde4a577bc3804bac8774e4e3d164e3dc55b2804bd5c8e0c7"
6
+ const val RELEASE_IDENTITY: String = "3.4.0-beta.1300"
7
+ const val RELEASE_SET_ID: String = "mentra-3.4.0-beta.1300"
8
+ const val SOURCE_COMMIT: String = "4d2f7ba80d269bf2371c689f34eb379a47900877"
9
+ const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1300.json"
10
+ const val OTA_MANIFEST_SHA256: String = "0c568a3d89f078890a4b4fcc45f6f007f22e7b8a4337a731becc09026e669379"
11
11
  }
@@ -11,6 +11,18 @@ internal fun readyClassicAudioSnapshot(states: Map<ClassicAudioProfile, Boolean>
11
11
  return if (connected.isNotEmpty() || states.size == ClassicAudioProfile.entries.size) connected else null
12
12
  }
13
13
 
14
+ /**
15
+ * Android is disconnecting the whole device, not one profile: every profile that was connected
16
+ * started disconnecting within [windowMs] of [nowMs]. Turning off Media or Call audio leaves the
17
+ * other one up.
18
+ */
19
+ internal fun wholeClassicDeviceDisconnecting(
20
+ wereUp: Set<ClassicAudioProfile>,
21
+ disconnectingAt: Map<ClassicAudioProfile, Long>,
22
+ nowMs: Long,
23
+ windowMs: Long,
24
+ ): Boolean = wereUp.all { profile -> disconnectingAt[profile]?.let { nowMs - it <= windowMs } == true }
25
+
14
26
  /**
15
27
  * Tracks the Android Classic audio profiles for one dual-mode glasses device.
16
28
  *
@@ -29,6 +41,9 @@ internal class ClassicAudioConnectionTracker(
29
41
  val connected: Boolean
30
42
  get() = connectedProfiles.isNotEmpty()
31
43
 
44
+ @Synchronized
45
+ fun connectedProfiles(): Set<ClassicAudioProfile> = connectedProfiles.toSet()
46
+
32
47
  /** BLE may already be gone when the user explicitly disconnects Classic audio. */
33
48
  @Synchronized
34
49
  fun targetForDisconnect(): String? = targetAddress
@@ -155,6 +155,12 @@ class MentraLive : SGCManager() {
155
155
  private const val A2DP_CONNECT_MAX_ATTEMPTS = 5
156
156
  private const val A2DP_CONNECT_RETRY_MS = 800L
157
157
  private const val UNPAIR_FLUSH_MS = 400L
158
+ /** Classic profile disconnects this soon after the app's own teardown are the app's. */
159
+ private const val OWN_CLASSIC_TEARDOWN_MS = 10_000L
160
+ /** Classic profiles going down this close together are one disconnect of the whole device. */
161
+ private const val CLASSIC_DISCONNECT_PAIR_MS = 3_000L
162
+ /** How long after the Classic drop the glasses must still be answering over BLE. */
163
+ private const val CLASSIC_DISCONNECT_CONFIRM_MS = 2_000L
158
164
  // Longer than the glasses' bounded relay of one report (BES logs, two file transfers,
159
165
  // the phone POST), so an unreleased name cannot be reused while its report is in flight.
160
166
  internal const val INCIDENT_RELAY_OWNERSHIP_MS = 10 * 60_000L
@@ -692,6 +698,13 @@ class MentraLive : SGCManager() {
692
698
  private var secureFirmwareRefreshRunnable: Runnable? = null
693
699
  /** elapsedRealtime of the last GATT link that was not an explicit pairing attempt. */
694
700
  private var lastAutoReconnectLinkAt: Long? = null
701
+ /** elapsedRealtime of the app's last own A2DP/HFP teardown. */
702
+ private var lastOwnClassicTeardownAt: Long? = null
703
+ /** elapsedRealtime when Android started disconnecting each Classic profile. */
704
+ private val classicDisconnectingAt = mutableMapOf<ClassicAudioProfile, Long>()
705
+ private var classicDisconnectCheck: Runnable? = null
706
+ /** elapsedRealtime of the last message from the glasses. */
707
+ private var lastInboundAt = 0L
695
708
  /** Hold GATT teardown until the unpair write can leave the phone. */
696
709
  private var unpairFlushPending = false
697
710
  private var unpairFlushRunnable: Runnable? = null
@@ -1637,29 +1650,17 @@ class MentraLive : SGCManager() {
1637
1650
  savedDeviceName.isNotEmpty() && savedDeviceName == deviceName
1638
1651
  val isNamedConnectTarget =
1639
1652
  isSavedGlasses && (isReconnecting || explicitConnectByName)
1640
- if (MentraLiveOwnerLossPolicy.shouldExposeAsNonPairable(
1653
+ if (MentraLiveOwnerLossPolicy.shouldIgnoreNotPairable(
1641
1654
  savedGlasses = isSavedGlasses,
1642
1655
  reconnectScan = isReconnecting,
1643
1656
  secureTrailer = advertisesPairingFlag(result),
1644
1657
  pairingDiscoverable = isPairingDiscoverable(result),
1645
1658
  )
1646
1659
  ) {
1647
- // Other secure units stay visible with pairing-mode guidance, and
1648
- // the scan screen blocks the connection until they are pairable.
1660
+ // Only glasses that can pair now are listed; a closed window drops them.
1649
1661
  // The saved glasses fall through so the pause watch scan can see
1650
1662
  // the pairing flag clear and reconnect.
1651
- Bridge.log(
1652
- "LIVE: Nearby $deviceName is secure firmware not in pairing mode — exposing as non-pairable"
1653
- )
1654
- Bridge.sendDiscoveredDevice(
1655
- DeviceTypes.LIVE,
1656
- deviceName,
1657
- deviceAddress,
1658
- result.rssi,
1659
- pairingMode = false,
1660
- pairingCode = null,
1661
- securePairingCapable = true,
1662
- )
1663
+ Bridge.removeDiscoveredDevice(DeviceTypes.LIVE, deviceName)
1663
1664
  return
1664
1665
  }
1665
1666
  val glassType = if (deviceName == "Xy_A") "Standard" else "K900"
@@ -1672,17 +1673,21 @@ class MentraLive : SGCManager() {
1672
1673
  if (secureCapable) " (pairingMode=$pairingMode)"
1673
1674
  else " (legacy firmware, pairable)"
1674
1675
  )
1675
- Bridge.sendDiscoveredDevice(
1676
- DeviceTypes.LIVE,
1677
- deviceName,
1678
- deviceAddress,
1679
- result.rssi,
1680
- // Field firmware has no pairing flag. Treat it as pairable so the
1681
- // new Mentra App can still find old glasses.
1682
- pairingMode = if (secureCapable) pairingMode else true,
1683
- pairingCode = pairingCode,
1684
- securePairingCapable = secureCapable,
1685
- )
1676
+ // Field firmware has no pairing flag. Treat it as pairable so the new
1677
+ // Mentra App can still find old glasses.
1678
+ if (secureCapable && !pairingMode) {
1679
+ Bridge.removeDiscoveredDevice(DeviceTypes.LIVE, deviceName)
1680
+ } else {
1681
+ Bridge.sendDiscoveredDevice(
1682
+ DeviceTypes.LIVE,
1683
+ deviceName,
1684
+ deviceAddress,
1685
+ result.rssi,
1686
+ pairingMode = true,
1687
+ pairingCode = pairingCode,
1688
+ securePairingCapable = secureCapable,
1689
+ )
1690
+ }
1686
1691
 
1687
1692
  if (savedDeviceName.isNotEmpty() && savedDeviceName == deviceName) {
1688
1693
  observeSavedGlassesAdvertisement(result)
@@ -4346,6 +4351,7 @@ class MentraLive : SGCManager() {
4346
4351
  }
4347
4352
  BleTraceLogger.logJson("glasses_to_phone", "sdk_ble_event", json, null)
4348
4353
  GlassesLinkDiagnostics.recordInbound()
4354
+ lastInboundAt = SystemClock.elapsedRealtime()
4349
4355
 
4350
4356
  if (MessageChunker.isChunkedMessage(json)) {
4351
4357
  processChunkedJsonMessage(json)
@@ -8018,11 +8024,56 @@ class MentraLive : SGCManager() {
8018
8024
  if (intent?.action != BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED &&
8019
8025
  intent?.action != BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED) return
8020
8026
  val device = intent.bluetoothDeviceExtra() ?: return
8027
+ noteClassicDisconnecting(device, intent)
8021
8028
  refreshClassicAudioConnectionState(device)
8022
8029
  }
8023
8030
  }
8024
8031
  }
8025
8032
 
8033
+ /**
8034
+ * Android's Bluetooth settings Disconnect drops every Classic profile of the glasses (A2DP,
8035
+ * and HFP unless the unworn glasses closed it) and leaves the app's BLE link up, so Home went
8036
+ * on showing them connected. When all the connected profiles start disconnecting within
8037
+ * [CLASSIC_DISCONNECT_PAIR_MS] while the app neither asked nor lost BLE, and the glasses
8038
+ * answer over BLE within [CLASSIC_DISCONNECT_CONFIRM_MS], the person disconnected them: it
8039
+ * lasts like the app's Disconnect, even if the glasses paged their audio back meanwhile. A
8040
+ * restart, power off, pairing window or range loss takes BLE down too; turning off Media or
8041
+ * Call audio leaves the other profile up.
8042
+ */
8043
+ private fun noteClassicDisconnecting(device: BluetoothDevice, intent: Intent) {
8044
+ if (intent.getIntExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, -1) != BluetoothProfile.STATE_CONNECTED ||
8045
+ intent.getIntExtra(BluetoothProfile.EXTRA_STATE, -1) != BluetoothProfile.STATE_DISCONNECTING
8046
+ ) {
8047
+ return
8048
+ }
8049
+ if (isKilled || !isConnected || connectedDevice?.address != device.address) return
8050
+ if (bluetoothAdapter?.state != BluetoothAdapter.STATE_ON) return
8051
+ val now = SystemClock.elapsedRealtime()
8052
+ val ownTeardownAt = lastOwnClassicTeardownAt
8053
+ if (ownTeardownAt != null && now - ownTeardownAt < OWN_CLASSIC_TEARDOWN_MS) return
8054
+ val profile =
8055
+ if (intent.action == BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED) ClassicAudioProfile.A2DP
8056
+ else ClassicAudioProfile.HEADSET
8057
+ classicDisconnectingAt[profile] = now
8058
+ val wereUp = classicAudioConnectionTracker.connectedProfiles() + profile
8059
+ if (!wholeClassicDeviceDisconnecting(wereUp, classicDisconnectingAt, now, CLASSIC_DISCONNECT_PAIR_MS)) return
8060
+ if (classicDisconnectCheck != null) return
8061
+ Bridge.log("LIVE: Classic: Android is disconnecting the glasses' audio - checking the glasses stay up")
8062
+ val session = gattEpoch
8063
+ sendJsonWithoutAck(JSONObject().put("type", "ping"))
8064
+ val check =
8065
+ Runnable {
8066
+ classicDisconnectCheck = null
8067
+ if (isKilled || !isConnected || gattEpoch != session || lastInboundAt <= now) {
8068
+ return@Runnable
8069
+ }
8070
+ Bridge.log("LIVE: Classic: Android disconnected the glasses - staying disconnected")
8071
+ DeviceManager.getInstance().disconnectByUser()
8072
+ }
8073
+ classicDisconnectCheck = check
8074
+ handler.postDelayed(check, CLASSIC_DISCONNECT_CONFIRM_MS)
8075
+ }
8076
+
8026
8077
  private fun registerClassicAudioReceiver() {
8027
8078
  val ctx = context ?: return
8028
8079
  val receiver = classicAudioReceiver ?: return
@@ -8656,6 +8707,7 @@ class MentraLive : SGCManager() {
8656
8707
  // The BLE device reference may already be cleared after a GATT drop. The tracker owns the
8657
8708
  // authoritative target address, so let it decide whether this teardown belongs to the
8658
8709
  // active Classic session instead of consulting connectedDevice.
8710
+ lastOwnClassicTeardownAt = SystemClock.elapsedRealtime()
8659
8711
  if (classicAudioConnectionTracker.invalidate(device.address)) {
8660
8712
  audioConnected = false
8661
8713
  }
@@ -142,12 +142,12 @@ internal object MentraLiveOwnerLossPolicy {
142
142
  ): Boolean = pairingMode && savedGlasses && !explicitPairing
143
143
 
144
144
  /**
145
- * A discovery scan lists other secure glasses that are not in pairing mode as non-pairable
146
- * and does not connect to them. The saved glasses are the exception: the pause watch scan
147
- * has to read their trailer, so a cleared pairing flag ends the pause and reconnects.
148
- * Mirrors iOS, which skips this return when the advertisement is the saved device.
145
+ * A discovery scan neither lists nor connects to other secure glasses that are not in pairing
146
+ * mode. The saved glasses are the exception: the pause watch scan has to read their trailer,
147
+ * so a cleared pairing flag ends the pause and reconnects. Mirrors iOS, which skips this
148
+ * return when the advertisement is the saved device.
149
149
  */
150
- fun shouldExposeAsNonPairable(
150
+ fun shouldIgnoreNotPairable(
151
151
  savedGlasses: Boolean,
152
152
  reconnectScan: Boolean,
153
153
  secureTrailer: Boolean,
@@ -19,6 +19,32 @@ class ClassicAudioConnectionTrackerTest {
19
19
  ClassicAudioProfile.HEADSET to false))).isEmpty()
20
20
  }
21
21
 
22
+ private val both = setOf(ClassicAudioProfile.A2DP, ClassicAudioProfile.HEADSET)
23
+
24
+ @Test
25
+ fun `android Disconnect drops every connected profile together`() {
26
+ val at = mapOf(ClassicAudioProfile.HEADSET to 1_000L, ClassicAudioProfile.A2DP to 1_001L)
27
+ assertThat(wholeClassicDeviceDisconnecting(both, at, 1_001L, 3_000L)).isTrue()
28
+ }
29
+
30
+ @Test
31
+ fun `turning off Media or Call audio is not a disconnect`() {
32
+ assertThat(wholeClassicDeviceDisconnecting(both, mapOf(ClassicAudioProfile.A2DP to 1_000L), 1_000L, 3_000L)).isFalse()
33
+ assertThat(wholeClassicDeviceDisconnecting(both, mapOf(ClassicAudioProfile.HEADSET to 1_000L), 1_000L, 3_000L)).isFalse()
34
+ }
35
+
36
+ @Test
37
+ fun `unworn glasses with only A2DP up are disconnected by that profile alone`() {
38
+ val a2dp = setOf(ClassicAudioProfile.A2DP)
39
+ assertThat(wholeClassicDeviceDisconnecting(a2dp, mapOf(ClassicAudioProfile.A2DP to 1_000L), 1_000L, 3_000L)).isTrue()
40
+ }
41
+
42
+ @Test
43
+ fun `two profile toggles far apart are not one disconnect`() {
44
+ val at = mapOf(ClassicAudioProfile.HEADSET to 1_000L, ClassicAudioProfile.A2DP to 10_000L)
45
+ assertThat(wholeClassicDeviceDisconnecting(both, at, 10_000L, 3_000L)).isFalse()
46
+ }
47
+
22
48
  private val address = "AA:BB:CC:DD:EE:FF"
23
49
 
24
50
  private fun snapshot(tracker: ClassicAudioConnectionTracker, vararg profiles: ClassicAudioProfile) {
@@ -193,7 +193,7 @@ class MentraLiveOwnerLossPolicyTest {
193
193
  @Test
194
194
  fun aClearedPairingFlagOnTheSavedGlassesIsNotHiddenFromThePauseWatchScan() {
195
195
  assertFalse(
196
- MentraLiveOwnerLossPolicy.shouldExposeAsNonPairable(
196
+ MentraLiveOwnerLossPolicy.shouldIgnoreNotPairable(
197
197
  savedGlasses = true,
198
198
  reconnectScan = false,
199
199
  secureTrailer = true,
@@ -201,7 +201,7 @@ class MentraLiveOwnerLossPolicyTest {
201
201
  )
202
202
  )
203
203
  assertTrue(
204
- MentraLiveOwnerLossPolicy.shouldExposeAsNonPairable(
204
+ MentraLiveOwnerLossPolicy.shouldIgnoreNotPairable(
205
205
  savedGlasses = false,
206
206
  reconnectScan = false,
207
207
  secureTrailer = true,
@@ -209,7 +209,7 @@ class MentraLiveOwnerLossPolicyTest {
209
209
  )
210
210
  )
211
211
  assertFalse(
212
- MentraLiveOwnerLossPolicy.shouldExposeAsNonPairable(
212
+ MentraLiveOwnerLossPolicy.shouldIgnoreNotPairable(
213
213
  savedGlasses = false,
214
214
  reconnectScan = false,
215
215
  secureTrailer = true,
@@ -1,10 +1,10 @@
1
1
  export const BLUETOOTH_SDK_RELEASE_METADATA = Object.freeze({
2
2
  "schemaVersion": 1,
3
3
  "familyBaseVersion": "3.4.0",
4
- "releaseIdentity": "3.4.0-beta.1297",
5
- "releaseSetId": "mentra-3.4.0-beta.1297",
6
- "sourceCommit": "0380ba8fea16ed46215a90d762f595577994ec88",
7
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1297.json",
8
- "otaManifestSha256": "2144f4c7a33ec9bbde4a577bc3804bac8774e4e3d164e3dc55b2804bd5c8e0c7"
4
+ "releaseIdentity": "3.4.0-beta.1300",
5
+ "releaseSetId": "mentra-3.4.0-beta.1300",
6
+ "sourceCommit": "4d2f7ba80d269bf2371c689f34eb379a47900877",
7
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1300.json",
8
+ "otaManifestSha256": "0c568a3d89f078890a4b4fcc45f6f007f22e7b8a4337a731becc09026e669379"
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,iBAAiB;IACpC,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,mIAAmI;IACrJ,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.4.0\",\n \"releaseIdentity\": \"3.4.0-beta.1297\",\n \"releaseSetId\": \"mentra-3.4.0-beta.1297\",\n \"sourceCommit\": \"0380ba8fea16ed46215a90d762f595577994ec88\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1297.json\",\n \"otaManifestSha256\": \"2144f4c7a33ec9bbde4a577bc3804bac8774e4e3d164e3dc55b2804bd5c8e0c7\"\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,iBAAiB;IACpC,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,mIAAmI;IACrJ,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.4.0\",\n \"releaseIdentity\": \"3.4.0-beta.1300\",\n \"releaseSetId\": \"mentra-3.4.0-beta.1300\",\n \"sourceCommit\": \"4d2f7ba80d269bf2371c689f34eb379a47900877\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1300.json\",\n \"otaManifestSha256\": \"0c568a3d89f078890a4b4fcc45f6f007f22e7b8a4337a731becc09026e669379\"\n})\n"]}
@@ -16,7 +16,7 @@ enum BluetoothSdkDefaults {
16
16
  /// 20-minute unworn power-off 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.4.0-beta.1297"
19
+ private static let swiftPackageSdkVersion = "3.4.0-beta.1300"
20
20
  private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
21
21
 
22
22
  private static func normalizedSdkVersion(_ value: String?) -> String? {
@@ -253,6 +253,20 @@ class Bridge {
253
253
  }
254
254
  }
255
255
 
256
+ /// Drops glasses from the search results, for example when their pairing window closed.
257
+ static func removeDiscoveredDevice(_ deviceModel: String, _ deviceName: String) {
258
+ Task {
259
+ await MainActor.run {
260
+ let searchResults = DeviceStore.shared.get("bluetooth", "searchResults") as? [[String: Any]] ?? []
261
+ let remaining = searchResults.filter {
262
+ !($0["model"] as? String == deviceModel && $0["name"] as? String == deviceName)
263
+ }
264
+ if remaining.count == searchResults.count { return }
265
+ DeviceStore.shared.set("bluetooth", "searchResults", remaining)
266
+ }
267
+ }
268
+ }
269
+
256
270
  private static func mergeStableSearchResults(
257
271
  _ currentResults: [[String: Any]],
258
272
  newResult: [String: Any],
@@ -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.4.0"
6
- static let releaseIdentity = "3.4.0-beta.1297"
7
- static let releaseSetId = "mentra-3.4.0-beta.1297"
8
- static let sourceCommit = "0380ba8fea16ed46215a90d762f595577994ec88"
9
- static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1297.json"
10
- static let otaManifestSha256 = "2144f4c7a33ec9bbde4a577bc3804bac8774e4e3d164e3dc55b2804bd5c8e0c7"
6
+ static let releaseIdentity = "3.4.0-beta.1300"
7
+ static let releaseSetId = "mentra-3.4.0-beta.1300"
8
+ static let sourceCommit = "4d2f7ba80d269bf2371c689f34eb379a47900877"
9
+ static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1300.json"
10
+ static let otaManifestSha256 = "0c568a3d89f078890a4b4fcc45f6f007f22e7b8a4337a731becc09026e669379"
11
11
  }
@@ -786,26 +786,8 @@ extension MentraLive: CBCentralManagerDelegate {
786
786
  if !isReconnectTarget && advertisesPairingFlag(advertisementData)
787
787
  && !isPairingDiscoverable(advertisementData)
788
788
  {
789
- // Keep nearby secure units visible with pairing-mode guidance, while RN blocks
790
- // the connection until a pairable advertisement arrives.
791
- pairFlow(
792
- "discover",
793
- "name=\(name) id=\(peripheral.identifier.uuidString) saved=\(savedDeviceName ?? "-") pairingMode=false secure=true connect=false"
794
- )
795
- discoveredPeripherals[name] = peripheral
796
- rememberPeripheral(peripheral, name: name)
797
- if cacheAdvPairing(
798
- name,
799
- pairingMode: false,
800
- pairingCode: nil,
801
- securePairingCapable: true
802
- ) {
803
- emitDiscoveredDeviceFromCache(
804
- name,
805
- identifier: peripheral.identifier.uuidString,
806
- rssi: rssi?.intValue
807
- )
808
- }
789
+ // Only glasses that can pair now are listed; a closed window drops them.
790
+ unlistNotPairable(name)
809
791
  return
810
792
  }
811
793
 
@@ -831,11 +813,13 @@ extension MentraLive: CBCentralManagerDelegate {
831
813
  discoveredPeripherals[name] = peripheral
832
814
  rememberPeripheral(peripheral, name: name)
833
815
 
834
- if !partialAdvertisement, cacheAdvPairing(
816
+ if trailer.secureCapable && !trailer.pairingMode {
817
+ unlistNotPairable(name)
818
+ } else if !partialAdvertisement, cacheAdvPairing(
835
819
  name,
836
820
  // Field firmware has no pairing flag. Treat it as pairable so the
837
821
  // new Mentra App can still find old glasses.
838
- pairingMode: trailer.secureCapable ? trailer.pairingMode : true,
822
+ pairingMode: true,
839
823
  pairingCode: trailer.pairingCode,
840
824
  securePairingCapable: trailer.secureCapable
841
825
  ) {
@@ -2925,7 +2909,7 @@ class MentraLive: NSObject, SGCManager {
2925
2909
 
2926
2910
  // The choose-glasses scan has to hear a later advertisement when the glasses
2927
2911
  // enter pairing mode. iOS reports each peripheral once unless duplicates are
2928
- // allowed, so the row would stay "Not in pairing mode". Reconnect scans stay
2912
+ // allowed, so the glasses would stay off the list. Reconnect scans stay
2929
2913
  // duplicate-free so a saved glasses advertisement cannot start another connect.
2930
2914
  let scanOptions: [String: Any] = [
2931
2915
  CBCentralManagerScanOptionAllowDuplicatesKey: manualDiscoveryActive,
@@ -6941,6 +6925,14 @@ class MentraLive: NSObject, SGCManager {
6941
6925
  return true
6942
6926
  }
6943
6927
 
6928
+ /// Drops glasses that are not in pairing mode from the search results, once per change, so the
6929
+ /// next pairable advertisement lists them again.
6930
+ private func unlistNotPairable(_ name: String) {
6931
+ if cacheAdvPairing(name, pairingMode: false, pairingCode: nil, securePairingCapable: true) {
6932
+ Bridge.removeDiscoveredDevice("Mentra Live", name)
6933
+ }
6934
+ }
6935
+
6944
6936
  private func emitDiscoveredDeviceFromCache(
6945
6937
  _ name: String,
6946
6938
  identifier: String = "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/bluetooth-sdk",
3
- "version": "3.4.0-beta.1297",
3
+ "version": "3.4.0-beta.1300",
4
4
  "description": "SDK for communicating with smart glasses",
5
5
  "main": "build/index.js",
6
6
  "react-native": "src/index.ts",
@@ -115,7 +115,7 @@
115
115
  "registry": "https://registry.npmjs.org/"
116
116
  },
117
117
  "dependencies": {
118
- "@mentra/cloud-protocol": "3.4.0-beta.1297"
118
+ "@mentra/cloud-protocol": "3.4.0-beta.1300"
119
119
  },
120
120
  "devDependencies": {
121
121
  "@types/node": "^25.9.3",
@@ -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.4.0",
15
- "releaseIdentity": "3.4.0-beta.1297",
16
- "releaseSetId": "mentra-3.4.0-beta.1297",
17
- "sourceCommit": "0380ba8fea16ed46215a90d762f595577994ec88",
18
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1297.json",
19
- "otaManifestSha256": "2144f4c7a33ec9bbde4a577bc3804bac8774e4e3d164e3dc55b2804bd5c8e0c7"
15
+ "releaseIdentity": "3.4.0-beta.1300",
16
+ "releaseSetId": "mentra-3.4.0-beta.1300",
17
+ "sourceCommit": "4d2f7ba80d269bf2371c689f34eb379a47900877",
18
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1300.json",
19
+ "otaManifestSha256": "0c568a3d89f078890a4b4fcc45f6f007f22e7b8a4337a731becc09026e669379"
20
20
  })