@mentra/glasses-media 3.5.0-dev.1465 → 3.5.0-dev.1468
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/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Native receivers, WHIP publishers and network helpers shared by the Mentra App.
|
|
|
4
4
|
|
|
5
5
|
- Android: the existing `GlassesMediaSource`, local WHIP and WHEP receivers, scoped SoftAP networking, decoded I420/PCM delivery, and transport diagnostics moved here. The ACS session and raw outgoing streams remain in `acs-meeting`.
|
|
6
6
|
- iOS: `DecodedGlassesMediaSource` delivers `CVPixelBuffer` video and interleaved PCM16. `LocalWhipIngestSource` answers the glasses' existing WHIP client; `WhepVideoSource` retains the cloud subscription path.
|
|
7
|
-
- `GlassesHotspotNetwork` owns hotspot association for OTA, gallery transfers and media. iPhone uses persistent `NEHotspotConfiguration`, and keeps only the one it is joining: every join first removes the app's configurations for other hotspots, and each launch removes leftovers, so a phone near many pairs never rejoins another pair by itself; iOS-on-Mac uses
|
|
7
|
+
- `GlassesHotspotNetwork` owns hotspot association for OTA, gallery transfers and media. iPhone uses persistent `NEHotspotConfiguration`, and keeps only the one it is joining: every join first removes the app's configurations for other hotspots, and each launch removes leftovers, so a phone near many pairs never rejoins another pair by itself; iOS-on-Mac uses CoreWLAN in the app process (its channel-scoped scan and forget call are not public) and the standard Location permission needed to identify Wi-Fi networks. Wi-Fi carries the glasses link; cellular carries the call. The owner verifies the requested SSID and actual Wi-Fi interface address, retains that interface for loss checks and ACS binding, and serializes network writers across consumers. Cancellation retains custody until blocking native work and cleanup finish. Cleanup preserves a network the user joined afterward; a failed release rejects and retains ownership for a later cleanup attempt.
|
|
8
8
|
|
|
9
9
|
The publisher owns its outgoing encoders, audio policy, and destination. Receivers do not open the phone microphone or play the glasses microphone locally. iOS uses a receive-only audio device to drive decoded PCM delivery without changing the app's audio session.
|
|
10
10
|
|
package/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export const glassesHotspot: {
|
|
|
9
9
|
password: string,
|
|
10
10
|
gateway?: string,
|
|
11
11
|
purpose?: "outgoing-client" | "incoming-server",
|
|
12
|
+
/** The hotspot's channel in MHz, when the glasses report it: a Mac scans only that channel first. */
|
|
13
|
+
frequency?: number,
|
|
12
14
|
): Promise<string>
|
|
13
15
|
leave(id: string, waitForInternet?: boolean): Promise<void>
|
|
14
16
|
/** A join with this id has waited a few seconds for Local Network access, which the person may have denied.
|
package/index.js
CHANGED
|
@@ -21,8 +21,8 @@ export function installNativeLogConsole() {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const glassesHotspot = Object.freeze({
|
|
24
|
-
join: (id, ssid, password, gateway, purpose = "outgoing-client") =>
|
|
25
|
-
native().joinLocalHotspot(id, ssid, password, gateway ?? null, purpose),
|
|
24
|
+
join: (id, ssid, password, gateway, purpose = "outgoing-client", frequency) =>
|
|
25
|
+
native().joinLocalHotspot(id, ssid, password, gateway ?? null, purpose, frequency ?? null),
|
|
26
26
|
leave: (id, waitForInternet = false) => native().leaveLocalHotspot(id, waitForInternet),
|
|
27
27
|
onPermissionRequired: (listener) =>
|
|
28
28
|
native().addListener("onLocalHotspotPermissionRequired", (event) =>
|
|
@@ -2,7 +2,7 @@ import CoreLocation
|
|
|
2
2
|
import Foundation
|
|
3
3
|
import ObjectiveC
|
|
4
4
|
|
|
5
|
-
/// Blocking
|
|
5
|
+
/// Blocking CoreWLAN calls are isolated here; the existing hotspot owner
|
|
6
6
|
/// retains custody until they return, even after cancellation or a timeout.
|
|
7
7
|
final class MacHotspotAssociation {
|
|
8
8
|
/// Rejoining the hotspot seconds after leaving it, as between an update's passes, can be refused while the
|
|
@@ -16,8 +16,8 @@ final class MacHotspotAssociation {
|
|
|
16
16
|
/// macOS answers an app without the scan entitlement from its cache until 10 s after its last live
|
|
17
17
|
/// scan returned (airportd, 2026-11-17), so scanning sooner only reads the scan that just missed.
|
|
18
18
|
static let scanInterval: TimeInterval = 10
|
|
19
|
-
/// Time to find and join the hotspot. A live scan
|
|
20
|
-
///
|
|
19
|
+
/// Time to find and join the hotspot. A full live scan took about 22 s while the Mac was on another network,
|
|
20
|
+
/// and one could miss an AP that had just come up (lab Mac, 2026-11-17). This window holds four.
|
|
21
21
|
static let joinWindow: TimeInterval = 120
|
|
22
22
|
|
|
23
23
|
private let condition = NSCondition()
|
|
@@ -31,6 +31,7 @@ final class MacHotspotAssociation {
|
|
|
31
31
|
private let pause: ((TimeInterval) -> Void)?
|
|
32
32
|
private let makeInterface: () throws -> MacWifiInterface
|
|
33
33
|
private let authorization: MacHotspotAuthorization?
|
|
34
|
+
private var scansStarted = 0
|
|
34
35
|
|
|
35
36
|
init(deadline: TimeInterval = ProcessInfo.processInfo.systemUptime + MacHotspotAssociation.joinWindow,
|
|
36
37
|
now: @escaping () -> TimeInterval = { ProcessInfo.processInfo.systemUptime },
|
|
@@ -46,7 +47,8 @@ final class MacHotspotAssociation {
|
|
|
46
47
|
self.makeInterface = makeInterface ?? { try PublicCoreWlanInterface(authorizationFacts: authorizationFacts, authorization: authorization) }
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
/// `frequency` is the channel the glasses report for their AP, in MHz, when they know it.
|
|
51
|
+
func associate(ssid: String, password: String, frequency: Int? = nil) throws -> String {
|
|
50
52
|
try checkCurrent()
|
|
51
53
|
let interface = try makeInterface()
|
|
52
54
|
self.interface = interface
|
|
@@ -54,7 +56,7 @@ final class MacHotspotAssociation {
|
|
|
54
56
|
if before != ssid { previousSSID = before }
|
|
55
57
|
for attempt in 1 ... Self.associationAttempts {
|
|
56
58
|
guard try readSSID(interface) != ssid else { break }
|
|
57
|
-
let network = try discoverNetwork(ssid: ssid, interface: interface)
|
|
59
|
+
let network = try discoverNetwork(ssid: ssid, frequency: frequency, interface: interface)
|
|
58
60
|
try checkDiscoveryCurrent()
|
|
59
61
|
guard let network, try readSSID(interface) != ssid else { break }
|
|
60
62
|
try checkDiscoveryCurrent()
|
|
@@ -170,13 +172,14 @@ final class MacHotspotAssociation {
|
|
|
170
172
|
try PublicCoreWlanInterface().currentSSID()
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
private func discoverNetwork(ssid: String, interface: MacWifiInterface) throws -> NSObject? {
|
|
175
|
+
private func discoverNetwork(ssid: String, frequency: Int?, interface: MacWifiInterface) throws -> NSObject? {
|
|
174
176
|
while true {
|
|
175
177
|
try checkDiscoveryCurrent()
|
|
176
178
|
// Recheck Location authorization before and after each blocking scan.
|
|
177
179
|
if try readSSID(interface) == ssid { return nil }
|
|
178
180
|
try authorization?.requireCurrentAuthorization()
|
|
179
|
-
let network = try interface.network(ssid: ssid)
|
|
181
|
+
let network = try interface.network(ssid: ssid, channels: MacHotspotScan.next(after: scansStarted, frequency: frequency))
|
|
182
|
+
scansStarted += 1
|
|
180
183
|
try checkDiscoveryCurrent()
|
|
181
184
|
if try readSSID(interface) == ssid { return nil }
|
|
182
185
|
if let network { return network }
|
|
@@ -207,10 +210,46 @@ final class MacHotspotAssociation {
|
|
|
207
210
|
}
|
|
208
211
|
}
|
|
209
212
|
|
|
213
|
+
/// Which channels a hotspot scan covers. A scan of every channel took about 22 s, most of it in a 6 GHz pass
|
|
214
|
+
/// (2026-11-17), and these glasses cannot run a 6 GHz AP. One channel takes 0.07 s, the 2.4 GHz band 0.65 s (air-3).
|
|
215
|
+
enum MacHotspotScan: Equatable {
|
|
216
|
+
/// The channel the glasses reported: their station's, which their AP shares while it is connected.
|
|
217
|
+
case channel(band: Int, number: Int)
|
|
218
|
+
/// Where the glasses start their own AP, with their station off Wi-Fi (Android's 2.4 GHz SoftAP band).
|
|
219
|
+
case band2GHz
|
|
220
|
+
/// Every 2.4 and 5 GHz channel, once a narrower scan has missed.
|
|
221
|
+
case below6GHz
|
|
222
|
+
|
|
223
|
+
/// CWChannelBand raw values.
|
|
224
|
+
static let band2 = 1, band5 = 2
|
|
225
|
+
|
|
226
|
+
static func next(after scans: Int, frequency: Int?) -> MacHotspotScan {
|
|
227
|
+
guard scans == 0 else { return .below6GHz }
|
|
228
|
+
return frequency.flatMap(channel(frequency:)) ?? .band2GHz
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
static func channel(frequency: Int) -> MacHotspotScan? {
|
|
232
|
+
switch frequency {
|
|
233
|
+
case 2412 ... 2472: .channel(band: band2, number: (frequency - 2407) / 5)
|
|
234
|
+
case 2484: .channel(band: band2, number: 14)
|
|
235
|
+
case 5160 ... 5885: .channel(band: band5, number: (frequency - 5000) / 5)
|
|
236
|
+
default: nil
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
func includes(band: Int, number: Int) -> Bool {
|
|
241
|
+
switch self {
|
|
242
|
+
case let .channel(b, n): band == b && number == n
|
|
243
|
+
case .band2GHz: band == Self.band2
|
|
244
|
+
case .below6GHz: band == Self.band2 || band == Self.band5
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
210
249
|
protocol MacWifiInterface: AnyObject {
|
|
211
250
|
func name() throws -> String
|
|
212
251
|
func currentSSID() throws -> String?
|
|
213
|
-
func network(ssid: String) throws -> NSObject?
|
|
252
|
+
func network(ssid: String, channels: MacHotspotScan) throws -> NSObject?
|
|
214
253
|
func associate(network: NSObject, password: String) throws
|
|
215
254
|
func disassociate()
|
|
216
255
|
/// Removes the network from the Mac's known networks, so auto-join never picks it.
|
|
@@ -245,7 +284,7 @@ enum MacHotspotRestore: String, Equatable {
|
|
|
245
284
|
enum MacWifiInvocation {
|
|
246
285
|
// Objective-C NSError** parameters use autoreleasing writeback. Strong
|
|
247
286
|
// pointer storage would over-release errors when the native pool drains.
|
|
248
|
-
typealias Scan = @convention(c) (AnyObject, Selector, NSData, AutoreleasingUnsafeMutablePointer<NSError?>) -> Unmanaged<NSSet>?
|
|
287
|
+
typealias Scan = @convention(c) (AnyObject, Selector, NSSet, NSData, NSString?, AutoreleasingUnsafeMutablePointer<NSError?>) -> Unmanaged<NSSet>?
|
|
249
288
|
typealias Associate = @convention(c) (AnyObject, Selector, AnyObject, NSString, AutoreleasingUnsafeMutablePointer<NSError?>) -> Bool
|
|
250
289
|
typealias Forget = @convention(c) (AnyObject, Selector, NSData, UInt64, AutoreleasingUnsafeMutablePointer<NSError?>) -> Bool
|
|
251
290
|
typealias SetPower = @convention(c) (AnyObject, Selector, Bool, AutoreleasingUnsafeMutablePointer<NSError?>) -> Bool
|
|
@@ -276,7 +315,8 @@ private final class PublicCoreWlanInterface: MacWifiInterface {
|
|
|
276
315
|
client.responds(to: NSSelectorFromString("interface")),
|
|
277
316
|
let interface = client.perform(NSSelectorFromString("interface"))?.takeUnretainedValue() as? NSObject
|
|
278
317
|
else { throw LocalMediaError("Mac Wi-Fi interface is unavailable") }
|
|
279
|
-
for method in ["interfaceName", "ssidData", "
|
|
318
|
+
for method in ["interfaceName", "ssidData", "supportedWLANChannels", "scanForNetworksWithChannels:ssid:bssid:error:",
|
|
319
|
+
"associateToNetwork:password:error:", "disassociate"] {
|
|
280
320
|
guard interface.responds(to: NSSelectorFromString(method)) else {
|
|
281
321
|
throw LocalMediaError("Mac Wi-Fi interface does not support hotspot association")
|
|
282
322
|
}
|
|
@@ -309,12 +349,19 @@ private final class PublicCoreWlanInterface: MacWifiInterface {
|
|
|
309
349
|
}
|
|
310
350
|
}
|
|
311
351
|
|
|
312
|
-
|
|
352
|
+
/// CoreWLAN's public scan always covers every channel, 6 GHz included; its channel-scoped scan is not public.
|
|
353
|
+
func network(ssid: String, channels scan: MacHotspotScan) throws -> NSObject? {
|
|
313
354
|
try requireAuthorization()
|
|
314
|
-
let
|
|
355
|
+
let supported = interface.perform(NSSelectorFromString("supportedWLANChannels"))?.takeUnretainedValue() as? NSSet ?? []
|
|
356
|
+
let channels = NSSet(array: supported.compactMap { $0 as? NSObject }.filter {
|
|
357
|
+
scan.includes(band: $0.value(forKey: "channelBand") as? Int ?? 0, number: $0.value(forKey: "channelNumber") as? Int ?? 0)
|
|
358
|
+
})
|
|
359
|
+
// A reported channel this Mac cannot use is a miss: an empty set would scan every channel.
|
|
360
|
+
guard channels.count > 0 else { return nil }
|
|
361
|
+
let selector = NSSelectorFromString("scanForNetworksWithChannels:ssid:bssid:error:")
|
|
315
362
|
let invoke = unsafeBitCast(interface.method(for: selector), to: MacWifiInvocation.Scan.self)
|
|
316
363
|
var error: NSError?
|
|
317
|
-
guard let networks = invoke(interface, selector, NSData(data: Data(ssid.utf8)), &error)?.takeUnretainedValue() else {
|
|
364
|
+
guard let networks = invoke(interface, selector, channels, NSData(data: Data(ssid.utf8)), nil, &error)?.takeUnretainedValue() else {
|
|
318
365
|
throw Self.failure("scan", error)
|
|
319
366
|
}
|
|
320
367
|
// A directed scan can include unrelated networks. Match the requested
|
|
@@ -57,7 +57,8 @@ public final class GlassesHotspotNetwork {
|
|
|
57
57
|
}
|
|
58
58
|
}()
|
|
59
59
|
|
|
60
|
-
public func join(ssid: String, passphrase: String, gateway: String? = nil,
|
|
60
|
+
public func join(ssid: String, passphrase: String, gateway: String? = nil, frequency: Int? = nil, purpose: HotspotAccessPurpose = .outgoingClient,
|
|
61
|
+
completion: @escaping (Result<String, Error>) -> Void) {
|
|
61
62
|
queue.async {
|
|
62
63
|
guard self.ssid == nil, !self.applying else { completion(.failure(LocalMediaError("Previous hotspot session has not finished cleaning up"))); return }
|
|
63
64
|
if let gateway, !LocalMediaPolicy.isPrivate(gateway) {
|
|
@@ -87,7 +88,7 @@ public final class GlassesHotspotNetwork {
|
|
|
87
88
|
self.joinReply = completion
|
|
88
89
|
self.startInterfaceMonitors(generation: gen)
|
|
89
90
|
if ProcessInfo.processInfo.isiOSAppOnMac {
|
|
90
|
-
self.authorizeMacAssociation(ssid: ssid, passphrase: passphrase, generation: gen, deadline: deadline)
|
|
91
|
+
self.authorizeMacAssociation(ssid: ssid, passphrase: passphrase, frequency: frequency, generation: gen, deadline: deadline)
|
|
91
92
|
} else {
|
|
92
93
|
NEHotspotConfigurationManager.shared.getConfiguredSSIDs { saved in
|
|
93
94
|
self.queue.async {
|
|
@@ -283,7 +284,7 @@ public final class GlassesHotspotNetwork {
|
|
|
283
284
|
}
|
|
284
285
|
}
|
|
285
286
|
|
|
286
|
-
private func authorizeMacAssociation(ssid: String, passphrase: String, generation gen: Int, deadline: TimeInterval) {
|
|
287
|
+
private func authorizeMacAssociation(ssid: String, passphrase: String, frequency: Int?, generation gen: Int, deadline: TimeInterval) {
|
|
287
288
|
let facts = MacHotspotAuthorizationFacts()
|
|
288
289
|
let authorization = MacHotspotAuthorization(facts: facts)
|
|
289
290
|
macAuthorization = authorization
|
|
@@ -310,7 +311,9 @@ public final class GlassesHotspotNetwork {
|
|
|
310
311
|
self.queue.async {
|
|
311
312
|
guard gen == self.generation, !self.cancelled else { return }
|
|
312
313
|
switch result {
|
|
313
|
-
case .success:
|
|
314
|
+
case .success:
|
|
315
|
+
self.applyMacAssociation(ssid: ssid, passphrase: passphrase, frequency: frequency, generation: gen, deadline: deadline,
|
|
316
|
+
authorizationFacts: facts, authorization: authorization)
|
|
314
317
|
case let .failure(error):
|
|
315
318
|
self.finishJoin(.failure(error)); self.finishLeave()
|
|
316
319
|
}
|
|
@@ -318,12 +321,13 @@ public final class GlassesHotspotNetwork {
|
|
|
318
321
|
}
|
|
319
322
|
}
|
|
320
323
|
|
|
321
|
-
private func applyMacAssociation(ssid: String, passphrase: String, generation gen: Int, deadline: TimeInterval,
|
|
324
|
+
private func applyMacAssociation(ssid: String, passphrase: String, frequency: Int?, generation gen: Int, deadline: TimeInterval,
|
|
325
|
+
authorizationFacts: MacHotspotAuthorizationFacts, authorization: MacHotspotAuthorization) {
|
|
322
326
|
let association = MacHotspotAssociation(deadline: deadline, authorizationFacts: authorizationFacts, authorization: authorization)
|
|
323
327
|
macAssociation = association
|
|
324
328
|
applying = true
|
|
325
329
|
macWorker.async {
|
|
326
|
-
let result = Result { try association.associate(ssid: ssid, password: passphrase) }
|
|
330
|
+
let result = Result { try association.associate(ssid: ssid, password: passphrase, frequency: frequency) }
|
|
327
331
|
self.queue.async {
|
|
328
332
|
guard gen == self.generation else { return }
|
|
329
333
|
self.applying = false
|
|
@@ -23,7 +23,7 @@ public final class GlassesMediaRelayModule: Module {
|
|
|
23
23
|
permissionLog.notice("\(line, privacy: .public)")
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
AsyncFunction("joinLocalHotspot") { (id: String, ssid: String, password: String, gateway: String?, purpose: String, promise: Promise) in
|
|
26
|
+
AsyncFunction("joinLocalHotspot") { (id: String, ssid: String, password: String, gateway: String?, purpose: String, frequency: Int?, promise: Promise) in
|
|
27
27
|
self.queue.async {
|
|
28
28
|
guard self.localHotspotOwner == nil else {
|
|
29
29
|
promise.reject(LocalMediaError("Previous hotspot session has not been released")); return
|
|
@@ -36,7 +36,7 @@ public final class GlassesMediaRelayModule: Module {
|
|
|
36
36
|
self.localHotspot.onPermissionRequired = { [weak self] systemAnswer in
|
|
37
37
|
self?.sendEvent("onLocalHotspotPermissionRequired", ["id": id, "systemAnswer": systemAnswer])
|
|
38
38
|
}
|
|
39
|
-
self.localHotspot.join(ssid: ssid, passphrase: password, gateway: gateway, purpose: accessPurpose) { result in
|
|
39
|
+
self.localHotspot.join(ssid: ssid, passphrase: password, gateway: gateway, frequency: frequency, purpose: accessPurpose) { result in
|
|
40
40
|
switch result {
|
|
41
41
|
case let .success(address): promise.resolve(address)
|
|
42
42
|
case let .failure(error):
|
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.1468",
|
|
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.1468"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"expo-modules-core": "~55.0.25"
|