@mentra/bluetooth-sdk 3.4.0-beta.1275 → 3.4.0-beta.1279
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 +57 -196
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/Ipv4Prefix.kt +51 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/NetworkFacts.kt +81 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkError.kt +109 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadiness.kt +103 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpec.kt +53 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkState.kt +127 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedSoftApNetwork.kt +604 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/SoftApTrace.kt +143 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/otaserver/MentraOtaServerModule.kt +0 -7
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/Ipv4PrefixTest.kt +59 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/NetworkFactsTest.kt +59 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedLocalNetworkPermissionTest.kt +35 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkErrorTest.kt +96 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkLifecycleTest.kt +187 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadinessTest.kt +141 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpecTest.kt +69 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/SoftApTraceTest.kt +97 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/UnavailableRetryTest.kt +47 -0
- package/build/_private/MentraLocalNetworkModule.d.ts +1 -1
- 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-server/MentraOtaServerModule.d.ts +0 -2
- package/build/ota-server/MentraOtaServerModule.d.ts.map +1 -1
- package/build/ota-server/MentraOtaServerModule.js.map +1 -1
- package/build/ota-server/MentraOtaServerModule.web.d.ts +0 -1
- package/build/ota-server/MentraOtaServerModule.web.d.ts.map +1 -1
- package/build/ota-server/MentraOtaServerModule.web.js +0 -3
- package/build/ota-server/MentraOtaServerModule.web.js.map +1 -1
- package/build/ota-transport/index.d.ts +3 -3
- package/build/ota-transport/index.d.ts.map +1 -1
- package/build/ota-transport/index.js +4 -4
- package/build/ota-transport/index.js.map +1 -1
- package/ios/LocalIPv4.swift +0 -61
- package/ios/MentraOtaServerModule.swift +0 -16
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/package.json +2 -2
- package/src/_private/MentraLocalNetworkModule.ts +5 -1
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/ota-server/MentraOtaServerModule.ts +0 -2
- package/src/ota-server/MentraOtaServerModule.web.ts +0 -4
- package/src/ota-transport/index.ts +4 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/ScopedNetworkReadiness.kt +0 -17
- package/android/src/test/java/com/mentra/bluetoothsdk/ScopedNetworkReadinessTest.kt +0 -39
package/ios/LocalIPv4.swift
CHANGED
|
@@ -5,54 +5,6 @@ import Foundation
|
|
|
5
5
|
/// (photo upload receiver, hotspot-served OTA). Prefers WiFi-ish interfaces carrying RFC1918
|
|
6
6
|
/// addresses — under a glasses-hotspot session en0 holds the 192.168.43.x client address.
|
|
7
7
|
enum LocalIPv4 {
|
|
8
|
-
/// Return the active Wi-Fi address only when it is on the glasses gateway's /24.
|
|
9
|
-
/// iPhone Wi-Fi is `en0`; accepting AWDL, VPN, cellular, or another private
|
|
10
|
-
/// interface can publish an endpoint that the glasses cannot reach.
|
|
11
|
-
static func wifiIPv4Address(matchingGateway gateway: String) -> String? {
|
|
12
|
-
guard let gatewayPrefix = subnet24Prefix(gateway) else {
|
|
13
|
-
return nil
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
var interfaces: UnsafeMutablePointer<ifaddrs>?
|
|
17
|
-
guard getifaddrs(&interfaces) == 0, let first = interfaces else {
|
|
18
|
-
return nil
|
|
19
|
-
}
|
|
20
|
-
defer { freeifaddrs(interfaces) }
|
|
21
|
-
|
|
22
|
-
var cursor: UnsafeMutablePointer<ifaddrs>? = first
|
|
23
|
-
while let current = cursor {
|
|
24
|
-
defer { cursor = current.pointee.ifa_next }
|
|
25
|
-
let interface = current.pointee
|
|
26
|
-
guard String(cString: interface.ifa_name) == "en0",
|
|
27
|
-
let addressPointer = interface.ifa_addr,
|
|
28
|
-
addressPointer.pointee.sa_family == UInt8(AF_INET),
|
|
29
|
-
(interface.ifa_flags & UInt32(IFF_UP)) != 0
|
|
30
|
-
else {
|
|
31
|
-
continue
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var address = addressPointer.pointee
|
|
35
|
-
var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
|
|
36
|
-
guard getnameinfo(
|
|
37
|
-
&address,
|
|
38
|
-
socklen_t(address.sa_len),
|
|
39
|
-
&hostname,
|
|
40
|
-
socklen_t(hostname.count),
|
|
41
|
-
nil,
|
|
42
|
-
0,
|
|
43
|
-
NI_NUMERICHOST
|
|
44
|
-
) == 0 else {
|
|
45
|
-
continue
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let ip = String(cString: hostname)
|
|
49
|
-
if subnet24Prefix(ip) == gatewayPrefix {
|
|
50
|
-
return ip
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return nil
|
|
54
|
-
}
|
|
55
|
-
|
|
56
8
|
static func bestLocalIPv4Address() -> String? {
|
|
57
9
|
var interfaces: UnsafeMutablePointer<ifaddrs>?
|
|
58
10
|
guard getifaddrs(&interfaces) == 0, let first = interfaces else {
|
|
@@ -134,17 +86,4 @@ enum LocalIPv4 {
|
|
|
134
86
|
private static func isLinkLocalIPv4(_ ip: String) -> Bool {
|
|
135
87
|
ip.hasPrefix("169.254.")
|
|
136
88
|
}
|
|
137
|
-
|
|
138
|
-
private static func subnet24Prefix(_ ip: String) -> String? {
|
|
139
|
-
let parts = ip.split(separator: ".")
|
|
140
|
-
guard parts.count == 4,
|
|
141
|
-
parts.allSatisfy({ part in
|
|
142
|
-
guard let value = Int(part) else { return false }
|
|
143
|
-
return (0 ... 255).contains(value)
|
|
144
|
-
})
|
|
145
|
-
else {
|
|
146
|
-
return nil
|
|
147
|
-
}
|
|
148
|
-
return parts.prefix(3).joined(separator: ".")
|
|
149
|
-
}
|
|
150
89
|
}
|
|
@@ -31,10 +31,6 @@ public class MentraOtaServerModule: Module {
|
|
|
31
31
|
self.stopOtaServerInternal()
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
AsyncFunction("waitForWifiAddress") { (gateway: String, timeoutMs: Int) -> String in
|
|
35
|
-
try await self.waitForWifiAddress(gateway: gateway, timeoutMs: timeoutMs)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
34
|
AsyncFunction("downloadArtifact") { (source: String, destination: String) in
|
|
39
35
|
try await self.artifactDownloader.download(from: source, to: destination)
|
|
40
36
|
}
|
|
@@ -97,18 +93,6 @@ public class MentraOtaServerModule: Module {
|
|
|
97
93
|
)
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
private func waitForWifiAddress(gateway: String, timeoutMs: Int) async throws -> String {
|
|
101
|
-
let deadline = Date().addingTimeInterval(Double(max(timeoutMs, 0)) / 1000.0)
|
|
102
|
-
repeat {
|
|
103
|
-
if let address = LocalIPv4.wifiIPv4Address(matchingGateway: gateway) {
|
|
104
|
-
return address
|
|
105
|
-
}
|
|
106
|
-
try await Task.sleep(nanoseconds: 250_000_000)
|
|
107
|
-
} while Date() < deadline
|
|
108
|
-
|
|
109
|
-
throw OtaServerModuleError("The iPhone did not join the glasses hotspot subnet.")
|
|
110
|
-
}
|
|
111
|
-
|
|
112
96
|
private func stopOtaServerInternal() {
|
|
113
97
|
serverLock.lock()
|
|
114
98
|
defer { serverLock.unlock() }
|
|
@@ -16,7 +16,7 @@ enum BluetoothSdkDefaults {
|
|
|
16
16
|
/// silently disable it on every pair the app touches.
|
|
17
17
|
static let autoPowerOffEnabled = true
|
|
18
18
|
private static let infoSdkVersionKey = "MentraBluetoothSdkVersion"
|
|
19
|
-
private static let swiftPackageSdkVersion = "3.4.0-beta.
|
|
19
|
+
private static let swiftPackageSdkVersion = "3.4.0-beta.1279"
|
|
20
20
|
private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
|
|
21
21
|
|
|
22
22
|
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.4.0"
|
|
6
|
-
static let releaseIdentity = "3.4.0-beta.
|
|
7
|
-
static let releaseSetId = "mentra-3.4.0-beta.
|
|
8
|
-
static let sourceCommit = "
|
|
9
|
-
static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.
|
|
10
|
-
static let otaManifestSha256 = "
|
|
6
|
+
static let releaseIdentity = "3.4.0-beta.1279"
|
|
7
|
+
static let releaseSetId = "mentra-3.4.0-beta.1279"
|
|
8
|
+
static let sourceCommit = "403a689616b3b39896db3a8ee090af4f9f08db2f"
|
|
9
|
+
static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1279.json"
|
|
10
|
+
static let otaManifestSha256 = "136a926627ae19e3f6ee42e2e75a6791994cd21b90d8299376cd83771e055545"
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mentra/bluetooth-sdk",
|
|
3
|
-
"version": "3.4.0-beta.
|
|
3
|
+
"version": "3.4.0-beta.1279",
|
|
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.4.0-beta.
|
|
118
|
+
"@mentra/cloud-protocol": "3.4.0-beta.1279"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@types/node": "^25.9.3",
|
|
@@ -54,7 +54,11 @@ type LocalNetworkEvents = {
|
|
|
54
54
|
|
|
55
55
|
declare class MentraLocalNetworkNativeModule extends NativeModule<LocalNetworkEvents> {
|
|
56
56
|
getNetworkDiagnostics(): NetworkDiagnostics
|
|
57
|
-
connect(
|
|
57
|
+
connect(
|
|
58
|
+
ssid: string,
|
|
59
|
+
password: string,
|
|
60
|
+
incoming: boolean,
|
|
61
|
+
): Promise<{connected: boolean; ssid: string; localAddress?: string}>
|
|
58
62
|
request(
|
|
59
63
|
requestId: string,
|
|
60
64
|
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.4.0",
|
|
15
|
-
"releaseIdentity": "3.4.0-beta.
|
|
16
|
-
"releaseSetId": "mentra-3.4.0-beta.
|
|
17
|
-
"sourceCommit": "
|
|
18
|
-
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.
|
|
19
|
-
"otaManifestSha256": "
|
|
15
|
+
"releaseIdentity": "3.4.0-beta.1279",
|
|
16
|
+
"releaseSetId": "mentra-3.4.0-beta.1279",
|
|
17
|
+
"sourceCommit": "403a689616b3b39896db3a8ee090af4f9f08db2f",
|
|
18
|
+
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1279.json",
|
|
19
|
+
"otaManifestSha256": "136a926627ae19e3f6ee42e2e75a6791994cd21b90d8299376cd83771e055545"
|
|
20
20
|
})
|
|
@@ -15,8 +15,6 @@ declare class MentraOtaServerModule extends NativeModule<MentraOtaServerModuleEv
|
|
|
15
15
|
host?: string | null,
|
|
16
16
|
): Promise<OtaServerResult>
|
|
17
17
|
stopOtaServer(): Promise<void>
|
|
18
|
-
/** Wait for iPhone Wi-Fi (`en0`) to acquire an address on the glasses gateway subnet. */
|
|
19
|
-
waitForWifiAddress(gateway: string, timeoutMs: number): Promise<string>
|
|
20
18
|
downloadArtifact(source: string, destination: string): Promise<{statusCode: number; bytesWritten: number}>
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -8,10 +8,6 @@ class MentraOtaServerModule extends NativeModule<MentraOtaServerModuleEvents> {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async stopOtaServer(): Promise<void> {}
|
|
11
|
-
|
|
12
|
-
async waitForWifiAddress(): Promise<string> {
|
|
13
|
-
throw new Error("The OTA server is only available in native apps.")
|
|
14
|
-
}
|
|
15
11
|
}
|
|
16
12
|
|
|
17
13
|
export default registerWebModule(MentraOtaServerModule, "MentraOtaServer")
|
|
@@ -58,15 +58,16 @@ export type OtaServerResult = {
|
|
|
58
58
|
* Scoped networking for traffic that must stay on a Mentra Live hotspot while
|
|
59
59
|
* the phone's default route remains on cellular or another Wi-Fi network.
|
|
60
60
|
*
|
|
61
|
-
* The module is optional because iOS
|
|
61
|
+
* The module is optional because iOS joins through glasses-media's hotspot owner instead.
|
|
62
62
|
*/
|
|
63
63
|
export const otaLocalNetwork = Object.freeze({
|
|
64
64
|
isAvailable: (): boolean => MentraLocalNetwork != null,
|
|
65
65
|
/** Synchronous local observation; no network I/O, route changes or network identities. */
|
|
66
66
|
getNetworkDiagnostics: (): NetworkDiagnostics | null => MentraLocalNetwork?.getNetworkDiagnostics() ?? null,
|
|
67
|
-
connect
|
|
67
|
+
/** `incoming`: the glasses will connect to a server on this phone (OTA), not only the reverse. */
|
|
68
|
+
connect: async (ssid: string, password: string, incoming = true): Promise<OtaLocalNetworkConnection> => {
|
|
68
69
|
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
69
|
-
return MentraLocalNetwork.connect(ssid, password)
|
|
70
|
+
return MentraLocalNetwork.connect(ssid, password, incoming)
|
|
70
71
|
},
|
|
71
72
|
request: async (
|
|
72
73
|
requestId: string,
|
|
@@ -116,8 +117,6 @@ export const otaServer = Object.freeze({
|
|
|
116
117
|
host?: string | null,
|
|
117
118
|
): Promise<OtaServerResult> => MentraOtaServer.startOtaServer(manifestJson, artifactPaths, host),
|
|
118
119
|
stop: (): Promise<void> => MentraOtaServer.stopOtaServer(),
|
|
119
|
-
waitForWifiAddress: (gateway: string, timeoutMs: number): Promise<string> =>
|
|
120
|
-
MentraOtaServer.waitForWifiAddress(gateway, timeoutMs),
|
|
121
120
|
downloadArtifact: (source: string, destination: string): Promise<{statusCode: number; bytesWritten: number}> =>
|
|
122
121
|
MentraOtaServer.downloadArtifact(source, destination),
|
|
123
122
|
onArtifactDownloadProgress: (listener: (event: OtaArtifactDownloadProgress) => void): OtaTransportSubscription =>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
package com.mentra.bluetoothsdk
|
|
2
|
-
|
|
3
|
-
internal class ScopedNetworkReadiness<T> {
|
|
4
|
-
private var candidate: T? = null
|
|
5
|
-
|
|
6
|
-
fun onAvailable(network: T) {
|
|
7
|
-
candidate = network
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
fun isReady(network: T, isForeground: Boolean): Boolean = candidate == network && isForeground
|
|
11
|
-
|
|
12
|
-
fun contains(network: T): Boolean = candidate == network
|
|
13
|
-
|
|
14
|
-
fun clear() {
|
|
15
|
-
candidate = null
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
package com.mentra.bluetoothsdk
|
|
2
|
-
|
|
3
|
-
import org.junit.Assert.assertFalse
|
|
4
|
-
import org.junit.Assert.assertTrue
|
|
5
|
-
import org.junit.Test
|
|
6
|
-
|
|
7
|
-
class ScopedNetworkReadinessTest {
|
|
8
|
-
@Test
|
|
9
|
-
fun `waits for the available network to become foreground`() {
|
|
10
|
-
val readiness = ScopedNetworkReadiness<String>()
|
|
11
|
-
|
|
12
|
-
readiness.onAvailable("glasses")
|
|
13
|
-
|
|
14
|
-
assertFalse(readiness.isReady("glasses", isForeground = false))
|
|
15
|
-
assertTrue(readiness.isReady("glasses", isForeground = true))
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Test
|
|
19
|
-
fun `rejects capabilities from a stale network`() {
|
|
20
|
-
val readiness = ScopedNetworkReadiness<String>()
|
|
21
|
-
|
|
22
|
-
readiness.onAvailable("old")
|
|
23
|
-
readiness.onAvailable("current")
|
|
24
|
-
|
|
25
|
-
assertFalse(readiness.isReady("old", isForeground = true))
|
|
26
|
-
assertTrue(readiness.isReady("current", isForeground = true))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@Test
|
|
30
|
-
fun `clears the candidate when the request ends`() {
|
|
31
|
-
val readiness = ScopedNetworkReadiness<String>()
|
|
32
|
-
readiness.onAvailable("glasses")
|
|
33
|
-
|
|
34
|
-
readiness.clear()
|
|
35
|
-
|
|
36
|
-
assertFalse(readiness.contains("glasses"))
|
|
37
|
-
assertFalse(readiness.isReady("glasses", isForeground = true))
|
|
38
|
-
}
|
|
39
|
-
}
|