@mentra/bluetooth-sdk 0.1.13 → 0.1.16

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 (80) hide show
  1. package/README.md +18 -8
  2. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +48 -48
  3. package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +5 -20
  4. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +360 -269
  5. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +3 -7
  6. package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +152 -72
  7. package/android/src/main/java/com/mentra/bluetoothsdk/OtaManifest.kt +12 -12
  8. package/android/src/main/java/com/mentra/bluetoothsdk/camera/CameraModels.kt +25 -11
  9. package/android/src/main/java/com/mentra/bluetoothsdk/controllers/ControllerManager.kt +1 -2
  10. package/android/src/main/java/com/mentra/bluetoothsdk/controllers/R1.kt +1 -2
  11. package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +1 -22
  12. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G1.kt +51 -8
  13. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G2.kt +1184 -800
  14. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Mach1.kt +1 -5
  15. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +423 -117
  16. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraNex.kt +4 -6
  17. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +2532 -0
  18. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +17 -5
  19. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Simulated.kt +3 -7
  20. package/android/src/main/java/com/mentra/bluetoothsdk/status/DeviceStatus.kt +0 -6
  21. package/android/src/main/java/com/mentra/bluetoothsdk/streaming/StreamModels.kt +16 -33
  22. package/android/src/main/java/com/mentra/bluetoothsdk/types/DeviceModels.kt +5 -3
  23. package/android/src/main/java/com/mentra/bluetoothsdk/utils/Constants.kt +2 -1
  24. package/android/src/test/java/com/mentra/bluetoothsdk/camera/PhotoRequestTest.kt +60 -1
  25. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoProtocolTest.kt +333 -0
  26. package/build/BluetoothSdk.types.d.ts +50 -24
  27. package/build/BluetoothSdk.types.d.ts.map +1 -1
  28. package/build/BluetoothSdk.types.js +1 -0
  29. package/build/BluetoothSdk.types.js.map +1 -1
  30. package/build/_internal.d.ts +4 -4
  31. package/build/_internal.js +4 -4
  32. package/build/_internal.js.map +1 -1
  33. package/build/_private/BluetoothSdkModule.d.ts +14 -8
  34. package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
  35. package/build/_private/BluetoothSdkModule.js +4 -3
  36. package/build/_private/BluetoothSdkModule.js.map +1 -1
  37. package/build/_private/cameraRequestPayload.d.ts +4 -0
  38. package/build/_private/cameraRequestPayload.d.ts.map +1 -0
  39. package/build/_private/cameraRequestPayload.js +25 -0
  40. package/build/_private/cameraRequestPayload.js.map +1 -0
  41. package/build/_private/photoRequestPayload.d.ts.map +1 -1
  42. package/build/_private/photoRequestPayload.js +11 -3
  43. package/build/_private/photoRequestPayload.js.map +1 -1
  44. package/build/index.d.ts +1 -1
  45. package/build/index.d.ts.map +1 -1
  46. package/build/index.js +70 -61
  47. package/build/index.js.map +1 -1
  48. package/ios/BluetoothSdkModule.swift +51 -28
  49. package/ios/Source/Bridge.swift +4 -16
  50. package/ios/Source/DeviceManager.swift +76 -22
  51. package/ios/Source/DeviceStore.swift +0 -4
  52. package/ios/Source/MentraBluetoothSDK.swift +144 -78
  53. package/ios/Source/OtaManifest.swift +13 -13
  54. package/ios/Source/camera/CameraModels.swift +82 -20
  55. package/ios/Source/controllers/ControllerManager.swift +1 -2
  56. package/ios/Source/controllers/R1.swift +1 -2
  57. package/ios/Source/errors/{BluetoothError.swift → BluetoothSdkError.swift} +1 -1
  58. package/ios/Source/events/BluetoothEvents.swift +5 -27
  59. package/ios/Source/internal/BluetoothAvailability.swift +5 -5
  60. package/ios/Source/sgcs/Frame.swift +0 -2
  61. package/ios/Source/sgcs/G1.swift +52 -4
  62. package/ios/Source/sgcs/G2.swift +643 -204
  63. package/ios/Source/sgcs/Mach1.swift +1 -3
  64. package/ios/Source/sgcs/MentraLive.swift +64 -77
  65. package/ios/Source/sgcs/MentraNex.swift +1 -3
  66. package/ios/Source/sgcs/Nimo.swift +1928 -0
  67. package/ios/Source/sgcs/SGCManager.swift +16 -10
  68. package/ios/Source/sgcs/Simulated.swift +2 -6
  69. package/ios/Source/status/DeviceStatus.swift +0 -8
  70. package/ios/Source/streaming/StreamModels.swift +7 -32
  71. package/ios/Source/stt/STTTools.swift +1 -1
  72. package/ios/Source/types/DeviceModels.swift +5 -0
  73. package/ios/Source/utils/Constants.swift +2 -0
  74. package/package.json +6 -1
  75. package/src/BluetoothSdk.types.ts +54 -28
  76. package/src/_internal.ts +4 -4
  77. package/src/_private/BluetoothSdkModule.ts +20 -11
  78. package/src/_private/cameraRequestPayload.ts +29 -0
  79. package/src/_private/photoRequestPayload.ts +12 -3
  80. package/src/index.ts +77 -67
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@ import type {
3
3
  BluetoothSdkEventListener,
4
4
  BluetoothSdkEventName,
5
5
  BluetoothSdkPublicModule,
6
- ButtonPhotoSettings,
6
+ VideoRecordingDefaults,
7
7
  } from "./BluetoothSdk.types"
8
8
 
9
9
  const PUBLIC_EVENT_NAMES = new Set<BluetoothSdkEventName>([
@@ -25,6 +25,7 @@ const PUBLIC_EVENT_NAMES = new Set<BluetoothSdkEventName>([
25
25
  "hotspot_error",
26
26
  "photo_response",
27
27
  "photo_status",
28
+ "camera_status",
28
29
  "video_recording_status",
29
30
  "media_success",
30
31
  "media_error",
@@ -58,74 +59,84 @@ const startOtaUpdate: BluetoothSdkPublicModule["startOtaUpdate"] = () => {
58
59
  return PrivateBluetoothSdkModule.startOtaUpdate()
59
60
  }
60
61
 
62
+ const bindPublicMethod = <K extends keyof BluetoothSdkPublicModule>(name: K): BluetoothSdkPublicModule[K] => {
63
+ const method = (PrivateBluetoothSdkModule as unknown as Record<string, unknown>)[name]
64
+ if (typeof method === "function") {
65
+ return method.bind(PrivateBluetoothSdkModule) as BluetoothSdkPublicModule[K]
66
+ }
67
+
68
+ return (async () => {
69
+ throw new Error(`BluetoothSdk.${String(name)} is not available in this native build. Rebuild the app.`)
70
+ }) as unknown as BluetoothSdkPublicModule[K]
71
+ }
72
+
61
73
  export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
62
74
  addListener,
63
- getDefaultDevice: PrivateBluetoothSdkModule.getDefaultDevice.bind(PrivateBluetoothSdkModule),
64
- setDefaultDevice: PrivateBluetoothSdkModule.setDefaultDevice.bind(PrivateBluetoothSdkModule),
65
- clearDefaultDevice: PrivateBluetoothSdkModule.clearDefaultDevice.bind(PrivateBluetoothSdkModule),
66
- startScan: PrivateBluetoothSdkModule.startScan.bind(PrivateBluetoothSdkModule),
67
- stopScan: PrivateBluetoothSdkModule.stopScan.bind(PrivateBluetoothSdkModule),
68
- scan: PrivateBluetoothSdkModule.scan.bind(PrivateBluetoothSdkModule) as BluetoothSdkPublicModule["scan"],
69
- connect: PrivateBluetoothSdkModule.connect.bind(PrivateBluetoothSdkModule),
70
- connectDefault: PrivateBluetoothSdkModule.connectDefault.bind(PrivateBluetoothSdkModule),
71
- cancelConnectionAttempt: PrivateBluetoothSdkModule.cancelConnectionAttempt.bind(PrivateBluetoothSdkModule),
72
- disconnect: PrivateBluetoothSdkModule.disconnect.bind(PrivateBluetoothSdkModule),
73
- forget: PrivateBluetoothSdkModule.forget.bind(PrivateBluetoothSdkModule),
74
- displayText: PrivateBluetoothSdkModule.displayText.bind(PrivateBluetoothSdkModule),
75
- clearDisplay: PrivateBluetoothSdkModule.clearDisplay.bind(PrivateBluetoothSdkModule),
76
- showDashboard: PrivateBluetoothSdkModule.showDashboard.bind(PrivateBluetoothSdkModule),
77
- setDashboardPosition: PrivateBluetoothSdkModule.setDashboardPosition.bind(PrivateBluetoothSdkModule),
78
- setHeadUpAngle: PrivateBluetoothSdkModule.setHeadUpAngle.bind(PrivateBluetoothSdkModule),
79
- setImuEnabled: PrivateBluetoothSdkModule.setImuEnabled.bind(PrivateBluetoothSdkModule),
80
- setScreenDisabled: PrivateBluetoothSdkModule.setScreenDisabled.bind(PrivateBluetoothSdkModule),
81
- requestWifiScan: PrivateBluetoothSdkModule.requestWifiScan.bind(PrivateBluetoothSdkModule),
82
- sendWifiCredentials: PrivateBluetoothSdkModule.sendWifiCredentials.bind(PrivateBluetoothSdkModule),
83
- forgetWifiNetwork: PrivateBluetoothSdkModule.forgetWifiNetwork.bind(PrivateBluetoothSdkModule),
84
- setHotspotState: PrivateBluetoothSdkModule.setHotspotState.bind(PrivateBluetoothSdkModule),
85
- setGalleryModeEnabled: PrivateBluetoothSdkModule.setGalleryModeEnabled.bind(PrivateBluetoothSdkModule),
86
- setVoiceActivityDetectionEnabled:
87
- PrivateBluetoothSdkModule.setVoiceActivityDetectionEnabled.bind(PrivateBluetoothSdkModule),
88
- setButtonPhotoSettings: (settings: ButtonPhotoSettings) => {
89
- // setButtonPhotoCaptureSettings is available in SDK 0.1.13+. Guard for OTA version-skew
90
- // where a new JS bundle runs against an older native module that only has the string form.
91
- if (typeof PrivateBluetoothSdkModule.setButtonPhotoCaptureSettings === "function") {
92
- return PrivateBluetoothSdkModule.setButtonPhotoCaptureSettings(settings)
75
+ getDefaultDevice: bindPublicMethod("getDefaultDevice"),
76
+ setDefaultDevice: bindPublicMethod("setDefaultDevice"),
77
+ clearDefaultDevice: bindPublicMethod("clearDefaultDevice"),
78
+ startScan: bindPublicMethod("startScan"),
79
+ stopScan: bindPublicMethod("stopScan"),
80
+ scan: bindPublicMethod("scan") as BluetoothSdkPublicModule["scan"],
81
+ connect: bindPublicMethod("connect"),
82
+ connectDefault: bindPublicMethod("connectDefault"),
83
+ cancelConnectionAttempt: bindPublicMethod("cancelConnectionAttempt"),
84
+ disconnect: bindPublicMethod("disconnect"),
85
+ forget: bindPublicMethod("forget"),
86
+ displayText: bindPublicMethod("displayText"),
87
+ clearDisplay: bindPublicMethod("clearDisplay"),
88
+ showDashboard: bindPublicMethod("showDashboard"),
89
+ setDashboardPosition: bindPublicMethod("setDashboardPosition"),
90
+ setHeadUpAngle: bindPublicMethod("setHeadUpAngle"),
91
+ setImuEnabled: bindPublicMethod("setImuEnabled"),
92
+ setScreenDisabled: bindPublicMethod("setScreenDisabled"),
93
+ requestWifiScan: bindPublicMethod("requestWifiScan"),
94
+ sendWifiCredentials: bindPublicMethod("sendWifiCredentials"),
95
+ forgetWifiNetwork: bindPublicMethod("forgetWifiNetwork"),
96
+ setHotspotState: bindPublicMethod("setHotspotState"),
97
+ setGalleryModeEnabled: bindPublicMethod("setGalleryModeEnabled"),
98
+ setVoiceActivityDetectionEnabled: bindPublicMethod("setVoiceActivityDetectionEnabled"),
99
+ setPhotoCaptureDefaults: bindPublicMethod("setPhotoCaptureDefaults"),
100
+ setVideoRecordingDefaults: ({width, height, fps}: VideoRecordingDefaults) => {
101
+ const method = (PrivateBluetoothSdkModule as unknown as Record<string, unknown>).setVideoRecordingDefaults
102
+ if (typeof method !== "function") {
103
+ return Promise.reject(
104
+ new Error("BluetoothSdk.setVideoRecordingDefaults is not available in this native build. Rebuild the app."),
105
+ )
93
106
  }
94
- // Legacy fallback: old native bridge only accepts a size string
95
- return PrivateBluetoothSdkModule.setButtonPhotoSettings({size: settings.size ?? "max"} as any)
107
+ return PrivateBluetoothSdkModule.setVideoRecordingDefaults(width, height, fps)
96
108
  },
97
- setButtonVideoRecordingSettings:
98
- PrivateBluetoothSdkModule.setButtonVideoRecordingSettings.bind(PrivateBluetoothSdkModule),
99
- setButtonCameraLed: PrivateBluetoothSdkModule.setButtonCameraLed.bind(PrivateBluetoothSdkModule),
100
- setButtonMaxRecordingTime: PrivateBluetoothSdkModule.setButtonMaxRecordingTime.bind(PrivateBluetoothSdkModule),
101
- setCameraFov: PrivateBluetoothSdkModule.setCameraFov.bind(PrivateBluetoothSdkModule),
102
- queryGalleryStatus: PrivateBluetoothSdkModule.queryGalleryStatus.bind(PrivateBluetoothSdkModule),
103
- requestPhoto: PrivateBluetoothSdkModule.requestPhoto.bind(PrivateBluetoothSdkModule),
104
- startVideoRecording: PrivateBluetoothSdkModule.startVideoRecording.bind(PrivateBluetoothSdkModule),
105
- stopVideoRecording: PrivateBluetoothSdkModule.stopVideoRecording.bind(PrivateBluetoothSdkModule),
106
- startStream: PrivateBluetoothSdkModule.startStream.bind(PrivateBluetoothSdkModule),
107
- stopStream: PrivateBluetoothSdkModule.stopStream.bind(PrivateBluetoothSdkModule),
108
- setMicState: PrivateBluetoothSdkModule.setMicState.bind(PrivateBluetoothSdkModule),
109
- setPreferredMic: PrivateBluetoothSdkModule.setPreferredMic.bind(PrivateBluetoothSdkModule),
110
- setOwnAppAudioPlaying: PrivateBluetoothSdkModule.setOwnAppAudioPlaying.bind(PrivateBluetoothSdkModule),
111
- getGlassesMediaVolume: PrivateBluetoothSdkModule.getGlassesMediaVolume.bind(PrivateBluetoothSdkModule),
112
- setGlassesMediaVolume: PrivateBluetoothSdkModule.setGlassesMediaVolume.bind(PrivateBluetoothSdkModule),
113
- rgbLedControl: PrivateBluetoothSdkModule.rgbLedControl.bind(PrivateBluetoothSdkModule),
114
- requestVersionInfo: PrivateBluetoothSdkModule.requestVersionInfo.bind(PrivateBluetoothSdkModule),
115
- checkForOtaUpdate: PrivateBluetoothSdkModule.checkForOtaUpdate.bind(PrivateBluetoothSdkModule),
109
+ setMaxVideoRecordingDuration: bindPublicMethod("setMaxVideoRecordingDuration"),
110
+ setCameraFov: bindPublicMethod("setCameraFov"),
111
+ setCameraTuningConfig: bindPublicMethod("setCameraTuningConfig"),
112
+ queryGalleryStatus: bindPublicMethod("queryGalleryStatus"),
113
+ requestPhoto: bindPublicMethod("requestPhoto"),
114
+ warmUpCamera: bindPublicMethod("warmUpCamera"),
115
+ startVideoRecording: bindPublicMethod("startVideoRecording"),
116
+ stopVideoRecording: bindPublicMethod("stopVideoRecording"),
117
+ startStream: bindPublicMethod("startStream"),
118
+ stopStream: bindPublicMethod("stopStream"),
119
+ setMicState: bindPublicMethod("setMicState"),
120
+ setPreferredMic: bindPublicMethod("setPreferredMic"),
121
+ setOwnAppAudioPlaying: bindPublicMethod("setOwnAppAudioPlaying"),
122
+ getGlassesMediaVolume: bindPublicMethod("getGlassesMediaVolume"),
123
+ setGlassesMediaVolume: bindPublicMethod("setGlassesMediaVolume"),
124
+ rgbLedControl: bindPublicMethod("rgbLedControl"),
125
+ requestVersionInfo: bindPublicMethod("requestVersionInfo"),
126
+ checkForOtaUpdate: bindPublicMethod("checkForOtaUpdate"),
116
127
  startOtaUpdate,
117
- setSttModelDetails: PrivateBluetoothSdkModule.setSttModelDetails.bind(PrivateBluetoothSdkModule),
118
- getSttModelPath: PrivateBluetoothSdkModule.getSttModelPath.bind(PrivateBluetoothSdkModule),
119
- checkSttModelAvailable: PrivateBluetoothSdkModule.checkSttModelAvailable.bind(PrivateBluetoothSdkModule),
120
- validateSttModel: PrivateBluetoothSdkModule.validateSttModel.bind(PrivateBluetoothSdkModule),
121
- extractTarBz2: PrivateBluetoothSdkModule.extractTarBz2.bind(PrivateBluetoothSdkModule),
122
- restartTranscriber: PrivateBluetoothSdkModule.restartTranscriber.bind(PrivateBluetoothSdkModule),
123
- setTtsModelDetails: PrivateBluetoothSdkModule.setTtsModelDetails.bind(PrivateBluetoothSdkModule),
124
- getTtsModelPath: PrivateBluetoothSdkModule.getTtsModelPath.bind(PrivateBluetoothSdkModule),
125
- getTtsModelLanguage: PrivateBluetoothSdkModule.getTtsModelLanguage.bind(PrivateBluetoothSdkModule),
126
- checkTtsModelAvailable: PrivateBluetoothSdkModule.checkTtsModelAvailable.bind(PrivateBluetoothSdkModule),
127
- validateTtsModel: PrivateBluetoothSdkModule.validateTtsModel.bind(PrivateBluetoothSdkModule),
128
- generateTtsAudio: PrivateBluetoothSdkModule.generateTtsAudio.bind(PrivateBluetoothSdkModule),
128
+ setSttModelDetails: bindPublicMethod("setSttModelDetails"),
129
+ getSttModelPath: bindPublicMethod("getSttModelPath"),
130
+ checkSttModelAvailable: bindPublicMethod("checkSttModelAvailable"),
131
+ validateSttModel: bindPublicMethod("validateSttModel"),
132
+ extractTarBz2: bindPublicMethod("extractTarBz2"),
133
+ restartTranscriber: bindPublicMethod("restartTranscriber"),
134
+ setTtsModelDetails: bindPublicMethod("setTtsModelDetails"),
135
+ getTtsModelPath: bindPublicMethod("getTtsModelPath"),
136
+ getTtsModelLanguage: bindPublicMethod("getTtsModelLanguage"),
137
+ checkTtsModelAvailable: bindPublicMethod("checkTtsModelAvailable"),
138
+ validateTtsModel: bindPublicMethod("validateTtsModel"),
139
+ generateTtsAudio: bindPublicMethod("generateTtsAudio"),
129
140
  })
130
141
 
131
142
  export default BluetoothSdk
@@ -155,7 +166,7 @@ export type {
155
166
  BluetoothSdkPublicModule as BluetoothSdkModule,
156
167
  BluetoothSdkSubscription,
157
168
  ButtonPhotoSize,
158
- ButtonPhotoSettings,
169
+ PhotoCaptureDefaults,
159
170
  ButtonPressEvent,
160
171
  CameraFovPreset,
161
172
  CameraFovRequest,
@@ -187,8 +198,6 @@ export type {
187
198
  OtaStatus,
188
199
  OtaStatusEvent,
189
200
  OtaQueryResult,
190
- OtaUpdateAvailableEvent,
191
- OtaUpdateInfo,
192
201
  PairFailureEvent,
193
202
  PhotoCaptureMetadata,
194
203
  PhotoResolvedConfig,
@@ -226,6 +235,7 @@ export type {
226
235
  SwipeVolumeStatusEvent,
227
236
  SwitchStatusEvent,
228
237
  TouchEvent,
238
+ VideoRecordingDefaults,
229
239
  VideoRecordingStartedStatusEvent,
230
240
  VideoRecordingStatusEvent,
231
241
  VideoRecordingStatusState,