@mentra/glasses-media 3.5.0-dev.1309 → 3.5.0-dev.1316
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/ios/GlassesHotspotNetwork.swift +38 -13
- package/package.json +2 -2
|
@@ -16,6 +16,9 @@ public final class GlassesHotspotNetwork {
|
|
|
16
16
|
private var applying = false
|
|
17
17
|
private var ownsConfiguration = false
|
|
18
18
|
private var applies = 0
|
|
19
|
+
/// When the pending apply() started: iOS answers it only once the person answers its join prompt.
|
|
20
|
+
private var promptSince: TimeInterval?
|
|
21
|
+
private var joinDeadline: TimeInterval = 0
|
|
19
22
|
private let reapplyPolicy = HotspotReapplyPolicy()
|
|
20
23
|
private var cancelled = false
|
|
21
24
|
private var joinReply: ((Result<String, Error>) -> Void)?
|
|
@@ -56,6 +59,8 @@ public final class GlassesHotspotNetwork {
|
|
|
56
59
|
self.generation += 1
|
|
57
60
|
let gen = self.generation
|
|
58
61
|
let deadline = ProcessInfo.processInfo.systemUptime + 60
|
|
62
|
+
self.joinDeadline = deadline
|
|
63
|
+
self.promptSince = nil
|
|
59
64
|
self.ssid = ssid
|
|
60
65
|
self.lastHotspotSSID = ssid
|
|
61
66
|
self.gatewayAddress = gateway
|
|
@@ -71,19 +76,32 @@ public final class GlassesHotspotNetwork {
|
|
|
71
76
|
} else {
|
|
72
77
|
self.applyConfiguration(ssid: ssid, passphrase: passphrase, generation: gen)
|
|
73
78
|
}
|
|
74
|
-
self.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
self.scheduleJoinDeadline(ssid: ssid, generation: gen)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/// Time to associate after the person answers a join prompt late in the join.
|
|
84
|
+
private static let afterAnswer: TimeInterval = 30
|
|
85
|
+
|
|
86
|
+
/// The join gets 60 s of its own, plus however long the person takes to answer iOS's join
|
|
87
|
+
/// prompt. The engine keeps the glasses AP up meanwhile.
|
|
88
|
+
private func scheduleJoinDeadline(ssid: String, generation gen: Int) {
|
|
89
|
+
queue.asyncAfter(deadline: .now() + max(1, joinDeadline - ProcessInfo.processInfo.systemUptime)) {
|
|
90
|
+
// Once associated, the user may still be reading the Local Network alert.
|
|
91
|
+
// Its response time is not a hotspot association timeout.
|
|
92
|
+
guard gen == self.generation, self.joinReply != nil, self.localAccess == nil else { return }
|
|
93
|
+
let now = ProcessInfo.processInfo.systemUptime
|
|
94
|
+
if self.promptSince != nil { self.joinDeadline = max(self.joinDeadline, now + 1) }
|
|
95
|
+
if now < self.joinDeadline { self.scheduleJoinDeadline(ssid: ssid, generation: gen); return }
|
|
96
|
+
MediaLog.log("HOTSPOT_JOIN timed_out prompt_pending=\(self.promptSince != nil)")
|
|
97
|
+
self.cancelled = true
|
|
98
|
+
self.macAssociation?.cancel()
|
|
99
|
+
self.macAuthorization?.cancelPending()
|
|
100
|
+
self.finishJoin(.failure(LocalMediaError("Hotspot join timed out")))
|
|
101
|
+
// apply() cannot be cancelled. Retain the reservation until its callback and remove the
|
|
102
|
+
// late configuration before another call is permitted to acquire the network.
|
|
103
|
+
if self.ownsConfiguration { NEHotspotConfigurationManager.shared.removeConfiguration(forSSID: ssid) }
|
|
104
|
+
if !self.applying { self.finishLeave() }
|
|
87
105
|
}
|
|
88
106
|
}
|
|
89
107
|
|
|
@@ -331,11 +349,18 @@ public final class GlassesHotspotNetwork {
|
|
|
331
349
|
applying = true
|
|
332
350
|
ownsConfiguration = true
|
|
333
351
|
applies += 1
|
|
352
|
+
promptSince = ProcessInfo.processInfo.systemUptime
|
|
334
353
|
MediaLog.log("HOTSPOT_JOIN apply_start attempt=\(self.applies) ios_on_mac=\(ProcessInfo.processInfo.isiOSAppOnMac)")
|
|
335
354
|
NEHotspotConfigurationManager.shared.apply(config) { error in
|
|
336
355
|
self.queue.async {
|
|
337
356
|
guard gen == self.generation else { return }
|
|
338
357
|
self.applying = false
|
|
358
|
+
if let asked = self.promptSince {
|
|
359
|
+
let now = ProcessInfo.processInfo.systemUptime
|
|
360
|
+
self.promptSince = nil
|
|
361
|
+
self.joinDeadline = max(self.joinDeadline, now + Self.afterAnswer)
|
|
362
|
+
MediaLog.log("HOTSPOT_JOIN apply_answered after_s=\(Int(now - asked))")
|
|
363
|
+
}
|
|
339
364
|
if self.cancelled { self.finishLeave(); return }
|
|
340
365
|
if let error {
|
|
341
366
|
let nativeError = error as NSError
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mentra/glasses-media",
|
|
3
|
-
"version": "3.5.0-dev.
|
|
3
|
+
"version": "3.5.0-dev.1316",
|
|
4
4
|
"description": "Shared native glasses media receivers and local network transport",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Mentra Community",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@mentra/bluetooth-sdk": "3.5.0-dev.
|
|
19
|
+
"@mentra/bluetooth-sdk": "3.5.0-dev.1316"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"expo-modules-core": "~55.0.25"
|