@mentra/bluetooth-sdk 3.5.0-dev.1511 → 3.5.0-dev.1513

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.
@@ -1143,23 +1143,9 @@ class BluetoothSdkModule : Module() {
1143
1143
  }
1144
1144
  }
1145
1145
 
1146
- private fun Map<String, Any>?.toMentraDevice(): Device? {
1147
- val values = this ?: return null
1148
- val model = values["model"] as? String ?: return null
1149
- val name = values["name"] as? String ?: return null
1150
- val address = values["address"] as? String
1151
- val projectName = values["projectName"] as? String
1152
- val rssi = (values["rssi"] as? Number)?.toInt()
1153
- val id = values["id"] as? String
1154
- return Device(
1155
- model = DeviceModel.fromDeviceType(model),
1156
- name = name,
1157
- address = address?.takeIf { it.isNotBlank() },
1158
- projectName = projectName?.takeIf { it.isNotBlank() },
1159
- rssi = rssi,
1160
- id = id?.takeIf { it.isNotBlank() } ?: address?.takeIf { it.isNotBlank() } ?: "$model:$name",
1161
- )
1162
- }
1146
+ // Every field the scan reported, securePairingCapable included: the pairing flow reads it to tell a declined secure
1147
+ // pair from a failed legacy one before the glasses send pairing_info.
1148
+ private fun Map<String, Any>?.toMentraDevice(): Device? = this?.let(Device::fromMap)
1163
1149
 
1164
1150
  private fun Map<String, Any>?.toMentraConnectOptions(): ConnectOptions {
1165
1151
  val values = this ?: return ConnectOptions()
@@ -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.5.0"
6
- const val RELEASE_IDENTITY: String = "3.5.0-dev.1511"
7
- const val RELEASE_SET_ID: String = "mentra-3.5.0-dev.1511"
8
- const val SOURCE_COMMIT: String = "07c807b48f72e9013789bcadf3724d12db912cb0"
9
- const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1511.json"
10
- const val OTA_MANIFEST_SHA256: String = "c9927399f16d823be1c614b845e7e47631c1b3ab4d09dafc8772a3b1c62ed0b8"
6
+ const val RELEASE_IDENTITY: String = "3.5.0-dev.1513"
7
+ const val RELEASE_SET_ID: String = "mentra-3.5.0-dev.1513"
8
+ const val SOURCE_COMMIT: String = "027fbe5f4c4109d8b48bc3aac3982ec69f99ae90"
9
+ const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1513.json"
10
+ const val OTA_MANIFEST_SHA256: String = "1ffa737ac3a6141e4bda0055188ed608c555100f3e0ab90ecda72f0877e9b45b"
11
11
  }
@@ -2382,9 +2382,11 @@ class MentraLive : SGCManager() {
2382
2382
 
2383
2383
  /** Remember what the connected glasses reported so later rejections can be read correctly. */
2384
2384
  private fun rememberSecureFirmware(secure: Boolean) {
2385
- if (isSavedGlassesSecureFirmware() == secure) return
2385
+ if (DeviceStore.get("bluetooth", "mentra_live_secure_firmware") as? Boolean == secure) return
2386
2386
  DeviceStore.apply("bluetooth", "mentra_live_secure_firmware", secure)
2387
2387
  Bridge.saveSetting("mentra_live_secure_firmware", secure)
2388
+ // Older firmware, newly known or rolled back to: the app starts its audio.
2389
+ if (!secure) connectedDevice?.let { prepareClassicAudio(it) }
2388
2390
  }
2389
2391
 
2390
2392
  /**
@@ -4645,6 +4647,7 @@ class MentraLive : SGCManager() {
4645
4647
  resolveUnknownCapabilityReadiness("pairing_info")
4646
4648
  }
4647
4649
  maybeInitiateCtkdAudioAfterBleReady()
4650
+ connectedDevice?.let { prepareClassicAudio(it) }
4648
4651
  Bridge.sendPairingInfo(
4649
4652
  json.optBoolean("had_previous_bond", false),
4650
4653
  jsonNullableString(json, "pairing_code"),
@@ -8019,14 +8022,31 @@ class MentraLive : SGCManager() {
8019
8022
  }
8020
8023
  audioConnected = false
8021
8024
  if (previousBondState == BluetoothDevice.BOND_BONDING &&
8025
+ isExplicitPairingAttempt() &&
8026
+ isSecurePairingTarget() &&
8027
+ !MentraLiveOwnerLossPolicy.isSecurePairingDeclined(
8028
+ // AOSP's EXTRA_UNBOND_REASON key is
8029
+ // "extra.REASON".
8030
+ reason
8031
+ )
8032
+ ) {
8033
+ // Not a decline, such as Android removing a stale bond
8034
+ // while it bonds again: no result yet. The owner commit
8035
+ // and bond decide, within the secure bond wait.
8036
+ Bridge.log(
8037
+ "LIVE: CTKD: secure pairing bond reset (reason=$reason), not declined — waiting for the bond"
8038
+ )
8039
+ armSecureBondWait()
8040
+ } else if (previousBondState == BluetoothDevice.BOND_BONDING &&
8022
8041
  isExplicitPairingAttempt() &&
8023
8042
  isSecurePairingTarget()
8024
8043
  ) {
8025
- // Secure glasses own a phone only through this bond.
8026
- // Re-prompting after a decline only repeats the
8027
- // system dialog; let the pairing screen offer Try again.
8044
+ // The person declined Android's pairing request. Secure
8045
+ // glasses own a phone only through this bond, and
8046
+ // re-prompting only repeats the system dialog; let the
8047
+ // pairing screen offer Try again.
8028
8048
  Bridge.log(
8029
- "LIVE: CTKD: secure pairing bond not completed — reporting pairing failure"
8049
+ "LIVE: CTKD: secure pairing declined (reason=$reason) — reporting pairing failure"
8030
8050
  )
8031
8051
  bondingRetryCount = 0
8032
8052
  cancelSecureBondWait()
@@ -8398,6 +8418,15 @@ class MentraLive : SGCManager() {
8398
8418
 
8399
8419
  private fun prepareClassicAudio(device: BluetoothDevice) {
8400
8420
  if (!canConnectClassicAudio(device)) return
8421
+ // Secure glasses (BES 3.4+) connect their owner's A2DP/HFP themselves; starting it here
8422
+ // too races them, and in pairing mode Android shows "Couldn't connect". The app start
8423
+ // below is only for glasses on 3.3 or older: delete it once none remain.
8424
+ val secure = sessionPairingInfoSecure
8425
+ ?: if (isExplicitPairingAttempt()) selectedTargetSecureCapability() ?: false.takeIf { unknownCapabilityWaitExpired }
8426
+ else DeviceStore.get("bluetooth", "mentra_live_secure_firmware") as? Boolean
8427
+ if (secure == true) return refreshClassicAudioConnectionState(device)
8428
+ // Not known yet: pairing_info, or its deadline, calls this again.
8429
+ if (secure == null) return
8401
8430
  val gatt = bluetoothGatt
8402
8431
  classicAudioServiceDiscovery.connectWhenDiscovered(device) {
8403
8432
  if (bluetoothGatt === gatt && canConnectClassicAudio(device)) connectA2dpProfile(device)
@@ -8596,6 +8625,7 @@ class MentraLive : SGCManager() {
8596
8625
  "after glasses_ready — treating the pairing target as legacy firmware"
8597
8626
  )
8598
8627
  resolveUnknownCapabilityReadiness("unknown_capability_timeout")
8628
+ connectedDevice?.let { prepareClassicAudio(it) }
8599
8629
  }
8600
8630
  unknownCapabilityWaitRunnable = runnable
8601
8631
  handler.postDelayed(
@@ -197,6 +197,23 @@ internal object MentraLiveOwnerLossPolicy {
197
197
  (bondState != BluetoothDevice.BOND_BONDED ||
198
198
  !pairingInfoConfirmsOwner(ownerCommitted))
199
199
 
200
+ /**
201
+ * Android's hidden unbond reasons for a person declining a pairing request: auth failed (1),
202
+ * rejected (2), cancelled (3) and remote auth cancelled (8). Samsung reports Cancel on its
203
+ * pairing request as 1. Hidden constants with stable values; the bond-state broadcast carries
204
+ * them under `android.bluetooth.device.extra.REASON`.
205
+ */
206
+ private val DECLINE_UNBOND_REASONS = setOf(1, 2, 3, 8)
207
+
208
+ /**
209
+ * Whether a bond that went BONDING→NONE during an explicit secure pair was declined. Only a
210
+ * decline ends the attempt at once. Success comes from the glasses (`pairing_info`
211
+ * `owner_committed`) with the bond reaching BONDED. Any other reason, such as 9 (removed:
212
+ * Android dropping a stale bond while it bonds again), is not a result: the attempt stays
213
+ * bounded by [SECURE_BOND_WAIT_MS].
214
+ */
215
+ fun isSecurePairingDeclined(unbondReason: Int): Boolean = unbondReason in DECLINE_UNBOND_REASONS
216
+
200
217
  /** How long an explicit secure pair may wait for a bond result before the attempt fails. */
201
218
  const val SECURE_BOND_WAIT_MS = 40_000L
202
219
 
@@ -0,0 +1,19 @@
1
+ package com.mentra.bluetoothsdk
2
+
3
+ import org.junit.Assert.assertEquals
4
+ import org.junit.Test
5
+
6
+ class DeviceMapTest {
7
+ /** The scan row that JS hands back to connect: the pairing flow needs its capability before pairing_info. */
8
+ @Test fun `a selected scan row keeps its secure pairing capability`() {
9
+ val row = Device(
10
+ model = DeviceModel.MENTRA_LIVE,
11
+ name = "Mentra_Live_0BB0",
12
+ address = "AA:BB:CC:DD:0B:B0",
13
+ pairingMode = true,
14
+ pairingCode = "1A2B",
15
+ securePairingCapable = true,
16
+ )
17
+ assertEquals(row, Device.fromMap(row.toMap()))
18
+ }
19
+ }
@@ -379,4 +379,25 @@ class MentraLiveOwnerLossPolicyTest {
379
379
  msSinceAutoReconnectLink = msSinceAutoReconnectLink,
380
380
  secureFirmware = secureFirmware,
381
381
  )
382
+
383
+ @Test
384
+ fun onlyADeclineEndsASecurePairAtOnce() {
385
+ // auth failed (Samsung's Cancel), rejected, cancelled, remote auth cancelled
386
+ for (reason in listOf(1, 2, 3, 8)) {
387
+ assertTrue(MentraLiveOwnerLossPolicy.isSecurePairingDeclined(reason))
388
+ }
389
+ }
390
+
391
+ @Test
392
+ fun aStaleBondRemovedWhileRebondingIsNotADecline() {
393
+ assertFalse(MentraLiveOwnerLossPolicy.isSecurePairingDeclined(9))
394
+ }
395
+
396
+ @Test
397
+ fun otherBondEndingsWaitForTheSecureBondWait() {
398
+ // remote device down, timeout, repeated attempts, no reason
399
+ for (reason in listOf(4, 6, 7, -1)) {
400
+ assertFalse(MentraLiveOwnerLossPolicy.isSecurePairingDeclined(reason))
401
+ }
402
+ }
382
403
  }
@@ -1,10 +1,10 @@
1
1
  export const BLUETOOTH_SDK_RELEASE_METADATA = Object.freeze({
2
2
  "schemaVersion": 1,
3
3
  "familyBaseVersion": "3.5.0",
4
- "releaseIdentity": "3.5.0-dev.1511",
5
- "releaseSetId": "mentra-3.5.0-dev.1511",
6
- "sourceCommit": "07c807b48f72e9013789bcadf3724d12db912cb0",
7
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1511.json",
8
- "otaManifestSha256": "c9927399f16d823be1c614b845e7e47631c1b3ab4d09dafc8772a3b1c62ed0b8"
4
+ "releaseIdentity": "3.5.0-dev.1513",
5
+ "releaseSetId": "mentra-3.5.0-dev.1513",
6
+ "sourceCommit": "027fbe5f4c4109d8b48bc3aac3982ec69f99ae90",
7
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1513.json",
8
+ "otaManifestSha256": "1ffa737ac3a6141e4bda0055188ed608c555100f3e0ab90ecda72f0877e9b45b"
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.5.0\",\n \"releaseIdentity\": \"3.5.0-dev.1511\",\n \"releaseSetId\": \"mentra-3.5.0-dev.1511\",\n \"sourceCommit\": \"07c807b48f72e9013789bcadf3724d12db912cb0\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1511.json\",\n \"otaManifestSha256\": \"c9927399f16d823be1c614b845e7e47631c1b3ab4d09dafc8772a3b1c62ed0b8\"\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.5.0\",\n \"releaseIdentity\": \"3.5.0-dev.1513\",\n \"releaseSetId\": \"mentra-3.5.0-dev.1513\",\n \"sourceCommit\": \"027fbe5f4c4109d8b48bc3aac3982ec69f99ae90\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1513.json\",\n \"otaManifestSha256\": \"1ffa737ac3a6141e4bda0055188ed608c555100f3e0ab90ecda72f0877e9b45b\"\n})\n"]}
@@ -1126,8 +1126,13 @@ private extension Device {
1126
1126
  model: DeviceModel.fromDeviceType(model),
1127
1127
  name: name,
1128
1128
  identifier: identifier?.isEmpty == true ? nil : identifier,
1129
+ projectName: (values["projectName"] as? String).flatMap { $0.isEmpty ? nil : $0 },
1129
1130
  rssi: rssi,
1130
- id: id
1131
+ id: id,
1132
+ pairingMode: values["pairingMode"] as? Bool,
1133
+ pairingCode: (values["pairingCode"] as? String).flatMap { $0.isEmpty ? nil : $0 },
1134
+ // The pairing flow reads it to tell a declined secure pair from a failed legacy one.
1135
+ securePairingCapable: values["securePairingCapable"] as? Bool
1131
1136
  )
1132
1137
  }
1133
1138
  }
@@ -17,7 +17,7 @@ enum BluetoothSdkDefaults {
17
17
  /// persist.mentra.wear_detection_off=1.
18
18
  static let autoPowerOffEnabled = true
19
19
  private static let infoSdkVersionKey = "MentraBluetoothSdkVersion"
20
- private static let swiftPackageSdkVersion = "3.5.0-dev.1511"
20
+ private static let swiftPackageSdkVersion = "3.5.0-dev.1513"
21
21
  private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
22
22
 
23
23
  private static func normalizedSdkVersion(_ value: String?) -> String? {
@@ -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.5.0"
6
- static let releaseIdentity = "3.5.0-dev.1511"
7
- static let releaseSetId = "mentra-3.5.0-dev.1511"
8
- static let sourceCommit = "07c807b48f72e9013789bcadf3724d12db912cb0"
9
- static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1511.json"
10
- static let otaManifestSha256 = "c9927399f16d823be1c614b845e7e47631c1b3ab4d09dafc8772a3b1c62ed0b8"
6
+ static let releaseIdentity = "3.5.0-dev.1513"
7
+ static let releaseSetId = "mentra-3.5.0-dev.1513"
8
+ static let sourceCommit = "027fbe5f4c4109d8b48bc3aac3982ec69f99ae90"
9
+ static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1513.json"
10
+ static let otaManifestSha256 = "1ffa737ac3a6141e4bda0055188ed608c555100f3e0ab90ecda72f0877e9b45b"
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/bluetooth-sdk",
3
- "version": "3.5.0-dev.1511",
3
+ "version": "3.5.0-dev.1513",
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.5.0-dev.1511"
118
+ "@mentra/cloud-protocol": "3.5.0-dev.1513"
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.5.0",
15
- "releaseIdentity": "3.5.0-dev.1511",
16
- "releaseSetId": "mentra-3.5.0-dev.1511",
17
- "sourceCommit": "07c807b48f72e9013789bcadf3724d12db912cb0",
18
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1511.json",
19
- "otaManifestSha256": "c9927399f16d823be1c614b845e7e47631c1b3ab4d09dafc8772a3b1c62ed0b8"
15
+ "releaseIdentity": "3.5.0-dev.1513",
16
+ "releaseSetId": "mentra-3.5.0-dev.1513",
17
+ "sourceCommit": "027fbe5f4c4109d8b48bc3aac3982ec69f99ae90",
18
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1513.json",
19
+ "otaManifestSha256": "1ffa737ac3a6141e4bda0055188ed608c555100f3e0ab90ecda72f0877e9b45b"
20
20
  })