@mentra/bluetooth-sdk 3.5.0-dev.1518 → 3.5.0-dev.1519
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/MIGRATION.md +9 -0
- package/README.md +64 -11
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt +10 -0
- package/build/BluetoothSdk.types.d.ts +23 -5
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js +5 -0
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_internal.d.ts +1 -0
- package/build/_internal.d.ts.map +1 -1
- package/build/_internal.js +1 -0
- package/build/_internal.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js +20 -9
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/_private/MentraLocalNetworkModule.d.ts +21 -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/glasses-wifi/connection.d.ts +6 -0
- package/build/glasses-wifi/connection.d.ts.map +1 -0
- package/build/glasses-wifi/connection.js +44 -0
- package/build/glasses-wifi/connection.js.map +1 -0
- package/build/glasses-wifi/continuous.d.ts +39 -0
- package/build/glasses-wifi/continuous.d.ts.map +1 -0
- package/build/glasses-wifi/continuous.js +151 -0
- package/build/glasses-wifi/continuous.js.map +1 -0
- package/build/glasses-wifi/files.d.ts +11 -0
- package/build/glasses-wifi/files.d.ts.map +1 -0
- package/build/glasses-wifi/files.js +33 -0
- package/build/glasses-wifi/files.js.map +1 -0
- package/build/glasses-wifi/index.d.ts +20 -0
- package/build/glasses-wifi/index.d.ts.map +1 -0
- package/build/glasses-wifi/index.js +15 -0
- package/build/glasses-wifi/index.js.map +1 -0
- package/build/glasses-wifi/link.d.ts +31 -0
- package/build/glasses-wifi/link.d.ts.map +1 -0
- package/build/glasses-wifi/link.js +71 -0
- package/build/glasses-wifi/link.js.map +1 -0
- package/build/glasses-wifi/native.d.ts +63 -0
- package/build/glasses-wifi/native.d.ts.map +1 -0
- package/build/glasses-wifi/native.js +138 -0
- package/build/glasses-wifi/native.js.map +1 -0
- package/build/glasses-wifi/service.d.ts +86 -0
- package/build/glasses-wifi/service.d.ts.map +1 -0
- package/build/glasses-wifi/service.js +497 -0
- package/build/glasses-wifi/service.js.map +1 -0
- package/build/index.d.ts +4 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +24 -6
- package/build/index.js.map +1 -1
- package/build/ota-transport/index.d.ts +2 -43
- package/build/ota-transport/index.d.ts.map +1 -1
- package/build/ota-transport/index.js +3 -49
- package/build/ota-transport/index.js.map +1 -1
- package/build/react/useBluetoothStatus.d.ts.map +1 -1
- package/build/react/useBluetoothStatus.js +5 -24
- package/build/react/useBluetoothStatus.js.map +1 -1
- package/build/react/useMentraBluetooth.d.ts +1 -2
- package/build/react/useMentraBluetooth.d.ts.map +1 -1
- package/build/react/useMentraBluetooth.js +0 -1
- package/build/react/useMentraBluetooth.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/ios/MentraBluetoothSDK.podspec +5 -4
- package/ios/MentraLocalNetworkModule.swift +264 -0
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/ios/Source/hotspot/GlassesHotspotNetwork.swift +563 -0
- package/ios/Source/hotspot/HotspotAccessPurpose.swift +5 -0
- package/ios/Source/hotspot/HotspotAddressPolicy.swift +50 -0
- package/ios/Source/hotspot/HotspotInterfacePolicy.swift +155 -0
- package/ios/Source/hotspot/HotspotJoinFailure.swift +27 -0
- package/ios/Source/hotspot/HotspotLeaveCompletion.swift +24 -0
- package/ios/Source/hotspot/HotspotNetworkOwnership.swift +22 -0
- package/ios/Source/hotspot/HotspotReapplyPolicy.swift +26 -0
- package/ios/Source/hotspot/LocalNetworkAccessRequest.swift +160 -0
- package/ios/Source/hotspot/MacHotspotAssociation.swift +415 -0
- package/ios/Source/hotspot/MacHotspotAuthorization.swift +126 -0
- package/ios/Source/hotspot/MacHotspotAuthorizationFacts.swift +51 -0
- package/ios/Source/hotspot/MacHotspotCleanupContinuation.swift +35 -0
- package/ios/Tests/HotspotAddressPolicyTests.swift +30 -0
- package/ios/Tests/HotspotInterfacePolicyTests.swift +304 -0
- package/ios/Tests/HotspotJoinFailureTests.swift +37 -0
- package/ios/Tests/HotspotLeaveCompletionTests.swift +29 -0
- package/ios/Tests/HotspotReapplyPolicyTests.swift +18 -0
- package/ios/Tests/LocalNetworkAccessRequestTests.swift +237 -0
- package/ios/Tests/MacHotspotAssociationTests.swift +521 -0
- package/ios/Tests/MacHotspotAuthorizationFactsTests.swift +62 -0
- package/ios/Tests/MacHotspotAuthorizationTests.swift +348 -0
- package/ios/Tests/MacWifiInvocationTests.swift +76 -0
- package/package.json +7 -2
- package/plugin/build/withIos.d.ts +4 -0
- package/plugin/build/withIos.js +20 -1
- package/src/BluetoothSdk.types.ts +27 -5
- package/src/_internal.ts +1 -0
- package/src/_private/BluetoothSdkModule.ts +20 -10
- package/src/_private/MentraLocalNetworkModule.ts +22 -0
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/glasses-wifi/connection.ts +47 -0
- package/src/glasses-wifi/continuous.ts +177 -0
- package/src/glasses-wifi/files.ts +32 -0
- package/src/glasses-wifi/index.ts +24 -0
- package/src/glasses-wifi/link.ts +94 -0
- package/src/glasses-wifi/native.ts +193 -0
- package/src/glasses-wifi/service.ts +554 -0
- package/src/index.ts +34 -10
- package/src/ota-transport/index.ts +3 -85
- package/src/react/useBluetoothStatus.ts +5 -26
- package/src/react/useMentraBluetooth.ts +0 -3
|
@@ -13,36 +13,6 @@ export type {
|
|
|
13
13
|
|
|
14
14
|
export type OtaTransportSubscription = {remove(): void}
|
|
15
15
|
|
|
16
|
-
export type OtaLocalNetworkConnection = {
|
|
17
|
-
connected: boolean
|
|
18
|
-
ssid: string
|
|
19
|
-
localAddress?: string
|
|
20
|
-
/** The glasses' address on the joined network. */
|
|
21
|
-
gateway?: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type OtaLocalNetworkLostEvent = {ssid: string}
|
|
25
|
-
|
|
26
|
-
export type OtaLocalNetworkResponse = {
|
|
27
|
-
status: number
|
|
28
|
-
headers: Record<string, string>
|
|
29
|
-
bodyBase64: string
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type OtaLocalNetworkDownloadResult = {
|
|
33
|
-
statusCode: number
|
|
34
|
-
bytesWritten: number
|
|
35
|
-
headers: Record<string, string>
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type OtaLocalNetworkDownloadProgress = {
|
|
39
|
-
requestId: string
|
|
40
|
-
bytesWritten: number
|
|
41
|
-
contentLength: number
|
|
42
|
-
statusCode?: number
|
|
43
|
-
headers?: Record<string, string>
|
|
44
|
-
}
|
|
45
|
-
|
|
46
16
|
export type OtaArtifactDownloadProgress = {
|
|
47
17
|
destination: string
|
|
48
18
|
bytesWritten: number
|
|
@@ -57,65 +27,13 @@ export type OtaServerResult = {
|
|
|
57
27
|
}
|
|
58
28
|
|
|
59
29
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* The module is optional because iOS joins through glasses-media's hotspot owner instead.
|
|
30
|
+
* The phone's network as OTA sees it. The glasses Wi-Fi link, and every request over it, is the
|
|
31
|
+
* Bluetooth SDK's glasses Wi-Fi service's own.
|
|
64
32
|
*/
|
|
65
33
|
export const otaLocalNetwork = Object.freeze({
|
|
66
34
|
isAvailable: (): boolean => MentraLocalNetwork != null,
|
|
67
35
|
/** Synchronous local observation; no network I/O, route changes or network identities. */
|
|
68
|
-
getNetworkDiagnostics: (): NetworkDiagnostics | null => MentraLocalNetwork?.getNetworkDiagnostics() ?? null,
|
|
69
|
-
/** `incoming`: the glasses will connect to a server on this phone (OTA), not only the reverse. */
|
|
70
|
-
connect: async (ssid: string, password: string, incoming = true): Promise<OtaLocalNetworkConnection> => {
|
|
71
|
-
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
72
|
-
return MentraLocalNetwork.connect(ssid, password, incoming)
|
|
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,
|
|
81
|
-
request: async (
|
|
82
|
-
requestId: string,
|
|
83
|
-
url: string,
|
|
84
|
-
method: string,
|
|
85
|
-
headers: Record<string, string>,
|
|
86
|
-
body: string | null,
|
|
87
|
-
timeoutMs: number,
|
|
88
|
-
): Promise<OtaLocalNetworkResponse> => {
|
|
89
|
-
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
90
|
-
return MentraLocalNetwork.request(requestId, url, method, headers, body, timeoutMs)
|
|
91
|
-
},
|
|
92
|
-
download: async (
|
|
93
|
-
requestId: string,
|
|
94
|
-
url: string,
|
|
95
|
-
destination: string,
|
|
96
|
-
headers: Record<string, string>,
|
|
97
|
-
connectionTimeoutMs: number,
|
|
98
|
-
readTimeoutMs: number,
|
|
99
|
-
): Promise<OtaLocalNetworkDownloadResult> => {
|
|
100
|
-
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
101
|
-
return MentraLocalNetwork.download(requestId, url, destination, headers, connectionTimeoutMs, readTimeoutMs)
|
|
102
|
-
},
|
|
103
|
-
cancel: async (requestId: string): Promise<void> => {
|
|
104
|
-
if (!MentraLocalNetwork) return
|
|
105
|
-
await MentraLocalNetwork.cancel(requestId)
|
|
106
|
-
},
|
|
107
|
-
disconnect: async (): Promise<void> => {
|
|
108
|
-
if (!MentraLocalNetwork) return
|
|
109
|
-
await MentraLocalNetwork.disconnect()
|
|
110
|
-
},
|
|
111
|
-
onDownloadProgress: (listener: (event: OtaLocalNetworkDownloadProgress) => void): OtaTransportSubscription => {
|
|
112
|
-
if (!MentraLocalNetwork) return {remove() {}}
|
|
113
|
-
return MentraLocalNetwork.addListener("downloadProgress", listener)
|
|
114
|
-
},
|
|
115
|
-
onNetworkLost: (listener: (event: OtaLocalNetworkLostEvent) => void): OtaTransportSubscription => {
|
|
116
|
-
if (!MentraLocalNetwork) return {remove() {}}
|
|
117
|
-
return MentraLocalNetwork.addListener("networkLost", listener)
|
|
118
|
-
},
|
|
36
|
+
getNetworkDiagnostics: (): NetworkDiagnostics | null => MentraLocalNetwork?.getNetworkDiagnostics?.() ?? null,
|
|
119
37
|
})
|
|
120
38
|
|
|
121
39
|
/** Native HTTP server and artifact downloader used by the Engine OTA coordinator. */
|
|
@@ -5,11 +5,10 @@ import {
|
|
|
5
5
|
createDisconnectedGlassesStatus,
|
|
6
6
|
isConnectedGlassesConnectionStatus,
|
|
7
7
|
isReadyGlassesConnectionStatus,
|
|
8
|
+
publicGlassesStatus,
|
|
8
9
|
} from "../BluetoothSdk.types"
|
|
9
10
|
import type {
|
|
10
11
|
BatteryStatusEvent,
|
|
11
|
-
HotspotStatus,
|
|
12
|
-
HotspotStatusChangeEvent,
|
|
13
12
|
PublicBluetoothStatus,
|
|
14
13
|
PublicGlassesStatus,
|
|
15
14
|
WifiStatus,
|
|
@@ -40,23 +39,11 @@ function wifiStatusFromEvent(event: WifiStatusChangeEvent): WifiStatus {
|
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
function hotspotStatusFromEvent(event: HotspotStatusChangeEvent): HotspotStatus {
|
|
44
|
-
if (event.state === "enabled") {
|
|
45
|
-
return {
|
|
46
|
-
state: "enabled",
|
|
47
|
-
ssid: event.ssid,
|
|
48
|
-
password: event.password,
|
|
49
|
-
localIp: event.localIp,
|
|
50
|
-
...(event.frequency ? {frequency: event.frequency} : {}),
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return {state: event.state}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
42
|
function mergeGlassesStatus(
|
|
57
43
|
current: Partial<PublicGlassesStatus>,
|
|
58
|
-
|
|
44
|
+
update: Partial<PublicGlassesStatus>,
|
|
59
45
|
): Partial<PublicGlassesStatus> {
|
|
46
|
+
const changed = publicGlassesStatus(update)
|
|
60
47
|
if (changed.connection?.state === "disconnected") {
|
|
61
48
|
return {...createDisconnectedGlassesStatus(), ...changed}
|
|
62
49
|
}
|
|
@@ -84,7 +71,7 @@ export function useBluetoothStatus(options: UseBluetoothStatusOptions = {}): Blu
|
|
|
84
71
|
BluetoothSdk.getGlassesStatus(),
|
|
85
72
|
BluetoothSdk.getBluetoothStatus(),
|
|
86
73
|
])
|
|
87
|
-
setGlassesStatus(nextGlassesStatus)
|
|
74
|
+
setGlassesStatus(publicGlassesStatus(nextGlassesStatus))
|
|
88
75
|
setBluetoothStatus(nextBluetoothStatus)
|
|
89
76
|
setError(null)
|
|
90
77
|
} catch (nextError) {
|
|
@@ -113,7 +100,7 @@ export function useBluetoothStatus(options: UseBluetoothStatusOptions = {}): Blu
|
|
|
113
100
|
if (!mounted) {
|
|
114
101
|
return
|
|
115
102
|
}
|
|
116
|
-
setGlassesStatus(nextGlassesStatus)
|
|
103
|
+
setGlassesStatus(publicGlassesStatus(nextGlassesStatus))
|
|
117
104
|
setBluetoothStatus(nextBluetoothStatus)
|
|
118
105
|
setError(null)
|
|
119
106
|
} catch (nextError) {
|
|
@@ -147,12 +134,6 @@ export function useBluetoothStatus(options: UseBluetoothStatusOptions = {}): Blu
|
|
|
147
134
|
const wifiSubscription = BluetoothSdk.addListener("wifi_status_change", (event) => {
|
|
148
135
|
setGlassesStatus((current) => ({...current, wifi: wifiStatusFromEvent(event)}))
|
|
149
136
|
})
|
|
150
|
-
const hotspotSubscription = BluetoothSdk.addListener("hotspot_status_change", (event) => {
|
|
151
|
-
setGlassesStatus((current) => ({...current, hotspot: hotspotStatusFromEvent(event)}))
|
|
152
|
-
})
|
|
153
|
-
const hotspotErrorSubscription = BluetoothSdk.addListener("hotspot_error", () => {
|
|
154
|
-
setGlassesStatus((current) => ({...current, hotspot: {state: "disabled"}}))
|
|
155
|
-
})
|
|
156
137
|
|
|
157
138
|
return () => {
|
|
158
139
|
mounted = false
|
|
@@ -160,8 +141,6 @@ export function useBluetoothStatus(options: UseBluetoothStatusOptions = {}): Blu
|
|
|
160
141
|
removeBluetooth()
|
|
161
142
|
batterySubscription.remove()
|
|
162
143
|
wifiSubscription.remove()
|
|
163
|
-
hotspotSubscription.remove()
|
|
164
|
-
hotspotErrorSubscription.remove()
|
|
165
144
|
}
|
|
166
145
|
}, [enabled])
|
|
167
146
|
|
|
@@ -13,7 +13,6 @@ import type {
|
|
|
13
13
|
Device,
|
|
14
14
|
DeviceModel,
|
|
15
15
|
GlassesConnectionStatus,
|
|
16
|
-
HotspotStatus,
|
|
17
16
|
PublicBluetoothStatus,
|
|
18
17
|
PublicGlassesStatus,
|
|
19
18
|
MicMode,
|
|
@@ -76,7 +75,6 @@ export type GlassesRuntimeState =
|
|
|
76
75
|
connection: Extract<GlassesConnectionStatus, {state: "connected"}>
|
|
77
76
|
device: ConnectedGlassesInfo
|
|
78
77
|
firmware: FirmwareInfo
|
|
79
|
-
hotspot: HotspotStatus
|
|
80
78
|
ready: boolean
|
|
81
79
|
signal: SignalState
|
|
82
80
|
voiceActivityDetectionEnabled: boolean
|
|
@@ -223,7 +221,6 @@ function runtimeGlassesState(status: Partial<PublicGlassesStatus>): GlassesRunti
|
|
|
223
221
|
connection,
|
|
224
222
|
device: connectedGlassesInfo(status),
|
|
225
223
|
firmware: firmwareInfo(status),
|
|
226
|
-
hotspot: status.hotspot ?? {state: "disabled"},
|
|
227
224
|
ready: isReadyGlassesConnectionStatus(connection),
|
|
228
225
|
signal: {
|
|
229
226
|
strengthDbm: numberValue((status as Record<string, unknown>).signalStrength),
|