@mentra/bluetooth-sdk 3.5.0-dev.1518 → 3.5.0-dev.1520

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.
Files changed (110) hide show
  1. package/MIGRATION.md +9 -0
  2. package/README.md +64 -11
  3. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
  4. package/android/src/main/java/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt +10 -0
  5. package/build/BluetoothSdk.types.d.ts +23 -5
  6. package/build/BluetoothSdk.types.d.ts.map +1 -1
  7. package/build/BluetoothSdk.types.js +5 -0
  8. package/build/BluetoothSdk.types.js.map +1 -1
  9. package/build/_internal.d.ts +1 -0
  10. package/build/_internal.d.ts.map +1 -1
  11. package/build/_internal.js +1 -0
  12. package/build/_internal.js.map +1 -1
  13. package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
  14. package/build/_private/BluetoothSdkModule.js +20 -9
  15. package/build/_private/BluetoothSdkModule.js.map +1 -1
  16. package/build/_private/MentraLocalNetworkModule.d.ts +21 -0
  17. package/build/_private/MentraLocalNetworkModule.d.ts.map +1 -1
  18. package/build/_private/MentraLocalNetworkModule.js.map +1 -1
  19. package/build/generated/releaseMetadata.js +5 -5
  20. package/build/generated/releaseMetadata.js.map +1 -1
  21. package/build/glasses-wifi/connection.d.ts +6 -0
  22. package/build/glasses-wifi/connection.d.ts.map +1 -0
  23. package/build/glasses-wifi/connection.js +44 -0
  24. package/build/glasses-wifi/connection.js.map +1 -0
  25. package/build/glasses-wifi/continuous.d.ts +39 -0
  26. package/build/glasses-wifi/continuous.d.ts.map +1 -0
  27. package/build/glasses-wifi/continuous.js +151 -0
  28. package/build/glasses-wifi/continuous.js.map +1 -0
  29. package/build/glasses-wifi/files.d.ts +11 -0
  30. package/build/glasses-wifi/files.d.ts.map +1 -0
  31. package/build/glasses-wifi/files.js +33 -0
  32. package/build/glasses-wifi/files.js.map +1 -0
  33. package/build/glasses-wifi/index.d.ts +20 -0
  34. package/build/glasses-wifi/index.d.ts.map +1 -0
  35. package/build/glasses-wifi/index.js +15 -0
  36. package/build/glasses-wifi/index.js.map +1 -0
  37. package/build/glasses-wifi/link.d.ts +31 -0
  38. package/build/glasses-wifi/link.d.ts.map +1 -0
  39. package/build/glasses-wifi/link.js +71 -0
  40. package/build/glasses-wifi/link.js.map +1 -0
  41. package/build/glasses-wifi/native.d.ts +63 -0
  42. package/build/glasses-wifi/native.d.ts.map +1 -0
  43. package/build/glasses-wifi/native.js +138 -0
  44. package/build/glasses-wifi/native.js.map +1 -0
  45. package/build/glasses-wifi/service.d.ts +86 -0
  46. package/build/glasses-wifi/service.d.ts.map +1 -0
  47. package/build/glasses-wifi/service.js +497 -0
  48. package/build/glasses-wifi/service.js.map +1 -0
  49. package/build/index.d.ts +4 -2
  50. package/build/index.d.ts.map +1 -1
  51. package/build/index.js +24 -6
  52. package/build/index.js.map +1 -1
  53. package/build/ota-transport/index.d.ts +2 -43
  54. package/build/ota-transport/index.d.ts.map +1 -1
  55. package/build/ota-transport/index.js +3 -49
  56. package/build/ota-transport/index.js.map +1 -1
  57. package/build/react/useBluetoothStatus.d.ts.map +1 -1
  58. package/build/react/useBluetoothStatus.js +5 -24
  59. package/build/react/useBluetoothStatus.js.map +1 -1
  60. package/build/react/useMentraBluetooth.d.ts +1 -2
  61. package/build/react/useMentraBluetooth.d.ts.map +1 -1
  62. package/build/react/useMentraBluetooth.js +0 -1
  63. package/build/react/useMentraBluetooth.js.map +1 -1
  64. package/expo-module.config.json +1 -1
  65. package/ios/MentraBluetoothSDK.podspec +5 -4
  66. package/ios/MentraLocalNetworkModule.swift +264 -0
  67. package/ios/Source/BluetoothSdkDefaults.swift +1 -1
  68. package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
  69. package/ios/Source/hotspot/GlassesHotspotNetwork.swift +563 -0
  70. package/ios/Source/hotspot/HotspotAccessPurpose.swift +5 -0
  71. package/ios/Source/hotspot/HotspotAddressPolicy.swift +50 -0
  72. package/ios/Source/hotspot/HotspotInterfacePolicy.swift +155 -0
  73. package/ios/Source/hotspot/HotspotJoinFailure.swift +27 -0
  74. package/ios/Source/hotspot/HotspotLeaveCompletion.swift +24 -0
  75. package/ios/Source/hotspot/HotspotNetworkOwnership.swift +22 -0
  76. package/ios/Source/hotspot/HotspotReapplyPolicy.swift +26 -0
  77. package/ios/Source/hotspot/LocalNetworkAccessRequest.swift +160 -0
  78. package/ios/Source/hotspot/MacHotspotAssociation.swift +415 -0
  79. package/ios/Source/hotspot/MacHotspotAuthorization.swift +126 -0
  80. package/ios/Source/hotspot/MacHotspotAuthorizationFacts.swift +51 -0
  81. package/ios/Source/hotspot/MacHotspotCleanupContinuation.swift +35 -0
  82. package/ios/Tests/HotspotAddressPolicyTests.swift +30 -0
  83. package/ios/Tests/HotspotInterfacePolicyTests.swift +304 -0
  84. package/ios/Tests/HotspotJoinFailureTests.swift +37 -0
  85. package/ios/Tests/HotspotLeaveCompletionTests.swift +29 -0
  86. package/ios/Tests/HotspotReapplyPolicyTests.swift +18 -0
  87. package/ios/Tests/LocalNetworkAccessRequestTests.swift +237 -0
  88. package/ios/Tests/MacHotspotAssociationTests.swift +521 -0
  89. package/ios/Tests/MacHotspotAuthorizationFactsTests.swift +62 -0
  90. package/ios/Tests/MacHotspotAuthorizationTests.swift +348 -0
  91. package/ios/Tests/MacWifiInvocationTests.swift +76 -0
  92. package/package.json +7 -2
  93. package/plugin/build/withIos.d.ts +4 -0
  94. package/plugin/build/withIos.js +20 -1
  95. package/src/BluetoothSdk.types.ts +27 -5
  96. package/src/_internal.ts +1 -0
  97. package/src/_private/BluetoothSdkModule.ts +20 -10
  98. package/src/_private/MentraLocalNetworkModule.ts +22 -0
  99. package/src/generated/releaseMetadata.ts +5 -5
  100. package/src/glasses-wifi/connection.ts +47 -0
  101. package/src/glasses-wifi/continuous.ts +177 -0
  102. package/src/glasses-wifi/files.ts +32 -0
  103. package/src/glasses-wifi/index.ts +24 -0
  104. package/src/glasses-wifi/link.ts +94 -0
  105. package/src/glasses-wifi/native.ts +193 -0
  106. package/src/glasses-wifi/service.ts +554 -0
  107. package/src/index.ts +34 -10
  108. package/src/ota-transport/index.ts +3 -85
  109. package/src/react/useBluetoothStatus.ts +5 -26
  110. 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
- * Scoped networking for traffic that must stay on a Mentra Live hotspot while
61
- * the phone's default route remains on cellular or another Wi-Fi network.
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
- changed: Partial<PublicGlassesStatus>,
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),