@mentra/bluetooth-sdk 3.5.0-dev.1509 → 3.5.0-dev.1511
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt +39 -18
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/GlassesWifiDirect.kt +42 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpec.kt +1 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedSoftApNetwork.kt +63 -20
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/WifiDirectJoin.kt +256 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +12 -0
- package/build/_private/MentraLocalNetworkModule.d.ts +8 -0
- package/build/_private/MentraLocalNetworkModule.d.ts.map +1 -1
- package/build/_private/MentraLocalNetworkModule.js.map +1 -1
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/ota-transport/index.d.ts +6 -0
- package/build/ota-transport/index.d.ts.map +1 -1
- package/build/ota-transport/index.js +8 -0
- package/build/ota-transport/index.js.map +1 -1
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/package.json +2 -2
- package/src/_private/MentraLocalNetworkModule.ts +3 -1
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/ota-transport/index.ts +9 -0
|
@@ -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.
|
|
7
|
-
const val RELEASE_SET_ID: String = "mentra-3.5.0-dev.
|
|
8
|
-
const val SOURCE_COMMIT: String = "
|
|
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.
|
|
10
|
-
const val OTA_MANIFEST_SHA256: String = "
|
|
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"
|
|
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.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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")
|
|
@@ -64,7 +67,17 @@ class MentraLocalNetworkModule : Module() {
|
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
AsyncFunction("connect") { ssid: String, password: String, incoming: Boolean, promise: Promise ->
|
|
67
|
-
connect(ssid, password, incoming, promise)
|
|
70
|
+
connect(ssid, password, incoming, wifiDirect = false, promise)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The glasses' Wi-Fi Direct group instead of their hotspot; this asks them for it too. */
|
|
74
|
+
AsyncFunction("connectWifiDirect") { incoming: Boolean, promise: Promise ->
|
|
75
|
+
connect("", "", incoming, wifiDirect = true, promise)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Whether this phone and the connected glasses can use Wi-Fi Direct now. */
|
|
79
|
+
Function("wifiDirectAvailable") {
|
|
80
|
+
appContext.reactContext?.let { ScopedSoftApNetwork.shared(it).wifiDirectAvailable() } == true
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
AsyncFunction("request") {
|
|
@@ -113,7 +126,7 @@ class MentraLocalNetworkModule : Module() {
|
|
|
113
126
|
"ConnectivityManager is unavailable"
|
|
114
127
|
}
|
|
115
128
|
|
|
116
|
-
private fun connect(ssid: String, password: String, incoming: Boolean, promise: Promise) {
|
|
129
|
+
private fun connect(ssid: String, password: String, incoming: Boolean, wifiDirect: Boolean, promise: Promise) {
|
|
117
130
|
joins.execute {
|
|
118
131
|
disconnect()
|
|
119
132
|
val context = appContext.reactContext?.applicationContext
|
|
@@ -121,22 +134,26 @@ class MentraLocalNetworkModule : Module() {
|
|
|
121
134
|
promise.reject("ERR_LOCAL_WIFI_REQUEST", "No React context", null)
|
|
122
135
|
return@execute
|
|
123
136
|
}
|
|
124
|
-
|
|
125
|
-
|
|
137
|
+
// The process's one glasses network: Mentra Call and the relay borrow what this joins.
|
|
138
|
+
val network = ScopedSoftApNetwork.shared(context)
|
|
139
|
+
val mine = synchronized(lock) {
|
|
140
|
+
scoped = network
|
|
141
|
+
++generation
|
|
142
|
+
}
|
|
143
|
+
val current = { synchronized(lock) { generation == mine } }
|
|
126
144
|
val listener =
|
|
127
145
|
object : ScopedSoftApNetwork.Listener {
|
|
128
146
|
override fun onAvailable(network: Network, localIpv4: String) = Unit
|
|
129
147
|
|
|
130
148
|
override fun onLost(error: ScopedNetworkError) {
|
|
131
|
-
if (
|
|
149
|
+
if (!current()) return
|
|
132
150
|
cancelAll()
|
|
133
151
|
sendEvent("networkLost", mapOf("ssid" to ssid))
|
|
134
152
|
}
|
|
135
153
|
}
|
|
136
154
|
try {
|
|
137
|
-
network.join(
|
|
138
|
-
if (
|
|
139
|
-
network.release()
|
|
155
|
+
val name = if (wifiDirect) network.joinWifiDirect(listener) else ssid.also { network.join(it, password, listener, incoming) }
|
|
156
|
+
if (!current()) {
|
|
140
157
|
promise.reject("ERR_LOCAL_WIFI_CANCELLED", "Local WiFi connection cancelled", null)
|
|
141
158
|
return@execute
|
|
142
159
|
}
|
|
@@ -144,16 +161,16 @@ class MentraLocalNetworkModule : Module() {
|
|
|
144
161
|
promise.resolve(
|
|
145
162
|
buildMap<String, Any> {
|
|
146
163
|
put("connected", true)
|
|
147
|
-
put("ssid",
|
|
164
|
+
put("ssid", name)
|
|
148
165
|
network.localIpv4()?.let { put("localAddress", it) }
|
|
166
|
+
network.gatewayIpv4()?.let { put("gateway", it) }
|
|
149
167
|
},
|
|
150
168
|
)
|
|
151
169
|
} catch (error: Exception) {
|
|
152
|
-
|
|
153
|
-
if (cancelled) {
|
|
170
|
+
if (!current()) {
|
|
154
171
|
promise.reject("ERR_LOCAL_WIFI_CANCELLED", "Local WiFi connection cancelled", error)
|
|
155
172
|
} else {
|
|
156
|
-
|
|
173
|
+
disconnect()
|
|
157
174
|
val code = (error as? ScopedNetworkError)?.code ?: "ERR_LOCAL_WIFI_REQUEST"
|
|
158
175
|
promise.reject(code, error.message ?: "Could not connect to $ssid", error)
|
|
159
176
|
}
|
|
@@ -271,9 +288,10 @@ class MentraLocalNetworkModule : Module() {
|
|
|
271
288
|
}
|
|
272
289
|
|
|
273
290
|
private fun openConnection(requestId: String, url: String): HttpURLConnection {
|
|
274
|
-
val
|
|
291
|
+
val scoped = synchronized(lock) { scoped }?.takeIf { it.isAvailable() }
|
|
275
292
|
?: throw IllegalStateException("Local WiFi is not connected")
|
|
276
|
-
|
|
293
|
+
// A Wi-Fi Direct group has no Network: its subnet is directly reachable.
|
|
294
|
+
val connection = (scoped.network()?.openConnection(URL(url)) ?: URL(url).openConnection()) as HttpURLConnection
|
|
277
295
|
activeConnections[requestId] = connection
|
|
278
296
|
return connection
|
|
279
297
|
}
|
|
@@ -293,7 +311,10 @@ class MentraLocalNetworkModule : Module() {
|
|
|
293
311
|
|
|
294
312
|
private fun disconnect() {
|
|
295
313
|
cancelAll()
|
|
296
|
-
val network = synchronized(lock) {
|
|
314
|
+
val network = synchronized(lock) {
|
|
315
|
+
generation++
|
|
316
|
+
scoped.also { scoped = null }
|
|
317
|
+
}
|
|
297
318
|
network?.release()
|
|
298
319
|
}
|
|
299
320
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.hotspot
|
|
2
|
+
|
|
3
|
+
import org.json.JSONObject
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The Bluetooth half of the glasses' Wi-Fi Direct link: what the connected glasses advertise, the
|
|
7
|
+
* `wifi_direct_start` / `wifi_direct_stop` pair, and the `wifi_direct_status` answers. Only the
|
|
8
|
+
* glasses Wi-Fi service's join in [ScopedSoftApNetwork] uses it; nothing else talks to the radio.
|
|
9
|
+
*/
|
|
10
|
+
object GlassesWifiDirect {
|
|
11
|
+
/** The connected glasses' `wifi_direct_version`; 0 when they can't hold a group or are gone. */
|
|
12
|
+
@Volatile var version: Int = 0
|
|
13
|
+
|
|
14
|
+
/** Sends a command to the connected glasses; false when none are connected. */
|
|
15
|
+
@Volatile internal var sender: ((JSONObject) -> Boolean)? = null
|
|
16
|
+
|
|
17
|
+
@Volatile private var listener: ((JSONObject) -> Unit)? = null
|
|
18
|
+
|
|
19
|
+
fun start(frequencyMhz: Int): Boolean =
|
|
20
|
+
sender?.invoke(
|
|
21
|
+
JSONObject().put("type", "wifi_direct_start").apply { if (frequencyMhz > 0) put("frequency", frequencyMhz) },
|
|
22
|
+
) == true
|
|
23
|
+
|
|
24
|
+
fun stop() {
|
|
25
|
+
sender?.invoke(JSONObject().put("type", "wifi_direct_stop"))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
internal fun onStatus(listener: ((JSONObject) -> Unit)?) {
|
|
29
|
+
this.listener = listener
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A `wifi_direct_status` from the glasses, or a synthetic `stopped` when they disconnect. */
|
|
33
|
+
fun onGlassesStatus(json: JSONObject) {
|
|
34
|
+
listener?.invoke(json)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The glasses left Bluetooth: no group survives that. */
|
|
38
|
+
fun onGlassesDisconnected() {
|
|
39
|
+
version = 0
|
|
40
|
+
onGlassesStatus(JSONObject().put("type", "wifi_direct_status").put("state", "stopped").put("error", "glasses_disconnected"))
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -11,7 +11,7 @@ import android.net.NetworkCapabilities
|
|
|
11
11
|
* `NET_CAPABILITY_INTERNET` — assertable without a device.
|
|
12
12
|
*
|
|
13
13
|
* Dropping the internet capability is what keeps the phone dual-homed: Android will not promote the
|
|
14
|
-
* glasses hotspot to the default network, so
|
|
14
|
+
* glasses hotspot to the default network, so internet traffic stays on the phone's own while media crosses the
|
|
15
15
|
* local link. The other half of that guarantee is the MTK firmware patch that stops the AP
|
|
16
16
|
* advertising a default route.
|
|
17
17
|
*/
|
|
@@ -17,14 +17,15 @@ 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
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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
|
*
|
|
26
26
|
* The request drops `NET_CAPABILITY_INTERNET` (see [ScopedNetworkRequestSpec]), so Android never
|
|
27
|
-
* promotes the hotspot to the default network
|
|
27
|
+
* promotes the hotspot to the default network: internet traffic keeps the phone's default network,
|
|
28
|
+
* whatever it is.
|
|
28
29
|
*/
|
|
29
30
|
class ScopedSoftApNetwork(private val context: Context) {
|
|
30
31
|
|
|
@@ -48,12 +49,41 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
48
49
|
private var localIpv4: String? = null
|
|
49
50
|
private var spec: ScopedNetworkRequestSpec? = null
|
|
50
51
|
private var listener: Listener? = null
|
|
52
|
+
/** The second link: the glasses' Wi-Fi Direct group, when that is what is joined. */
|
|
53
|
+
private val direct = WifiDirectJoin(context)
|
|
54
|
+
private var joinedDirect: WifiDirectJoin.Joined? = null
|
|
51
55
|
|
|
52
56
|
/** The joined network, or null. Pass this to anything that must send over the SoftAP link. */
|
|
53
57
|
fun network(): Network? = synchronized(lock) { network }
|
|
54
58
|
|
|
55
|
-
/** This phone's address on the
|
|
56
|
-
fun localIpv4(): String? = synchronized(lock) { localIpv4 }
|
|
59
|
+
/** This phone's address on the glasses' subnet, e.g. `192.168.43.20`. */
|
|
60
|
+
fun localIpv4(): String? = synchronized(lock) { localIpv4 ?: joinedDirect?.localIpv4 }
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* True on Wi-Fi Direct: the phone keeps its own internet, and there is no [network] to bind to.
|
|
64
|
+
*/
|
|
65
|
+
fun keepsPhoneInternet(): Boolean = synchronized(lock) { joinedDirect != null }
|
|
66
|
+
|
|
67
|
+
/** The Wi-Fi Direct group's interface name, while it is the joined link. */
|
|
68
|
+
fun wifiDirectInterface(): String? = synchronized(lock) { joinedDirect?.interfaceName }
|
|
69
|
+
|
|
70
|
+
/** Whether the phone and the connected glasses can use Wi-Fi Direct now. */
|
|
71
|
+
fun wifiDirectAvailable(): Boolean = direct.available()
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Join the glasses' Wi-Fi Direct group instead of their hotspot: ask them for it over Bluetooth
|
|
75
|
+
* and join with its name and passphrase, with no prompt. Returns the group's name; the phone's
|
|
76
|
+
* address on it is [localIpv4] and the glasses' is [gatewayIpv4].
|
|
77
|
+
*
|
|
78
|
+
* @throws ScopedNetworkError when the glasses or the phone can't, or on release
|
|
79
|
+
*/
|
|
80
|
+
@Throws(ScopedNetworkError::class)
|
|
81
|
+
fun joinWifiDirect(listener: Listener? = null): String {
|
|
82
|
+
release()
|
|
83
|
+
val joined = direct.join { listener?.onLost(ScopedNetworkError.Lost("the Wi-Fi Direct group")) }
|
|
84
|
+
synchronized(lock) { joinedDirect = joined }
|
|
85
|
+
return joined.ssid
|
|
86
|
+
}
|
|
57
87
|
|
|
58
88
|
/**
|
|
59
89
|
* The subnet this phone joined, straight from `LinkProperties`.
|
|
@@ -64,6 +94,7 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
64
94
|
* subnet.
|
|
65
95
|
*/
|
|
66
96
|
fun scopedPrefix(): Ipv4Prefix? {
|
|
97
|
+
synchronized(lock) { joinedDirect }?.let { return Ipv4Prefix(it.localIpv4, it.prefixLength) }
|
|
67
98
|
val net = network() ?: return null
|
|
68
99
|
val properties = connectivityManager().getLinkProperties(net) ?: return null
|
|
69
100
|
return properties.linkAddresses
|
|
@@ -71,7 +102,8 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
71
102
|
?.let { link -> link.address.hostAddress?.let { Ipv4Prefix(it, link.prefixLength) } }
|
|
72
103
|
}
|
|
73
104
|
|
|
74
|
-
fun isAvailable(): Boolean =
|
|
105
|
+
fun isAvailable(): Boolean =
|
|
106
|
+
synchronized(lock) { state.phase == ScopedNetworkState.Phase.AVAILABLE || joinedDirect != null }
|
|
75
107
|
|
|
76
108
|
/** Station radio on? `WifiNetworkSpecifier` is a no-op while this is false. */
|
|
77
109
|
fun isWifiEnabled(): Boolean {
|
|
@@ -97,7 +129,7 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
97
129
|
/**
|
|
98
130
|
* True when a VPN is this app's default network — i.e. our UID falls inside its captured
|
|
99
131
|
* ranges. A VPN that excludes us (split tunneling) or is simply installed does not count: the
|
|
100
|
-
* default network is then
|
|
132
|
+
* default network is then another one and the hotspot path works.
|
|
101
133
|
*/
|
|
102
134
|
fun isVpnCapturingApp(): Boolean {
|
|
103
135
|
val manager = connectivityManager()
|
|
@@ -114,6 +146,7 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
114
146
|
* deliberately advertise no default route. Falls back to `.1` of the phone's /24.
|
|
115
147
|
*/
|
|
116
148
|
fun gatewayIpv4(): String? {
|
|
149
|
+
synchronized(lock) { joinedDirect }?.let { return it.gateway }
|
|
117
150
|
val net = network() ?: return null
|
|
118
151
|
val properties = connectivityManager().getLinkProperties(net)
|
|
119
152
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
@@ -128,19 +161,21 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
128
161
|
* Prove the phone can reach the glasses over the network it just joined.
|
|
129
162
|
*
|
|
130
163
|
* TCP, through [Network.getSocketFactory], so the kernel routes via the hotspot's table rather
|
|
131
|
-
* than the
|
|
164
|
+
* than the default network that unbound sockets would take. A *refused* connection is a pass:
|
|
132
165
|
* the SYN arrived and the RST came back, which is the reachability question. Only a timeout or
|
|
133
166
|
* an unreachable-network error is a fail.
|
|
134
167
|
*/
|
|
135
168
|
fun probeGateway(timeoutMs: Int = GATEWAY_PROBE_TIMEOUT_MS): GatewayProbe {
|
|
136
|
-
val net = network()
|
|
169
|
+
val net = network()
|
|
170
|
+
if (net == null && !keepsPhoneInternet()) return GatewayProbe(false, "no scoped network")
|
|
137
171
|
val gateway = gatewayIpv4() ?: return GatewayProbe(false, "no gateway address on the scoped network")
|
|
138
172
|
var lastFailure = "no ports tried"
|
|
139
173
|
for (port in GATEWAY_PROBE_PORTS) {
|
|
140
174
|
val startedAt = android.os.SystemClock.elapsedRealtime()
|
|
141
175
|
val socket =
|
|
142
176
|
try {
|
|
143
|
-
|
|
177
|
+
// The Wi-Fi Direct group has no Network: its subnet is directly reachable.
|
|
178
|
+
net?.socketFactory?.createSocket() ?: java.net.Socket()
|
|
144
179
|
} catch (error: java.io.IOException) {
|
|
145
180
|
// netd answers EPERM when a VPN owns our UID and forbids binding elsewhere.
|
|
146
181
|
val message = error.message ?: error.javaClass.simpleName
|
|
@@ -269,7 +304,6 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
269
304
|
"ssid" to ssid,
|
|
270
305
|
"localIpv4" to resolvedIpv4,
|
|
271
306
|
"joinMs" to (System.currentTimeMillis() - startedAtMs),
|
|
272
|
-
"defaultNetworkIsCellular" to defaultNetworkIsCellular(manager),
|
|
273
307
|
)
|
|
274
308
|
// Does the address we were just handed exist in the kernel's interface table,
|
|
275
309
|
// and under the name LinkProperties claims? ICE gathers from that table, so a
|
|
@@ -473,11 +507,15 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
473
507
|
|
|
474
508
|
/** Drop the network. A join in progress on another thread stops waiting and fails. */
|
|
475
509
|
fun release() {
|
|
476
|
-
synchronized(lock) {
|
|
510
|
+
val wasDirect = synchronized(lock) {
|
|
477
511
|
releases++
|
|
478
512
|
pendingReady?.countDown()
|
|
479
513
|
releaseLocked()
|
|
514
|
+
joinedDirect.also { joinedDirect = null } != null
|
|
480
515
|
}
|
|
516
|
+
// Ends a Wi-Fi Direct join in progress too, and tells the glasses to remove the group.
|
|
517
|
+
direct.release()
|
|
518
|
+
if (wasDirect) SoftApTrace.stage("wifi_direct_released")
|
|
481
519
|
}
|
|
482
520
|
|
|
483
521
|
private fun releaseLocked() {
|
|
@@ -532,14 +570,19 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
532
570
|
?.address
|
|
533
571
|
?.hostAddress
|
|
534
572
|
|
|
535
|
-
/** Dual-homing check: the default route must still be cellular after the scoped join. */
|
|
536
|
-
private fun defaultNetworkIsCellular(manager: ConnectivityManager): Boolean {
|
|
537
|
-
val active = manager.activeNetwork ?: return false
|
|
538
|
-
val capabilities = manager.getNetworkCapabilities(active) ?: return false
|
|
539
|
-
return capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
|
|
540
|
-
}
|
|
541
|
-
|
|
542
573
|
companion object {
|
|
574
|
+
@Volatile private var sharedInstance: ScopedSoftApNetwork? = null
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* The process's one glasses network. The glasses Wi-Fi service joins it, through
|
|
578
|
+
* `MentraLocalNetworkModule`, for every consumer; Mentra Call and the managed relay read its
|
|
579
|
+
* [network] and address instead of joining themselves.
|
|
580
|
+
*/
|
|
581
|
+
fun shared(context: Context): ScopedSoftApNetwork =
|
|
582
|
+
sharedInstance ?: synchronized(this) {
|
|
583
|
+
sharedInstance ?: ScopedSoftApNetwork(context.applicationContext).also { sharedInstance = it }
|
|
584
|
+
}
|
|
585
|
+
|
|
543
586
|
/** Android 17. `ACCESS_LOCAL_NETWORK` is enforced for apps targeting SDK 37+. */
|
|
544
587
|
const val LOCAL_NETWORK_ENFORCED_SDK = 37
|
|
545
588
|
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.hotspot
|
|
2
|
+
|
|
3
|
+
import android.Manifest
|
|
4
|
+
import android.content.BroadcastReceiver
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.content.Intent
|
|
7
|
+
import android.content.IntentFilter
|
|
8
|
+
import android.content.pm.PackageManager
|
|
9
|
+
import android.net.wifi.WifiManager
|
|
10
|
+
import android.net.wifi.p2p.WifiP2pConfig
|
|
11
|
+
import android.net.wifi.p2p.WifiP2pManager
|
|
12
|
+
import android.os.Build
|
|
13
|
+
import android.os.Looper
|
|
14
|
+
import android.os.SystemClock
|
|
15
|
+
import java.net.Inet4Address
|
|
16
|
+
import java.net.NetworkInterface
|
|
17
|
+
import java.util.concurrent.CountDownLatch
|
|
18
|
+
import java.util.concurrent.TimeUnit
|
|
19
|
+
import org.json.JSONObject
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The phone's join of the glasses' Wi-Fi Direct group, the second link of the glasses Wi-Fi service.
|
|
23
|
+
*
|
|
24
|
+
* Bluetooth asks the glasses for a group (`wifi_direct_start`); they create it as group owner and
|
|
25
|
+
* answer with its name and passphrase. The phone joins with [WifiP2pConfig.Builder], which goes
|
|
26
|
+
* straight to the WPA2 join: no discovery, no WPS and no dialog on either side. Android keeps the
|
|
27
|
+
* group on its local network, so the phone's own Wi-Fi or cellular stays its internet, and there
|
|
28
|
+
* is no [android.net.Network] for it: sockets reach the group's subnet without one.
|
|
29
|
+
*
|
|
30
|
+
* Blocking; runs on the joining thread. [release] ends a join in progress.
|
|
31
|
+
*/
|
|
32
|
+
internal class WifiDirectJoin(context: Context) {
|
|
33
|
+
data class Joined(
|
|
34
|
+
val ssid: String,
|
|
35
|
+
val interfaceName: String,
|
|
36
|
+
val localIpv4: String,
|
|
37
|
+
val prefixLength: Int,
|
|
38
|
+
val gateway: String,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
private val context = context.applicationContext
|
|
42
|
+
private val lock = Any()
|
|
43
|
+
private var manager: WifiP2pManager? = null
|
|
44
|
+
private var channel: WifiP2pManager.Channel? = null
|
|
45
|
+
private var receiver: BroadcastReceiver? = null
|
|
46
|
+
private var wake: CountDownLatch? = null
|
|
47
|
+
private var joined: Joined? = null
|
|
48
|
+
private var onLost: (() -> Unit)? = null
|
|
49
|
+
private var releases = 0
|
|
50
|
+
|
|
51
|
+
/** Whether the phone and the connected glasses can hold this link now. */
|
|
52
|
+
fun available(): Boolean = blocker() == null
|
|
53
|
+
|
|
54
|
+
@Throws(ScopedNetworkError::class)
|
|
55
|
+
fun join(onLost: () -> Unit): Joined {
|
|
56
|
+
blocker()?.let { throw ScopedNetworkError.RequestFailed("wifi_direct_$it") }
|
|
57
|
+
val releasesAtStart = synchronized(lock) { releases }
|
|
58
|
+
val cancelled = { synchronized(lock) { releases != releasesAtStart } }
|
|
59
|
+
|
|
60
|
+
// 1. Ask the glasses for a group, on the phone's own Wi-Fi channel when it has one.
|
|
61
|
+
val status = arrayOfNulls<JSONObject>(1)
|
|
62
|
+
val answered = latch()
|
|
63
|
+
GlassesWifiDirect.onStatus { json ->
|
|
64
|
+
if (json.optString("state") in setOf("ready", "error", "stopped")) {
|
|
65
|
+
status[0] = json
|
|
66
|
+
answered.countDown()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!GlassesWifiDirect.start(currentWifiFrequency())) {
|
|
70
|
+
throw ScopedNetworkError.RequestFailed("wifi_direct_glasses_not_connected")
|
|
71
|
+
}
|
|
72
|
+
await(answered, GLASSES_ANSWER_TIMEOUT_MS, cancelled, "wifi_direct_glasses_no_answer")
|
|
73
|
+
val group = status[0]!!
|
|
74
|
+
if (group.optString("state") != "ready") {
|
|
75
|
+
throw ScopedNetworkError.RequestFailed("wifi_direct_glasses_" + group.optString("error", group.optString("state")))
|
|
76
|
+
}
|
|
77
|
+
val ssid = group.optString("ssid")
|
|
78
|
+
val passphrase = group.optString("passphrase")
|
|
79
|
+
val gateway = group.optString("address")
|
|
80
|
+
if (ssid.isEmpty() || passphrase.isEmpty() || gateway.isEmpty()) {
|
|
81
|
+
throw ScopedNetworkError.RequestFailed("wifi_direct_glasses_sent_no_credentials")
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 2. Join it.
|
|
85
|
+
var refused: Int? = null
|
|
86
|
+
val formed = latch()
|
|
87
|
+
val (m, c) = ensureChannel { info ->
|
|
88
|
+
if (info.groupFormed && !info.isGroupOwner && info.groupOwnerAddress?.hostAddress == gateway) formed.countDown()
|
|
89
|
+
}
|
|
90
|
+
val config =
|
|
91
|
+
WifiP2pConfig.Builder()
|
|
92
|
+
.setNetworkName(ssid)
|
|
93
|
+
.setPassphrase(passphrase)
|
|
94
|
+
.enablePersistentMode(false)
|
|
95
|
+
.apply { group.optInt("frequency", 0).takeIf { it > 0 }?.let(::setGroupOperatingFrequency) }
|
|
96
|
+
.build()
|
|
97
|
+
SoftApTrace.stage("wifi_direct_join_requested", "ssid" to ssid)
|
|
98
|
+
try {
|
|
99
|
+
m.connect(
|
|
100
|
+
c,
|
|
101
|
+
config,
|
|
102
|
+
object : WifiP2pManager.ActionListener {
|
|
103
|
+
override fun onSuccess() = Unit
|
|
104
|
+
|
|
105
|
+
override fun onFailure(reason: Int) {
|
|
106
|
+
refused = reason
|
|
107
|
+
formed.countDown()
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
)
|
|
111
|
+
} catch (error: SecurityException) {
|
|
112
|
+
throw ScopedNetworkError.PermissionDenied(nearbyPermission())
|
|
113
|
+
}
|
|
114
|
+
await(formed, JOIN_TIMEOUT_MS, cancelled, "wifi_direct_join_timeout")
|
|
115
|
+
refused?.let { throw ScopedNetworkError.RequestFailed("wifi_direct_connect_refused_$it") }
|
|
116
|
+
|
|
117
|
+
// 3. The phone's address on the group's interface.
|
|
118
|
+
val deadline = SystemClock.elapsedRealtime() + ADDRESS_WAIT_MS
|
|
119
|
+
var local: Pair<NetworkInterface, java.net.InterfaceAddress>? = null
|
|
120
|
+
while (local == null && SystemClock.elapsedRealtime() < deadline && !cancelled()) {
|
|
121
|
+
local = p2pAddress(gateway)
|
|
122
|
+
if (local == null) Thread.sleep(150)
|
|
123
|
+
}
|
|
124
|
+
if (cancelled()) throw ScopedNetworkError.Cancelled(ssid)
|
|
125
|
+
val (iface, address) = local ?: throw ScopedNetworkError.NoLocalAddress(ssid)
|
|
126
|
+
val result =
|
|
127
|
+
Joined(ssid, iface.name, address.address.hostAddress!!, address.networkPrefixLength.toInt(), gateway)
|
|
128
|
+
synchronized(lock) {
|
|
129
|
+
joined = result
|
|
130
|
+
this.onLost = onLost
|
|
131
|
+
}
|
|
132
|
+
// From now on, the group going away on either side is a loss.
|
|
133
|
+
GlassesWifiDirect.onStatus { json -> if (json.optString("state") in setOf("stopped", "error")) lost() }
|
|
134
|
+
SoftApTrace.stage("wifi_direct_joined", "ssid" to ssid, "localIpv4" to result.localIpv4, "interface" to iface.name)
|
|
135
|
+
return result
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Leave the group and tell the glasses to remove it. Ends a join in progress. */
|
|
139
|
+
fun release() {
|
|
140
|
+
val hadLink: Boolean
|
|
141
|
+
synchronized(lock) {
|
|
142
|
+
releases++
|
|
143
|
+
wake?.countDown()
|
|
144
|
+
hadLink = joined != null || wake != null
|
|
145
|
+
joined = null
|
|
146
|
+
onLost = null
|
|
147
|
+
}
|
|
148
|
+
GlassesWifiDirect.onStatus(null)
|
|
149
|
+
leaveGroup()
|
|
150
|
+
if (hadLink) GlassesWifiDirect.stop()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private fun lost() {
|
|
154
|
+
val notify = synchronized(lock) {
|
|
155
|
+
if (joined == null) return
|
|
156
|
+
joined = null
|
|
157
|
+
onLost.also { onLost = null }
|
|
158
|
+
}
|
|
159
|
+
SoftApTrace.failure("wifi_direct_lost")
|
|
160
|
+
notify?.invoke()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private fun latch(): CountDownLatch = CountDownLatch(1).also { synchronized(lock) { wake = it } }
|
|
164
|
+
|
|
165
|
+
private fun await(latch: CountDownLatch, timeoutMs: Long, cancelled: () -> Boolean, timeoutReason: String) {
|
|
166
|
+
val done = latch.await(timeoutMs, TimeUnit.MILLISECONDS)
|
|
167
|
+
synchronized(lock) { if (wake === latch) wake = null }
|
|
168
|
+
if (cancelled()) throw ScopedNetworkError.Cancelled("the Wi-Fi Direct group")
|
|
169
|
+
if (!done) throw ScopedNetworkError.RequestFailed(timeoutReason)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Why the phone can't use Wi-Fi Direct with these glasses now, or null. */
|
|
173
|
+
private fun blocker(): String? {
|
|
174
|
+
if (GlassesWifiDirect.version < 1) return "glasses_unsupported"
|
|
175
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return "android_too_old"
|
|
176
|
+
if (!context.packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT)) return "unsupported"
|
|
177
|
+
val wifi = context.getSystemService(WifiManager::class.java)
|
|
178
|
+
if (wifi == null || !wifi.isWifiEnabled) return "wifi_off"
|
|
179
|
+
if (context.checkSelfPermission(nearbyPermission()) != PackageManager.PERMISSION_GRANTED) return "permission"
|
|
180
|
+
return null
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private fun nearbyPermission(): String =
|
|
184
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
185
|
+
Manifest.permission.NEARBY_WIFI_DEVICES
|
|
186
|
+
} else {
|
|
187
|
+
Manifest.permission.ACCESS_FINE_LOCATION
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@Suppress("DEPRECATION")
|
|
191
|
+
private fun currentWifiFrequency(): Int =
|
|
192
|
+
runCatching { context.getSystemService(WifiManager::class.java)?.connectionInfo?.frequency ?: 0 }
|
|
193
|
+
.getOrDefault(0)
|
|
194
|
+
.coerceAtLeast(0)
|
|
195
|
+
|
|
196
|
+
/** The interface address on the group's subnet, beside the group owner's [gateway]. */
|
|
197
|
+
private fun p2pAddress(gateway: String): Pair<NetworkInterface, java.net.InterfaceAddress>? {
|
|
198
|
+
for (iface in NetworkInterface.getNetworkInterfaces()?.toList().orEmpty()) {
|
|
199
|
+
if (!iface.name.startsWith("p2p") || !iface.isUp) continue
|
|
200
|
+
for (address in iface.interfaceAddresses) {
|
|
201
|
+
val mine = (address.address as? Inet4Address)?.hostAddress ?: continue
|
|
202
|
+
if (Ipv4Prefix(mine, address.networkPrefixLength.toInt()).contains(gateway)) return iface to address
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return null
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@Suppress("DEPRECATION")
|
|
209
|
+
private fun ensureChannel(onInfo: (android.net.wifi.p2p.WifiP2pInfo) -> Unit): Pair<WifiP2pManager, WifiP2pManager.Channel> {
|
|
210
|
+
val m = manager ?: (context.getSystemService(Context.WIFI_P2P_SERVICE) as? WifiP2pManager)
|
|
211
|
+
?: throw ScopedNetworkError.RequestFailed("wifi_direct_unsupported")
|
|
212
|
+
val c = channel ?: m.initialize(context, Looper.getMainLooper()) {
|
|
213
|
+
channel = null
|
|
214
|
+
lost()
|
|
215
|
+
} ?: throw ScopedNetworkError.RequestFailed("wifi_direct_unsupported")
|
|
216
|
+
manager = m
|
|
217
|
+
channel = c
|
|
218
|
+
receiver?.let { runCatching { context.unregisterReceiver(it) } }
|
|
219
|
+
val r =
|
|
220
|
+
object : BroadcastReceiver() {
|
|
221
|
+
override fun onReceive(ctx: Context, intent: Intent) {
|
|
222
|
+
// The broadcast's extras vary by Android version and vendor: ask for the connection.
|
|
223
|
+
runCatching {
|
|
224
|
+
m.requestConnectionInfo(c) { info ->
|
|
225
|
+
if (info == null) return@requestConnectionInfo
|
|
226
|
+
onInfo(info)
|
|
227
|
+
if (!info.groupFormed) lost()
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
val filter = IntentFilter(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION)
|
|
233
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
234
|
+
context.registerReceiver(r, filter, Context.RECEIVER_NOT_EXPORTED)
|
|
235
|
+
} else {
|
|
236
|
+
context.registerReceiver(r, filter)
|
|
237
|
+
}
|
|
238
|
+
receiver = r
|
|
239
|
+
return m to c
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private fun leaveGroup() {
|
|
243
|
+
val m = manager ?: return
|
|
244
|
+
val c = channel ?: return
|
|
245
|
+
runCatching {
|
|
246
|
+
m.cancelConnect(c, null)
|
|
247
|
+
m.removeGroup(c, null)
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
private companion object {
|
|
252
|
+
const val GLASSES_ANSWER_TIMEOUT_MS = 20_000L
|
|
253
|
+
const val JOIN_TIMEOUT_MS = 20_000L
|
|
254
|
+
const val ADDRESS_WAIT_MS = 5_000L
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.mentra.bluetoothsdk.sgcs
|
|
2
2
|
|
|
3
3
|
import com.mentra.bluetoothsdk.PhotoCompression
|
|
4
|
+
import com.mentra.bluetoothsdk.hotspot.GlassesWifiDirect
|
|
4
5
|
|
|
5
6
|
// Mentra
|
|
6
7
|
// old augmentos imports:
|
|
@@ -1163,6 +1164,14 @@ class MentraLive : SGCManager() {
|
|
|
1163
1164
|
this.hasMic = true
|
|
1164
1165
|
this.context = Bridge.getContext()
|
|
1165
1166
|
forgetLegacyCoreToken()
|
|
1167
|
+
GlassesWifiDirect.sender = { json ->
|
|
1168
|
+
if (connectionState == ConnTypes.CONNECTED) {
|
|
1169
|
+
sendJson(json, true)
|
|
1170
|
+
true
|
|
1171
|
+
} else {
|
|
1172
|
+
false
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1166
1175
|
|
|
1167
1176
|
// Initialize bluetooth adapter
|
|
1168
1177
|
val bluetoothManager =
|
|
@@ -1320,6 +1329,7 @@ class MentraLive : SGCManager() {
|
|
|
1320
1329
|
if (state == ConnTypes.DISCONNECTED) {
|
|
1321
1330
|
wifiAdbPeerIdentity = null
|
|
1322
1331
|
DeviceStore.apply("glasses", "hotspotOtaVersion", 0)
|
|
1332
|
+
GlassesWifiDirect.onGlassesDisconnected()
|
|
1323
1333
|
}
|
|
1324
1334
|
val isEqual = state == connectionState
|
|
1325
1335
|
if (isEqual) {
|
|
@@ -4723,6 +4733,7 @@ class MentraLive : SGCManager() {
|
|
|
4723
4733
|
error = json.optString("error", "").ifEmpty { null },
|
|
4724
4734
|
)
|
|
4725
4735
|
}
|
|
4736
|
+
"wifi_direct_status" -> GlassesWifiDirect.onGlassesStatus(json)
|
|
4726
4737
|
"hotspot_status_update" -> {
|
|
4727
4738
|
// Process hotspot status information (same pattern as "wifi_status")
|
|
4728
4739
|
val hotspotEnabled = json.optBoolean("hotspot_enabled", false)
|
|
@@ -5660,6 +5671,7 @@ class MentraLive : SGCManager() {
|
|
|
5660
5671
|
DeviceStore.apply("glasses", "systemTimeMs", v.toLong())
|
|
5661
5672
|
}
|
|
5662
5673
|
}
|
|
5674
|
+
(fields["wifi_direct_version"] as? Number)?.let { GlassesWifiDirect.version = it.toInt() }
|
|
5663
5675
|
if (fields.containsKey("hotspot_ota_version")) {
|
|
5664
5676
|
val version = fields["hotspot_ota_version"]
|
|
5665
5677
|
if (version is Number) {
|
|
@@ -50,7 +50,15 @@ declare class MentraLocalNetworkNativeModule extends NativeModule<LocalNetworkEv
|
|
|
50
50
|
connected: boolean;
|
|
51
51
|
ssid: string;
|
|
52
52
|
localAddress?: string;
|
|
53
|
+
gateway?: string;
|
|
53
54
|
}>;
|
|
55
|
+
connectWifiDirect(incoming: boolean): Promise<{
|
|
56
|
+
connected: boolean;
|
|
57
|
+
ssid: string;
|
|
58
|
+
localAddress?: string;
|
|
59
|
+
gateway?: string;
|
|
60
|
+
}>;
|
|
61
|
+
wifiDirectAvailable(): boolean;
|
|
54
62
|
request(requestId: string, url: string, method: string, headers: Record<string, string>, body: string | null, timeoutMs: number): Promise<LocalNetworkResponse>;
|
|
55
63
|
download(requestId: string, url: string, destination: string, headers: Record<string, string>, connectionTimeoutMs: number, readTimeoutMs: number): Promise<LocalNetworkDownloadResult>;
|
|
56
64
|
cancel(requestId: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentraLocalNetworkModule.d.ts","sourceRoot":"","sources":["../../src/_private/MentraLocalNetworkModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAA8B,MAAM,MAAM,CAAA;AAE9D,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,GAAG,EAAE,OAAO,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAA;IAEhB,YAAY,EAAE,6BAA6B,GAAG,IAAI,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,kBAAkB,CAAA;IAEhC,aAAa,EAAE,kBAAkB,CAAA;IACjC,YAAY,EAAE,kBAAkB,CAAA;IAChC,yBAAyB,EAAE,OAAO,CAAA;IAClC,+BAA+B,EAAE,OAAO,CAAA;IACxC,gCAAgC,EAAE,OAAO,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,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AQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IACvF,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IAC1H,mBAAmB,IAAI,OAAO;IAC9B,OAAO,CACL,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC;IAChC,QAAQ,CACN,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,mBAAmB,EAAE,MAAM,EAC3B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,0BAA0B,CAAC;IACtC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACxC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAC5B;;AAED,wBAAgG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentraLocalNetworkModule.js","sourceRoot":"","sources":["../../src/_private/MentraLocalNetworkModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,2BAA2B,EAAC,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"MentraLocalNetworkModule.js","sourceRoot":"","sources":["../../src/_private/MentraLocalNetworkModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,2BAA2B,EAAC,MAAM,MAAM,CAAA;AAmF9D,eAAe,2BAA2B,CAAiC,oBAAoB,CAAC,CAAA","sourcesContent":["import {NativeModule, requireOptionalNativeModule} from \"expo\"\n\nexport type NetworkCapabilitiesDiagnostic = {\n wifi: boolean\n cellular: boolean\n ethernet: boolean\n vpn: boolean\n internet: boolean\n validated: boolean\n captivePortal: boolean\n}\n\nexport type NetworkObservation = {\n present: boolean\n // A present network with null capabilities has disappeared or cannot be inspected.\n capabilities: NetworkCapabilitiesDiagnostic | null\n}\n\nexport type NetworkDiagnostics = {\n sampledAtMs: number\n processBound: NetworkObservation\n // ConnectivityManager.activeNetwork is the caller's active default, not a privileged global read.\n activeNetwork: NetworkObservation\n glassesLocal: NetworkObservation\n processBoundMatchesActive: boolean\n processBoundMatchesGlassesLocal: boolean\n activeNetworkMatchesGlassesLocal: boolean\n}\n\nexport type LocalNetworkResponse = {\n status: number\n headers: Record<string, string>\n bodyBase64: string\n}\n\nexport type LocalNetworkDownloadResult = {\n statusCode: number\n bytesWritten: number\n headers: Record<string, string>\n}\n\nexport type LocalNetworkDownloadProgress = {\n requestId: string\n bytesWritten: number\n contentLength: number\n statusCode?: number\n headers?: Record<string, string>\n}\n\ntype LocalNetworkEvents = {\n downloadProgress: (event: LocalNetworkDownloadProgress) => void\n networkLost: (event: {ssid: string}) => void\n}\n\ndeclare class MentraLocalNetworkNativeModule extends NativeModule<LocalNetworkEvents> {\n getNetworkDiagnostics(): NetworkDiagnostics\n connect(\n ssid: string,\n password: string,\n incoming: boolean,\n ): Promise<{connected: boolean; ssid: string; localAddress?: string; gateway?: string}>\n connectWifiDirect(incoming: boolean): Promise<{connected: boolean; ssid: string; localAddress?: string; gateway?: string}>\n wifiDirectAvailable(): boolean\n request(\n requestId: string,\n url: string,\n method: string,\n headers: Record<string, string>,\n body: string | null,\n timeoutMs: number,\n ): Promise<LocalNetworkResponse>\n download(\n requestId: string,\n url: string,\n destination: string,\n headers: Record<string, string>,\n connectionTimeoutMs: number,\n readTimeoutMs: number,\n ): Promise<LocalNetworkDownloadResult>\n cancel(requestId: string): Promise<void>\n disconnect(): Promise<void>\n}\n\nexport default requireOptionalNativeModule<MentraLocalNetworkNativeModule>(\"MentraLocalNetwork\")\n"]}
|
|
@@ -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.
|
|
5
|
-
"releaseSetId": "mentra-3.5.0-dev.
|
|
6
|
-
"sourceCommit": "
|
|
7
|
-
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.
|
|
8
|
-
"otaManifestSha256": "
|
|
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"
|
|
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.
|
|
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"]}
|
|
@@ -7,6 +7,8 @@ export type OtaLocalNetworkConnection = {
|
|
|
7
7
|
connected: boolean;
|
|
8
8
|
ssid: string;
|
|
9
9
|
localAddress?: string;
|
|
10
|
+
/** The glasses' address on the joined network. */
|
|
11
|
+
gateway?: string;
|
|
10
12
|
};
|
|
11
13
|
export type OtaLocalNetworkLostEvent = {
|
|
12
14
|
ssid: string;
|
|
@@ -51,6 +53,10 @@ export declare const otaLocalNetwork: Readonly<{
|
|
|
51
53
|
getNetworkDiagnostics: () => NetworkDiagnostics | null;
|
|
52
54
|
/** `incoming`: the glasses will connect to a server on this phone (OTA), not only the reverse. */
|
|
53
55
|
connect: (ssid: string, password: string, incoming?: boolean) => Promise<OtaLocalNetworkConnection>;
|
|
56
|
+
/** The glasses' Wi-Fi Direct group instead of their hotspot; the native join asks them for it. */
|
|
57
|
+
connectWifiDirect: (incoming?: boolean) => Promise<OtaLocalNetworkConnection>;
|
|
58
|
+
/** Whether this phone and the connected glasses can use Wi-Fi Direct now: Android only. */
|
|
59
|
+
wifiDirectAvailable: () => boolean;
|
|
54
60
|
request: (requestId: string, url: string, method: string, headers: Record<string, string>, body: string | null, timeoutMs: number) => Promise<OtaLocalNetworkResponse>;
|
|
55
61
|
download: (requestId: string, url: string, destination: string, headers: Record<string, string>, connectionTimeoutMs: number, readTimeoutMs: number) => Promise<OtaLocalNetworkDownloadResult>;
|
|
56
62
|
cancel: (requestId: string) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ota-transport/index.ts"],"names":[],"mappings":"AAEA,OAA2B,EAAC,KAAK,kBAAkB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BAAwB;EAI9F,CAAA;AAEF,qFAAqF;AACrF,eAAO,MAAM,SAAS;0BAEJ,MAAM,iBACL,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,SAC9B,MAAM,GAAG,IAAI,KACnB,OAAO,CAAC,eAAe,CAAC;gBACjB,OAAO,CAAC,IAAI,CAAC;+BACI,MAAM,eAAe,MAAM,KAAG,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAC,CAAC;2CAErE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,KAAG,wBAAwB;EAE9G,CAAA"}
|
|
@@ -19,6 +19,14 @@ export const otaLocalNetwork = Object.freeze({
|
|
|
19
19
|
throw new Error("Scoped local networking is not available in this native build");
|
|
20
20
|
return MentraLocalNetwork.connect(ssid, password, incoming);
|
|
21
21
|
},
|
|
22
|
+
/** The glasses' Wi-Fi Direct group instead of their hotspot; the native join asks them for it. */
|
|
23
|
+
connectWifiDirect: async (incoming = true) => {
|
|
24
|
+
if (!MentraLocalNetwork)
|
|
25
|
+
throw new Error("Scoped local networking is not available in this native build");
|
|
26
|
+
return MentraLocalNetwork.connectWifiDirect(incoming);
|
|
27
|
+
},
|
|
28
|
+
/** Whether this phone and the connected glasses can use Wi-Fi Direct now: Android only. */
|
|
29
|
+
wifiDirectAvailable: () => MentraLocalNetwork?.wifiDirectAvailable?.() === true,
|
|
22
30
|
request: async (requestId, url, method, headers, body, timeoutMs) => {
|
|
23
31
|
if (!MentraLocalNetwork)
|
|
24
32
|
throw new Error("Scoped local networking is not available in this native build");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ota-transport/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,iDAAiD;AACjD,OAAO,kBAA6C,MAAM,sCAAsC,CAAA;AAChG,iDAAiD;AACjD,OAAO,eAAe,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":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E,CACL,YAAoB,EACpB,aAAqC,EACrC,IAAoB,EACM,EAAE,CAAC,eAAe,CAAC,cAAc,CAAC,YAAY,EAAE,aAAa,EAAE,IAAI,CAAC;IAChG,IAAI,EAAE,GAAkB,EAAE,CAAC,eAAe,CAAC,aAAa,EAAE;IAC1D,gBAAgB,EAAE,CAAC,MAAc,EAAE,WAAmB,EAAuD,EAAE,CAC7G,eAAe,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC;IACvD,0BAA0B,EAAE,CAAC,QAAsD,EAA4B,EAAE,CAC/G,eAAe,CAAC,WAAW,CAAC,0BAA0B,EAAE,QAAQ,CAAC;CACpE,CAAC,CAAA","sourcesContent":["// This public adapter is the package-owned boundary over its native implementation.\n// eslint-disable-next-line no-restricted-imports\nimport MentraLocalNetwork, {type NetworkDiagnostics} from \"../_private/MentraLocalNetworkModule\"\n// eslint-disable-next-line no-restricted-imports\nimport MentraOtaServer from \"../ota-server\"\n\n// eslint-disable-next-line no-restricted-imports\nexport type {\n NetworkCapabilitiesDiagnostic,\n NetworkDiagnostics,\n NetworkObservation,\n} from \"../_private/MentraLocalNetworkModule\"\n\nexport type OtaTransportSubscription = {remove(): void}\n\nexport type OtaLocalNetworkConnection = {\n connected: boolean\n ssid: string\n localAddress?: string\n /** The glasses' address on the joined network. */\n gateway?: string\n}\n\nexport type OtaLocalNetworkLostEvent = {ssid: string}\n\nexport type OtaLocalNetworkResponse = {\n status: number\n headers: Record<string, string>\n bodyBase64: string\n}\n\nexport type OtaLocalNetworkDownloadResult = {\n statusCode: number\n bytesWritten: number\n headers: Record<string, string>\n}\n\nexport type OtaLocalNetworkDownloadProgress = {\n requestId: string\n bytesWritten: number\n contentLength: number\n statusCode?: number\n headers?: Record<string, string>\n}\n\nexport type OtaArtifactDownloadProgress = {\n destination: string\n bytesWritten: number\n contentLength: number\n}\n\nexport type OtaServerResult = {\n baseUrl: string\n host: string\n manifestUrl: string\n port: number\n}\n\n/**\n * Scoped networking for traffic that must stay on a Mentra Live hotspot while\n * the phone's default route remains on cellular or another Wi-Fi network.\n *\n * The module is optional because iOS joins through glasses-media's hotspot owner instead.\n */\nexport const otaLocalNetwork = Object.freeze({\n isAvailable: (): boolean => MentraLocalNetwork != null,\n /** Synchronous local observation; no network I/O, route changes or network identities. */\n getNetworkDiagnostics: (): NetworkDiagnostics | null => MentraLocalNetwork?.getNetworkDiagnostics() ?? null,\n /** `incoming`: the glasses will connect to a server on this phone (OTA), not only the reverse. */\n connect: async (ssid: string, password: string, incoming = true): Promise<OtaLocalNetworkConnection> => {\n if (!MentraLocalNetwork) throw new Error(\"Scoped local networking is not available in this native build\")\n return MentraLocalNetwork.connect(ssid, password, incoming)\n },\n /** The glasses' Wi-Fi Direct group instead of their hotspot; the native join asks them for it. */\n connectWifiDirect: async (incoming = true): Promise<OtaLocalNetworkConnection> => {\n if (!MentraLocalNetwork) throw new Error(\"Scoped local networking is not available in this native build\")\n return MentraLocalNetwork.connectWifiDirect(incoming)\n },\n /** Whether this phone and the connected glasses can use Wi-Fi Direct now: Android only. */\n wifiDirectAvailable: (): boolean => MentraLocalNetwork?.wifiDirectAvailable?.() === true,\n request: async (\n requestId: string,\n url: string,\n method: string,\n headers: Record<string, string>,\n body: string | null,\n timeoutMs: number,\n ): Promise<OtaLocalNetworkResponse> => {\n if (!MentraLocalNetwork) throw new Error(\"Scoped local networking is not available in this native build\")\n return MentraLocalNetwork.request(requestId, url, method, headers, body, timeoutMs)\n },\n download: async (\n requestId: string,\n url: string,\n destination: string,\n headers: Record<string, string>,\n connectionTimeoutMs: number,\n readTimeoutMs: number,\n ): Promise<OtaLocalNetworkDownloadResult> => {\n if (!MentraLocalNetwork) throw new Error(\"Scoped local networking is not available in this native build\")\n return MentraLocalNetwork.download(requestId, url, destination, headers, connectionTimeoutMs, readTimeoutMs)\n },\n cancel: async (requestId: string): Promise<void> => {\n if (!MentraLocalNetwork) return\n await MentraLocalNetwork.cancel(requestId)\n },\n disconnect: async (): Promise<void> => {\n if (!MentraLocalNetwork) return\n await MentraLocalNetwork.disconnect()\n },\n onDownloadProgress: (listener: (event: OtaLocalNetworkDownloadProgress) => void): OtaTransportSubscription => {\n if (!MentraLocalNetwork) return {remove() {}}\n return MentraLocalNetwork.addListener(\"downloadProgress\", listener)\n },\n onNetworkLost: (listener: (event: OtaLocalNetworkLostEvent) => void): OtaTransportSubscription => {\n if (!MentraLocalNetwork) return {remove() {}}\n return MentraLocalNetwork.addListener(\"networkLost\", listener)\n },\n})\n\n/** Native HTTP server and artifact downloader used by the Engine OTA coordinator. */\nexport const otaServer = Object.freeze({\n start: (\n manifestJson: string,\n artifactPaths: Record<string, string>,\n host?: string | null,\n ): Promise<OtaServerResult> => MentraOtaServer.startOtaServer(manifestJson, artifactPaths, host),\n stop: (): Promise<void> => MentraOtaServer.stopOtaServer(),\n downloadArtifact: (source: string, destination: string): Promise<{statusCode: number; bytesWritten: number}> =>\n MentraOtaServer.downloadArtifact(source, destination),\n onArtifactDownloadProgress: (listener: (event: OtaArtifactDownloadProgress) => void): OtaTransportSubscription =>\n MentraOtaServer.addListener(\"artifactDownloadProgress\", listener),\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.
|
|
20
|
+
private static let swiftPackageSdkVersion = "3.5.0-dev.1511"
|
|
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.
|
|
7
|
-
static let releaseSetId = "mentra-3.5.0-dev.
|
|
8
|
-
static let sourceCommit = "
|
|
9
|
-
static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.
|
|
10
|
-
static let otaManifestSha256 = "
|
|
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"
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mentra/bluetooth-sdk",
|
|
3
|
-
"version": "3.5.0-dev.
|
|
3
|
+
"version": "3.5.0-dev.1511",
|
|
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.
|
|
118
|
+
"@mentra/cloud-protocol": "3.5.0-dev.1511"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@types/node": "^25.9.3",
|
|
@@ -58,7 +58,9 @@ declare class MentraLocalNetworkNativeModule extends NativeModule<LocalNetworkEv
|
|
|
58
58
|
ssid: string,
|
|
59
59
|
password: string,
|
|
60
60
|
incoming: boolean,
|
|
61
|
-
): Promise<{connected: boolean; ssid: string; localAddress?: string}>
|
|
61
|
+
): Promise<{connected: boolean; ssid: string; localAddress?: string; gateway?: string}>
|
|
62
|
+
connectWifiDirect(incoming: boolean): Promise<{connected: boolean; ssid: string; localAddress?: string; gateway?: string}>
|
|
63
|
+
wifiDirectAvailable(): boolean
|
|
62
64
|
request(
|
|
63
65
|
requestId: string,
|
|
64
66
|
url: string,
|
|
@@ -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.
|
|
16
|
-
"releaseSetId": "mentra-3.5.0-dev.
|
|
17
|
-
"sourceCommit": "
|
|
18
|
-
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.
|
|
19
|
-
"otaManifestSha256": "
|
|
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"
|
|
20
20
|
})
|
|
@@ -17,6 +17,8 @@ export type OtaLocalNetworkConnection = {
|
|
|
17
17
|
connected: boolean
|
|
18
18
|
ssid: string
|
|
19
19
|
localAddress?: string
|
|
20
|
+
/** The glasses' address on the joined network. */
|
|
21
|
+
gateway?: string
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export type OtaLocalNetworkLostEvent = {ssid: string}
|
|
@@ -69,6 +71,13 @@ export const otaLocalNetwork = Object.freeze({
|
|
|
69
71
|
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
70
72
|
return MentraLocalNetwork.connect(ssid, password, incoming)
|
|
71
73
|
},
|
|
74
|
+
/** The glasses' Wi-Fi Direct group instead of their hotspot; the native join asks them for it. */
|
|
75
|
+
connectWifiDirect: async (incoming = true): Promise<OtaLocalNetworkConnection> => {
|
|
76
|
+
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
77
|
+
return MentraLocalNetwork.connectWifiDirect(incoming)
|
|
78
|
+
},
|
|
79
|
+
/** Whether this phone and the connected glasses can use Wi-Fi Direct now: Android only. */
|
|
80
|
+
wifiDirectAvailable: (): boolean => MentraLocalNetwork?.wifiDirectAvailable?.() === true,
|
|
72
81
|
request: async (
|
|
73
82
|
requestId: string,
|
|
74
83
|
url: string,
|