@mentra/bluetooth-sdk 3.1.0-dev.20 → 3.1.0-dev.22
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 +15 -20
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +4 -4
- package/build/BluetoothSdk.types.d.ts +18 -0
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/generated/releaseMetadata.js +4 -4
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +12 -0
- package/build/index.js.map +1 -1
- package/build/ota-transport/index.d.ts +67 -0
- package/build/ota-transport/index.d.ts.map +1 -0
- package/build/ota-transport/index.js +58 -0
- package/build/ota-transport/index.js.map +1 -0
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/GeneratedReleaseMetadata.swift +4 -4
- package/package.json +6 -1
- package/scripts/public-ota-api.test.mjs +37 -0
- package/src/BluetoothSdk.types.ts +19 -0
- package/src/generated/releaseMetadata.ts +4 -4
- package/src/index.ts +21 -0
- package/src/ota-transport/index.ts +116 -0
package/build/index.js
CHANGED
|
@@ -39,6 +39,8 @@ const PUBLIC_EVENT_NAMES = new Set([
|
|
|
39
39
|
"mic_lc3",
|
|
40
40
|
"mic_health",
|
|
41
41
|
"stream_status",
|
|
42
|
+
"mtk_update_complete",
|
|
43
|
+
"glasses_session_changed",
|
|
42
44
|
"ota_start_ack",
|
|
43
45
|
"ota_status",
|
|
44
46
|
"ar99_ota_status",
|
|
@@ -54,6 +56,9 @@ const addListener = (eventName, listener) => {
|
|
|
54
56
|
const startOtaUpdate = (otaVersionUrl) => {
|
|
55
57
|
return PrivateBluetoothSdkModule.startOtaUpdate(otaVersionUrl);
|
|
56
58
|
};
|
|
59
|
+
const queryOtaStatus = () => {
|
|
60
|
+
return PrivateBluetoothSdkModule.sendOtaQueryStatus();
|
|
61
|
+
};
|
|
57
62
|
const bindPublicMethod = (name) => {
|
|
58
63
|
const method = PrivateBluetoothSdkModule[name];
|
|
59
64
|
if (typeof method === "function") {
|
|
@@ -65,6 +70,10 @@ const bindPublicMethod = (name) => {
|
|
|
65
70
|
};
|
|
66
71
|
export const BluetoothSdk = Object.freeze({
|
|
67
72
|
addListener,
|
|
73
|
+
getGlassesStatus: bindPublicMethod("getGlassesStatus"),
|
|
74
|
+
getBluetoothStatus: bindPublicMethod("getBluetoothStatus"),
|
|
75
|
+
subscribeGlassesStatus: (listener) => PrivateBluetoothSdkModule.onGlassesStatus(listener),
|
|
76
|
+
subscribeBluetoothStatus: (listener) => PrivateBluetoothSdkModule.onBluetoothStatus(listener),
|
|
68
77
|
getDefaultDevice: bindPublicMethod("getDefaultDevice"),
|
|
69
78
|
setDefaultDevice: bindPublicMethod("setDefaultDevice"),
|
|
70
79
|
clearDefaultDevice: bindPublicMethod("clearDefaultDevice"),
|
|
@@ -83,10 +92,12 @@ export const BluetoothSdk = Object.freeze({
|
|
|
83
92
|
setHeadUpAngle: bindPublicMethod("setHeadUpAngle"),
|
|
84
93
|
setImuEnabled: bindPublicMethod("setImuEnabled"),
|
|
85
94
|
setScreenDisabled: bindPublicMethod("setScreenDisabled"),
|
|
95
|
+
ping: bindPublicMethod("ping"),
|
|
86
96
|
requestWifiScan: bindPublicMethod("requestWifiScan"),
|
|
87
97
|
sendWifiCredentials: bindPublicMethod("sendWifiCredentials"),
|
|
88
98
|
forgetWifiNetwork: bindPublicMethod("forgetWifiNetwork"),
|
|
89
99
|
setHotspotState: bindPublicMethod("setHotspotState"),
|
|
100
|
+
setSystemTime: bindPublicMethod("setSystemTime"),
|
|
90
101
|
setWifiAdbState: bindPublicMethod("setWifiAdbState"),
|
|
91
102
|
setGalleryModeEnabled: bindPublicMethod("setGalleryModeEnabled"),
|
|
92
103
|
setVoiceActivityDetectionEnabled: bindPublicMethod("setVoiceActivityDetectionEnabled"),
|
|
@@ -130,6 +141,7 @@ export const BluetoothSdk = Object.freeze({
|
|
|
130
141
|
getOtaVersionUrl: bindPublicMethod("getOtaVersionUrl"),
|
|
131
142
|
checkForOtaUpdate: bindPublicMethod("checkForOtaUpdate"),
|
|
132
143
|
startOtaUpdate,
|
|
144
|
+
queryOtaStatus,
|
|
133
145
|
startAr99OtaFromFile: bindPublicMethod("startAr99OtaFromFile"),
|
|
134
146
|
cancelAr99Ota: bindPublicMethod("cancelAr99Ota"),
|
|
135
147
|
sendAr99FactoryReset: bindPublicMethod("sendAr99FactoryReset"),
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,MAAM,+BAA+B,CAAA;AAQrE,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAwB;IACxD,KAAK;IACL,mBAAmB;IACnB,wBAAwB;IACxB,mBAAmB;IACnB,cAAc;IACd,aAAa;IACb,aAAa;IACb,SAAS;IACT,iCAAiC;IACjC,iBAAiB;IACjB,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,uBAAuB;IACvB,eAAe;IACf,gBAAgB;IAChB,cAAc;IACd,eAAe;IACf,wBAAwB;IACxB,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,gCAAgC;IAChC,qBAAqB;IACrB,eAAe;IACf,0BAA0B;IAC1B,cAAc;IACd,cAAc;IACd,cAAc;IACd,uBAAuB;IACvB,gBAAgB;IAChB,sBAAsB;IACtB,iBAAiB;IACjB,oBAAoB;IACpB,SAAS;IACT,SAAS;IACT,YAAY;IACZ,eAAe;IACf,eAAe;IACf,YAAY;IACZ,iBAAiB;IACjB,cAAc;IACd,qBAAqB;CACtB,CAAC,CAAA;AAEF,MAAM,WAAW,GAA4C,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE;IACnF,IAAI,CAAC,kBAAkB,CAAC,GAA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AgB,CAAC,sBAAsB,CAAC;IAC9D,aAAa,EAAE,gBAAgB,CAAC,eAAe,CAAC;IAChD,oBAAoB,EAAE,gBAAgB,CAAC,sBAAsB,CAAC;IAC9D,qBAAqB,EAAE,gBAAgB,CAAC,uBAAuB,CAAC;IAChE,kBAAkB,EAAE,gBAAgB,CAAC,oBAAoB,CAAC;IAC1D,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAAC;IACpD,sBAAsB,EAAE,gBAAgB,CAAC,wBAAwB,CAAC;IAClE,gBAAgB,EAAE,gBAAgB,CAAC,kBAAkB,CAAC;IACtD,aAAa,EAAE,gBAAgB,CAAC,eAAe,CAAC;IAChD,kBAAkB,EAAE,gBAAgB,CAAC,oBAAoB,CAAC;IAC1D,kBAAkB,EAAE,gBAAgB,CAAC,oBAAoB,CAAC;IAC1D,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAAC;IACpD,mBAAmB,EAAE,gBAAgB,CAAC,qBAAqB,CAAC;IAC5D,sBAAsB,EAAE,gBAAgB,CAAC,wBAAwB,CAAC;IAClE,gBAAgB,EAAE,gBAAgB,CAAC,kBAAkB,CAAC;IACtD,gBAAgB,EAAE,gBAAgB,CAAC,kBAAkB,CAAC;CACvD,CAAC,CAAA;AAEF,eAAe,YAAY,CAAA;AAE3B,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,6BAA6B,EAC7B,kCAAkC,EAClC,qBAAqB,EACrB,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,sBAAsB,CAAA","sourcesContent":["import PrivateBluetoothSdkModule from \"./_private/BluetoothSdkModule\"\nimport type {\n BluetoothSdkEventListener,\n BluetoothSdkEventName,\n BluetoothSdkPublicModule,\n VideoRecordingDefaults,\n} from \"./BluetoothSdk.types\"\n\nconst PUBLIC_EVENT_NAMES = new Set<BluetoothSdkEventName>([\n \"log\",\n \"device_discovered\",\n \"default_device_changed\",\n \"glasses_not_ready\",\n \"button_press\",\n \"touch_event\",\n \"accel_event\",\n \"head_up\",\n \"voice_activity_detection_status\",\n \"speaking_status\",\n \"battery_status\",\n \"local_transcription\",\n \"wifi_status_change\",\n \"wifi_scan_result\",\n \"hotspot_status_change\",\n \"hotspot_error\",\n \"photo_response\",\n \"photo_status\",\n \"camera_status\",\n \"video_recording_status\",\n \"media_success\",\n \"media_error\",\n \"gallery_status\",\n \"compatible_glasses_search_stop\",\n \"swipe_volume_status\",\n \"switch_status\",\n \"rgb_led_control_response\",\n \"settings_ack\",\n \"pair_failure\",\n \"pairing_info\",\n \"entering_pairing_mode\",\n \"owner_replaced\",\n \"audio_pairing_needed\",\n \"audio_connected\",\n \"audio_disconnected\",\n \"mic_pcm\",\n \"mic_lc3\",\n \"mic_health\",\n \"stream_status\",\n \"ota_start_ack\",\n \"ota_status\",\n \"ar99_ota_status\",\n \"version_info\",\n \"extraction_progress\",\n])\n\nconst addListener: BluetoothSdkPublicModule[\"addListener\"] = (eventName, listener) => {\n if (!PUBLIC_EVENT_NAMES.has(eventName)) {\n throw new Error(`Unsupported BluetoothSdk event \"${eventName}\". Use @mentra/bluetooth-sdk/react for status state.`)\n }\n return PrivateBluetoothSdkModule.addListener(eventName, listener as BluetoothSdkEventListener<BluetoothSdkEventName>)\n}\n\nconst startOtaUpdate: BluetoothSdkPublicModule[\"startOtaUpdate\"] = (otaVersionUrl) => {\n return PrivateBluetoothSdkModule.startOtaUpdate(otaVersionUrl)\n}\n\nconst bindPublicMethod = <K extends keyof BluetoothSdkPublicModule>(name: K): BluetoothSdkPublicModule[K] => {\n const method = (PrivateBluetoothSdkModule as unknown as Record<string, unknown>)[name]\n if (typeof method === \"function\") {\n return method.bind(PrivateBluetoothSdkModule) as BluetoothSdkPublicModule[K]\n }\n\n return (async () => {\n throw new Error(`BluetoothSdk.${String(name)} is not available in this native build. Rebuild the app.`)\n }) as unknown as BluetoothSdkPublicModule[K]\n}\n\nexport const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({\n addListener,\n getDefaultDevice: bindPublicMethod(\"getDefaultDevice\"),\n setDefaultDevice: bindPublicMethod(\"setDefaultDevice\"),\n clearDefaultDevice: bindPublicMethod(\"clearDefaultDevice\"),\n startScan: bindPublicMethod(\"startScan\"),\n stopScan: bindPublicMethod(\"stopScan\"),\n scan: bindPublicMethod(\"scan\") as BluetoothSdkPublicModule[\"scan\"],\n connect: bindPublicMethod(\"connect\"),\n connectDefault: bindPublicMethod(\"connectDefault\"),\n cancelConnectionAttempt: bindPublicMethod(\"cancelConnectionAttempt\"),\n disconnect: bindPublicMethod(\"disconnect\"),\n forget: bindPublicMethod(\"forget\"),\n displayText: bindPublicMethod(\"displayText\"),\n clearDisplay: bindPublicMethod(\"clearDisplay\"),\n showDashboard: bindPublicMethod(\"showDashboard\"),\n setDashboardPosition: bindPublicMethod(\"setDashboardPosition\"),\n setHeadUpAngle: bindPublicMethod(\"setHeadUpAngle\"),\n setImuEnabled: bindPublicMethod(\"setImuEnabled\"),\n setScreenDisabled: bindPublicMethod(\"setScreenDisabled\"),\n requestWifiScan: bindPublicMethod(\"requestWifiScan\"),\n sendWifiCredentials: bindPublicMethod(\"sendWifiCredentials\"),\n forgetWifiNetwork: bindPublicMethod(\"forgetWifiNetwork\"),\n setHotspotState: bindPublicMethod(\"setHotspotState\"),\n setWifiAdbState: bindPublicMethod(\"setWifiAdbState\"),\n setGalleryModeEnabled: bindPublicMethod(\"setGalleryModeEnabled\"),\n setVoiceActivityDetectionEnabled: bindPublicMethod(\"setVoiceActivityDetectionEnabled\"),\n setLoudnessGateEnabled: bindPublicMethod(\"setLoudnessGateEnabled\"),\n /**\n * @deprecated Sticky action-button photo presets are deprecated. Prefer per-request\n * `requestPhoto(...)` options (e.g. `mode: \"text\"` for text sensor size/crop, or explicit per-shot\n * fields). Still functional until removed in a future release.\n */\n setPhotoCaptureDefaults: bindPublicMethod(\"setPhotoCaptureDefaults\"),\n setVideoRecordingDefaults: ({width, height, fps}: VideoRecordingDefaults) => {\n const method = (PrivateBluetoothSdkModule as unknown as Record<string, unknown>).setVideoRecordingDefaults\n if (typeof method !== \"function\") {\n return Promise.reject(\n new Error(\"BluetoothSdk.setVideoRecordingDefaults is not available in this native build. Rebuild the app.\"),\n )\n }\n return PrivateBluetoothSdkModule.setVideoRecordingDefaults(width, height, fps)\n },\n setMaxVideoRecordingDuration: bindPublicMethod(\"setMaxVideoRecordingDuration\"),\n setCameraFov: bindPublicMethod(\"setCameraFov\"),\n setLegacyCameraFov: bindPublicMethod(\"setLegacyCameraFov\"),\n setCameraFovOverride: bindPublicMethod(\"setCameraFovOverride\"),\n releaseCameraFovOverride: bindPublicMethod(\"releaseCameraFovOverride\"),\n setCameraTuningConfig: bindPublicMethod(\"setCameraTuningConfig\"),\n queryGalleryStatus: bindPublicMethod(\"queryGalleryStatus\"),\n requestPhoto: bindPublicMethod(\"requestPhoto\"),\n warmUpCamera: bindPublicMethod(\"warmUpCamera\"),\n stopCameraWarmUp: bindPublicMethod(\"stopCameraWarmUp\"),\n startVideoRecording: bindPublicMethod(\"startVideoRecording\"),\n stopVideoRecording: bindPublicMethod(\"stopVideoRecording\"),\n queryVideoRecordingStatus: bindPublicMethod(\"queryVideoRecordingStatus\"),\n startStream: bindPublicMethod(\"startStream\"),\n stopStream: bindPublicMethod(\"stopStream\"),\n setMicState: bindPublicMethod(\"setMicState\"),\n setPreferredMic: bindPublicMethod(\"setPreferredMic\"),\n setOwnAppAudioPlaying: bindPublicMethod(\"setOwnAppAudioPlaying\"),\n getGlassesMediaVolume: bindPublicMethod(\"getGlassesMediaVolume\"),\n setGlassesMediaVolume: bindPublicMethod(\"setGlassesMediaVolume\"),\n rgbLedControl: bindPublicMethod(\"rgbLedControl\"),\n requestVersionInfo: bindPublicMethod(\"requestVersionInfo\"),\n setOtaVersionUrl: bindPublicMethod(\"setOtaVersionUrl\"),\n getOtaVersionUrl: bindPublicMethod(\"getOtaVersionUrl\"),\n checkForOtaUpdate: bindPublicMethod(\"checkForOtaUpdate\"),\n startOtaUpdate,\n startAr99OtaFromFile: bindPublicMethod(\"startAr99OtaFromFile\"),\n cancelAr99Ota: bindPublicMethod(\"cancelAr99Ota\"),\n sendAr99FactoryReset: bindPublicMethod(\"sendAr99FactoryReset\"),\n buildAr99OtaSignature: bindPublicMethod(\"buildAr99OtaSignature\"),\n setSttModelDetails: bindPublicMethod(\"setSttModelDetails\"),\n getSttModelPath: bindPublicMethod(\"getSttModelPath\"),\n checkSttModelAvailable: bindPublicMethod(\"checkSttModelAvailable\"),\n validateSttModel: bindPublicMethod(\"validateSttModel\"),\n extractTarBz2: bindPublicMethod(\"extractTarBz2\"),\n restartTranscriber: bindPublicMethod(\"restartTranscriber\"),\n setTtsModelDetails: bindPublicMethod(\"setTtsModelDetails\"),\n getTtsModelPath: bindPublicMethod(\"getTtsModelPath\"),\n getTtsModelLanguage: bindPublicMethod(\"getTtsModelLanguage\"),\n checkTtsModelAvailable: bindPublicMethod(\"checkTtsModelAvailable\"),\n validateTtsModel: bindPublicMethod(\"validateTtsModel\"),\n generateTtsAudio: bindPublicMethod(\"generateTtsAudio\"),\n})\n\nexport default BluetoothSdk\n\nexport {\n CAMERA_FOV_DEFAULT,\n CAMERA_FOV_MAX,\n CAMERA_FOV_MIN,\n DeviceModels,\n isBusyGlassesConnectionStatus,\n isConnectedGlassesConnectionStatus,\n isConnectedWifiStatus,\n isEnabledHotspotStatus,\n isReadyGlassesConnectionStatus,\n} from \"./BluetoothSdk.types\"\n\nexport type {\n AccelEvent,\n Ar99OtaStatusEvent,\n AudioConnectedEvent,\n AudioDisconnectedEvent,\n AudioPairingNeededEvent,\n BatteryStatusEvent,\n BluetoothSdkEvent,\n BluetoothSdkEventListener,\n BluetoothSdkEventMap,\n BluetoothSdkEventName,\n BluetoothSdkPublicModule as BluetoothSdkModule,\n BluetoothSdkSubscription,\n ButtonPhotoSize,\n PhotoCaptureDefaults,\n ButtonPressEvent,\n CameraFovPreset,\n CameraFovRequest,\n CameraFovResult,\n CameraRoiPosition,\n CompatibleGlassesSearchStopEvent,\n ConnectOptions,\n ConnectedGlassesConnectionStatus,\n ConnectedWifiStatus,\n Device,\n DeviceModel,\n EnabledHotspotStatus,\n GalleryStatusEvent,\n GlassesConnectionStatus,\n GlassesMediaVolumeGetResult,\n GlassesMediaVolumeSetResult,\n GlassesNotReadyEvent,\n HeadUpEvent,\n HotspotErrorEvent,\n HotspotStatus,\n HotspotStatusChangeEvent,\n KeepAliveAckEvent,\n LocalTranscriptionEvent,\n LogEvent,\n MicLc3Event,\n MicHealthEvent,\n MicMode,\n MicPcmEvent,\n MicPreference,\n OtaStartAckEvent,\n OtaProgress,\n OtaProgressStatus,\n OtaStage,\n OtaStatus,\n OtaStatusEvent,\n OtaQueryResult,\n OtaUpdateInfo,\n PairFailureEvent,\n PairingInfoEvent,\n EnteringPairingModeEvent,\n OwnerReplacedEvent,\n PhotoCaptureMetadata,\n PhotoResolvedConfig,\n PhotoCompression,\n PhotoFpsRange,\n PhotoMeteredPreview,\n PhotoMode,\n PhotoTransferMethod,\n PhotoResponseEvent,\n PhotoRequestedCaptureConfig,\n PhotoRequestParams,\n PhotoSize,\n PhotoStatusEvent,\n PhotoStatusState,\n PhotoSuccessResponseEvent,\n RgbLedAction,\n RgbLedColor,\n RgbLedControlResponseEvent,\n RgbLedControlSuccessResponseEvent,\n ScanModelOptions,\n ScanOptions,\n ScanResultsCallback,\n SpeakingStatusEvent,\n SettingsAckEvent,\n SettingsAckSetting,\n SettingsAckSuccessEvent,\n SettingsAckSuccessStatus,\n SettingsAckStatus,\n StreamAudioConfig,\n StreamResolvedConfig,\n StreamStartRequest,\n StreamStatusEvent,\n StreamStatusLifecycleState,\n StreamStatusReconnectState,\n StreamStatusState,\n StreamVideoConfig,\n SwipeVolumeStatusEvent,\n SwitchStatusEvent,\n TouchEvent,\n VideoRecordingDefaults,\n VideoRecordingStartedStatusEvent,\n VideoRecordingStatusEvent,\n VideoRecordingStatusState,\n VideoRecordingStoppedStatusEvent,\n VideoRecordingSuccessStatusEvent,\n VersionInfoEvent,\n VersionInfoResult,\n WifiScanResultEvent,\n VoiceActivityDetectionStatusEvent,\n WifiSearchResult,\n WifiStatus,\n WifiStatusChangeEvent,\n} from \"./BluetoothSdk.types\"\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,MAAM,+BAA+B,CAAA;AAUrE,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAwB;IACxD,KAAK;IACL,mBAAmB;IACnB,wBAAwB;IACxB,mBAAmB;IACnB,cAAc;IACd,aAAa;IACb,aAAa;IACb,SAAS;IACT,iCAAiC;IACjC,iBAAiB;IACjB,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,uBAAuB;IACvB,eAAe;IACf,gBAAgB;IAChB,cAAc;IACd,eAAe;IACf,wBAAwB;IACxB,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,gCAAgC;IAChC,qBAAqB;IACrB,eAAe;IACf,0BAA0B;IAC1B,cAAc;IACd,cAAc;IACd,cAAc;IACd,uBAAuB;IACvB,gBAAgB;IAChB,sBAAsB;IACtB,iBAAiB;IACjB,oBAAoB;IACpB,SAAS;IACT,SAAS;IACT,YAAY;IACZ,eAAe;IACf,qBAAqB;IACrB,yBAAyB;IACzB,eAAe;IACf,YAAY;IACZ,iBAAiB;IACjB,cAAc;IACd,qBAAqB;CACtB,CAAC,CAAA;AAEF,MAAM,WAAW,GAA4C,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE;IACnF,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,mCAAmC,SAAS,sDAAsD,CAAC,CAAA;IACrH,CAAC;IACD,OAAO,yBAAyB,CAAC,WAAW,CAAC,SAAS,EAAE,QAA4D,CAAC,CAAA;AACvH,CAAC,CAAA;AAED,MAAM,cAAc,GAA+C,CAAC,aAA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ivateBluetoothSdkModule from \"./_private/BluetoothSdkModule\"\nimport type {\n BluetoothSdkEventListener,\n BluetoothSdkEventName,\n BluetoothSdkPublicModule,\n PublicBluetoothStatus,\n PublicGlassesStatus,\n VideoRecordingDefaults,\n} from \"./BluetoothSdk.types\"\n\nconst PUBLIC_EVENT_NAMES = new Set<BluetoothSdkEventName>([\n \"log\",\n \"device_discovered\",\n \"default_device_changed\",\n \"glasses_not_ready\",\n \"button_press\",\n \"touch_event\",\n \"accel_event\",\n \"head_up\",\n \"voice_activity_detection_status\",\n \"speaking_status\",\n \"battery_status\",\n \"local_transcription\",\n \"wifi_status_change\",\n \"wifi_scan_result\",\n \"hotspot_status_change\",\n \"hotspot_error\",\n \"photo_response\",\n \"photo_status\",\n \"camera_status\",\n \"video_recording_status\",\n \"media_success\",\n \"media_error\",\n \"gallery_status\",\n \"compatible_glasses_search_stop\",\n \"swipe_volume_status\",\n \"switch_status\",\n \"rgb_led_control_response\",\n \"settings_ack\",\n \"pair_failure\",\n \"pairing_info\",\n \"entering_pairing_mode\",\n \"owner_replaced\",\n \"audio_pairing_needed\",\n \"audio_connected\",\n \"audio_disconnected\",\n \"mic_pcm\",\n \"mic_lc3\",\n \"mic_health\",\n \"stream_status\",\n \"mtk_update_complete\",\n \"glasses_session_changed\",\n \"ota_start_ack\",\n \"ota_status\",\n \"ar99_ota_status\",\n \"version_info\",\n \"extraction_progress\",\n])\n\nconst addListener: BluetoothSdkPublicModule[\"addListener\"] = (eventName, listener) => {\n if (!PUBLIC_EVENT_NAMES.has(eventName)) {\n throw new Error(`Unsupported BluetoothSdk event \"${eventName}\". Use @mentra/bluetooth-sdk/react for status state.`)\n }\n return PrivateBluetoothSdkModule.addListener(eventName, listener as BluetoothSdkEventListener<BluetoothSdkEventName>)\n}\n\nconst startOtaUpdate: BluetoothSdkPublicModule[\"startOtaUpdate\"] = (otaVersionUrl) => {\n return PrivateBluetoothSdkModule.startOtaUpdate(otaVersionUrl)\n}\n\nconst queryOtaStatus: BluetoothSdkPublicModule[\"queryOtaStatus\"] = () => {\n return PrivateBluetoothSdkModule.sendOtaQueryStatus()\n}\n\nconst bindPublicMethod = <K extends keyof BluetoothSdkPublicModule>(name: K): BluetoothSdkPublicModule[K] => {\n const method = (PrivateBluetoothSdkModule as unknown as Record<string, unknown>)[name]\n if (typeof method === \"function\") {\n return method.bind(PrivateBluetoothSdkModule) as BluetoothSdkPublicModule[K]\n }\n\n return (async () => {\n throw new Error(`BluetoothSdk.${String(name)} is not available in this native build. Rebuild the app.`)\n }) as unknown as BluetoothSdkPublicModule[K]\n}\n\nexport const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({\n addListener,\n getGlassesStatus: bindPublicMethod(\"getGlassesStatus\"),\n getBluetoothStatus: bindPublicMethod(\"getBluetoothStatus\"),\n subscribeGlassesStatus: (listener: (changed: Partial<PublicGlassesStatus>) => void) =>\n PrivateBluetoothSdkModule.onGlassesStatus(listener),\n subscribeBluetoothStatus: (listener: (changed: Partial<PublicBluetoothStatus>) => void) =>\n PrivateBluetoothSdkModule.onBluetoothStatus(listener),\n getDefaultDevice: bindPublicMethod(\"getDefaultDevice\"),\n setDefaultDevice: bindPublicMethod(\"setDefaultDevice\"),\n clearDefaultDevice: bindPublicMethod(\"clearDefaultDevice\"),\n startScan: bindPublicMethod(\"startScan\"),\n stopScan: bindPublicMethod(\"stopScan\"),\n scan: bindPublicMethod(\"scan\") as BluetoothSdkPublicModule[\"scan\"],\n connect: bindPublicMethod(\"connect\"),\n connectDefault: bindPublicMethod(\"connectDefault\"),\n cancelConnectionAttempt: bindPublicMethod(\"cancelConnectionAttempt\"),\n disconnect: bindPublicMethod(\"disconnect\"),\n forget: bindPublicMethod(\"forget\"),\n displayText: bindPublicMethod(\"displayText\"),\n clearDisplay: bindPublicMethod(\"clearDisplay\"),\n showDashboard: bindPublicMethod(\"showDashboard\"),\n setDashboardPosition: bindPublicMethod(\"setDashboardPosition\"),\n setHeadUpAngle: bindPublicMethod(\"setHeadUpAngle\"),\n setImuEnabled: bindPublicMethod(\"setImuEnabled\"),\n setScreenDisabled: bindPublicMethod(\"setScreenDisabled\"),\n ping: bindPublicMethod(\"ping\"),\n requestWifiScan: bindPublicMethod(\"requestWifiScan\"),\n sendWifiCredentials: bindPublicMethod(\"sendWifiCredentials\"),\n forgetWifiNetwork: bindPublicMethod(\"forgetWifiNetwork\"),\n setHotspotState: bindPublicMethod(\"setHotspotState\"),\n setSystemTime: bindPublicMethod(\"setSystemTime\"),\n setWifiAdbState: bindPublicMethod(\"setWifiAdbState\"),\n setGalleryModeEnabled: bindPublicMethod(\"setGalleryModeEnabled\"),\n setVoiceActivityDetectionEnabled: bindPublicMethod(\"setVoiceActivityDetectionEnabled\"),\n setLoudnessGateEnabled: bindPublicMethod(\"setLoudnessGateEnabled\"),\n /**\n * @deprecated Sticky action-button photo presets are deprecated. Prefer per-request\n * `requestPhoto(...)` options (e.g. `mode: \"text\"` for text sensor size/crop, or explicit per-shot\n * fields). Still functional until removed in a future release.\n */\n setPhotoCaptureDefaults: bindPublicMethod(\"setPhotoCaptureDefaults\"),\n setVideoRecordingDefaults: ({width, height, fps}: VideoRecordingDefaults) => {\n const method = (PrivateBluetoothSdkModule as unknown as Record<string, unknown>).setVideoRecordingDefaults\n if (typeof method !== \"function\") {\n return Promise.reject(\n new Error(\"BluetoothSdk.setVideoRecordingDefaults is not available in this native build. Rebuild the app.\"),\n )\n }\n return PrivateBluetoothSdkModule.setVideoRecordingDefaults(width, height, fps)\n },\n setMaxVideoRecordingDuration: bindPublicMethod(\"setMaxVideoRecordingDuration\"),\n setCameraFov: bindPublicMethod(\"setCameraFov\"),\n setLegacyCameraFov: bindPublicMethod(\"setLegacyCameraFov\"),\n setCameraFovOverride: bindPublicMethod(\"setCameraFovOverride\"),\n releaseCameraFovOverride: bindPublicMethod(\"releaseCameraFovOverride\"),\n setCameraTuningConfig: bindPublicMethod(\"setCameraTuningConfig\"),\n queryGalleryStatus: bindPublicMethod(\"queryGalleryStatus\"),\n requestPhoto: bindPublicMethod(\"requestPhoto\"),\n warmUpCamera: bindPublicMethod(\"warmUpCamera\"),\n stopCameraWarmUp: bindPublicMethod(\"stopCameraWarmUp\"),\n startVideoRecording: bindPublicMethod(\"startVideoRecording\"),\n stopVideoRecording: bindPublicMethod(\"stopVideoRecording\"),\n queryVideoRecordingStatus: bindPublicMethod(\"queryVideoRecordingStatus\"),\n startStream: bindPublicMethod(\"startStream\"),\n stopStream: bindPublicMethod(\"stopStream\"),\n setMicState: bindPublicMethod(\"setMicState\"),\n setPreferredMic: bindPublicMethod(\"setPreferredMic\"),\n setOwnAppAudioPlaying: bindPublicMethod(\"setOwnAppAudioPlaying\"),\n getGlassesMediaVolume: bindPublicMethod(\"getGlassesMediaVolume\"),\n setGlassesMediaVolume: bindPublicMethod(\"setGlassesMediaVolume\"),\n rgbLedControl: bindPublicMethod(\"rgbLedControl\"),\n requestVersionInfo: bindPublicMethod(\"requestVersionInfo\"),\n setOtaVersionUrl: bindPublicMethod(\"setOtaVersionUrl\"),\n getOtaVersionUrl: bindPublicMethod(\"getOtaVersionUrl\"),\n checkForOtaUpdate: bindPublicMethod(\"checkForOtaUpdate\"),\n startOtaUpdate,\n queryOtaStatus,\n startAr99OtaFromFile: bindPublicMethod(\"startAr99OtaFromFile\"),\n cancelAr99Ota: bindPublicMethod(\"cancelAr99Ota\"),\n sendAr99FactoryReset: bindPublicMethod(\"sendAr99FactoryReset\"),\n buildAr99OtaSignature: bindPublicMethod(\"buildAr99OtaSignature\"),\n setSttModelDetails: bindPublicMethod(\"setSttModelDetails\"),\n getSttModelPath: bindPublicMethod(\"getSttModelPath\"),\n checkSttModelAvailable: bindPublicMethod(\"checkSttModelAvailable\"),\n validateSttModel: bindPublicMethod(\"validateSttModel\"),\n extractTarBz2: bindPublicMethod(\"extractTarBz2\"),\n restartTranscriber: bindPublicMethod(\"restartTranscriber\"),\n setTtsModelDetails: bindPublicMethod(\"setTtsModelDetails\"),\n getTtsModelPath: bindPublicMethod(\"getTtsModelPath\"),\n getTtsModelLanguage: bindPublicMethod(\"getTtsModelLanguage\"),\n checkTtsModelAvailable: bindPublicMethod(\"checkTtsModelAvailable\"),\n validateTtsModel: bindPublicMethod(\"validateTtsModel\"),\n generateTtsAudio: bindPublicMethod(\"generateTtsAudio\"),\n})\n\nexport default BluetoothSdk\n\nexport {\n CAMERA_FOV_DEFAULT,\n CAMERA_FOV_MAX,\n CAMERA_FOV_MIN,\n DeviceModels,\n isBusyGlassesConnectionStatus,\n isConnectedGlassesConnectionStatus,\n isConnectedWifiStatus,\n isEnabledHotspotStatus,\n isReadyGlassesConnectionStatus,\n} from \"./BluetoothSdk.types\"\n\nexport type {\n AccelEvent,\n Ar99OtaStatusEvent,\n AudioConnectedEvent,\n AudioDisconnectedEvent,\n AudioPairingNeededEvent,\n BatteryStatusEvent,\n BluetoothSdkEvent,\n BluetoothSdkEventListener,\n BluetoothSdkEventMap,\n BluetoothSdkEventName,\n BluetoothSdkPublicModule as BluetoothSdkModule,\n BluetoothSdkSubscription,\n ButtonPhotoSize,\n PhotoCaptureDefaults,\n ButtonPressEvent,\n CameraFovPreset,\n CameraFovRequest,\n CameraFovResult,\n CameraRoiPosition,\n CompatibleGlassesSearchStopEvent,\n ConnectOptions,\n ConnectedGlassesConnectionStatus,\n ConnectedWifiStatus,\n Device,\n DeviceModel,\n EnabledHotspotStatus,\n GalleryStatusEvent,\n GlassesConnectionStatus,\n GlassesMediaVolumeGetResult,\n GlassesMediaVolumeSetResult,\n GlassesNotReadyEvent,\n HeadUpEvent,\n HotspotErrorEvent,\n HotspotStatus,\n HotspotStatusChangeEvent,\n GlassesSessionChangedEvent,\n KeepAliveAckEvent,\n LocalTranscriptionEvent,\n LogEvent,\n MicLc3Event,\n MicHealthEvent,\n MicMode,\n MicPcmEvent,\n MicPreference,\n OtaStartAckEvent,\n OtaProgress,\n OtaProgressStatus,\n OtaStage,\n OtaStatus,\n OtaStatusEvent,\n OtaQueryResult,\n OtaUpdateInfo,\n MtkUpdateCompleteEvent,\n PairFailureEvent,\n PairingInfoEvent,\n EnteringPairingModeEvent,\n OwnerReplacedEvent,\n PhotoCaptureMetadata,\n PhotoResolvedConfig,\n PhotoCompression,\n PhotoFpsRange,\n PhotoMeteredPreview,\n PhotoMode,\n PublicBluetoothStatus,\n PublicGlassesStatus,\n PhotoTransferMethod,\n PhotoResponseEvent,\n PhotoRequestedCaptureConfig,\n PhotoRequestParams,\n PhotoSize,\n PhotoStatusEvent,\n PhotoStatusState,\n PhotoSuccessResponseEvent,\n RgbLedAction,\n RgbLedColor,\n RgbLedControlResponseEvent,\n RgbLedControlSuccessResponseEvent,\n ScanModelOptions,\n ScanOptions,\n ScanResultsCallback,\n SpeakingStatusEvent,\n SettingsAckEvent,\n SettingsAckSetting,\n SettingsAckSuccessEvent,\n SettingsAckSuccessStatus,\n SettingsAckStatus,\n StreamAudioConfig,\n StreamResolvedConfig,\n StreamStartRequest,\n StreamStatusEvent,\n StreamStatusLifecycleState,\n StreamStatusReconnectState,\n StreamStatusState,\n StreamVideoConfig,\n SwipeVolumeStatusEvent,\n SwitchStatusEvent,\n TouchEvent,\n VideoRecordingDefaults,\n VideoRecordingStartedStatusEvent,\n VideoRecordingStatusEvent,\n VideoRecordingStatusState,\n VideoRecordingStoppedStatusEvent,\n VideoRecordingSuccessStatusEvent,\n VersionInfoEvent,\n VersionInfoResult,\n WifiScanResultEvent,\n VoiceActivityDetectionStatusEvent,\n WifiSearchResult,\n WifiStatus,\n WifiStatusChangeEvent,\n} from \"./BluetoothSdk.types\"\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type OtaTransportSubscription = {
|
|
2
|
+
remove(): void;
|
|
3
|
+
};
|
|
4
|
+
export type OtaLocalNetworkConnection = {
|
|
5
|
+
connected: boolean;
|
|
6
|
+
ssid: string;
|
|
7
|
+
localAddress?: string;
|
|
8
|
+
};
|
|
9
|
+
export type OtaLocalNetworkLostEvent = {
|
|
10
|
+
ssid: string;
|
|
11
|
+
};
|
|
12
|
+
export type OtaLocalNetworkResponse = {
|
|
13
|
+
status: number;
|
|
14
|
+
headers: Record<string, string>;
|
|
15
|
+
bodyBase64: string;
|
|
16
|
+
};
|
|
17
|
+
export type OtaLocalNetworkDownloadResult = {
|
|
18
|
+
statusCode: number;
|
|
19
|
+
bytesWritten: number;
|
|
20
|
+
headers: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
export type OtaLocalNetworkDownloadProgress = {
|
|
23
|
+
requestId: string;
|
|
24
|
+
bytesWritten: number;
|
|
25
|
+
contentLength: number;
|
|
26
|
+
statusCode?: number;
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
};
|
|
29
|
+
export type OtaArtifactDownloadProgress = {
|
|
30
|
+
destination: string;
|
|
31
|
+
bytesWritten: number;
|
|
32
|
+
contentLength: number;
|
|
33
|
+
};
|
|
34
|
+
export type OtaServerResult = {
|
|
35
|
+
baseUrl: string;
|
|
36
|
+
host: string;
|
|
37
|
+
manifestUrl: string;
|
|
38
|
+
port: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Scoped networking for traffic that must stay on a Mentra Live hotspot while
|
|
42
|
+
* the phone's default route remains on cellular or another Wi-Fi network.
|
|
43
|
+
*
|
|
44
|
+
* The module is optional because iOS uses its system Wi-Fi join flow instead.
|
|
45
|
+
*/
|
|
46
|
+
export declare const otaLocalNetwork: Readonly<{
|
|
47
|
+
isAvailable: () => boolean;
|
|
48
|
+
connect: (ssid: string, password: string) => Promise<OtaLocalNetworkConnection>;
|
|
49
|
+
request: (requestId: string, url: string, method: string, headers: Record<string, string>, body: string | null, timeoutMs: number) => Promise<OtaLocalNetworkResponse>;
|
|
50
|
+
download: (requestId: string, url: string, destination: string, headers: Record<string, string>, connectionTimeoutMs: number, readTimeoutMs: number) => Promise<OtaLocalNetworkDownloadResult>;
|
|
51
|
+
cancel: (requestId: string) => Promise<void>;
|
|
52
|
+
disconnect: () => Promise<void>;
|
|
53
|
+
onDownloadProgress: (listener: (event: OtaLocalNetworkDownloadProgress) => void) => OtaTransportSubscription;
|
|
54
|
+
onNetworkLost: (listener: (event: OtaLocalNetworkLostEvent) => void) => OtaTransportSubscription;
|
|
55
|
+
}>;
|
|
56
|
+
/** Native HTTP server and artifact downloader used by the Engine OTA coordinator. */
|
|
57
|
+
export declare const otaServer: Readonly<{
|
|
58
|
+
start: (manifestJson: string, artifactPaths: Record<string, string>, host?: string | null) => Promise<OtaServerResult>;
|
|
59
|
+
stop: () => Promise<void>;
|
|
60
|
+
waitForWifiAddress: (gateway: string, timeoutMs: number) => Promise<string>;
|
|
61
|
+
downloadArtifact: (source: string, destination: string) => Promise<{
|
|
62
|
+
statusCode: number;
|
|
63
|
+
bytesWritten: number;
|
|
64
|
+
}>;
|
|
65
|
+
onArtifactDownloadProgress: (listener: (event: OtaArtifactDownloadProgress) => void) => OtaTransportSubscription;
|
|
66
|
+
}>;
|
|
67
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ota-transport/index.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,wBAAwB,GAAG;IAAC,MAAM,IAAI,IAAI,CAAA;CAAC,CAAA;AAEvD,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAA;AAErD,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,EAAE,MAAM,CAAA;IAClB,YA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FAAqF;AACrF,eAAO,MAAM,SAAS;0BAEJ,MAAM,iBACL,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,SAC9B,MAAM,GAAG,IAAI,KACnB,OAAO,CAAC,eAAe,CAAC;gBACjB,OAAO,CAAC,IAAI,CAAC;kCACO,MAAM,aAAa,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;+BAE9C,MAAM,eAAe,MAAM,KAAG,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAC,CAAC;2CAErE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,KAAG,wBAAwB;EAE9G,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// This public adapter is the package-owned boundary over its native implementation.
|
|
2
|
+
// eslint-disable-next-line no-restricted-imports
|
|
3
|
+
import MentraLocalNetwork from "../_private/MentraLocalNetworkModule";
|
|
4
|
+
// eslint-disable-next-line no-restricted-imports
|
|
5
|
+
import MentraOtaServer from "../ota-server";
|
|
6
|
+
/**
|
|
7
|
+
* Scoped networking for traffic that must stay on a Mentra Live hotspot while
|
|
8
|
+
* the phone's default route remains on cellular or another Wi-Fi network.
|
|
9
|
+
*
|
|
10
|
+
* The module is optional because iOS uses its system Wi-Fi join flow instead.
|
|
11
|
+
*/
|
|
12
|
+
export const otaLocalNetwork = Object.freeze({
|
|
13
|
+
isAvailable: () => MentraLocalNetwork != null,
|
|
14
|
+
connect: async (ssid, password) => {
|
|
15
|
+
if (!MentraLocalNetwork)
|
|
16
|
+
throw new Error("Scoped local networking is not available in this native build");
|
|
17
|
+
return MentraLocalNetwork.connect(ssid, password);
|
|
18
|
+
},
|
|
19
|
+
request: async (requestId, url, method, headers, body, timeoutMs) => {
|
|
20
|
+
if (!MentraLocalNetwork)
|
|
21
|
+
throw new Error("Scoped local networking is not available in this native build");
|
|
22
|
+
return MentraLocalNetwork.request(requestId, url, method, headers, body, timeoutMs);
|
|
23
|
+
},
|
|
24
|
+
download: async (requestId, url, destination, headers, connectionTimeoutMs, readTimeoutMs) => {
|
|
25
|
+
if (!MentraLocalNetwork)
|
|
26
|
+
throw new Error("Scoped local networking is not available in this native build");
|
|
27
|
+
return MentraLocalNetwork.download(requestId, url, destination, headers, connectionTimeoutMs, readTimeoutMs);
|
|
28
|
+
},
|
|
29
|
+
cancel: async (requestId) => {
|
|
30
|
+
if (!MentraLocalNetwork)
|
|
31
|
+
return;
|
|
32
|
+
await MentraLocalNetwork.cancel(requestId);
|
|
33
|
+
},
|
|
34
|
+
disconnect: async () => {
|
|
35
|
+
if (!MentraLocalNetwork)
|
|
36
|
+
return;
|
|
37
|
+
await MentraLocalNetwork.disconnect();
|
|
38
|
+
},
|
|
39
|
+
onDownloadProgress: (listener) => {
|
|
40
|
+
if (!MentraLocalNetwork)
|
|
41
|
+
return { remove() { } };
|
|
42
|
+
return MentraLocalNetwork.addListener("downloadProgress", listener);
|
|
43
|
+
},
|
|
44
|
+
onNetworkLost: (listener) => {
|
|
45
|
+
if (!MentraLocalNetwork)
|
|
46
|
+
return { remove() { } };
|
|
47
|
+
return MentraLocalNetwork.addListener("networkLost", listener);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
/** Native HTTP server and artifact downloader used by the Engine OTA coordinator. */
|
|
51
|
+
export const otaServer = Object.freeze({
|
|
52
|
+
start: (manifestJson, artifactPaths, host) => MentraOtaServer.startOtaServer(manifestJson, artifactPaths, host),
|
|
53
|
+
stop: () => MentraOtaServer.stopOtaServer(),
|
|
54
|
+
waitForWifiAddress: (gateway, timeoutMs) => MentraOtaServer.waitForWifiAddress(gateway, timeoutMs),
|
|
55
|
+
downloadArtifact: (source, destination) => MentraOtaServer.downloadArtifact(source, destination),
|
|
56
|
+
onArtifactDownloadProgress: (listener) => MentraOtaServer.addListener("artifactDownloadProgress", listener),
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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CAAC,WAAW,CAAC,0BAA0B,EAAE,QAAQ,CAAC;CACpE,CAAC,CAAA","sourcesContent":["// This public adapter is the package-owned boundary over its native implementation.\n// eslint-disable-next-line no-restricted-imports\nimport MentraLocalNetwork from \"../_private/MentraLocalNetworkModule\"\n// eslint-disable-next-line no-restricted-imports\nimport MentraOtaServer from \"../ota-server\"\n\nexport type OtaTransportSubscription = {remove(): void}\n\nexport type OtaLocalNetworkConnection = {\n connected: boolean\n ssid: string\n localAddress?: string\n}\n\nexport type OtaLocalNetworkLostEvent = {ssid: string}\n\nexport type OtaLocalNetworkResponse = {\n status: number\n headers: Record<string, string>\n bodyBase64: string\n}\n\nexport type OtaLocalNetworkDownloadResult = {\n statusCode: number\n bytesWritten: number\n headers: Record<string, string>\n}\n\nexport type OtaLocalNetworkDownloadProgress = {\n requestId: string\n bytesWritten: number\n contentLength: number\n statusCode?: number\n headers?: Record<string, string>\n}\n\nexport type OtaArtifactDownloadProgress = {\n destination: string\n bytesWritten: number\n contentLength: number\n}\n\nexport type OtaServerResult = {\n baseUrl: string\n host: string\n manifestUrl: string\n port: number\n}\n\n/**\n * Scoped networking for traffic that must stay on a Mentra Live hotspot while\n * the phone's default route remains on cellular or another Wi-Fi network.\n *\n * The module is optional because iOS uses its system Wi-Fi join flow instead.\n */\nexport const otaLocalNetwork = Object.freeze({\n isAvailable: (): boolean => MentraLocalNetwork != null,\n connect: async (ssid: string, password: string): Promise<OtaLocalNetworkConnection> => {\n if (!MentraLocalNetwork) throw new Error(\"Scoped local networking is not available in this native build\")\n return MentraLocalNetwork.connect(ssid, password)\n },\n request: async (\n requestId: string,\n url: string,\n method: string,\n headers: Record<string, string>,\n body: string | null,\n timeoutMs: number,\n ): Promise<OtaLocalNetworkResponse> => {\n if (!MentraLocalNetwork) throw new Error(\"Scoped local networking is not available in this native build\")\n return MentraLocalNetwork.request(requestId, url, method, headers, body, timeoutMs)\n },\n download: async (\n requestId: string,\n url: string,\n destination: string,\n headers: Record<string, string>,\n connectionTimeoutMs: number,\n readTimeoutMs: number,\n ): Promise<OtaLocalNetworkDownloadResult> => {\n if (!MentraLocalNetwork) throw new Error(\"Scoped local networking is not available in this native build\")\n return MentraLocalNetwork.download(requestId, url, destination, headers, connectionTimeoutMs, readTimeoutMs)\n },\n cancel: async (requestId: string): Promise<void> => {\n if (!MentraLocalNetwork) return\n await MentraLocalNetwork.cancel(requestId)\n },\n disconnect: async (): Promise<void> => {\n if (!MentraLocalNetwork) return\n await MentraLocalNetwork.disconnect()\n },\n onDownloadProgress: (listener: (event: OtaLocalNetworkDownloadProgress) => void): OtaTransportSubscription => {\n if (!MentraLocalNetwork) return {remove() {}}\n return MentraLocalNetwork.addListener(\"downloadProgress\", listener)\n },\n onNetworkLost: (listener: (event: OtaLocalNetworkLostEvent) => void): OtaTransportSubscription => {\n if (!MentraLocalNetwork) return {remove() {}}\n return MentraLocalNetwork.addListener(\"networkLost\", listener)\n },\n})\n\n/** Native HTTP server and artifact downloader used by the Engine OTA coordinator. */\nexport const otaServer = Object.freeze({\n start: (\n manifestJson: string,\n artifactPaths: Record<string, string>,\n host?: string | null,\n ): Promise<OtaServerResult> => MentraOtaServer.startOtaServer(manifestJson, artifactPaths, host),\n stop: (): Promise<void> => MentraOtaServer.stopOtaServer(),\n waitForWifiAddress: (gateway: string, timeoutMs: number): Promise<string> =>\n MentraOtaServer.waitForWifiAddress(gateway, timeoutMs),\n downloadArtifact: (source: string, destination: string): Promise<{statusCode: number; bytesWritten: number}> =>\n MentraOtaServer.downloadArtifact(source, destination),\n onArtifactDownloadProgress: (listener: (event: OtaArtifactDownloadProgress) => void): OtaTransportSubscription =>\n MentraOtaServer.addListener(\"artifactDownloadProgress\", listener),\n})\n"]}
|
|
@@ -11,7 +11,7 @@ enum BluetoothSdkDefaults {
|
|
|
11
11
|
static let voiceActivityDetectionEnabled = false
|
|
12
12
|
static let loudnessGateEnabled = true
|
|
13
13
|
private static let infoSdkVersionKey = "MentraBluetoothSdkVersion"
|
|
14
|
-
private static let swiftPackageSdkVersion = "3.1.0-dev.
|
|
14
|
+
private static let swiftPackageSdkVersion = "3.1.0-dev.22"
|
|
15
15
|
private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
|
|
16
16
|
|
|
17
17
|
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.1.0"
|
|
6
|
-
static let releaseIdentity = "3.1.0-dev.
|
|
7
|
-
static let releaseSetId = "mentra-3.1.0-dev.
|
|
8
|
-
static let sourceCommit = "
|
|
9
|
-
static let otaManifestUrl = "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.
|
|
6
|
+
static let releaseIdentity = "3.1.0-dev.22"
|
|
7
|
+
static let releaseSetId = "mentra-3.1.0-dev.22"
|
|
8
|
+
static let sourceCommit = "7922b0473444e14a18baec745311327ce0747993"
|
|
9
|
+
static let otaManifestUrl = "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.22/mentra-live-ota-3.1.0-dev.22.json"
|
|
10
10
|
static let otaManifestSha256 = "faa45840c71e996726a8c21a091d833635198570ef7d9045b8e95251d6f564a8"
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mentra/bluetooth-sdk",
|
|
3
|
-
"version": "3.1.0-dev.
|
|
3
|
+
"version": "3.1.0-dev.22",
|
|
4
4
|
"description": "SDK for communicating with smart glasses",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
"types": "./build/photo-receiver/index.d.ts",
|
|
33
33
|
"default": "./build/photo-receiver/index.js"
|
|
34
34
|
},
|
|
35
|
+
"./ota-transport": {
|
|
36
|
+
"react-native": "./src/ota-transport/index.ts",
|
|
37
|
+
"types": "./build/ota-transport/index.d.ts",
|
|
38
|
+
"default": "./build/ota-transport/index.js"
|
|
39
|
+
},
|
|
35
40
|
"./debug": {
|
|
36
41
|
"react-native": "./src/debug.ts",
|
|
37
42
|
"types": "./build/debug.d.ts",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import assert from "node:assert/strict"
|
|
2
|
+
import {readFileSync} from "node:fs"
|
|
3
|
+
import path from "node:path"
|
|
4
|
+
import test from "node:test"
|
|
5
|
+
import {fileURLToPath} from "node:url"
|
|
6
|
+
|
|
7
|
+
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
|
8
|
+
|
|
9
|
+
test("publishes the supported OTA transport entrypoint", () => {
|
|
10
|
+
const manifest = JSON.parse(readFileSync(path.join(packageRoot, "package.json"), "utf8"))
|
|
11
|
+
assert.deepEqual(manifest.exports["./ota-transport"], {
|
|
12
|
+
"react-native": "./src/ota-transport/index.ts",
|
|
13
|
+
"types": "./build/ota-transport/index.d.ts",
|
|
14
|
+
"default": "./build/ota-transport/index.js",
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const source = readFileSync(path.join(packageRoot, "src/ota-transport/index.ts"), "utf8")
|
|
18
|
+
assert.match(source, /export const otaLocalNetwork/)
|
|
19
|
+
assert.match(source, /export const otaServer/)
|
|
20
|
+
assert.doesNotMatch(source, /export \{default as Mentra(LocalNetwork|OtaServer)/)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test("keeps restart signals and correlated OTA status on the public root", () => {
|
|
24
|
+
const source = readFileSync(path.join(packageRoot, "src/index.ts"), "utf8")
|
|
25
|
+
for (const required of [
|
|
26
|
+
'"glasses_session_changed"',
|
|
27
|
+
'"mtk_update_complete"',
|
|
28
|
+
"queryOtaStatus",
|
|
29
|
+
"subscribeGlassesStatus",
|
|
30
|
+
"subscribeBluetoothStatus",
|
|
31
|
+
"setSystemTime",
|
|
32
|
+
"ping",
|
|
33
|
+
]) {
|
|
34
|
+
assert.ok(source.includes(required), `missing public OTA primitive: ${required}`)
|
|
35
|
+
}
|
|
36
|
+
assert.match(source, /Unsupported BluetoothSdk event/)
|
|
37
|
+
})
|
|
@@ -1043,6 +1043,10 @@ export type BluetoothSdkEventMap = {
|
|
|
1043
1043
|
mic_lc3: MicLc3Event
|
|
1044
1044
|
mic_health: MicHealthEvent
|
|
1045
1045
|
stream_status: StreamStatusEvent
|
|
1046
|
+
/** Mentra Live MTK updater completed and the glasses are about to restart. */
|
|
1047
|
+
mtk_update_complete: MtkUpdateCompleteEvent
|
|
1048
|
+
/** The ASG process restarted while the BES kept the BLE connection alive. */
|
|
1049
|
+
glasses_session_changed: GlassesSessionChangedEvent
|
|
1046
1050
|
ota_start_ack: OtaStartAckEvent
|
|
1047
1051
|
ota_status: OtaStatusEvent
|
|
1048
1052
|
ar99_ota_status: Ar99OtaStatusEvent
|
|
@@ -1068,6 +1072,15 @@ export interface BluetoothSdkPublicModule {
|
|
|
1068
1072
|
listener: BluetoothSdkEventListener<EventName>,
|
|
1069
1073
|
): BluetoothSdkSubscription
|
|
1070
1074
|
|
|
1075
|
+
/** Read an immutable snapshot of the current glasses state. */
|
|
1076
|
+
getGlassesStatus(): Promise<PublicGlassesStatus>
|
|
1077
|
+
/** Read an immutable snapshot of the phone Bluetooth adapter state. */
|
|
1078
|
+
getBluetoothStatus(): Promise<PublicBluetoothStatus>
|
|
1079
|
+
/** Observe immutable glasses-state patches. Returns an unsubscribe function. */
|
|
1080
|
+
subscribeGlassesStatus(listener: (changed: Partial<PublicGlassesStatus>) => void): () => void
|
|
1081
|
+
/** Observe immutable Bluetooth-state patches. Returns an unsubscribe function. */
|
|
1082
|
+
subscribeBluetoothStatus(listener: (changed: Partial<PublicBluetoothStatus>) => void): () => void
|
|
1083
|
+
|
|
1071
1084
|
getDefaultDevice(): Promise<Device | null>
|
|
1072
1085
|
setDefaultDevice(device: Device | null): Promise<void>
|
|
1073
1086
|
clearDefaultDevice(): Promise<void>
|
|
@@ -1089,11 +1102,15 @@ export interface BluetoothSdkPublicModule {
|
|
|
1089
1102
|
setHeadUpAngle(angleDegrees: number): Promise<void>
|
|
1090
1103
|
setImuEnabled(enabled: boolean): Promise<void>
|
|
1091
1104
|
setScreenDisabled(disabled: boolean): Promise<void>
|
|
1105
|
+
/** Keep legacy Mentra Live OTA sessions awake. Modern sessions normally do not require this. */
|
|
1106
|
+
ping(): Promise<void>
|
|
1092
1107
|
|
|
1093
1108
|
requestWifiScan(): Promise<WifiSearchResult[]>
|
|
1094
1109
|
sendWifiCredentials(ssid: string, password: string): Promise<WifiStatusChangeEvent>
|
|
1095
1110
|
forgetWifiNetwork(ssid: string): Promise<WifiStatusChangeEvent>
|
|
1096
1111
|
setHotspotState(enabled: boolean): Promise<HotspotStatusChangeEvent>
|
|
1112
|
+
/** Set the glasses clock from the phone after an OTA clock-skew failure. */
|
|
1113
|
+
setSystemTime(timestampMs: number): Promise<void>
|
|
1097
1114
|
/** Enable or disable Wi-Fi ADB on Mentra Live (no-op on other devices). */
|
|
1098
1115
|
setWifiAdbState(enabled: boolean): Promise<void>
|
|
1099
1116
|
|
|
@@ -1184,6 +1201,8 @@ export interface BluetoothSdkPublicModule {
|
|
|
1184
1201
|
checkForOtaUpdate(): Promise<boolean>
|
|
1185
1202
|
/** Start OTA from the configured or explicitly supplied manifest URL. */
|
|
1186
1203
|
startOtaUpdate(otaVersionUrl?: string | null): Promise<OtaStartAckEvent>
|
|
1204
|
+
/** Query the active OTA session and return the correlated status response. */
|
|
1205
|
+
queryOtaStatus(): Promise<OtaQueryResult>
|
|
1187
1206
|
startAr99OtaFromFile(path: string): Promise<boolean>
|
|
1188
1207
|
cancelAr99Ota(): Promise<void>
|
|
1189
1208
|
sendAr99FactoryReset(): Promise<void>
|
|
@@ -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.1.0",
|
|
15
|
-
"releaseIdentity": "3.1.0-dev.
|
|
16
|
-
"releaseSetId": "mentra-3.1.0-dev.
|
|
17
|
-
"sourceCommit": "
|
|
18
|
-
"otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.
|
|
15
|
+
"releaseIdentity": "3.1.0-dev.22",
|
|
16
|
+
"releaseSetId": "mentra-3.1.0-dev.22",
|
|
17
|
+
"sourceCommit": "7922b0473444e14a18baec745311327ce0747993",
|
|
18
|
+
"otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.22/mentra-live-ota-3.1.0-dev.22.json",
|
|
19
19
|
"otaManifestSha256": "faa45840c71e996726a8c21a091d833635198570ef7d9045b8e95251d6f564a8"
|
|
20
20
|
})
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
BluetoothSdkEventListener,
|
|
4
4
|
BluetoothSdkEventName,
|
|
5
5
|
BluetoothSdkPublicModule,
|
|
6
|
+
PublicBluetoothStatus,
|
|
7
|
+
PublicGlassesStatus,
|
|
6
8
|
VideoRecordingDefaults,
|
|
7
9
|
} from "./BluetoothSdk.types"
|
|
8
10
|
|
|
@@ -46,6 +48,8 @@ const PUBLIC_EVENT_NAMES = new Set<BluetoothSdkEventName>([
|
|
|
46
48
|
"mic_lc3",
|
|
47
49
|
"mic_health",
|
|
48
50
|
"stream_status",
|
|
51
|
+
"mtk_update_complete",
|
|
52
|
+
"glasses_session_changed",
|
|
49
53
|
"ota_start_ack",
|
|
50
54
|
"ota_status",
|
|
51
55
|
"ar99_ota_status",
|
|
@@ -64,6 +68,10 @@ const startOtaUpdate: BluetoothSdkPublicModule["startOtaUpdate"] = (otaVersionUr
|
|
|
64
68
|
return PrivateBluetoothSdkModule.startOtaUpdate(otaVersionUrl)
|
|
65
69
|
}
|
|
66
70
|
|
|
71
|
+
const queryOtaStatus: BluetoothSdkPublicModule["queryOtaStatus"] = () => {
|
|
72
|
+
return PrivateBluetoothSdkModule.sendOtaQueryStatus()
|
|
73
|
+
}
|
|
74
|
+
|
|
67
75
|
const bindPublicMethod = <K extends keyof BluetoothSdkPublicModule>(name: K): BluetoothSdkPublicModule[K] => {
|
|
68
76
|
const method = (PrivateBluetoothSdkModule as unknown as Record<string, unknown>)[name]
|
|
69
77
|
if (typeof method === "function") {
|
|
@@ -77,6 +85,12 @@ const bindPublicMethod = <K extends keyof BluetoothSdkPublicModule>(name: K): Bl
|
|
|
77
85
|
|
|
78
86
|
export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
79
87
|
addListener,
|
|
88
|
+
getGlassesStatus: bindPublicMethod("getGlassesStatus"),
|
|
89
|
+
getBluetoothStatus: bindPublicMethod("getBluetoothStatus"),
|
|
90
|
+
subscribeGlassesStatus: (listener: (changed: Partial<PublicGlassesStatus>) => void) =>
|
|
91
|
+
PrivateBluetoothSdkModule.onGlassesStatus(listener),
|
|
92
|
+
subscribeBluetoothStatus: (listener: (changed: Partial<PublicBluetoothStatus>) => void) =>
|
|
93
|
+
PrivateBluetoothSdkModule.onBluetoothStatus(listener),
|
|
80
94
|
getDefaultDevice: bindPublicMethod("getDefaultDevice"),
|
|
81
95
|
setDefaultDevice: bindPublicMethod("setDefaultDevice"),
|
|
82
96
|
clearDefaultDevice: bindPublicMethod("clearDefaultDevice"),
|
|
@@ -95,10 +109,12 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
|
95
109
|
setHeadUpAngle: bindPublicMethod("setHeadUpAngle"),
|
|
96
110
|
setImuEnabled: bindPublicMethod("setImuEnabled"),
|
|
97
111
|
setScreenDisabled: bindPublicMethod("setScreenDisabled"),
|
|
112
|
+
ping: bindPublicMethod("ping"),
|
|
98
113
|
requestWifiScan: bindPublicMethod("requestWifiScan"),
|
|
99
114
|
sendWifiCredentials: bindPublicMethod("sendWifiCredentials"),
|
|
100
115
|
forgetWifiNetwork: bindPublicMethod("forgetWifiNetwork"),
|
|
101
116
|
setHotspotState: bindPublicMethod("setHotspotState"),
|
|
117
|
+
setSystemTime: bindPublicMethod("setSystemTime"),
|
|
102
118
|
setWifiAdbState: bindPublicMethod("setWifiAdbState"),
|
|
103
119
|
setGalleryModeEnabled: bindPublicMethod("setGalleryModeEnabled"),
|
|
104
120
|
setVoiceActivityDetectionEnabled: bindPublicMethod("setVoiceActivityDetectionEnabled"),
|
|
@@ -144,6 +160,7 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
|
144
160
|
getOtaVersionUrl: bindPublicMethod("getOtaVersionUrl"),
|
|
145
161
|
checkForOtaUpdate: bindPublicMethod("checkForOtaUpdate"),
|
|
146
162
|
startOtaUpdate,
|
|
163
|
+
queryOtaStatus,
|
|
147
164
|
startAr99OtaFromFile: bindPublicMethod("startAr99OtaFromFile"),
|
|
148
165
|
cancelAr99Ota: bindPublicMethod("cancelAr99Ota"),
|
|
149
166
|
sendAr99FactoryReset: bindPublicMethod("sendAr99FactoryReset"),
|
|
@@ -212,6 +229,7 @@ export type {
|
|
|
212
229
|
HotspotErrorEvent,
|
|
213
230
|
HotspotStatus,
|
|
214
231
|
HotspotStatusChangeEvent,
|
|
232
|
+
GlassesSessionChangedEvent,
|
|
215
233
|
KeepAliveAckEvent,
|
|
216
234
|
LocalTranscriptionEvent,
|
|
217
235
|
LogEvent,
|
|
@@ -228,6 +246,7 @@ export type {
|
|
|
228
246
|
OtaStatusEvent,
|
|
229
247
|
OtaQueryResult,
|
|
230
248
|
OtaUpdateInfo,
|
|
249
|
+
MtkUpdateCompleteEvent,
|
|
231
250
|
PairFailureEvent,
|
|
232
251
|
PairingInfoEvent,
|
|
233
252
|
EnteringPairingModeEvent,
|
|
@@ -238,6 +257,8 @@ export type {
|
|
|
238
257
|
PhotoFpsRange,
|
|
239
258
|
PhotoMeteredPreview,
|
|
240
259
|
PhotoMode,
|
|
260
|
+
PublicBluetoothStatus,
|
|
261
|
+
PublicGlassesStatus,
|
|
241
262
|
PhotoTransferMethod,
|
|
242
263
|
PhotoResponseEvent,
|
|
243
264
|
PhotoRequestedCaptureConfig,
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// This public adapter is the package-owned boundary over its native implementation.
|
|
2
|
+
// eslint-disable-next-line no-restricted-imports
|
|
3
|
+
import MentraLocalNetwork from "../_private/MentraLocalNetworkModule"
|
|
4
|
+
// eslint-disable-next-line no-restricted-imports
|
|
5
|
+
import MentraOtaServer from "../ota-server"
|
|
6
|
+
|
|
7
|
+
export type OtaTransportSubscription = {remove(): void}
|
|
8
|
+
|
|
9
|
+
export type OtaLocalNetworkConnection = {
|
|
10
|
+
connected: boolean
|
|
11
|
+
ssid: string
|
|
12
|
+
localAddress?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type OtaLocalNetworkLostEvent = {ssid: string}
|
|
16
|
+
|
|
17
|
+
export type OtaLocalNetworkResponse = {
|
|
18
|
+
status: number
|
|
19
|
+
headers: Record<string, string>
|
|
20
|
+
bodyBase64: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type OtaLocalNetworkDownloadResult = {
|
|
24
|
+
statusCode: number
|
|
25
|
+
bytesWritten: number
|
|
26
|
+
headers: Record<string, string>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type OtaLocalNetworkDownloadProgress = {
|
|
30
|
+
requestId: string
|
|
31
|
+
bytesWritten: number
|
|
32
|
+
contentLength: number
|
|
33
|
+
statusCode?: number
|
|
34
|
+
headers?: Record<string, string>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type OtaArtifactDownloadProgress = {
|
|
38
|
+
destination: string
|
|
39
|
+
bytesWritten: number
|
|
40
|
+
contentLength: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type OtaServerResult = {
|
|
44
|
+
baseUrl: string
|
|
45
|
+
host: string
|
|
46
|
+
manifestUrl: string
|
|
47
|
+
port: number
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Scoped networking for traffic that must stay on a Mentra Live hotspot while
|
|
52
|
+
* the phone's default route remains on cellular or another Wi-Fi network.
|
|
53
|
+
*
|
|
54
|
+
* The module is optional because iOS uses its system Wi-Fi join flow instead.
|
|
55
|
+
*/
|
|
56
|
+
export const otaLocalNetwork = Object.freeze({
|
|
57
|
+
isAvailable: (): boolean => MentraLocalNetwork != null,
|
|
58
|
+
connect: async (ssid: string, password: string): Promise<OtaLocalNetworkConnection> => {
|
|
59
|
+
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
60
|
+
return MentraLocalNetwork.connect(ssid, password)
|
|
61
|
+
},
|
|
62
|
+
request: async (
|
|
63
|
+
requestId: string,
|
|
64
|
+
url: string,
|
|
65
|
+
method: string,
|
|
66
|
+
headers: Record<string, string>,
|
|
67
|
+
body: string | null,
|
|
68
|
+
timeoutMs: number,
|
|
69
|
+
): Promise<OtaLocalNetworkResponse> => {
|
|
70
|
+
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
71
|
+
return MentraLocalNetwork.request(requestId, url, method, headers, body, timeoutMs)
|
|
72
|
+
},
|
|
73
|
+
download: async (
|
|
74
|
+
requestId: string,
|
|
75
|
+
url: string,
|
|
76
|
+
destination: string,
|
|
77
|
+
headers: Record<string, string>,
|
|
78
|
+
connectionTimeoutMs: number,
|
|
79
|
+
readTimeoutMs: number,
|
|
80
|
+
): Promise<OtaLocalNetworkDownloadResult> => {
|
|
81
|
+
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
82
|
+
return MentraLocalNetwork.download(requestId, url, destination, headers, connectionTimeoutMs, readTimeoutMs)
|
|
83
|
+
},
|
|
84
|
+
cancel: async (requestId: string): Promise<void> => {
|
|
85
|
+
if (!MentraLocalNetwork) return
|
|
86
|
+
await MentraLocalNetwork.cancel(requestId)
|
|
87
|
+
},
|
|
88
|
+
disconnect: async (): Promise<void> => {
|
|
89
|
+
if (!MentraLocalNetwork) return
|
|
90
|
+
await MentraLocalNetwork.disconnect()
|
|
91
|
+
},
|
|
92
|
+
onDownloadProgress: (listener: (event: OtaLocalNetworkDownloadProgress) => void): OtaTransportSubscription => {
|
|
93
|
+
if (!MentraLocalNetwork) return {remove() {}}
|
|
94
|
+
return MentraLocalNetwork.addListener("downloadProgress", listener)
|
|
95
|
+
},
|
|
96
|
+
onNetworkLost: (listener: (event: OtaLocalNetworkLostEvent) => void): OtaTransportSubscription => {
|
|
97
|
+
if (!MentraLocalNetwork) return {remove() {}}
|
|
98
|
+
return MentraLocalNetwork.addListener("networkLost", listener)
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
/** Native HTTP server and artifact downloader used by the Engine OTA coordinator. */
|
|
103
|
+
export const otaServer = Object.freeze({
|
|
104
|
+
start: (
|
|
105
|
+
manifestJson: string,
|
|
106
|
+
artifactPaths: Record<string, string>,
|
|
107
|
+
host?: string | null,
|
|
108
|
+
): Promise<OtaServerResult> => MentraOtaServer.startOtaServer(manifestJson, artifactPaths, host),
|
|
109
|
+
stop: (): Promise<void> => MentraOtaServer.stopOtaServer(),
|
|
110
|
+
waitForWifiAddress: (gateway: string, timeoutMs: number): Promise<string> =>
|
|
111
|
+
MentraOtaServer.waitForWifiAddress(gateway, timeoutMs),
|
|
112
|
+
downloadArtifact: (source: string, destination: string): Promise<{statusCode: number; bytesWritten: number}> =>
|
|
113
|
+
MentraOtaServer.downloadArtifact(source, destination),
|
|
114
|
+
onArtifactDownloadProgress: (listener: (event: OtaArtifactDownloadProgress) => void): OtaTransportSubscription =>
|
|
115
|
+
MentraOtaServer.addListener("artifactDownloadProgress", listener),
|
|
116
|
+
})
|