@mentra/glasses-media 3.5.0-dev.1268 → 3.5.0-dev.1271
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/glassesmedia/GlassesMediaRelayModule.kt +1 -7
- package/android/src/main/java/com/mentra/glassesmedia/network/ScopedSoftApNetwork.kt +18 -7
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/ios/CoreKit/Sources/GlassesMediaCore/HotspotJoinFailure.swift +4 -0
- package/ios/GlassesMediaRelayModule.swift +5 -1
- package/package.json +1 -1
|
@@ -57,13 +57,7 @@ class GlassesMediaRelayModule : Module() {
|
|
|
57
57
|
override fun onAvailable(network: android.net.Network, localIpv4: String) = Unit
|
|
58
58
|
override fun onLost(error: ScopedNetworkError) { emit(id, "failed", "Glasses hotspot connection was lost") }
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
scoped.join(ssid, password, listener)
|
|
62
|
-
} catch (error: ScopedNetworkError.Unavailable) {
|
|
63
|
-
// Same recovery as ACS: the first specifier can reject while leaving office Wi-Fi.
|
|
64
|
-
Thread.sleep(ScopedSoftApNetwork.UNAVAILABLE_RETRY_SETTLE_MS)
|
|
65
|
-
scoped.join(ssid, password, listener)
|
|
66
|
-
}
|
|
60
|
+
scoped.join(ssid, password, listener)
|
|
67
61
|
ScopedNetworkChangeDetector.registerRelayNetwork(scoped)
|
|
68
62
|
val outgoing = PhoneWhipPublisher(context, endpoint, options["captureAudio"] != false,
|
|
69
63
|
(options["bitrate"] as? Number)?.toInt() ?: 2_000_000) { state, reason -> emit(id, state, reason) }
|
|
@@ -195,7 +195,8 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
|
-
* Join [ssid] and block until it is usable or the request fails.
|
|
198
|
+
* Join [ssid] and block until it is usable or the request fails. An Unavailable request is
|
|
199
|
+
* made once more after a short settle; every caller gets that retry.
|
|
199
200
|
*
|
|
200
201
|
* @throws ScopedNetworkError on permission denial, timeout, or an unavailable network
|
|
201
202
|
*/
|
|
@@ -221,6 +222,20 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
221
222
|
throw ScopedNetworkError.VpnCapturesApp()
|
|
222
223
|
}
|
|
223
224
|
|
|
225
|
+
return try {
|
|
226
|
+
requestOnce(ssid, passphrase, listener)
|
|
227
|
+
} catch (error: ScopedNetworkError.Unavailable) {
|
|
228
|
+
// Leaving the phone's current Wi-Fi (office AP, a phone hotspot) can make the first
|
|
229
|
+
// specifier fail as Unavailable: Samsung assoc-rejects the glasses SoftAP (status 1025)
|
|
230
|
+
// after dropping the old network. The same request from the now idle STA succeeds.
|
|
231
|
+
SoftApTrace.stage("scoped_join_unavailable_retry", "ssid" to ssid, "settleMs" to UNAVAILABLE_RETRY_SETTLE_MS)
|
|
232
|
+
Thread.sleep(UNAVAILABLE_RETRY_SETTLE_MS)
|
|
233
|
+
requestOnce(ssid, passphrase, listener)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@Throws(ScopedNetworkError::class)
|
|
238
|
+
private fun requestOnce(ssid: String, passphrase: String, listener: Listener?): Network {
|
|
224
239
|
release()
|
|
225
240
|
|
|
226
241
|
val requestSpec = ScopedNetworkRequestSpec.forSoftAp(ssid, passphrase)
|
|
@@ -546,12 +561,8 @@ class ScopedSoftApNetwork(private val context: Context) {
|
|
|
546
561
|
/** Radio + scan need a beat after `isWifiEnabled` flips before specifier can see the AP. */
|
|
547
562
|
const val WIFI_ENABLE_SETTLE_MS = 1_500L
|
|
548
563
|
|
|
549
|
-
/**
|
|
550
|
-
|
|
551
|
-
* or a phone hotspot), Samsung has already dropped that network. A second specifier from
|
|
552
|
-
* an idle STA is the join that succeeds; this is the gap before we issue it.
|
|
553
|
-
*/
|
|
554
|
-
const val UNAVAILABLE_RETRY_SETTLE_MS = 2_000L
|
|
564
|
+
/** The gap before [join] asks again after an Unavailable while leaving another AP. */
|
|
565
|
+
private const val UNAVAILABLE_RETRY_SETTLE_MS = 2_000L
|
|
555
566
|
|
|
556
567
|
/**
|
|
557
568
|
* dnsmasq (DHCP/DNS) on the hotspot, then the glasses' local HTTP servers. Any answer —
|
package/index.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export const glassesHotspot: {
|
|
|
8
8
|
purpose?: "outgoing-client" | "incoming-server",
|
|
9
9
|
): Promise<string>
|
|
10
10
|
leave(id: string, waitForInternet?: boolean): Promise<void>
|
|
11
|
+
/** A join with this id is waiting for Local Network access, which the person may have denied. */
|
|
12
|
+
onPermissionRequired(listener: (id: string) => void): {remove(): void}
|
|
11
13
|
}
|
package/index.js
CHANGED
|
@@ -7,4 +7,6 @@ export const glassesHotspot = Object.freeze({
|
|
|
7
7
|
join: (id, ssid, password, gateway, purpose = "outgoing-client") =>
|
|
8
8
|
native().joinLocalHotspot(id, ssid, password, gateway ?? null, purpose),
|
|
9
9
|
leave: (id, waitForInternet = false) => native().leaveLocalHotspot(id, waitForInternet),
|
|
10
|
+
onPermissionRequired: (listener) =>
|
|
11
|
+
native().addListener("onLocalHotspotPermissionRequired", (event) => listener(event.id)),
|
|
10
12
|
})
|
|
@@ -13,6 +13,10 @@ public struct HotspotJoinFailure {
|
|
|
13
13
|
code = "ERR_HOTSPOT_JOIN"
|
|
14
14
|
// These messages are authored by the owned hotspot implementation, not NSError.
|
|
15
15
|
message = String(local.message.filter { !$0.unicodeScalars.contains(where: CharacterSet.controlCharacters.contains) }.prefix(512))
|
|
16
|
+
} else if (error as NSError).domain == "NEHotspotConfigurationErrorDomain", (error as NSError).code == 7 {
|
|
17
|
+
// NEHotspotConfigurationError.userDenied: the person declined the join prompt.
|
|
18
|
+
code = "ERR_HOTSPOT_USER_DENIED"
|
|
19
|
+
message = "The glasses hotspot join was declined"
|
|
16
20
|
} else {
|
|
17
21
|
code = "ERR_HOTSPOT_NATIVE"
|
|
18
22
|
let native = error as NSError
|
|
@@ -9,7 +9,7 @@ public final class GlassesMediaRelayModule: Module {
|
|
|
9
9
|
|
|
10
10
|
public func definition() -> ModuleDefinition {
|
|
11
11
|
Name("MentraGlassesMediaRelay")
|
|
12
|
-
Events("onRelayState")
|
|
12
|
+
Events("onRelayState", "onLocalHotspotPermissionRequired")
|
|
13
13
|
|
|
14
14
|
AsyncFunction("joinLocalHotspot") { (id: String, ssid: String, password: String, gateway: String?, purpose: String, promise: Promise) in
|
|
15
15
|
self.queue.async {
|
|
@@ -20,6 +20,10 @@ public final class GlassesMediaRelayModule: Module {
|
|
|
20
20
|
promise.reject(LocalMediaError("Invalid hotspot access purpose")); return
|
|
21
21
|
}
|
|
22
22
|
self.localHotspotOwner = id
|
|
23
|
+
// The join waits while Local Network access is pending or denied; the caller explains it.
|
|
24
|
+
self.localHotspot.onPermissionRequired = { [weak self] in
|
|
25
|
+
self?.sendEvent("onLocalHotspotPermissionRequired", ["id": id])
|
|
26
|
+
}
|
|
23
27
|
self.localHotspot.join(ssid: ssid, passphrase: password, gateway: gateway, purpose: accessPurpose) { result in
|
|
24
28
|
switch result {
|
|
25
29
|
case let .success(address): promise.resolve(address)
|