@mentra/bluetooth-sdk 3.5.0-dev.1508 → 3.5.0-dev.1510

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,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.1508"
7
- const val RELEASE_SET_ID: String = "mentra-3.5.0-dev.1508"
8
- const val SOURCE_COMMIT: String = "c51ab169af7e451ae9b250bc7436421c43b1ed66"
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.1508.json"
10
- const val OTA_MANIFEST_SHA256: String = "b5cc77cf766877fac51c2163e0d29ff5c7947b178a274393ca04b494bd75f71f"
6
+ const val RELEASE_IDENTITY: String = "3.5.0-dev.1510"
7
+ const val RELEASE_SET_ID: String = "mentra-3.5.0-dev.1510"
8
+ const val SOURCE_COMMIT: String = "6f239075b5c16083cc3c6bfbf5c85e88bb70d0e6"
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.1510.json"
10
+ const val OTA_MANIFEST_SHA256: String = "f1ed4038ae2196ffe00fc65470f4abfd62c2943a47ca6cf82ed64f0aabe4b33e"
11
11
  }
@@ -18,9 +18,10 @@ import java.util.concurrent.ConcurrentHashMap
18
18
  import java.util.concurrent.Executors
19
19
 
20
20
  /**
21
- * MentraOS-internal transport for glasses-local traffic without process network binding. Gallery
22
- * sync and hotspot OTA join through [ScopedSoftApNetwork], the same join Mentra Call and the
23
- * managed relay use, and send their HTTP over the `Network` it returns.
21
+ * MentraOS-internal transport for glasses-local traffic without process network binding. The
22
+ * glasses Wi-Fi service joins [ScopedSoftApNetwork.shared] here, once for every consumer; gallery
23
+ * sync and hotspot OTA send their HTTP over the `Network` it returns, and Mentra Call and the
24
+ * managed relay borrow it.
24
25
  */
25
26
  class MentraLocalNetworkModule : Module() {
26
27
  private companion object {
@@ -34,6 +35,8 @@ class MentraLocalNetworkModule : Module() {
34
35
  private val joins = Executors.newSingleThreadExecutor()
35
36
  private val activeConnections = ConcurrentHashMap<String, HttpURLConnection>()
36
37
  private var scoped: ScopedSoftApNetwork? = null
38
+ /** Bumped by every connect and disconnect, so a join that was superseded knows it. */
39
+ private var generation = 0
37
40
 
38
41
  override fun definition() = ModuleDefinition {
39
42
  Name("MentraLocalNetwork")
@@ -121,22 +124,26 @@ class MentraLocalNetworkModule : Module() {
121
124
  promise.reject("ERR_LOCAL_WIFI_REQUEST", "No React context", null)
122
125
  return@execute
123
126
  }
124
- val network = ScopedSoftApNetwork(context)
125
- synchronized(lock) { scoped = network }
127
+ // The process's one glasses network: Mentra Call and the relay borrow what this joins.
128
+ val network = ScopedSoftApNetwork.shared(context)
129
+ val mine = synchronized(lock) {
130
+ scoped = network
131
+ ++generation
132
+ }
133
+ val current = { synchronized(lock) { generation == mine } }
126
134
  val listener =
127
135
  object : ScopedSoftApNetwork.Listener {
128
136
  override fun onAvailable(network: Network, localIpv4: String) = Unit
129
137
 
130
138
  override fun onLost(error: ScopedNetworkError) {
131
- if (synchronized(lock) { scoped !== network }) return
139
+ if (!current()) return
132
140
  cancelAll()
133
141
  sendEvent("networkLost", mapOf("ssid" to ssid))
134
142
  }
135
143
  }
136
144
  try {
137
145
  network.join(ssid, password, listener, incoming)
138
- if (synchronized(lock) { scoped !== network }) {
139
- network.release()
146
+ if (!current()) {
140
147
  promise.reject("ERR_LOCAL_WIFI_CANCELLED", "Local WiFi connection cancelled", null)
141
148
  return@execute
142
149
  }
@@ -149,11 +156,10 @@ class MentraLocalNetworkModule : Module() {
149
156
  },
150
157
  )
151
158
  } catch (error: Exception) {
152
- val cancelled = synchronized(lock) { (scoped !== network).also { if (!it) scoped = null } }
153
- if (cancelled) {
159
+ if (!current()) {
154
160
  promise.reject("ERR_LOCAL_WIFI_CANCELLED", "Local WiFi connection cancelled", error)
155
161
  } else {
156
- network.release()
162
+ disconnect()
157
163
  val code = (error as? ScopedNetworkError)?.code ?: "ERR_LOCAL_WIFI_REQUEST"
158
164
  promise.reject(code, error.message ?: "Could not connect to $ssid", error)
159
165
  }
@@ -293,7 +299,10 @@ class MentraLocalNetworkModule : Module() {
293
299
 
294
300
  private fun disconnect() {
295
301
  cancelAll()
296
- val network = synchronized(lock) { scoped.also { scoped = null } }
302
+ val network = synchronized(lock) {
303
+ generation++
304
+ scoped.also { scoped = null }
305
+ }
297
306
  network?.release()
298
307
  }
299
308
  }
@@ -17,9 +17,9 @@ import java.util.concurrent.CountDownLatch
17
17
  * Joins the glasses' SoftAP as a scoped, internet-less network and keeps the [Network] handle
18
18
  * in-process.
19
19
  *
20
- * Gallery sync and hotspot OTA (through `MentraLocalNetworkModule`), Mentra Call and the managed
21
- * relay all join through this class, so the hotspot has one join on Android. Callers that use
22
- * libwebrtc bind their sockets to the [Network] it produces.
20
+ * The glasses Wi-Fi service joins [shared] once, through `MentraLocalNetworkModule`, for gallery
21
+ * sync, hotspot OTA, Mentra Call and the managed relay. Callers that use libwebrtc bind their
22
+ * sockets to the [Network] it produces.
23
23
  *
24
24
  * ## Dual-homing
25
25
  *
@@ -540,6 +540,18 @@ class ScopedSoftApNetwork(private val context: Context) {
540
540
  }
541
541
 
542
542
  companion object {
543
+ @Volatile private var sharedInstance: ScopedSoftApNetwork? = null
544
+
545
+ /**
546
+ * The process's one glasses network. The glasses Wi-Fi service joins it, through
547
+ * `MentraLocalNetworkModule`, for every consumer; Mentra Call and the managed relay read its
548
+ * [network] and address instead of joining themselves.
549
+ */
550
+ fun shared(context: Context): ScopedSoftApNetwork =
551
+ sharedInstance ?: synchronized(this) {
552
+ sharedInstance ?: ScopedSoftApNetwork(context.applicationContext).also { sharedInstance = it }
553
+ }
554
+
543
555
  /** Android 17. `ACCESS_LOCAL_NETWORK` is enforced for apps targeting SDK 37+. */
544
556
  const val LOCAL_NETWORK_ENFORCED_SDK = 37
545
557
 
@@ -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.1508",
5
- "releaseSetId": "mentra-3.5.0-dev.1508",
6
- "sourceCommit": "c51ab169af7e451ae9b250bc7436421c43b1ed66",
7
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1508.json",
8
- "otaManifestSha256": "b5cc77cf766877fac51c2163e0d29ff5c7947b178a274393ca04b494bd75f71f"
4
+ "releaseIdentity": "3.5.0-dev.1510",
5
+ "releaseSetId": "mentra-3.5.0-dev.1510",
6
+ "sourceCommit": "6f239075b5c16083cc3c6bfbf5c85e88bb70d0e6",
7
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1510.json",
8
+ "otaManifestSha256": "f1ed4038ae2196ffe00fc65470f4abfd62c2943a47ca6cf82ed64f0aabe4b33e"
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.1508\",\n \"releaseSetId\": \"mentra-3.5.0-dev.1508\",\n \"sourceCommit\": \"c51ab169af7e451ae9b250bc7436421c43b1ed66\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1508.json\",\n \"otaManifestSha256\": \"b5cc77cf766877fac51c2163e0d29ff5c7947b178a274393ca04b494bd75f71f\"\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.1510\",\n \"releaseSetId\": \"mentra-3.5.0-dev.1510\",\n \"sourceCommit\": \"6f239075b5c16083cc3c6bfbf5c85e88bb70d0e6\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1510.json\",\n \"otaManifestSha256\": \"f1ed4038ae2196ffe00fc65470f4abfd62c2943a47ca6cf82ed64f0aabe4b33e\"\n})\n"]}
@@ -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.1508"
20
+ private static let swiftPackageSdkVersion = "3.5.0-dev.1510"
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.1508"
7
- static let releaseSetId = "mentra-3.5.0-dev.1508"
8
- static let sourceCommit = "c51ab169af7e451ae9b250bc7436421c43b1ed66"
9
- static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1508.json"
10
- static let otaManifestSha256 = "b5cc77cf766877fac51c2163e0d29ff5c7947b178a274393ca04b494bd75f71f"
6
+ static let releaseIdentity = "3.5.0-dev.1510"
7
+ static let releaseSetId = "mentra-3.5.0-dev.1510"
8
+ static let sourceCommit = "6f239075b5c16083cc3c6bfbf5c85e88bb70d0e6"
9
+ static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1510.json"
10
+ static let otaManifestSha256 = "f1ed4038ae2196ffe00fc65470f4abfd62c2943a47ca6cf82ed64f0aabe4b33e"
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/bluetooth-sdk",
3
- "version": "3.5.0-dev.1508",
3
+ "version": "3.5.0-dev.1510",
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.1508"
118
+ "@mentra/cloud-protocol": "3.5.0-dev.1510"
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.1508",
16
- "releaseSetId": "mentra-3.5.0-dev.1508",
17
- "sourceCommit": "c51ab169af7e451ae9b250bc7436421c43b1ed66",
18
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1508.json",
19
- "otaManifestSha256": "b5cc77cf766877fac51c2163e0d29ff5c7947b178a274393ca04b494bd75f71f"
15
+ "releaseIdentity": "3.5.0-dev.1510",
16
+ "releaseSetId": "mentra-3.5.0-dev.1510",
17
+ "sourceCommit": "6f239075b5c16083cc3c6bfbf5c85e88bb70d0e6",
18
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1510.json",
19
+ "otaManifestSha256": "f1ed4038ae2196ffe00fc65470f4abfd62c2943a47ca6cf82ed64f0aabe4b33e"
20
20
  })