@mentra/bluetooth-sdk 3.1.0-dev.7 → 3.1.0-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +0 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +13 -8
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +7 -44
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisement.kt +54 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisementParserTest.kt +75 -0
- package/build/BluetoothSdk.types.d.ts +0 -5
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/Bridge.swift +1 -6
- package/ios/Source/DeviceManager.swift +13 -8
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/ios/Source/sgcs/MentraLive.swift +37 -66
- package/ios/Source/sgcs/MentraLivePairingAdvertisement.swift +64 -0
- package/ios/Tests/MentraLivePairingAdvertisementTests.swift +104 -0
- package/package.json +1 -1
- package/src/BluetoothSdk.types.ts +0 -5
- package/src/generated/releaseMetadata.ts +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BluetoothSdk.types.js","sourceRoot":"","sources":["../src/BluetoothSdk.types.ts"],"names":[],"mappings":"AAwCA,MAAM,CAAC,MAAM,wCAAwC,GAAG,KAAK,CAAA;AAwB7D,MAAM,UAAU,kCAAkC,CAChD,MAA+B;IAE/B,OAAO,MAAM,CAAC,KAAK,KAAK,WAAW,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,MAA+B;IAC5E,OAAO,MAAM,CAAC,KAAK,KAAK,WAAW,IAAI,MAAM,CAAC,WAAW,CAAA;AAC3D,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,MAA+B;IAC3E,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,KAAK,KAAK,YAAY,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,CAAA;AACnG,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,OAAO;QACL,UAAU,EAAE,EAAC,KAAK,EAAE,cAAc,EAAC;QACnC,OAAO,EAAE,EAAC,KAAK,EAAE,UAAU,EAAC;QAC5B,6BAA6B,EAAE,wCAAwC;QACvE,IAAI,EAAE,EAAC,KAAK,EAAE,cAAc,EAAC;KAC9B,CAAA;AACH,CAAC;AA2BD,MAAM,UAAU,qBAAqB,CAAC,MAAkB;IACtD,OAAO,MAAM,CAAC,KAAK,KAAK,WAAW,CAAA;AACrC,CAAC;AAoBD,MAAM,UAAU,sBAAsB,CAAC,MAAqB;IAC1D,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS,CAAA;AACnC,CAAC;AAmXD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE,mBAAmB;IAC9B,EAAE,EAAE,mBAAmB;IACvB,EAAE,EAAE,mBAAmB;IACvB,UAAU,EAAE,aAAa;IACzB,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,iBAAiB;IACxB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,mBAAmB;CACf,CAAA;AAWV,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AACjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAA","sourcesContent":["// Bluetooth SDK Event Types\nexport type GlassesNotReadyEvent = {\n type: \"glasses_not_ready\"\n message: string\n}\n\n// NOTE: unlike most events below, the native module does NOT include a `type`\n// field on the button_press payload 闂?it sends only {buttonId, pressType,\n// timestamp} (see BluetoothSdkModule on both iOS and Android). Consumers must\n// filter on `pressType` / the \"button_press\" listener name, never `event.type`.\nexport type ButtonPressEvent = {\n buttonId: string\n pressType: \"long\" | \"short\"\n timestamp: number\n}\n\nexport type TouchEvent = {\n type: \"touch_event\"\n deviceModel: DeviceModel\n gestureName: string\n timestamp: number\n}\n\nexport type AccelEvent = {\n type: \"accel_event\"\n x: number\n y: number\n z: number\n timestamp: number\n}\n\nexport type HeadUpEvent = {\n up: boolean\n}\n\nexport type VoiceActivityDetectionStatusEvent = {\n type: \"voice_activity_detection_status\"\n voiceActivityDetectionEnabled: boolean\n}\n\nexport const DEFAULT_VOICE_ACTIVITY_DETECTION_ENABLED = false\n\nexport type SpeakingStatusEvent = {\n type: \"speaking_status\"\n speaking: boolean\n timestamp: number\n}\n\nexport type BatteryStatusEvent = {\n type: \"battery_status\"\n level: number\n charging: boolean\n timestamp: number\n}\n\nexport type GlassesConnectionStatus =\n | {state: \"disconnected\"}\n | {state: \"scanning\"}\n | {state: \"connecting\"}\n | {state: \"bonding\"}\n | {state: \"connected\"; fullyBooted: boolean}\n\nexport type ConnectedGlassesConnectionStatus = Extract<GlassesConnectionStatus, {state: \"connected\"}>\n\nexport function isConnectedGlassesConnectionStatus(\n status: GlassesConnectionStatus,\n): status is ConnectedGlassesConnectionStatus {\n return status.state === \"connected\"\n}\n\nexport function isReadyGlassesConnectionStatus(status: GlassesConnectionStatus): boolean {\n return status.state === \"connected\" && status.fullyBooted\n}\n\nexport function isBusyGlassesConnectionStatus(status: GlassesConnectionStatus): boolean {\n return status.state === \"scanning\" || status.state === \"connecting\" || status.state === \"bonding\"\n}\n\nexport function createDisconnectedGlassesStatus(): Partial<GlassesStatus> {\n return {\n connection: {state: \"disconnected\"},\n hotspot: {state: \"disabled\"},\n voiceActivityDetectionEnabled: DEFAULT_VOICE_ACTIVITY_DETECTION_ENABLED,\n wifi: {state: \"disconnected\"},\n }\n}\n\n/** K900 `sr_getvol` response (Mentra Live glasses media step volume 0闂?5). */\nexport type GlassesMediaVolumeGetResult = {\n level: number\n statusCode: number\n}\n\n/** K900 `sr_vol` acknowledgment. */\nexport type GlassesMediaVolumeSetResult = {\n statusCode: number\n}\n\nexport type LocalTranscriptionEvent = {\n text: string\n isFinal?: boolean\n transcribeLanguage?: string\n}\n\nexport type LogEvent = {\n message: string\n}\n\nexport type WifiStatus = {state: \"disconnected\"} | {state: \"connected\"; ssid: string; localIp?: string}\n\nexport type ConnectedWifiStatus = Extract<WifiStatus, {state: \"connected\"}>\n\nexport function isConnectedWifiStatus(status: WifiStatus): status is ConnectedWifiStatus {\n return status.state === \"connected\"\n}\n\nexport type WifiStatusChangeEvent = WifiStatus & {\n type: \"wifi_status_change\"\n /**\n * Glasses-reported provisioning failure reason when THIS event is the verdict of a\n * failed connect attempt; absent on routine link-state updates. An attempt property,\n * not a link property 闂?which is why it lives on the event, not on WifiStatus:\n * \"connect_timeout\" arrives on a disconnected status (never associated), while\n * \"connected_to_other_network\" arrives on a *connected* status (the attempt failed\n * and the glasses ended up on / fell back to a different SSID than requested).\n * Requires ASG client v40+ 闂?older glasses never send it.\n */\n error?: string\n}\n\nexport type HotspotStatus = {state: \"disabled\"} | {state: \"enabled\"; ssid: string; password: string; localIp: string}\n\nexport type EnabledHotspotStatus = Extract<HotspotStatus, {state: \"enabled\"}>\n\nexport function isEnabledHotspotStatus(status: HotspotStatus): status is EnabledHotspotStatus {\n return status.state === \"enabled\"\n}\n\nexport type HotspotStatusChangeEvent = HotspotStatus & {\n type: \"hotspot_status_change\"\n}\n\nexport type HotspotErrorEvent = {\n type: \"hotspot_error\"\n errorMessage: string\n timestamp: number\n}\n\nexport type VersionInfoResult = {\n androidVersion: string\n firmwareVersion: string\n besFirmwareVersion: string\n mtkFirmwareVersion: string\n buildNumber: string\n systemTimeMs?: number\n otaVersionUrl: string\n appVersion: string\n /** Phone-served hotspot OTA protocol version; 0 means unsupported/legacy glasses. */\n hotspotOtaVersion: number\n}\n\nexport type VersionInfoEvent = VersionInfoResult & {\n type: \"version_info\"\n}\n\nexport type WifiScanResultEvent = {\n type: \"wifi_scan_result\"\n networks: WifiSearchResult[]\n scanComplete?: boolean\n}\n\nexport type PhotoResponseEvent =\n | {\n type: \"photo_response\"\n state: \"success\"\n requestId: string\n uploadUrl: string\n photoUrl?: string\n statusUrl?: string\n contentType?: string\n fileSizeBytes?: number\n timestamp: number\n }\n | {\n type: \"photo_response\"\n state: \"error\"\n requestId: string\n timestamp: number\n errorCode?: string\n errorMessage: string\n }\n\nexport type PhotoSuccessResponseEvent = Extract<PhotoResponseEvent, {state: \"success\"}>\n\nexport type PhotoStatusState =\n | \"accepted\"\n | \"queued\"\n | \"configuring\"\n | \"capturing\"\n | \"captured\"\n | \"compressing\"\n | \"ble_fallback_compression\"\n | \"uploading\"\n | \"uploaded\"\n | \"ready_for_transfer\"\n | \"transferring\"\n | \"failed\"\n\nexport type PhotoResolvedConfig = {\n format?: \"jpeg\" | string\n width?: number\n height?: number\n quality?: number\n requestedSize?: PhotoSize | string\n source?: \"sdk\" | \"button\" | string\n transferMethod?: \"webhook\" | \"ble\" | \"local\" | string\n compression?: PhotoCompression | string\n saveToGallery?: boolean\n exposureTimeNs?: number\n iso?: number\n}\n\nexport type PhotoFpsRange = {\n min?: number\n max?: number\n}\n\nexport type PhotoRequestedCaptureConfig = {\n manual?: boolean\n exposureTimeNs?: number\n iso?: number\n frameDurationNs?: number\n aeMode?: number\n aeLock?: boolean\n aeExposureCompensation?: number\n aeTargetFpsRange?: PhotoFpsRange\n noiseReductionMode?: number\n edgeMode?: number\n afMode?: number\n zsl?: boolean\n}\n\nexport type PhotoMeteredPreview = {\n exposureTimeNs?: number\n iso?: number\n totalLightProxy?: number\n}\n\nexport type PhotoCaptureMetadata = {\n manual?: boolean\n exposureTimeNs?: number\n iso?: number\n frameDurationNs?: number\n aeMode?: number\n aeState?: number\n aeStateName?: string\n noiseReductionMode?: number\n edgeMode?: number\n zsl?: boolean\n sensorTimestampNs?: number\n totalLightProxy?: number\n mfnrLikely?: boolean\n mfnrApplied?: boolean\n width?: number\n height?: number\n noiseReductionWarning?: \"not_implemented\" | string\n ispDigitalGainWarning?: \"not_implemented\" | string\n ispAnalogGainWarning?: \"not_implemented\" | string\n [key: string]: unknown\n}\n\nexport type PhotoStatusEvent = {\n type: \"photo_status\"\n requestId: string\n status: PhotoStatusState | string\n timestamp: number\n resolvedConfig?: PhotoResolvedConfig\n requestedCaptureConfig?: PhotoRequestedCaptureConfig\n meteredPreview?: PhotoMeteredPreview\n captureMetadata?: PhotoCaptureMetadata\n errorCode?: string\n errorMessage?: string\n}\n\nexport type CameraStatusEvent = {\n type: \"camera_status\"\n requestId: string\n state: \"warming\" | \"ready\" | \"stopped\" | \"error\" | string\n timestamp: number\n errorCode?: string\n errorMessage?: string\n}\n\nexport type VideoRecordingStatusEvent = {\n type: \"video_recording_status\"\n requestId?: string\n success: boolean\n status: VideoRecordingStatusState\n details?: string | null\n timestamp: number\n data?: {\n recording?: boolean\n duration_ms?: number\n duration_formatted?: string\n [key: string]: unknown\n }\n}\n\nexport type VideoRecordingStatusState =\n | \"recording_started\"\n | \"recording_status\"\n | \"already_recording\"\n | \"recording_stopped\"\n | \"not_recording\"\n | \"request_id_mismatch\"\n | \"service_unavailable\"\n | \"json_error\"\n | \"battery_low\"\n | \"camera_busy\"\n | \"storage_unavailable\"\n | \"integrity_failed\"\n | \"error\"\n\nexport type VideoRecordingStartedStatusEvent = Omit<VideoRecordingStatusEvent, \"success\" | \"status\"> & {\n success: true\n status: \"recording_started\"\n}\n\nexport type VideoRecordingStoppedStatusEvent = Omit<VideoRecordingStatusEvent, \"success\" | \"status\"> & {\n success: true\n status: \"recording_stopped\"\n}\n\nexport type VideoRecordingSuccessStatusEvent = VideoRecordingStartedStatusEvent | VideoRecordingStoppedStatusEvent\n\nexport type MediaUploadSuccessEvent = {\n type: \"media_success\"\n requestId: string\n mediaUrl: string\n mediaType: number\n timestamp: number\n}\n\nexport type MediaUploadErrorEvent = {\n type: \"media_error\"\n requestId: string\n errorMessage: string\n mediaType: number\n timestamp: number\n}\n\nexport type MediaUploadEvent = MediaUploadSuccessEvent | MediaUploadErrorEvent\n\nexport type GalleryStatusEvent = {\n type: \"gallery_status\"\n photos: number\n videos: number\n total: number\n totalSize?: number\n hasContent: boolean\n cameraBusy: boolean\n cameraBusyReason?: \"video\" | \"stream\" | (string & {})\n}\n\nexport type CompatibleGlassesSearchStopEvent = {\n type: \"compatible_glasses_search_stop\"\n deviceModel: DeviceModel\n}\n\nexport type HeartbeatSentEvent = {\n type: \"heartbeat_sent\"\n heartbeat_sent: {\n timestamp: number\n }\n}\n\nexport type HeartbeatReceivedEvent = {\n type: \"heartbeat_received\"\n heartbeat_received: {\n timestamp: number\n }\n}\n\nexport type SwipeVolumeStatusEvent = {\n type: \"swipe_volume_status\"\n enabled: boolean\n timestamp: number\n}\n\nexport type SwitchStatusEvent = {\n type: \"switch_status\"\n switchType?: number\n switchValue?: number\n timestamp: number\n}\n\nexport type RgbLedControlResponseEvent =\n | {\n type: \"rgb_led_control_response\"\n state: \"success\"\n requestId: string\n }\n | {\n type: \"rgb_led_control_response\"\n state: \"error\"\n requestId: string\n errorCode: string\n }\n\nexport type RgbLedControlSuccessResponseEvent = Extract<RgbLedControlResponseEvent, {state: \"success\"}>\n\nexport type SettingsAckStatus = \"applied\" | \"ready\" | \"error\" | \"failed\" | \"failure\" | \"rejected\"\n\nexport type SettingsAckSetting =\n | \"gallery_mode\"\n | \"button_photo\"\n | \"button_video_recording\"\n | \"button_max_recording_time\"\n | \"camera_fov\"\n | \"camera_fov_override\"\n | \"camera_tuning\"\n\nexport type SettingsAckEvent = {\n type: \"settings_ack\"\n requestId: string\n setting: SettingsAckSetting\n status: SettingsAckStatus\n timestamp: number\n fov?: number\n roiPosition?: CameraRoiPositionValue\n hardwareApplied?: boolean\n leaseId?: string\n active?: boolean\n size?: ButtonPhotoSize | string\n width?: number\n height?: number\n fps?: number\n enabled?: boolean\n minutes?: number\n /** ANR enabled flag; present when setting === \"camera_tuning\" */\n anr?: boolean\n /** Stock-gain flag; present when setting === \"camera_tuning\" */\n gain?: boolean\n errorCode?: string\n errorMessage?: string\n}\n\nexport type SettingsAckSuccessStatus = Exclude<SettingsAckStatus, \"error\" | \"failed\" | \"failure\" | \"rejected\">\n\nexport type SettingsAckSuccessEvent = Omit<SettingsAckEvent, \"status\"> & {\n status: SettingsAckSuccessStatus\n}\n\nexport type RgbLedAction = \"on\" | \"off\"\nexport type RgbLedColor = \"red\" | \"green\" | \"blue\" | \"orange\" | \"white\"\nexport type PhotoSize = \"low\" | \"medium\" | \"high\" | \"max\"\nexport type PhotoMode = \"photo\" | \"text\"\nexport type PhotoTransferMethod = \"auto\" | \"direct\" | \"ble\"\nexport type ButtonPhotoSize = \"low\" | \"medium\" | \"high\" | \"max\"\n\n/**\n * @deprecated Sticky action-button photo presets via {@link BluetoothSdkPublicModule.setPhotoCaptureDefaults}\n * are deprecated. Prefer per-request {@link BluetoothSdkPublicModule.requestPhoto} options\n * (e.g. `mode: \"text\"` for text sensor size/crop, or explicit `aeExposureDivisor`) instead of\n * persisting button-photo tuning on the glasses.\n */\nexport type PhotoCaptureDefaults = {\n size?: PhotoSize\n /** ZSL preview buffering for physical camera-button photos. */\n zsl?: boolean\n /** MFNR still capture for physical camera-button photos. */\n mfnr?: boolean\n noiseReduction?: boolean\n edgeEnhancement?: boolean\n ispDigitalGain?: number\n ispAnalogGain?: string\n aeExposureDivisor?: number\n isoCap?: number\n compress?: PhotoCompression\n sound?: boolean\n /** When true, clears stored NR/edge/ISP presets on the glasses before applying other fields. */\n resetCaptureTuning?: boolean\n}\nexport type PhotoCompression = \"none\" | \"medium\" | \"heavy\"\n\nexport type VideoRecordingDefaults = {\n width: number\n height: number\n fps: number\n}\n\n/**\n * Optional per-recording video settings for {@link startVideoRecording}. When\n * omitted, the glasses fall back to their saved video recording defaults. Any\n * field left undefined is omitted from the BLE command (glasses default applies).\n */\nexport interface VideoRecordingSettings {\n width?: number\n height?: number\n fps?: number\n /**\n * Optional auto-stop timer in minutes, sent on `start_video_recording`.\n * `0` (the default) means record until stopped or interrupted\n * (battery/storage/thermal/error).\n */\n maxRecordingTimeMinutes?: number\n}\nexport const DeviceModels = {\n Simulated: \"Simulated Glasses\",\n G1: \"Even Realities G1\",\n G2: \"Even Realities G2\",\n MentraLive: \"Mentra Live\",\n MentraNex: \"Mentra Display\",\n Mach1: \"Mentra Mach1\",\n Z100: \"Vuzix Z100\",\n Frame: \"Brilliant Frame\",\n Nimo: \"NIMO\",\n Ar99: \"AR99\",\n R1: \"Even Realities R1\",\n} as const\n\nexport type DeviceModel = (typeof DeviceModels)[keyof typeof DeviceModels]\nexport type ObservableStoreCategory = \"glasses\" | \"bluetooth\" | \"core\"\n\nexport type DashboardMenuItem = {\n title: string\n packageName: string\n values?: Record<string, unknown>\n}\n\nexport const CAMERA_FOV_MIN = 62\nexport const CAMERA_FOV_MAX = 118\nexport const CAMERA_FOV_DEFAULT = CAMERA_FOV_MAX\n\nexport type CameraRoiPosition = \"center\" | \"bottom\" | \"top\"\nexport type CameraRoiPositionValue = 0 | 1 | 2\nexport type CameraFovPreset = \"narrow\" | \"standard\" | \"wide\"\n\nexport type CameraFovRequest =\n | {\n fov: number\n roiPosition?: CameraRoiPosition\n }\n | {\n preset: CameraFovPreset\n }\n\nexport type CameraFovResult = {\n requestId: string\n fov: number\n roiPosition: CameraRoiPosition\n timestamp: number\n}\n\nexport type CameraFovOverrideRequest = CameraFovRequest & {\n /** Phone-owned lease used to make delayed releases safe. */\n leaseId: string\n /** Safety TTL; refresh the same lease/configuration to extend without a HAL restart. */\n ttlMs?: number\n}\n\nexport type CameraFovSetting = {\n fov: number\n roiPosition: CameraRoiPositionValue\n}\n\ntype NativeCameraFovSetting = {\n fov: number\n roi_position: CameraRoiPositionValue\n}\n\nexport type MicPreference = \"auto\" | \"phone\" | \"glasses\" | \"bluetooth\"\nexport type MicMode = \"phone\" | \"glasses\" | \"bluetoothClassic\" | \"bluetooth\"\n\nexport type PhotoRequestParams = {\n requestId?: string\n appId?: string\n size: PhotoSize\n mode?: PhotoMode\n /** `direct` disables BLE fallback; `ble` skips direct upload and forces phone-relayed transfer. */\n transferMethod?: PhotoTransferMethod\n webhookUrl: string | null\n authToken: string | null\n compress: PhotoCompression\n save?: boolean\n sound: boolean\n exposureTimeNs?: number | null\n /** Sensor ISO for this capture only. Only used when exposureTimeNs enables manual exposure. */\n iso?: number | null\n /** After AE convergence, divide metered exposure by this factor (scan mode). */\n aeExposureDivisor?: number\n /** Cap ISO after AE metering (scan mode). */\n isoCap?: number\n /** Requested on wire; glasses may log not_implemented. */\n noiseReduction?: boolean\n edgeEnhancement?: boolean\n /** ZSL buffering. Forced off for manual/scan stills because fixed sensor controls take priority. */\n zsl?: boolean\n /** MFNR still capture. Forced off for manual/scan stills because fixed sensor controls take priority. */\n mfnr?: boolean\n ispDigitalGain?: number\n ispAnalogGain?: string\n}\n\nexport type WarmUpCameraParams = {\n /** Supply this when the owner needs to call stopCameraWarmUp during teardown. */\n requestId?: string\n size: PhotoSize\n mode?: PhotoMode\n exposureTimeNs?: number | null\n /** Ready-state hold; defaults to 15 seconds and is capped at 60 seconds by ASG. */\n durationMs?: number\n /** ZSL preview buffering for the warm-up session. */\n zsl?: boolean\n /** MFNR still capture for the warm-up session. */\n mfnr?: boolean\n}\n\nexport type StreamVideoConfig = {\n width?: number\n height?: number\n bitrate?: number\n fps?: number\n}\n\nexport type StreamAudioConfig = {\n bitrate?: number\n sampleRate?: number\n echoCancellation?: boolean\n noiseSuppression?: boolean\n}\n\nexport type StreamStartRequest = {\n type?: \"start_stream\"\n streamUrl: string\n streamId?: string\n sound?: boolean\n video?: StreamVideoConfig\n audio?: StreamAudioConfig\n}\n\nexport type StreamKeepAliveRequest = {\n type?: \"keep_stream_alive\"\n streamId: string\n ackId: string\n}\n\nexport type PairFailureEvent = {\n type: \"pair_failure\"\n error: string\n}\n\nexport type PairingInfoEvent = {\n had_previous_bond: boolean\n /** 16-char uppercase hex transfer id when secure pairing is active. */\n transfer_id?: string\n pairing_code?: string\n classic_bond_ready?: boolean\n secure_pairing_capable?: boolean\n protocol_version?: number\n /** Credential binding mode negotiated for this transfer, when reported by the glasses. */\n binding?: \"ctkd\" | \"temporal\" | \"none\" | string\n}\n\nexport type EnteringPairingModeEvent = {\n window_ms: number\n reason?: string\n txn?: number\n}\n\nexport type OwnerReplacedEvent = {\n reason: string\n}\n\nexport type AudioPairingNeededEvent = {\n type: \"audio_pairing_needed\"\n deviceName: string\n}\n\nexport type AudioConnectedEvent = {\n type: \"audio_connected\"\n deviceName: string\n}\n\nexport type AudioDisconnectedEvent = {\n type: \"audio_disconnected\"\n}\n\nexport type SaveSettingEvent = {\n type: \"save_setting\"\n key: string\n value: any\n}\n\nexport type WsTextEvent = {\n type: \"ws_text\"\n text: string\n}\n\nexport type WsBinEvent = {\n type: \"ws_bin\"\n base64: string\n}\n\nexport type MicPcmEvent = {\n type: \"mic_pcm\"\n pcm: ArrayBuffer\n sampleRate: 16000\n bitsPerSample: 16\n channels: 1\n encoding: \"pcm_s16le\"\n voiceActivityDetectionEnabled: boolean\n}\n\nexport type MicLc3Event = {\n type: \"mic_lc3\"\n lc3: ArrayBuffer\n sampleRate: 16000\n channels: 1\n encoding: \"lc3\"\n frameDurationMs: 10\n frameSizeBytes: number\n bitrate: number\n packetizedFromGlasses: boolean\n voiceActivityDetectionEnabled: boolean\n}\n\n/** Native glasses-microphone diagnostics emitted when the SDK detects a transport or decode issue. */\nexport type MicHealthEvent = {\n type: \"mic_health\"\n reason: \"sequence_gap\" | \"decode_failure\"\n sequenceGapEvents: number\n decodeFailures: number\n lastLc3ReceivedAt?: number\n lastPcmProducedAt?: number\n timestamp: number\n}\n\nexport type StreamStatusLifecycleState = \"initializing\" | \"streaming\" | \"stopping\" | \"stopped\"\nexport type StreamStatusReconnectState = \"reconnecting\" | \"reconnected\" | \"reconnect_failed\"\nexport type StreamStatusState = StreamStatusLifecycleState | StreamStatusReconnectState | \"error\"\n\n/** Effective stream settings reported by the glasses after defaults and clamps. */\nexport type StreamResolvedConfig = {\n transport?: \"rtmp\" | \"srt\" | \"whip\"\n video?: {\n /** Encoded output width sent to the stream endpoint. */\n width: number\n /** Encoded output height sent to the stream endpoint. */\n height: number\n /** Native camera buffer width selected before crop/downscale. */\n captureWidth?: number\n /** Native camera buffer height selected before crop/downscale. */\n captureHeight?: number\n /** Encoded video bitrate in bits per second. */\n bitrate: number\n /** Resolved capture/encode frame rate. */\n fps: number\n }\n audio?: {\n /** Encoded audio bitrate in bits per second. */\n bitrate?: number\n /** Audio sample rate in Hz. */\n sampleRate?: number\n echoCancellation?: boolean\n noiseSuppression?: boolean\n }\n}\n\n/** Live encoder and device telemetry emitted periodically by supported glasses firmware. */\nexport type StreamLiveStats = {\n /** Current encoded video bitrate in bits per second. */\n bitrate?: number\n /** Current encode frame rate. */\n fps?: number\n droppedFrames?: number\n /** Seconds since the stream started. */\n duration?: number\n /** Device temperature in 闂佺娅i悡? if the hardware reports it. */\n temperatureC?: number\n}\n\ntype StreamStatusCommon = {\n type: \"stream_status\"\n streamId?: string\n timestamp?: number\n resolvedConfig?: StreamResolvedConfig\n stats?: StreamLiveStats\n}\n\nexport type StreamStatusEvent =\n | (StreamStatusCommon & {\n kind: \"lifecycle\"\n status: StreamStatusLifecycleState\n })\n | (StreamStatusCommon & {\n kind: \"reconnect\"\n status: \"reconnecting\"\n attempt: number\n maxAttempts: number\n reason: string\n })\n | (StreamStatusCommon & {\n kind: \"reconnect\"\n status: \"reconnected\"\n attempt: number\n })\n | (StreamStatusCommon & {\n kind: \"reconnect\"\n status: \"reconnect_failed\"\n maxAttempts: number\n })\n | (StreamStatusCommon & {\n kind: \"error\"\n status: \"error\"\n errorDetails: string\n })\n | (StreamStatusCommon & {\n kind: \"snapshot\"\n status: \"streaming\" | \"reconnecting\" | \"stopped\"\n streaming: boolean\n reconnecting: boolean\n attempt?: number\n })\n\nexport type KeepAliveAckEvent = {\n type: \"keep_alive_ack\"\n streamId: string\n ackId: string\n timestamp?: number\n}\n\nexport type MtkUpdateCompleteEvent = {\n type: \"mtk_update_complete\"\n message: string\n timestamp: number\n}\n\n/**\n * The glasses process restarted while the BES kept the BLE link alive (its `sid`\n * changed, or first appeared after an update from a pre-sid build). There is no\n * physical disconnect for this — treat it as the logical reconnect edge.\n */\nexport type GlassesSessionChangedEvent = {\n type: \"glasses_session_changed\"\n previous_sid: string\n sid: string\n}\n\n/** @deprecated Glasses no longer emit ota_progress; use {@link OtaStatusEvent} and status-store mapping. */\nexport type OtaProgressEvent = {\n type: \"ota_progress\"\n stage?: OtaStage\n status?: OtaProgressStatus\n progress?: number\n bytes_downloaded?: number\n total_bytes?: number\n current_update?: string\n error_message?: string\n}\n\nexport type OtaStartAckEvent = {\n type: \"ota_start_ack\"\n timestamp: number\n}\nexport type OtaStatusEvent = {\n type: \"ota_status\"\n session_id: string\n total_steps: number\n current_step: number\n step_type: \"apk\" | \"mtk\" | \"bes\"\n phase: \"download\" | \"install\"\n step_percent: number\n overall_percent: number\n status: \"in_progress\" | \"step_complete\" | \"complete\" | \"failed\" | \"idle\"\n error_message?: string\n}\n\nexport type OtaQueryResult = OtaStatusEvent\n\n/** Nex BLE protobuf trace (NexEventUtils); payload matches native Map keys. */\nexport type BleCommandTraceEvent = {\n command: string\n commandText: string\n timestamp: number\n}\n\nexport type MiniappSelectedEvent = {\n type: \"miniapp_selected\"\n packageName: string\n}\n\n// Union type of all native/internal Bluetooth SDK events.\nexport type BluetoothSdkInternalEvent = Parameters<BluetoothSdkModuleEvents[keyof BluetoothSdkModuleEvents]>[0]\n\nexport type BluetoothSdkModuleEvents = {\n glasses_status: (changed: Partial<GlassesStatus>) => void\n bluetooth_status: (changed: Partial<BluetoothStatus>) => void\n log: (event: LogEvent) => void\n device_discovered: (device: Device) => void\n default_device_changed: (event: {device?: Device}) => void\n // Individual event handlers\n glasses_not_ready: (event: GlassesNotReadyEvent) => void\n button_press: (event: ButtonPressEvent) => void\n touch_event: (event: TouchEvent) => void\n accel_event: (event: AccelEvent) => void\n head_up: (event: HeadUpEvent) => void\n voice_activity_detection_status: (event: VoiceActivityDetectionStatusEvent) => void\n speaking_status: (event: SpeakingStatusEvent) => void\n battery_status: (event: BatteryStatusEvent) => void\n local_transcription: (event: LocalTranscriptionEvent) => void\n phone_notification: (event: PhoneNotificationEvent) => void\n phone_notification_dismissed: (event: PhoneNotificationDismissedEvent) => void\n wifi_status_change: (event: WifiStatusChangeEvent) => void\n wifi_scan_result: (event: WifiScanResultEvent) => void\n hotspot_status_change: (event: HotspotStatusChangeEvent) => void\n hotspot_error: (event: HotspotErrorEvent) => void\n photo_response: (event: PhotoResponseEvent) => void\n photo_status: (event: PhotoStatusEvent) => void\n camera_status: (event: CameraStatusEvent) => void\n video_recording_status: (event: VideoRecordingStatusEvent) => void\n media_success: (event: MediaUploadSuccessEvent) => void\n media_error: (event: MediaUploadErrorEvent) => void\n gallery_status: (event: GalleryStatusEvent) => void\n compatible_glasses_search_stop: (event: CompatibleGlassesSearchStopEvent) => void\n heartbeat_sent: (event: HeartbeatSentEvent) => void\n heartbeat_received: (event: HeartbeatReceivedEvent) => void\n swipe_volume_status: (event: SwipeVolumeStatusEvent) => void\n switch_status: (event: SwitchStatusEvent) => void\n rgb_led_control_response: (event: RgbLedControlResponseEvent) => void\n settings_ack: (event: SettingsAckEvent) => void\n pair_failure: (event: PairFailureEvent) => void\n pairing_info: (event: PairingInfoEvent) => void\n entering_pairing_mode: (event: EnteringPairingModeEvent) => void\n owner_replaced: (event: OwnerReplacedEvent) => void\n audio_pairing_needed: (event: AudioPairingNeededEvent) => void\n audio_connected: (event: AudioConnectedEvent) => void\n audio_disconnected: (event: AudioDisconnectedEvent) => void\n save_setting: (event: SaveSettingEvent) => void\n ws_text: (event: WsTextEvent) => void\n ws_bin: (event: WsBinEvent) => void\n mic_pcm: (event: MicPcmEvent) => void\n mic_lc3: (event: MicLc3Event) => void\n mic_health: (event: MicHealthEvent) => void\n stream_status: (event: StreamStatusEvent) => void\n keep_alive_ack: (event: KeepAliveAckEvent) => void\n mtk_update_complete: (event: MtkUpdateCompleteEvent) => void\n glasses_session_changed: (event: GlassesSessionChangedEvent) => void\n ota_start_ack: (event: OtaStartAckEvent) => void\n ota_status: (event: OtaStatusEvent) => void\n ar99_ota_status: (event: Ar99OtaStatusEvent) => void\n version_info: (event: VersionInfoEvent) => void\n send_command_to_ble: (event: BleCommandTraceEvent) => void\n receive_command_from_ble: (event: BleCommandTraceEvent) => void\n miniapp_selected: (event: MiniappSelectedEvent) => void\n extraction_progress: (event: ExtractionProgressEvent) => void\n}\n\nexport interface ExtractionProgressEvent {\n percentage: number\n bytesRead: number\n totalBytes: number\n}\n\nexport interface Ar99OtaStatusEvent {\n type: \"ar99_ota_status\"\n phase: string\n progress: number\n offset: number\n total: number\n errorMessage?: string\n error_message?: string\n}\n\nexport interface PhoneNotificationEvent {\n notificationId: string\n app: string\n title: string\n content: string\n priority: string\n timestamp: number\n packageName: string\n}\n\nexport interface PhoneNotificationDismissedEvent {\n notificationId: string\n notificationKey: string\n packageName: string\n timestamp: number\n}\n\nexport type PublicGlassesStatus = Omit<\n GlassesStatus,\n \"otaUpdateAvailable\" | \"otaProgress\" | \"otaInProgress\" | \"otaVersionUrl\"\n>\n\nexport type PublicBluetoothStatus = Pick<\n BluetoothStatus,\n | \"searching\"\n | \"searchingController\"\n | \"systemMicUnavailable\"\n | \"micRanking\"\n | \"currentMic\"\n | \"searchResults\"\n | \"wifiScanResults\"\n | \"lastLog\"\n | \"otherBtConnected\"\n | \"galleryModeEnabled\"\n>\n\nexport type BluetoothSdkEventMap = {\n log: LogEvent\n device_discovered: Device\n default_device_changed: {device?: Device}\n glasses_not_ready: GlassesNotReadyEvent\n button_press: ButtonPressEvent\n touch_event: TouchEvent\n accel_event: AccelEvent\n head_up: HeadUpEvent\n voice_activity_detection_status: VoiceActivityDetectionStatusEvent\n speaking_status: SpeakingStatusEvent\n battery_status: BatteryStatusEvent\n local_transcription: LocalTranscriptionEvent\n wifi_status_change: WifiStatusChangeEvent\n wifi_scan_result: WifiScanResultEvent\n hotspot_status_change: HotspotStatusChangeEvent\n hotspot_error: HotspotErrorEvent\n photo_response: PhotoResponseEvent\n photo_status: PhotoStatusEvent\n camera_status: CameraStatusEvent\n video_recording_status: VideoRecordingStatusEvent\n media_success: MediaUploadSuccessEvent\n media_error: MediaUploadErrorEvent\n gallery_status: GalleryStatusEvent\n compatible_glasses_search_stop: CompatibleGlassesSearchStopEvent\n swipe_volume_status: SwipeVolumeStatusEvent\n switch_status: SwitchStatusEvent\n rgb_led_control_response: RgbLedControlResponseEvent\n settings_ack: SettingsAckEvent\n pair_failure: PairFailureEvent\n pairing_info: PairingInfoEvent\n entering_pairing_mode: EnteringPairingModeEvent\n owner_replaced: OwnerReplacedEvent\n audio_pairing_needed: AudioPairingNeededEvent\n audio_connected: AudioConnectedEvent\n audio_disconnected: AudioDisconnectedEvent\n mic_pcm: MicPcmEvent\n mic_lc3: MicLc3Event\n mic_health: MicHealthEvent\n stream_status: StreamStatusEvent\n ota_start_ack: OtaStartAckEvent\n ota_status: OtaStatusEvent\n ar99_ota_status: Ar99OtaStatusEvent\n version_info: VersionInfoEvent\n extraction_progress: ExtractionProgressEvent\n}\n\nexport type BluetoothSdkEventName = keyof BluetoothSdkEventMap\n\nexport type BluetoothSdkEventListener<EventName extends BluetoothSdkEventName> = (\n event: BluetoothSdkEventMap[EventName],\n) => void\n\nexport type BluetoothSdkSubscription = {\n remove(): void\n}\n\nexport type BluetoothSdkEvent = BluetoothSdkEventMap[BluetoothSdkEventName]\n\nexport interface BluetoothSdkPublicModule {\n addListener<EventName extends BluetoothSdkEventName>(\n eventName: EventName,\n listener: BluetoothSdkEventListener<EventName>,\n ): BluetoothSdkSubscription\n\n getDefaultDevice(): Promise<Device | null>\n setDefaultDevice(device: Device | null): Promise<void>\n clearDefaultDevice(): Promise<void>\n\n startScan(model: DeviceModel): Promise<void>\n stopScan(): Promise<void>\n scan(options: ScanOptions): Promise<Device[]>\n scan(model: DeviceModel, options?: ScanModelOptions): Promise<Device[]>\n connect(device: Device, options?: ConnectOptions): Promise<void>\n connectDefault(options?: ConnectOptions): Promise<void>\n cancelConnectionAttempt(): Promise<void>\n disconnect(): Promise<void>\n forget(): Promise<void>\n\n displayText(text: string, x?: number, y?: number, size?: number): Promise<void>\n clearDisplay(): Promise<void>\n showDashboard(): Promise<void>\n setDashboardPosition(height: number, depth: number): Promise<void>\n setHeadUpAngle(angleDegrees: number): Promise<void>\n setImuEnabled(enabled: boolean): Promise<void>\n setScreenDisabled(disabled: boolean): Promise<void>\n\n requestWifiScan(): Promise<WifiSearchResult[]>\n sendWifiCredentials(ssid: string, password: string): Promise<WifiStatusChangeEvent>\n forgetWifiNetwork(ssid: string): Promise<WifiStatusChangeEvent>\n setHotspotState(enabled: boolean): Promise<HotspotStatusChangeEvent>\n /** Enable or disable Wi-Fi ADB on Mentra Live (no-op on other devices). */\n setWifiAdbState(enabled: boolean): Promise<void>\n\n setGalleryModeEnabled(enabled: boolean): Promise<SettingsAckSuccessEvent>\n setVoiceActivityDetectionEnabled(enabled: boolean): Promise<void>\n setLoudnessGateEnabled(enabled: boolean): Promise<void>\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(settings: PhotoCaptureDefaults): Promise<SettingsAckSuccessEvent>\n setVideoRecordingDefaults(settings: VideoRecordingDefaults): Promise<SettingsAckSuccessEvent>\n setMaxVideoRecordingDuration(minutes: number): Promise<SettingsAckSuccessEvent>\n setCameraFov(request: CameraFovRequest): Promise<CameraFovResult>\n /** One-way FOV command for legacy ASG clients that do not send settings acknowledgements. */\n setLegacyCameraFov(request: CameraFovRequest): Promise<CameraFovResult>\n setCameraFovOverride(request: CameraFovOverrideRequest): Promise<CameraFovResult>\n releaseCameraFovOverride(leaseId: string): Promise<SettingsAckSuccessEvent>\n /**\n * Configure camera HAL tuning (ANR / gain) on Mentra Live glasses.\n *\n * The phone sends a {@code camera_tuning_config} BLE command; the glasses relay it as a\n * {@code camconfig} broadcast to the camera HAL so parameters take effect without a reboot.\n *\n * **Scan-mode convention**: call with `(false, false)` when activating scan mode to disable ANR\n * and pixsmart gain for sharper text/barcode captures. Call with `(true, true)` to restore\n * defaults when exiting scan mode.\n *\n * @param anrOn `true` = ANR enabled (default), `false` = ANR disabled\n * @param gainOn `true` = stock gain params (default), `false` = pixsmart gain-off params\n */\n setCameraTuningConfig(anrOn: boolean, gainOn: boolean): Promise<SettingsAckSuccessEvent>\n queryGalleryStatus(): Promise<GalleryStatusEvent>\n requestPhoto(params: PhotoRequestParams): Promise<PhotoSuccessResponseEvent>\n warmUpCamera(params: WarmUpCameraParams): Promise<CameraStatusEvent>\n /** Release one request-owned warm-up. Opening requests reject with camera_warm_up_cancelled. */\n stopCameraWarmUp(requestId: string): Promise<void>\n startVideoRecording(\n requestId: string,\n save: boolean,\n sound: boolean,\n settings?: VideoRecordingSettings,\n ): Promise<VideoRecordingStartedStatusEvent>\n /**\n * Stop the active recording. When {@link webhookUrl} is provided, the glasses\n * upload the recorded video to it (multipart) using {@link authToken}. These\n * are supplied at stop time (not start) so the token is fresh when the upload\n * runs 闂?a recording can last arbitrarily long. An empty/omitted webhook keeps\n * the video on device (no upload).\n */\n stopVideoRecording(\n requestId: string,\n webhookUrl?: string,\n authToken?: string,\n ): Promise<VideoRecordingStoppedStatusEvent>\n /** Query the glasses for the current recording state and elapsed duration. */\n queryVideoRecordingStatus(requestId: string): Promise<VideoRecordingStatusEvent>\n\n startStream(params: StreamStartRequest): Promise<StreamStatusEvent>\n stopStream(): Promise<StreamStatusEvent>\n\n setMicState(enabled: boolean, useGlassesMic?: boolean, sendTranscript?: boolean, sendLc3Data?: boolean): Promise<void>\n setPreferredMic(preferredMic: MicPreference): Promise<void>\n setOwnAppAudioPlaying(playing: boolean): Promise<void>\n getGlassesMediaVolume(): Promise<GlassesMediaVolumeGetResult>\n setGlassesMediaVolume(level: number): Promise<GlassesMediaVolumeSetResult>\n\n rgbLedControl(\n requestId: string,\n packageName: string | null,\n action: RgbLedAction,\n color: RgbLedColor | null,\n onDurationMs: number,\n offDurationMs: number,\n count: number,\n ): Promise<RgbLedControlSuccessResponseEvent>\n\n requestVersionInfo(): Promise<VersionInfoResult>\n /**\n * Select the OTA manifest used by subsequent update checks and installs.\n * The URL may point at Mentra's hosted manifest or any customer-controlled HTTP(S) server.\n */\n setOtaVersionUrl(otaVersionUrl: string): void\n /** Return the configured or release-embedded OTA manifest URL. Rejects when a source build is unconfigured. */\n getOtaVersionUrl(): string\n /** Fetch the configured OTA manifest and return whether any ASG/BES/MTK update is available. */\n checkForOtaUpdate(): Promise<boolean>\n /** Start OTA from the configured or explicitly supplied manifest URL. */\n startOtaUpdate(otaVersionUrl?: string | null): Promise<OtaStartAckEvent>\n startAr99OtaFromFile(path: string): Promise<boolean>\n cancelAr99Ota(): Promise<void>\n sendAr99FactoryReset(): Promise<void>\n buildAr99OtaSignature(\n secret: string,\n appName: string,\n currentVersion: string,\n serialNumber: string,\n nonce: string,\n ): string\n\n // // stt commands (MOVE TO CRUST)\n // setSttModelDetails(path: string, languageCode: string): Promise<void>\n // getSttModelPath(): Promise<string>\n // checkSttModelAvailable(): Promise<boolean>\n // validateSttModel(path: string): Promise<boolean>\n // extractTarBz2(sourcePath: string, destinationPath: string): Promise<boolean>\n\n // // tts commands (MOVE TO CRUST)\n // setTtsModelDetails(path: string, languageCode: string): Promise<void>\n // getTtsModelPath(): Promise<string>\n // getTtsModelLanguage(): Promise<string>\n // checkTtsModelAvailable(): Promise<boolean>\n // validateTtsModel(path: string): Promise<boolean>\n // generateTtsAudio(text: string, path: string, outputPath: string, speakerId: number, speed: number): Promise<boolean>\n\n // STT Commands (TODO: MOVE TO CRUST)\n setSttModelDetails(path: string, languageCode: string): Promise<void>\n getSttModelPath(): Promise<string>\n checkSttModelAvailable(): Promise<boolean>\n validateSttModel(path: string): Promise<boolean>\n extractTarBz2(sourcePath: string, destinationPath: string): Promise<boolean>\n restartTranscriber(): Promise<void>\n\n // TTS Commands (TODO: MOVE TO CRUST)\n setTtsModelDetails(path: string, languageCode: string): Promise<void>\n getTtsModelPath(): Promise<string>\n getTtsModelLanguage(): Promise<string>\n checkTtsModelAvailable(): Promise<boolean>\n validateTtsModel(path: string): Promise<boolean>\n generateTtsAudio(\n text: string,\n modelPath: string,\n outputPath: string,\n speakerId: number,\n speed: number,\n ): Promise<boolean>\n}\n\n// OTA update status types\nexport type OtaStage = \"download\" | \"install\"\nexport type OtaProgressStatus = \"STARTED\" | \"PROGRESS\" | \"FINISHED\" | \"FAILED\"\n\nexport interface OtaStatus {\n sessionId: string\n totalSteps: number\n currentStep: number\n stepType: \"apk\" | \"mtk\" | \"bes\"\n phase: \"download\" | \"install\"\n stepPercent: number\n overallPercent: number\n status: \"in_progress\" | \"step_complete\" | \"complete\" | \"failed\" | \"idle\"\n error?: string\n}\n\nexport interface OtaUpdateInfo {\n available: boolean\n versionCode: number\n versionName: string\n updates: string[] // [\"apk\", \"mtk\", \"bes\"]\n totalSize: number\n cacheReady?: boolean\n /** Exact BES target selected from the OTA manifest, when a BES step is pending. */\n besVersion?: string\n /** True when the APK step installs an older build than the glasses currently run (exact-pin manifests only). */\n isDowngrade?: boolean\n}\n\nexport interface OtaProgress {\n stage: OtaStage\n status: OtaProgressStatus\n progress: number\n bytesDownloaded: number\n totalBytes: number\n currentUpdate: string\n errorMessage?: string\n}\n\nexport interface GlassesStatus {\n // state:\n connection: GlassesConnectionStatus\n micEnabled: boolean\n voiceActivityDetectionEnabled: boolean\n bluetoothClassicConnected: boolean\n signalStrength: number\n /** Milliseconds since epoch when signalStrength was last refreshed by the phone BLE stack. */\n signalStrengthUpdatedAt: number\n // device info\n deviceModel: string\n androidVersion: string\n firmwareVersion: string\n besFirmwareVersion: string\n mtkFirmwareVersion: string\n bluetoothMacAddress: string\n wifiMacAddress: string\n leftMacAddress: string\n rightMacAddress: string\n buildNumber: string\n /** Glasses System.currentTimeMillis() from last version_info (clock skew detection). */\n systemTimeMs?: number\n otaVersionUrl: string\n appVersion: string\n /** Phone-served hotspot OTA protocol version; 0 means unsupported/legacy glasses. */\n hotspotOtaVersion: number\n bluetoothName: string\n serialNumber: string\n style: string\n color: string\n // wifi info\n wifi: WifiStatus\n // battery info\n batteryLevel: number\n charging: boolean\n caseBatteryLevel: number\n caseCharging: boolean\n caseOpen: boolean\n caseRemoved: boolean\n // hotspot info\n hotspot: HotspotStatus\n // OTA update info\n otaUpdateAvailable: OtaUpdateInfo | null\n otaProgress: OtaProgress | null\n otaInProgress: boolean\n // ring info\n controllerConnected: boolean\n controllerFullyBooted: boolean\n controllerMacAddress: string\n controllerBatteryLevel: number\n controllerSignalStrength: number\n}\n\nexport interface CoreDashboardMenuItem {\n name: string\n packageName: string\n running: boolean\n}\n\nexport interface CalendarEvent {\n title: string\n location?: string\n time: string\n endDate: number\n}\n\nexport interface CoreSettings {\n menu_apps: CoreDashboardMenuItem[]\n calendar_events: CalendarEvent[]\n}\n\nexport interface Device {\n /**\n * Stable app-facing key for this scan result, within the limits of the\n * platform identifier available to the SDK. Do not parse this value; use the\n * typed model, name, address, projectName, and rssi fields instead.\n */\n id: string\n model: DeviceModel\n name: string\n /** Platform address/identifier when available: Android Bluetooth address, iOS CoreBluetooth identifier. */\n address?: string\n /** Optional AR99 project discriminator. Supported value: AR99. */\n projectName?: string\n /**\n * Optional scan signal strength. It may be undefined at first discovery and\n * appear in a later scan update when the platform reports RSSI metadata.\n */\n rssi?: number\n /** Mentra Live: unit is currently in pairing mode (adv flag). */\n pairingMode?: boolean\n /** Mentra Live: four-character hex spoken pairing code when available. */\n pairingCode?: string\n /** Mentra Live: advertisement carries the secure-pairing capability trailer. */\n securePairingCapable?: boolean\n}\n\nexport interface ConnectOptions {\n saveAsDefault?: boolean\n cancelExistingConnectionAttempt?: boolean\n}\n\nexport type ScanResultsCallback = (devices: Device[]) => void\n\nexport interface ScanOptions {\n model: DeviceModel\n /** Defaults to 15000. */\n timeoutMs?: number\n /** Alias for `timeoutMs`, useful when mirroring native examples. */\n timeout?: number\n /** Called every time the discovered device list changes during the scan. */\n onResults?: ScanResultsCallback\n}\n\nexport type ScanModelOptions = Omit<ScanOptions, \"model\">\n\nexport interface WifiSearchResult {\n ssid: string\n requiresPassword: boolean\n signalStrength: number\n /** Frequency in MHz (from glasses scan). 5 GHz band is typically 5170闂?825. Omitted if unknown. */\n frequency?: number\n}\n\nexport interface BluetoothStatus {\n // state:\n searching: boolean\n searchingController: boolean\n default_wearable?: DeviceModel | \"\"\n pending_wearable?: DeviceModel | \"\"\n device_name?: string\n device_address?: string\n default_controller?: DeviceModel | \"\"\n pending_controller?: DeviceModel | \"\"\n controller_device_name?: string\n controller_address?: string\n systemMicUnavailable: boolean\n micRanking: MicMode[]\n currentMic: MicMode | \"\" | null\n /**\n * Nearby glasses in stable discovery order.\n * Existing entries keep their array position as details refresh; new glasses append at the end,\n * and removals should not reorder remaining entries.\n */\n searchResults: Device[]\n wifiScanResults: WifiSearchResult[]\n lastLog: string[]\n otherBtConnected: boolean\n // desired settings the SDK sends to compatible connected glasses:\n galleryModeEnabled: boolean\n}\n\nexport type BluetoothSettingsUpdate = Partial<{\n auth_email: string\n core_token: string\n sensing_enabled: boolean\n power_saving_mode: boolean\n lc3_frame_size: number\n preferred_mic: MicPreference\n screen_disabled: boolean\n contextual_dashboard: boolean\n head_up_angle: number\n imu_enabled: boolean\n brightness: number\n auto_brightness: boolean\n dashboard_height: number\n dashboard_depth: number\n menu_apps: DashboardMenuItem[] | CoreDashboardMenuItem[] | Array<Record<string, unknown>> | null\n calendar_events: CalendarEvent[]\n metric_system: boolean\n twelve_hour_time: boolean\n gallery_mode: boolean\n voice_activity_detection_enabled: boolean\n loudness_gate_enabled: boolean\n button_photo_size: ButtonPhotoSize\n button_video_settings: {width: number; height: number; fps: number}\n button_video_width: number\n button_video_height: number\n button_video_fps: number\n button_max_recording_time: number\n camera_fov: NativeCameraFovSetting\n should_send_pcm: boolean\n should_send_lc3: boolean\n should_send_transcript: boolean\n offline_mode: boolean\n local_stt_fallback_active: boolean\n pending_wearable: DeviceModel | \"\"\n default_wearable: DeviceModel | \"\"\n device_name: string\n device_address: string\n default_controller: DeviceModel | \"\"\n pending_controller: DeviceModel | \"\"\n controller_device_name: string\n controller_address: string\n}>\n"]}
|
|
1
|
+
{"version":3,"file":"BluetoothSdk.types.js","sourceRoot":"","sources":["../src/BluetoothSdk.types.ts"],"names":[],"mappings":"AAwCA,MAAM,CAAC,MAAM,wCAAwC,GAAG,KAAK,CAAA;AAwB7D,MAAM,UAAU,kCAAkC,CAChD,MAA+B;IAE/B,OAAO,MAAM,CAAC,KAAK,KAAK,WAAW,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,MAA+B;IAC5E,OAAO,MAAM,CAAC,KAAK,KAAK,WAAW,IAAI,MAAM,CAAC,WAAW,CAAA;AAC3D,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,MAA+B;IAC3E,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,KAAK,KAAK,YAAY,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,CAAA;AACnG,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,OAAO;QACL,UAAU,EAAE,EAAC,KAAK,EAAE,cAAc,EAAC;QACnC,OAAO,EAAE,EAAC,KAAK,EAAE,UAAU,EAAC;QAC5B,6BAA6B,EAAE,wCAAwC;QACvE,IAAI,EAAE,EAAC,KAAK,EAAE,cAAc,EAAC;KAC9B,CAAA;AACH,CAAC;AA2BD,MAAM,UAAU,qBAAqB,CAAC,MAAkB;IACtD,OAAO,MAAM,CAAC,KAAK,KAAK,WAAW,CAAA;AACrC,CAAC;AAoBD,MAAM,UAAU,sBAAsB,CAAC,MAAqB;IAC1D,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS,CAAA;AACnC,CAAC;AAmXD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE,mBAAmB;IAC9B,EAAE,EAAE,mBAAmB;IACvB,EAAE,EAAE,mBAAmB;IACvB,UAAU,EAAE,aAAa;IACzB,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,iBAAiB;IACxB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,mBAAmB;CACf,CAAA;AAWV,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AACjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAA","sourcesContent":["// Bluetooth SDK Event Types\nexport type GlassesNotReadyEvent = {\n type: \"glasses_not_ready\"\n message: string\n}\n\n// NOTE: unlike most events below, the native module does NOT include a `type`\n// field on the button_press payload 闂?it sends only {buttonId, pressType,\n// timestamp} (see BluetoothSdkModule on both iOS and Android). Consumers must\n// filter on `pressType` / the \"button_press\" listener name, never `event.type`.\nexport type ButtonPressEvent = {\n buttonId: string\n pressType: \"long\" | \"short\"\n timestamp: number\n}\n\nexport type TouchEvent = {\n type: \"touch_event\"\n deviceModel: DeviceModel\n gestureName: string\n timestamp: number\n}\n\nexport type AccelEvent = {\n type: \"accel_event\"\n x: number\n y: number\n z: number\n timestamp: number\n}\n\nexport type HeadUpEvent = {\n up: boolean\n}\n\nexport type VoiceActivityDetectionStatusEvent = {\n type: \"voice_activity_detection_status\"\n voiceActivityDetectionEnabled: boolean\n}\n\nexport const DEFAULT_VOICE_ACTIVITY_DETECTION_ENABLED = false\n\nexport type SpeakingStatusEvent = {\n type: \"speaking_status\"\n speaking: boolean\n timestamp: number\n}\n\nexport type BatteryStatusEvent = {\n type: \"battery_status\"\n level: number\n charging: boolean\n timestamp: number\n}\n\nexport type GlassesConnectionStatus =\n | {state: \"disconnected\"}\n | {state: \"scanning\"}\n | {state: \"connecting\"}\n | {state: \"bonding\"}\n | {state: \"connected\"; fullyBooted: boolean}\n\nexport type ConnectedGlassesConnectionStatus = Extract<GlassesConnectionStatus, {state: \"connected\"}>\n\nexport function isConnectedGlassesConnectionStatus(\n status: GlassesConnectionStatus,\n): status is ConnectedGlassesConnectionStatus {\n return status.state === \"connected\"\n}\n\nexport function isReadyGlassesConnectionStatus(status: GlassesConnectionStatus): boolean {\n return status.state === \"connected\" && status.fullyBooted\n}\n\nexport function isBusyGlassesConnectionStatus(status: GlassesConnectionStatus): boolean {\n return status.state === \"scanning\" || status.state === \"connecting\" || status.state === \"bonding\"\n}\n\nexport function createDisconnectedGlassesStatus(): Partial<GlassesStatus> {\n return {\n connection: {state: \"disconnected\"},\n hotspot: {state: \"disabled\"},\n voiceActivityDetectionEnabled: DEFAULT_VOICE_ACTIVITY_DETECTION_ENABLED,\n wifi: {state: \"disconnected\"},\n }\n}\n\n/** K900 `sr_getvol` response (Mentra Live glasses media step volume 0闂?5). */\nexport type GlassesMediaVolumeGetResult = {\n level: number\n statusCode: number\n}\n\n/** K900 `sr_vol` acknowledgment. */\nexport type GlassesMediaVolumeSetResult = {\n statusCode: number\n}\n\nexport type LocalTranscriptionEvent = {\n text: string\n isFinal?: boolean\n transcribeLanguage?: string\n}\n\nexport type LogEvent = {\n message: string\n}\n\nexport type WifiStatus = {state: \"disconnected\"} | {state: \"connected\"; ssid: string; localIp?: string}\n\nexport type ConnectedWifiStatus = Extract<WifiStatus, {state: \"connected\"}>\n\nexport function isConnectedWifiStatus(status: WifiStatus): status is ConnectedWifiStatus {\n return status.state === \"connected\"\n}\n\nexport type WifiStatusChangeEvent = WifiStatus & {\n type: \"wifi_status_change\"\n /**\n * Glasses-reported provisioning failure reason when THIS event is the verdict of a\n * failed connect attempt; absent on routine link-state updates. An attempt property,\n * not a link property 闂?which is why it lives on the event, not on WifiStatus:\n * \"connect_timeout\" arrives on a disconnected status (never associated), while\n * \"connected_to_other_network\" arrives on a *connected* status (the attempt failed\n * and the glasses ended up on / fell back to a different SSID than requested).\n * Requires ASG client v40+ 闂?older glasses never send it.\n */\n error?: string\n}\n\nexport type HotspotStatus = {state: \"disabled\"} | {state: \"enabled\"; ssid: string; password: string; localIp: string}\n\nexport type EnabledHotspotStatus = Extract<HotspotStatus, {state: \"enabled\"}>\n\nexport function isEnabledHotspotStatus(status: HotspotStatus): status is EnabledHotspotStatus {\n return status.state === \"enabled\"\n}\n\nexport type HotspotStatusChangeEvent = HotspotStatus & {\n type: \"hotspot_status_change\"\n}\n\nexport type HotspotErrorEvent = {\n type: \"hotspot_error\"\n errorMessage: string\n timestamp: number\n}\n\nexport type VersionInfoResult = {\n androidVersion: string\n firmwareVersion: string\n besFirmwareVersion: string\n mtkFirmwareVersion: string\n buildNumber: string\n systemTimeMs?: number\n otaVersionUrl: string\n appVersion: string\n /** Phone-served hotspot OTA protocol version; 0 means unsupported/legacy glasses. */\n hotspotOtaVersion: number\n}\n\nexport type VersionInfoEvent = VersionInfoResult & {\n type: \"version_info\"\n}\n\nexport type WifiScanResultEvent = {\n type: \"wifi_scan_result\"\n networks: WifiSearchResult[]\n scanComplete?: boolean\n}\n\nexport type PhotoResponseEvent =\n | {\n type: \"photo_response\"\n state: \"success\"\n requestId: string\n uploadUrl: string\n photoUrl?: string\n statusUrl?: string\n contentType?: string\n fileSizeBytes?: number\n timestamp: number\n }\n | {\n type: \"photo_response\"\n state: \"error\"\n requestId: string\n timestamp: number\n errorCode?: string\n errorMessage: string\n }\n\nexport type PhotoSuccessResponseEvent = Extract<PhotoResponseEvent, {state: \"success\"}>\n\nexport type PhotoStatusState =\n | \"accepted\"\n | \"queued\"\n | \"configuring\"\n | \"capturing\"\n | \"captured\"\n | \"compressing\"\n | \"ble_fallback_compression\"\n | \"uploading\"\n | \"uploaded\"\n | \"ready_for_transfer\"\n | \"transferring\"\n | \"failed\"\n\nexport type PhotoResolvedConfig = {\n format?: \"jpeg\" | string\n width?: number\n height?: number\n quality?: number\n requestedSize?: PhotoSize | string\n source?: \"sdk\" | \"button\" | string\n transferMethod?: \"webhook\" | \"ble\" | \"local\" | string\n compression?: PhotoCompression | string\n saveToGallery?: boolean\n exposureTimeNs?: number\n iso?: number\n}\n\nexport type PhotoFpsRange = {\n min?: number\n max?: number\n}\n\nexport type PhotoRequestedCaptureConfig = {\n manual?: boolean\n exposureTimeNs?: number\n iso?: number\n frameDurationNs?: number\n aeMode?: number\n aeLock?: boolean\n aeExposureCompensation?: number\n aeTargetFpsRange?: PhotoFpsRange\n noiseReductionMode?: number\n edgeMode?: number\n afMode?: number\n zsl?: boolean\n}\n\nexport type PhotoMeteredPreview = {\n exposureTimeNs?: number\n iso?: number\n totalLightProxy?: number\n}\n\nexport type PhotoCaptureMetadata = {\n manual?: boolean\n exposureTimeNs?: number\n iso?: number\n frameDurationNs?: number\n aeMode?: number\n aeState?: number\n aeStateName?: string\n noiseReductionMode?: number\n edgeMode?: number\n zsl?: boolean\n sensorTimestampNs?: number\n totalLightProxy?: number\n mfnrLikely?: boolean\n mfnrApplied?: boolean\n width?: number\n height?: number\n noiseReductionWarning?: \"not_implemented\" | string\n ispDigitalGainWarning?: \"not_implemented\" | string\n ispAnalogGainWarning?: \"not_implemented\" | string\n [key: string]: unknown\n}\n\nexport type PhotoStatusEvent = {\n type: \"photo_status\"\n requestId: string\n status: PhotoStatusState | string\n timestamp: number\n resolvedConfig?: PhotoResolvedConfig\n requestedCaptureConfig?: PhotoRequestedCaptureConfig\n meteredPreview?: PhotoMeteredPreview\n captureMetadata?: PhotoCaptureMetadata\n errorCode?: string\n errorMessage?: string\n}\n\nexport type CameraStatusEvent = {\n type: \"camera_status\"\n requestId: string\n state: \"warming\" | \"ready\" | \"stopped\" | \"error\" | string\n timestamp: number\n errorCode?: string\n errorMessage?: string\n}\n\nexport type VideoRecordingStatusEvent = {\n type: \"video_recording_status\"\n requestId?: string\n success: boolean\n status: VideoRecordingStatusState\n details?: string | null\n timestamp: number\n data?: {\n recording?: boolean\n duration_ms?: number\n duration_formatted?: string\n [key: string]: unknown\n }\n}\n\nexport type VideoRecordingStatusState =\n | \"recording_started\"\n | \"recording_status\"\n | \"already_recording\"\n | \"recording_stopped\"\n | \"not_recording\"\n | \"request_id_mismatch\"\n | \"service_unavailable\"\n | \"json_error\"\n | \"battery_low\"\n | \"camera_busy\"\n | \"storage_unavailable\"\n | \"integrity_failed\"\n | \"error\"\n\nexport type VideoRecordingStartedStatusEvent = Omit<VideoRecordingStatusEvent, \"success\" | \"status\"> & {\n success: true\n status: \"recording_started\"\n}\n\nexport type VideoRecordingStoppedStatusEvent = Omit<VideoRecordingStatusEvent, \"success\" | \"status\"> & {\n success: true\n status: \"recording_stopped\"\n}\n\nexport type VideoRecordingSuccessStatusEvent = VideoRecordingStartedStatusEvent | VideoRecordingStoppedStatusEvent\n\nexport type MediaUploadSuccessEvent = {\n type: \"media_success\"\n requestId: string\n mediaUrl: string\n mediaType: number\n timestamp: number\n}\n\nexport type MediaUploadErrorEvent = {\n type: \"media_error\"\n requestId: string\n errorMessage: string\n mediaType: number\n timestamp: number\n}\n\nexport type MediaUploadEvent = MediaUploadSuccessEvent | MediaUploadErrorEvent\n\nexport type GalleryStatusEvent = {\n type: \"gallery_status\"\n photos: number\n videos: number\n total: number\n totalSize?: number\n hasContent: boolean\n cameraBusy: boolean\n cameraBusyReason?: \"video\" | \"stream\" | (string & {})\n}\n\nexport type CompatibleGlassesSearchStopEvent = {\n type: \"compatible_glasses_search_stop\"\n deviceModel: DeviceModel\n}\n\nexport type HeartbeatSentEvent = {\n type: \"heartbeat_sent\"\n heartbeat_sent: {\n timestamp: number\n }\n}\n\nexport type HeartbeatReceivedEvent = {\n type: \"heartbeat_received\"\n heartbeat_received: {\n timestamp: number\n }\n}\n\nexport type SwipeVolumeStatusEvent = {\n type: \"swipe_volume_status\"\n enabled: boolean\n timestamp: number\n}\n\nexport type SwitchStatusEvent = {\n type: \"switch_status\"\n switchType?: number\n switchValue?: number\n timestamp: number\n}\n\nexport type RgbLedControlResponseEvent =\n | {\n type: \"rgb_led_control_response\"\n state: \"success\"\n requestId: string\n }\n | {\n type: \"rgb_led_control_response\"\n state: \"error\"\n requestId: string\n errorCode: string\n }\n\nexport type RgbLedControlSuccessResponseEvent = Extract<RgbLedControlResponseEvent, {state: \"success\"}>\n\nexport type SettingsAckStatus = \"applied\" | \"ready\" | \"error\" | \"failed\" | \"failure\" | \"rejected\"\n\nexport type SettingsAckSetting =\n | \"gallery_mode\"\n | \"button_photo\"\n | \"button_video_recording\"\n | \"button_max_recording_time\"\n | \"camera_fov\"\n | \"camera_fov_override\"\n | \"camera_tuning\"\n\nexport type SettingsAckEvent = {\n type: \"settings_ack\"\n requestId: string\n setting: SettingsAckSetting\n status: SettingsAckStatus\n timestamp: number\n fov?: number\n roiPosition?: CameraRoiPositionValue\n hardwareApplied?: boolean\n leaseId?: string\n active?: boolean\n size?: ButtonPhotoSize | string\n width?: number\n height?: number\n fps?: number\n enabled?: boolean\n minutes?: number\n /** ANR enabled flag; present when setting === \"camera_tuning\" */\n anr?: boolean\n /** Stock-gain flag; present when setting === \"camera_tuning\" */\n gain?: boolean\n errorCode?: string\n errorMessage?: string\n}\n\nexport type SettingsAckSuccessStatus = Exclude<SettingsAckStatus, \"error\" | \"failed\" | \"failure\" | \"rejected\">\n\nexport type SettingsAckSuccessEvent = Omit<SettingsAckEvent, \"status\"> & {\n status: SettingsAckSuccessStatus\n}\n\nexport type RgbLedAction = \"on\" | \"off\"\nexport type RgbLedColor = \"red\" | \"green\" | \"blue\" | \"orange\" | \"white\"\nexport type PhotoSize = \"low\" | \"medium\" | \"high\" | \"max\"\nexport type PhotoMode = \"photo\" | \"text\"\nexport type PhotoTransferMethod = \"auto\" | \"direct\" | \"ble\"\nexport type ButtonPhotoSize = \"low\" | \"medium\" | \"high\" | \"max\"\n\n/**\n * @deprecated Sticky action-button photo presets via {@link BluetoothSdkPublicModule.setPhotoCaptureDefaults}\n * are deprecated. Prefer per-request {@link BluetoothSdkPublicModule.requestPhoto} options\n * (e.g. `mode: \"text\"` for text sensor size/crop, or explicit `aeExposureDivisor`) instead of\n * persisting button-photo tuning on the glasses.\n */\nexport type PhotoCaptureDefaults = {\n size?: PhotoSize\n /** ZSL preview buffering for physical camera-button photos. */\n zsl?: boolean\n /** MFNR still capture for physical camera-button photos. */\n mfnr?: boolean\n noiseReduction?: boolean\n edgeEnhancement?: boolean\n ispDigitalGain?: number\n ispAnalogGain?: string\n aeExposureDivisor?: number\n isoCap?: number\n compress?: PhotoCompression\n sound?: boolean\n /** When true, clears stored NR/edge/ISP presets on the glasses before applying other fields. */\n resetCaptureTuning?: boolean\n}\nexport type PhotoCompression = \"none\" | \"medium\" | \"heavy\"\n\nexport type VideoRecordingDefaults = {\n width: number\n height: number\n fps: number\n}\n\n/**\n * Optional per-recording video settings for {@link startVideoRecording}. When\n * omitted, the glasses fall back to their saved video recording defaults. Any\n * field left undefined is omitted from the BLE command (glasses default applies).\n */\nexport interface VideoRecordingSettings {\n width?: number\n height?: number\n fps?: number\n /**\n * Optional auto-stop timer in minutes, sent on `start_video_recording`.\n * `0` (the default) means record until stopped or interrupted\n * (battery/storage/thermal/error).\n */\n maxRecordingTimeMinutes?: number\n}\nexport const DeviceModels = {\n Simulated: \"Simulated Glasses\",\n G1: \"Even Realities G1\",\n G2: \"Even Realities G2\",\n MentraLive: \"Mentra Live\",\n MentraNex: \"Mentra Display\",\n Mach1: \"Mentra Mach1\",\n Z100: \"Vuzix Z100\",\n Frame: \"Brilliant Frame\",\n Nimo: \"NIMO\",\n Ar99: \"AR99\",\n R1: \"Even Realities R1\",\n} as const\n\nexport type DeviceModel = (typeof DeviceModels)[keyof typeof DeviceModels]\nexport type ObservableStoreCategory = \"glasses\" | \"bluetooth\" | \"core\"\n\nexport type DashboardMenuItem = {\n title: string\n packageName: string\n values?: Record<string, unknown>\n}\n\nexport const CAMERA_FOV_MIN = 62\nexport const CAMERA_FOV_MAX = 118\nexport const CAMERA_FOV_DEFAULT = CAMERA_FOV_MAX\n\nexport type CameraRoiPosition = \"center\" | \"bottom\" | \"top\"\nexport type CameraRoiPositionValue = 0 | 1 | 2\nexport type CameraFovPreset = \"narrow\" | \"standard\" | \"wide\"\n\nexport type CameraFovRequest =\n | {\n fov: number\n roiPosition?: CameraRoiPosition\n }\n | {\n preset: CameraFovPreset\n }\n\nexport type CameraFovResult = {\n requestId: string\n fov: number\n roiPosition: CameraRoiPosition\n timestamp: number\n}\n\nexport type CameraFovOverrideRequest = CameraFovRequest & {\n /** Phone-owned lease used to make delayed releases safe. */\n leaseId: string\n /** Safety TTL; refresh the same lease/configuration to extend without a HAL restart. */\n ttlMs?: number\n}\n\nexport type CameraFovSetting = {\n fov: number\n roiPosition: CameraRoiPositionValue\n}\n\ntype NativeCameraFovSetting = {\n fov: number\n roi_position: CameraRoiPositionValue\n}\n\nexport type MicPreference = \"auto\" | \"phone\" | \"glasses\" | \"bluetooth\"\nexport type MicMode = \"phone\" | \"glasses\" | \"bluetoothClassic\" | \"bluetooth\"\n\nexport type PhotoRequestParams = {\n requestId?: string\n appId?: string\n size: PhotoSize\n mode?: PhotoMode\n /** `direct` disables BLE fallback; `ble` skips direct upload and forces phone-relayed transfer. */\n transferMethod?: PhotoTransferMethod\n webhookUrl: string | null\n authToken: string | null\n compress: PhotoCompression\n save?: boolean\n sound: boolean\n exposureTimeNs?: number | null\n /** Sensor ISO for this capture only. Only used when exposureTimeNs enables manual exposure. */\n iso?: number | null\n /** After AE convergence, divide metered exposure by this factor (scan mode). */\n aeExposureDivisor?: number\n /** Cap ISO after AE metering (scan mode). */\n isoCap?: number\n /** Requested on wire; glasses may log not_implemented. */\n noiseReduction?: boolean\n edgeEnhancement?: boolean\n /** ZSL buffering. Forced off for manual/scan stills because fixed sensor controls take priority. */\n zsl?: boolean\n /** MFNR still capture. Forced off for manual/scan stills because fixed sensor controls take priority. */\n mfnr?: boolean\n ispDigitalGain?: number\n ispAnalogGain?: string\n}\n\nexport type WarmUpCameraParams = {\n /** Supply this when the owner needs to call stopCameraWarmUp during teardown. */\n requestId?: string\n size: PhotoSize\n mode?: PhotoMode\n exposureTimeNs?: number | null\n /** Ready-state hold; defaults to 15 seconds and is capped at 60 seconds by ASG. */\n durationMs?: number\n /** ZSL preview buffering for the warm-up session. */\n zsl?: boolean\n /** MFNR still capture for the warm-up session. */\n mfnr?: boolean\n}\n\nexport type StreamVideoConfig = {\n width?: number\n height?: number\n bitrate?: number\n fps?: number\n}\n\nexport type StreamAudioConfig = {\n bitrate?: number\n sampleRate?: number\n echoCancellation?: boolean\n noiseSuppression?: boolean\n}\n\nexport type StreamStartRequest = {\n type?: \"start_stream\"\n streamUrl: string\n streamId?: string\n sound?: boolean\n video?: StreamVideoConfig\n audio?: StreamAudioConfig\n}\n\nexport type StreamKeepAliveRequest = {\n type?: \"keep_stream_alive\"\n streamId: string\n ackId: string\n}\n\nexport type PairFailureEvent = {\n type: \"pair_failure\"\n error: string\n}\n\nexport type PairingInfoEvent = {\n had_previous_bond: boolean\n pairing_code?: string\n classic_bond_ready?: boolean\n secure_pairing_capable?: boolean\n protocol_version?: number\n}\n\nexport type EnteringPairingModeEvent = {\n window_ms: number\n reason?: string\n}\n\nexport type OwnerReplacedEvent = {\n reason: string\n}\n\nexport type AudioPairingNeededEvent = {\n type: \"audio_pairing_needed\"\n deviceName: string\n}\n\nexport type AudioConnectedEvent = {\n type: \"audio_connected\"\n deviceName: string\n}\n\nexport type AudioDisconnectedEvent = {\n type: \"audio_disconnected\"\n}\n\nexport type SaveSettingEvent = {\n type: \"save_setting\"\n key: string\n value: any\n}\n\nexport type WsTextEvent = {\n type: \"ws_text\"\n text: string\n}\n\nexport type WsBinEvent = {\n type: \"ws_bin\"\n base64: string\n}\n\nexport type MicPcmEvent = {\n type: \"mic_pcm\"\n pcm: ArrayBuffer\n sampleRate: 16000\n bitsPerSample: 16\n channels: 1\n encoding: \"pcm_s16le\"\n voiceActivityDetectionEnabled: boolean\n}\n\nexport type MicLc3Event = {\n type: \"mic_lc3\"\n lc3: ArrayBuffer\n sampleRate: 16000\n channels: 1\n encoding: \"lc3\"\n frameDurationMs: 10\n frameSizeBytes: number\n bitrate: number\n packetizedFromGlasses: boolean\n voiceActivityDetectionEnabled: boolean\n}\n\n/** Native glasses-microphone diagnostics emitted when the SDK detects a transport or decode issue. */\nexport type MicHealthEvent = {\n type: \"mic_health\"\n reason: \"sequence_gap\" | \"decode_failure\"\n sequenceGapEvents: number\n decodeFailures: number\n lastLc3ReceivedAt?: number\n lastPcmProducedAt?: number\n timestamp: number\n}\n\nexport type StreamStatusLifecycleState = \"initializing\" | \"streaming\" | \"stopping\" | \"stopped\"\nexport type StreamStatusReconnectState = \"reconnecting\" | \"reconnected\" | \"reconnect_failed\"\nexport type StreamStatusState = StreamStatusLifecycleState | StreamStatusReconnectState | \"error\"\n\n/** Effective stream settings reported by the glasses after defaults and clamps. */\nexport type StreamResolvedConfig = {\n transport?: \"rtmp\" | \"srt\" | \"whip\"\n video?: {\n /** Encoded output width sent to the stream endpoint. */\n width: number\n /** Encoded output height sent to the stream endpoint. */\n height: number\n /** Native camera buffer width selected before crop/downscale. */\n captureWidth?: number\n /** Native camera buffer height selected before crop/downscale. */\n captureHeight?: number\n /** Encoded video bitrate in bits per second. */\n bitrate: number\n /** Resolved capture/encode frame rate. */\n fps: number\n }\n audio?: {\n /** Encoded audio bitrate in bits per second. */\n bitrate?: number\n /** Audio sample rate in Hz. */\n sampleRate?: number\n echoCancellation?: boolean\n noiseSuppression?: boolean\n }\n}\n\n/** Live encoder and device telemetry emitted periodically by supported glasses firmware. */\nexport type StreamLiveStats = {\n /** Current encoded video bitrate in bits per second. */\n bitrate?: number\n /** Current encode frame rate. */\n fps?: number\n droppedFrames?: number\n /** Seconds since the stream started. */\n duration?: number\n /** Device temperature in 闂佺娅i悡? if the hardware reports it. */\n temperatureC?: number\n}\n\ntype StreamStatusCommon = {\n type: \"stream_status\"\n streamId?: string\n timestamp?: number\n resolvedConfig?: StreamResolvedConfig\n stats?: StreamLiveStats\n}\n\nexport type StreamStatusEvent =\n | (StreamStatusCommon & {\n kind: \"lifecycle\"\n status: StreamStatusLifecycleState\n })\n | (StreamStatusCommon & {\n kind: \"reconnect\"\n status: \"reconnecting\"\n attempt: number\n maxAttempts: number\n reason: string\n })\n | (StreamStatusCommon & {\n kind: \"reconnect\"\n status: \"reconnected\"\n attempt: number\n })\n | (StreamStatusCommon & {\n kind: \"reconnect\"\n status: \"reconnect_failed\"\n maxAttempts: number\n })\n | (StreamStatusCommon & {\n kind: \"error\"\n status: \"error\"\n errorDetails: string\n })\n | (StreamStatusCommon & {\n kind: \"snapshot\"\n status: \"streaming\" | \"reconnecting\" | \"stopped\"\n streaming: boolean\n reconnecting: boolean\n attempt?: number\n })\n\nexport type KeepAliveAckEvent = {\n type: \"keep_alive_ack\"\n streamId: string\n ackId: string\n timestamp?: number\n}\n\nexport type MtkUpdateCompleteEvent = {\n type: \"mtk_update_complete\"\n message: string\n timestamp: number\n}\n\n/**\n * The glasses process restarted while the BES kept the BLE link alive (its `sid`\n * changed, or first appeared after an update from a pre-sid build). There is no\n * physical disconnect for this — treat it as the logical reconnect edge.\n */\nexport type GlassesSessionChangedEvent = {\n type: \"glasses_session_changed\"\n previous_sid: string\n sid: string\n}\n\n/** @deprecated Glasses no longer emit ota_progress; use {@link OtaStatusEvent} and status-store mapping. */\nexport type OtaProgressEvent = {\n type: \"ota_progress\"\n stage?: OtaStage\n status?: OtaProgressStatus\n progress?: number\n bytes_downloaded?: number\n total_bytes?: number\n current_update?: string\n error_message?: string\n}\n\nexport type OtaStartAckEvent = {\n type: \"ota_start_ack\"\n timestamp: number\n}\nexport type OtaStatusEvent = {\n type: \"ota_status\"\n session_id: string\n total_steps: number\n current_step: number\n step_type: \"apk\" | \"mtk\" | \"bes\"\n phase: \"download\" | \"install\"\n step_percent: number\n overall_percent: number\n status: \"in_progress\" | \"step_complete\" | \"complete\" | \"failed\" | \"idle\"\n error_message?: string\n}\n\nexport type OtaQueryResult = OtaStatusEvent\n\n/** Nex BLE protobuf trace (NexEventUtils); payload matches native Map keys. */\nexport type BleCommandTraceEvent = {\n command: string\n commandText: string\n timestamp: number\n}\n\nexport type MiniappSelectedEvent = {\n type: \"miniapp_selected\"\n packageName: string\n}\n\n// Union type of all native/internal Bluetooth SDK events.\nexport type BluetoothSdkInternalEvent = Parameters<BluetoothSdkModuleEvents[keyof BluetoothSdkModuleEvents]>[0]\n\nexport type BluetoothSdkModuleEvents = {\n glasses_status: (changed: Partial<GlassesStatus>) => void\n bluetooth_status: (changed: Partial<BluetoothStatus>) => void\n log: (event: LogEvent) => void\n device_discovered: (device: Device) => void\n default_device_changed: (event: {device?: Device}) => void\n // Individual event handlers\n glasses_not_ready: (event: GlassesNotReadyEvent) => void\n button_press: (event: ButtonPressEvent) => void\n touch_event: (event: TouchEvent) => void\n accel_event: (event: AccelEvent) => void\n head_up: (event: HeadUpEvent) => void\n voice_activity_detection_status: (event: VoiceActivityDetectionStatusEvent) => void\n speaking_status: (event: SpeakingStatusEvent) => void\n battery_status: (event: BatteryStatusEvent) => void\n local_transcription: (event: LocalTranscriptionEvent) => void\n phone_notification: (event: PhoneNotificationEvent) => void\n phone_notification_dismissed: (event: PhoneNotificationDismissedEvent) => void\n wifi_status_change: (event: WifiStatusChangeEvent) => void\n wifi_scan_result: (event: WifiScanResultEvent) => void\n hotspot_status_change: (event: HotspotStatusChangeEvent) => void\n hotspot_error: (event: HotspotErrorEvent) => void\n photo_response: (event: PhotoResponseEvent) => void\n photo_status: (event: PhotoStatusEvent) => void\n camera_status: (event: CameraStatusEvent) => void\n video_recording_status: (event: VideoRecordingStatusEvent) => void\n media_success: (event: MediaUploadSuccessEvent) => void\n media_error: (event: MediaUploadErrorEvent) => void\n gallery_status: (event: GalleryStatusEvent) => void\n compatible_glasses_search_stop: (event: CompatibleGlassesSearchStopEvent) => void\n heartbeat_sent: (event: HeartbeatSentEvent) => void\n heartbeat_received: (event: HeartbeatReceivedEvent) => void\n swipe_volume_status: (event: SwipeVolumeStatusEvent) => void\n switch_status: (event: SwitchStatusEvent) => void\n rgb_led_control_response: (event: RgbLedControlResponseEvent) => void\n settings_ack: (event: SettingsAckEvent) => void\n pair_failure: (event: PairFailureEvent) => void\n pairing_info: (event: PairingInfoEvent) => void\n entering_pairing_mode: (event: EnteringPairingModeEvent) => void\n owner_replaced: (event: OwnerReplacedEvent) => void\n audio_pairing_needed: (event: AudioPairingNeededEvent) => void\n audio_connected: (event: AudioConnectedEvent) => void\n audio_disconnected: (event: AudioDisconnectedEvent) => void\n save_setting: (event: SaveSettingEvent) => void\n ws_text: (event: WsTextEvent) => void\n ws_bin: (event: WsBinEvent) => void\n mic_pcm: (event: MicPcmEvent) => void\n mic_lc3: (event: MicLc3Event) => void\n mic_health: (event: MicHealthEvent) => void\n stream_status: (event: StreamStatusEvent) => void\n keep_alive_ack: (event: KeepAliveAckEvent) => void\n mtk_update_complete: (event: MtkUpdateCompleteEvent) => void\n glasses_session_changed: (event: GlassesSessionChangedEvent) => void\n ota_start_ack: (event: OtaStartAckEvent) => void\n ota_status: (event: OtaStatusEvent) => void\n ar99_ota_status: (event: Ar99OtaStatusEvent) => void\n version_info: (event: VersionInfoEvent) => void\n send_command_to_ble: (event: BleCommandTraceEvent) => void\n receive_command_from_ble: (event: BleCommandTraceEvent) => void\n miniapp_selected: (event: MiniappSelectedEvent) => void\n extraction_progress: (event: ExtractionProgressEvent) => void\n}\n\nexport interface ExtractionProgressEvent {\n percentage: number\n bytesRead: number\n totalBytes: number\n}\n\nexport interface Ar99OtaStatusEvent {\n type: \"ar99_ota_status\"\n phase: string\n progress: number\n offset: number\n total: number\n errorMessage?: string\n error_message?: string\n}\n\nexport interface PhoneNotificationEvent {\n notificationId: string\n app: string\n title: string\n content: string\n priority: string\n timestamp: number\n packageName: string\n}\n\nexport interface PhoneNotificationDismissedEvent {\n notificationId: string\n notificationKey: string\n packageName: string\n timestamp: number\n}\n\nexport type PublicGlassesStatus = Omit<\n GlassesStatus,\n \"otaUpdateAvailable\" | \"otaProgress\" | \"otaInProgress\" | \"otaVersionUrl\"\n>\n\nexport type PublicBluetoothStatus = Pick<\n BluetoothStatus,\n | \"searching\"\n | \"searchingController\"\n | \"systemMicUnavailable\"\n | \"micRanking\"\n | \"currentMic\"\n | \"searchResults\"\n | \"wifiScanResults\"\n | \"lastLog\"\n | \"otherBtConnected\"\n | \"galleryModeEnabled\"\n>\n\nexport type BluetoothSdkEventMap = {\n log: LogEvent\n device_discovered: Device\n default_device_changed: {device?: Device}\n glasses_not_ready: GlassesNotReadyEvent\n button_press: ButtonPressEvent\n touch_event: TouchEvent\n accel_event: AccelEvent\n head_up: HeadUpEvent\n voice_activity_detection_status: VoiceActivityDetectionStatusEvent\n speaking_status: SpeakingStatusEvent\n battery_status: BatteryStatusEvent\n local_transcription: LocalTranscriptionEvent\n wifi_status_change: WifiStatusChangeEvent\n wifi_scan_result: WifiScanResultEvent\n hotspot_status_change: HotspotStatusChangeEvent\n hotspot_error: HotspotErrorEvent\n photo_response: PhotoResponseEvent\n photo_status: PhotoStatusEvent\n camera_status: CameraStatusEvent\n video_recording_status: VideoRecordingStatusEvent\n media_success: MediaUploadSuccessEvent\n media_error: MediaUploadErrorEvent\n gallery_status: GalleryStatusEvent\n compatible_glasses_search_stop: CompatibleGlassesSearchStopEvent\n swipe_volume_status: SwipeVolumeStatusEvent\n switch_status: SwitchStatusEvent\n rgb_led_control_response: RgbLedControlResponseEvent\n settings_ack: SettingsAckEvent\n pair_failure: PairFailureEvent\n pairing_info: PairingInfoEvent\n entering_pairing_mode: EnteringPairingModeEvent\n owner_replaced: OwnerReplacedEvent\n audio_pairing_needed: AudioPairingNeededEvent\n audio_connected: AudioConnectedEvent\n audio_disconnected: AudioDisconnectedEvent\n mic_pcm: MicPcmEvent\n mic_lc3: MicLc3Event\n mic_health: MicHealthEvent\n stream_status: StreamStatusEvent\n ota_start_ack: OtaStartAckEvent\n ota_status: OtaStatusEvent\n ar99_ota_status: Ar99OtaStatusEvent\n version_info: VersionInfoEvent\n extraction_progress: ExtractionProgressEvent\n}\n\nexport type BluetoothSdkEventName = keyof BluetoothSdkEventMap\n\nexport type BluetoothSdkEventListener<EventName extends BluetoothSdkEventName> = (\n event: BluetoothSdkEventMap[EventName],\n) => void\n\nexport type BluetoothSdkSubscription = {\n remove(): void\n}\n\nexport type BluetoothSdkEvent = BluetoothSdkEventMap[BluetoothSdkEventName]\n\nexport interface BluetoothSdkPublicModule {\n addListener<EventName extends BluetoothSdkEventName>(\n eventName: EventName,\n listener: BluetoothSdkEventListener<EventName>,\n ): BluetoothSdkSubscription\n\n getDefaultDevice(): Promise<Device | null>\n setDefaultDevice(device: Device | null): Promise<void>\n clearDefaultDevice(): Promise<void>\n\n startScan(model: DeviceModel): Promise<void>\n stopScan(): Promise<void>\n scan(options: ScanOptions): Promise<Device[]>\n scan(model: DeviceModel, options?: ScanModelOptions): Promise<Device[]>\n connect(device: Device, options?: ConnectOptions): Promise<void>\n connectDefault(options?: ConnectOptions): Promise<void>\n cancelConnectionAttempt(): Promise<void>\n disconnect(): Promise<void>\n forget(): Promise<void>\n\n displayText(text: string, x?: number, y?: number, size?: number): Promise<void>\n clearDisplay(): Promise<void>\n showDashboard(): Promise<void>\n setDashboardPosition(height: number, depth: number): Promise<void>\n setHeadUpAngle(angleDegrees: number): Promise<void>\n setImuEnabled(enabled: boolean): Promise<void>\n setScreenDisabled(disabled: boolean): Promise<void>\n\n requestWifiScan(): Promise<WifiSearchResult[]>\n sendWifiCredentials(ssid: string, password: string): Promise<WifiStatusChangeEvent>\n forgetWifiNetwork(ssid: string): Promise<WifiStatusChangeEvent>\n setHotspotState(enabled: boolean): Promise<HotspotStatusChangeEvent>\n /** Enable or disable Wi-Fi ADB on Mentra Live (no-op on other devices). */\n setWifiAdbState(enabled: boolean): Promise<void>\n\n setGalleryModeEnabled(enabled: boolean): Promise<SettingsAckSuccessEvent>\n setVoiceActivityDetectionEnabled(enabled: boolean): Promise<void>\n setLoudnessGateEnabled(enabled: boolean): Promise<void>\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(settings: PhotoCaptureDefaults): Promise<SettingsAckSuccessEvent>\n setVideoRecordingDefaults(settings: VideoRecordingDefaults): Promise<SettingsAckSuccessEvent>\n setMaxVideoRecordingDuration(minutes: number): Promise<SettingsAckSuccessEvent>\n setCameraFov(request: CameraFovRequest): Promise<CameraFovResult>\n /** One-way FOV command for legacy ASG clients that do not send settings acknowledgements. */\n setLegacyCameraFov(request: CameraFovRequest): Promise<CameraFovResult>\n setCameraFovOverride(request: CameraFovOverrideRequest): Promise<CameraFovResult>\n releaseCameraFovOverride(leaseId: string): Promise<SettingsAckSuccessEvent>\n /**\n * Configure camera HAL tuning (ANR / gain) on Mentra Live glasses.\n *\n * The phone sends a {@code camera_tuning_config} BLE command; the glasses relay it as a\n * {@code camconfig} broadcast to the camera HAL so parameters take effect without a reboot.\n *\n * **Scan-mode convention**: call with `(false, false)` when activating scan mode to disable ANR\n * and pixsmart gain for sharper text/barcode captures. Call with `(true, true)` to restore\n * defaults when exiting scan mode.\n *\n * @param anrOn `true` = ANR enabled (default), `false` = ANR disabled\n * @param gainOn `true` = stock gain params (default), `false` = pixsmart gain-off params\n */\n setCameraTuningConfig(anrOn: boolean, gainOn: boolean): Promise<SettingsAckSuccessEvent>\n queryGalleryStatus(): Promise<GalleryStatusEvent>\n requestPhoto(params: PhotoRequestParams): Promise<PhotoSuccessResponseEvent>\n warmUpCamera(params: WarmUpCameraParams): Promise<CameraStatusEvent>\n /** Release one request-owned warm-up. Opening requests reject with camera_warm_up_cancelled. */\n stopCameraWarmUp(requestId: string): Promise<void>\n startVideoRecording(\n requestId: string,\n save: boolean,\n sound: boolean,\n settings?: VideoRecordingSettings,\n ): Promise<VideoRecordingStartedStatusEvent>\n /**\n * Stop the active recording. When {@link webhookUrl} is provided, the glasses\n * upload the recorded video to it (multipart) using {@link authToken}. These\n * are supplied at stop time (not start) so the token is fresh when the upload\n * runs 闂?a recording can last arbitrarily long. An empty/omitted webhook keeps\n * the video on device (no upload).\n */\n stopVideoRecording(\n requestId: string,\n webhookUrl?: string,\n authToken?: string,\n ): Promise<VideoRecordingStoppedStatusEvent>\n /** Query the glasses for the current recording state and elapsed duration. */\n queryVideoRecordingStatus(requestId: string): Promise<VideoRecordingStatusEvent>\n\n startStream(params: StreamStartRequest): Promise<StreamStatusEvent>\n stopStream(): Promise<StreamStatusEvent>\n\n setMicState(enabled: boolean, useGlassesMic?: boolean, sendTranscript?: boolean, sendLc3Data?: boolean): Promise<void>\n setPreferredMic(preferredMic: MicPreference): Promise<void>\n setOwnAppAudioPlaying(playing: boolean): Promise<void>\n getGlassesMediaVolume(): Promise<GlassesMediaVolumeGetResult>\n setGlassesMediaVolume(level: number): Promise<GlassesMediaVolumeSetResult>\n\n rgbLedControl(\n requestId: string,\n packageName: string | null,\n action: RgbLedAction,\n color: RgbLedColor | null,\n onDurationMs: number,\n offDurationMs: number,\n count: number,\n ): Promise<RgbLedControlSuccessResponseEvent>\n\n requestVersionInfo(): Promise<VersionInfoResult>\n /**\n * Select the OTA manifest used by subsequent update checks and installs.\n * The URL may point at Mentra's hosted manifest or any customer-controlled HTTP(S) server.\n */\n setOtaVersionUrl(otaVersionUrl: string): void\n /** Return the configured or release-embedded OTA manifest URL. Rejects when a source build is unconfigured. */\n getOtaVersionUrl(): string\n /** Fetch the configured OTA manifest and return whether any ASG/BES/MTK update is available. */\n checkForOtaUpdate(): Promise<boolean>\n /** Start OTA from the configured or explicitly supplied manifest URL. */\n startOtaUpdate(otaVersionUrl?: string | null): Promise<OtaStartAckEvent>\n startAr99OtaFromFile(path: string): Promise<boolean>\n cancelAr99Ota(): Promise<void>\n sendAr99FactoryReset(): Promise<void>\n buildAr99OtaSignature(\n secret: string,\n appName: string,\n currentVersion: string,\n serialNumber: string,\n nonce: string,\n ): string\n\n // // stt commands (MOVE TO CRUST)\n // setSttModelDetails(path: string, languageCode: string): Promise<void>\n // getSttModelPath(): Promise<string>\n // checkSttModelAvailable(): Promise<boolean>\n // validateSttModel(path: string): Promise<boolean>\n // extractTarBz2(sourcePath: string, destinationPath: string): Promise<boolean>\n\n // // tts commands (MOVE TO CRUST)\n // setTtsModelDetails(path: string, languageCode: string): Promise<void>\n // getTtsModelPath(): Promise<string>\n // getTtsModelLanguage(): Promise<string>\n // checkTtsModelAvailable(): Promise<boolean>\n // validateTtsModel(path: string): Promise<boolean>\n // generateTtsAudio(text: string, path: string, outputPath: string, speakerId: number, speed: number): Promise<boolean>\n\n // STT Commands (TODO: MOVE TO CRUST)\n setSttModelDetails(path: string, languageCode: string): Promise<void>\n getSttModelPath(): Promise<string>\n checkSttModelAvailable(): Promise<boolean>\n validateSttModel(path: string): Promise<boolean>\n extractTarBz2(sourcePath: string, destinationPath: string): Promise<boolean>\n restartTranscriber(): Promise<void>\n\n // TTS Commands (TODO: MOVE TO CRUST)\n setTtsModelDetails(path: string, languageCode: string): Promise<void>\n getTtsModelPath(): Promise<string>\n getTtsModelLanguage(): Promise<string>\n checkTtsModelAvailable(): Promise<boolean>\n validateTtsModel(path: string): Promise<boolean>\n generateTtsAudio(\n text: string,\n modelPath: string,\n outputPath: string,\n speakerId: number,\n speed: number,\n ): Promise<boolean>\n}\n\n// OTA update status types\nexport type OtaStage = \"download\" | \"install\"\nexport type OtaProgressStatus = \"STARTED\" | \"PROGRESS\" | \"FINISHED\" | \"FAILED\"\n\nexport interface OtaStatus {\n sessionId: string\n totalSteps: number\n currentStep: number\n stepType: \"apk\" | \"mtk\" | \"bes\"\n phase: \"download\" | \"install\"\n stepPercent: number\n overallPercent: number\n status: \"in_progress\" | \"step_complete\" | \"complete\" | \"failed\" | \"idle\"\n error?: string\n}\n\nexport interface OtaUpdateInfo {\n available: boolean\n versionCode: number\n versionName: string\n updates: string[] // [\"apk\", \"mtk\", \"bes\"]\n totalSize: number\n cacheReady?: boolean\n /** Exact BES target selected from the OTA manifest, when a BES step is pending. */\n besVersion?: string\n /** True when the APK step installs an older build than the glasses currently run (exact-pin manifests only). */\n isDowngrade?: boolean\n}\n\nexport interface OtaProgress {\n stage: OtaStage\n status: OtaProgressStatus\n progress: number\n bytesDownloaded: number\n totalBytes: number\n currentUpdate: string\n errorMessage?: string\n}\n\nexport interface GlassesStatus {\n // state:\n connection: GlassesConnectionStatus\n micEnabled: boolean\n voiceActivityDetectionEnabled: boolean\n bluetoothClassicConnected: boolean\n signalStrength: number\n /** Milliseconds since epoch when signalStrength was last refreshed by the phone BLE stack. */\n signalStrengthUpdatedAt: number\n // device info\n deviceModel: string\n androidVersion: string\n firmwareVersion: string\n besFirmwareVersion: string\n mtkFirmwareVersion: string\n bluetoothMacAddress: string\n wifiMacAddress: string\n leftMacAddress: string\n rightMacAddress: string\n buildNumber: string\n /** Glasses System.currentTimeMillis() from last version_info (clock skew detection). */\n systemTimeMs?: number\n otaVersionUrl: string\n appVersion: string\n /** Phone-served hotspot OTA protocol version; 0 means unsupported/legacy glasses. */\n hotspotOtaVersion: number\n bluetoothName: string\n serialNumber: string\n style: string\n color: string\n // wifi info\n wifi: WifiStatus\n // battery info\n batteryLevel: number\n charging: boolean\n caseBatteryLevel: number\n caseCharging: boolean\n caseOpen: boolean\n caseRemoved: boolean\n // hotspot info\n hotspot: HotspotStatus\n // OTA update info\n otaUpdateAvailable: OtaUpdateInfo | null\n otaProgress: OtaProgress | null\n otaInProgress: boolean\n // ring info\n controllerConnected: boolean\n controllerFullyBooted: boolean\n controllerMacAddress: string\n controllerBatteryLevel: number\n controllerSignalStrength: number\n}\n\nexport interface CoreDashboardMenuItem {\n name: string\n packageName: string\n running: boolean\n}\n\nexport interface CalendarEvent {\n title: string\n location?: string\n time: string\n endDate: number\n}\n\nexport interface CoreSettings {\n menu_apps: CoreDashboardMenuItem[]\n calendar_events: CalendarEvent[]\n}\n\nexport interface Device {\n /**\n * Stable app-facing key for this scan result, within the limits of the\n * platform identifier available to the SDK. Do not parse this value; use the\n * typed model, name, address, projectName, and rssi fields instead.\n */\n id: string\n model: DeviceModel\n name: string\n /** Platform address/identifier when available: Android Bluetooth address, iOS CoreBluetooth identifier. */\n address?: string\n /** Optional AR99 project discriminator. Supported value: AR99. */\n projectName?: string\n /**\n * Optional scan signal strength. It may be undefined at first discovery and\n * appear in a later scan update when the platform reports RSSI metadata.\n */\n rssi?: number\n /** Mentra Live: unit is currently in pairing mode (adv flag). */\n pairingMode?: boolean\n /** Mentra Live: four-character hex spoken pairing code when available. */\n pairingCode?: string\n /** Mentra Live: advertisement carries the secure-pairing capability trailer. */\n securePairingCapable?: boolean\n}\n\nexport interface ConnectOptions {\n saveAsDefault?: boolean\n cancelExistingConnectionAttempt?: boolean\n}\n\nexport type ScanResultsCallback = (devices: Device[]) => void\n\nexport interface ScanOptions {\n model: DeviceModel\n /** Defaults to 15000. */\n timeoutMs?: number\n /** Alias for `timeoutMs`, useful when mirroring native examples. */\n timeout?: number\n /** Called every time the discovered device list changes during the scan. */\n onResults?: ScanResultsCallback\n}\n\nexport type ScanModelOptions = Omit<ScanOptions, \"model\">\n\nexport interface WifiSearchResult {\n ssid: string\n requiresPassword: boolean\n signalStrength: number\n /** Frequency in MHz (from glasses scan). 5 GHz band is typically 5170闂?825. Omitted if unknown. */\n frequency?: number\n}\n\nexport interface BluetoothStatus {\n // state:\n searching: boolean\n searchingController: boolean\n default_wearable?: DeviceModel | \"\"\n pending_wearable?: DeviceModel | \"\"\n device_name?: string\n device_address?: string\n default_controller?: DeviceModel | \"\"\n pending_controller?: DeviceModel | \"\"\n controller_device_name?: string\n controller_address?: string\n systemMicUnavailable: boolean\n micRanking: MicMode[]\n currentMic: MicMode | \"\" | null\n /**\n * Nearby glasses in stable discovery order.\n * Existing entries keep their array position as details refresh; new glasses append at the end,\n * and removals should not reorder remaining entries.\n */\n searchResults: Device[]\n wifiScanResults: WifiSearchResult[]\n lastLog: string[]\n otherBtConnected: boolean\n // desired settings the SDK sends to compatible connected glasses:\n galleryModeEnabled: boolean\n}\n\nexport type BluetoothSettingsUpdate = Partial<{\n auth_email: string\n core_token: string\n sensing_enabled: boolean\n power_saving_mode: boolean\n lc3_frame_size: number\n preferred_mic: MicPreference\n screen_disabled: boolean\n contextual_dashboard: boolean\n head_up_angle: number\n imu_enabled: boolean\n brightness: number\n auto_brightness: boolean\n dashboard_height: number\n dashboard_depth: number\n menu_apps: DashboardMenuItem[] | CoreDashboardMenuItem[] | Array<Record<string, unknown>> | null\n calendar_events: CalendarEvent[]\n metric_system: boolean\n twelve_hour_time: boolean\n gallery_mode: boolean\n voice_activity_detection_enabled: boolean\n loudness_gate_enabled: boolean\n button_photo_size: ButtonPhotoSize\n button_video_settings: {width: number; height: number; fps: number}\n button_video_width: number\n button_video_height: number\n button_video_fps: number\n button_max_recording_time: number\n camera_fov: NativeCameraFovSetting\n should_send_pcm: boolean\n should_send_lc3: boolean\n should_send_transcript: boolean\n offline_mode: boolean\n local_stt_fallback_active: boolean\n pending_wearable: DeviceModel | \"\"\n default_wearable: DeviceModel | \"\"\n device_name: string\n device_address: string\n default_controller: DeviceModel | \"\"\n pending_controller: DeviceModel | \"\"\n controller_device_name: string\n controller_address: string\n}>\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const BLUETOOTH_SDK_RELEASE_METADATA = Object.freeze({
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"familyBaseVersion": "3.1.0",
|
|
4
|
-
"releaseIdentity": "3.1.0-dev.
|
|
5
|
-
"releaseSetId": "mentra-3.1.0-dev.
|
|
6
|
-
"sourceCommit": "
|
|
7
|
-
"otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.
|
|
8
|
-
"otaManifestSha256": "
|
|
4
|
+
"releaseIdentity": "3.1.0-dev.9",
|
|
5
|
+
"releaseSetId": "mentra-3.1.0-dev.9",
|
|
6
|
+
"sourceCommit": "24201a3bb26253c4ce435d1fc125b0164774ebec",
|
|
7
|
+
"otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.9/mentra-live-ota-3.1.0-dev.9.json",
|
|
8
|
+
"otaManifestSha256": "214d92c8894033eaab276e668cb553c79990005d3330d23aaf499a514dc08cff"
|
|
9
9
|
});
|
|
10
10
|
//# sourceMappingURL=releaseMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,8BAA8B,GAA0C,MAAM,CAAC,MAAM,CAAC;IACjG,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,aAAa;IAChC,cAAc,EAAE,oBAAoB;IACpC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,qHAAqH;IACvI,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface BluetoothSdkReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.1.0\",\n \"releaseIdentity\": \"3.1.0-dev.
|
|
1
|
+
{"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,8BAA8B,GAA0C,MAAM,CAAC,MAAM,CAAC;IACjG,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,aAAa;IAChC,cAAc,EAAE,oBAAoB;IACpC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,qHAAqH;IACvI,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface BluetoothSdkReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.1.0\",\n \"releaseIdentity\": \"3.1.0-dev.9\",\n \"releaseSetId\": \"mentra-3.1.0-dev.9\",\n \"sourceCommit\": \"24201a3bb26253c4ce435d1fc125b0164774ebec\",\n \"otaManifestUrl\": \"https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.9/mentra-live-ota-3.1.0-dev.9.json\",\n \"otaManifestSha256\": \"214d92c8894033eaab276e668cb553c79990005d3330d23aaf499a514dc08cff\"\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.9"
|
|
15
15
|
private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
|
|
16
16
|
|
|
17
17
|
private static func normalizedSdkVersion(_ value: String?) -> String? {
|
package/ios/Source/Bridge.swift
CHANGED
|
@@ -100,12 +100,10 @@ class Bridge {
|
|
|
100
100
|
|
|
101
101
|
static func sendPairingInfo(
|
|
102
102
|
hadPreviousBond: Bool,
|
|
103
|
-
transferId: String? = nil,
|
|
104
103
|
pairingCode: String? = nil,
|
|
105
104
|
classicBondReady: Bool = false,
|
|
106
105
|
securePairingCapable: Bool = true,
|
|
107
|
-
protocolVersion: Int = 1
|
|
108
|
-
binding: String? = nil
|
|
106
|
+
protocolVersion: Int = 1
|
|
109
107
|
) {
|
|
110
108
|
var body: [String: Any] = [
|
|
111
109
|
"had_previous_bond": hadPreviousBond,
|
|
@@ -113,9 +111,7 @@ class Bridge {
|
|
|
113
111
|
"secure_pairing_capable": securePairingCapable,
|
|
114
112
|
"protocol_version": protocolVersion,
|
|
115
113
|
]
|
|
116
|
-
if let transferId { body["transfer_id"] = transferId }
|
|
117
114
|
if let pairingCode { body["pairing_code"] = pairingCode }
|
|
118
|
-
if let binding { body["binding"] = binding }
|
|
119
115
|
Bridge.sendTypedMessage("pairing_info", body: body)
|
|
120
116
|
}
|
|
121
117
|
|
|
@@ -662,4 +658,3 @@ class Bridge {
|
|
|
662
658
|
|
|
663
659
|
|
|
664
660
|
|
|
665
|
-
|
|
@@ -1012,9 +1012,7 @@ struct ViewState {
|
|
|
1012
1012
|
if !pendingDeviceAddress.isEmpty {
|
|
1013
1013
|
deviceAddress = pendingDeviceAddress
|
|
1014
1014
|
}
|
|
1015
|
-
|
|
1016
|
-
pendingDeviceAddress = ""
|
|
1017
|
-
pendingWearable = ""
|
|
1015
|
+
clearPendingConnection()
|
|
1018
1016
|
defaultWearable = sgc.type
|
|
1019
1017
|
searching = false
|
|
1020
1018
|
|
|
@@ -1792,7 +1790,7 @@ struct ViewState {
|
|
|
1792
1790
|
}
|
|
1793
1791
|
|
|
1794
1792
|
Task {
|
|
1795
|
-
disconnect()
|
|
1793
|
+
disconnect(clearPendingConnection: false)
|
|
1796
1794
|
try? await Task.sleep(nanoseconds: 100 * 1_000_000) // 100ms
|
|
1797
1795
|
self.searching = true
|
|
1798
1796
|
self.pendingDeviceName = name
|
|
@@ -1826,7 +1824,7 @@ struct ViewState {
|
|
|
1826
1824
|
handleDeviceReady()
|
|
1827
1825
|
}
|
|
1828
1826
|
|
|
1829
|
-
func disconnect() {
|
|
1827
|
+
func disconnect(clearPendingConnection: Bool = true) {
|
|
1830
1828
|
sgc?.clearDisplay() // clear the screen
|
|
1831
1829
|
sgc?.disconnect()
|
|
1832
1830
|
sgc = nil // Clear the SGC reference after disconnect
|
|
@@ -1855,6 +1853,15 @@ struct ViewState {
|
|
|
1855
1853
|
DeviceStore.shared.apply("glasses", "controllerConnected", false)
|
|
1856
1854
|
controller?.disconnect()
|
|
1857
1855
|
controller = nil // Clear the controller reference after disconnect
|
|
1856
|
+
if clearPendingConnection {
|
|
1857
|
+
self.clearPendingConnection()
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
private func clearPendingConnection() {
|
|
1862
|
+
pendingDeviceName = ""
|
|
1863
|
+
pendingDeviceAddress = ""
|
|
1864
|
+
pendingWearable = ""
|
|
1858
1865
|
}
|
|
1859
1866
|
|
|
1860
1867
|
func disconnectController() {
|
|
@@ -1874,9 +1881,7 @@ struct ViewState {
|
|
|
1874
1881
|
defaultWearable = ""
|
|
1875
1882
|
deviceName = ""
|
|
1876
1883
|
deviceAddress = ""
|
|
1877
|
-
|
|
1878
|
-
pendingDeviceAddress = ""
|
|
1879
|
-
pendingWearable = ""
|
|
1884
|
+
clearPendingConnection()
|
|
1880
1885
|
Bridge.saveSetting("default_wearable", "")
|
|
1881
1886
|
Bridge.saveSetting("device_name", "")
|
|
1882
1887
|
Bridge.saveSetting("device_address", "")
|
|
@@ -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.
|
|
10
|
-
static let otaManifestSha256 = "
|
|
6
|
+
static let releaseIdentity = "3.1.0-dev.9"
|
|
7
|
+
static let releaseSetId = "mentra-3.1.0-dev.9"
|
|
8
|
+
static let sourceCommit = "24201a3bb26253c4ce435d1fc125b0164774ebec"
|
|
9
|
+
static let otaManifestUrl = "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.9/mentra-live-ota-3.1.0-dev.9.json"
|
|
10
|
+
static let otaManifestSha256 = "214d92c8894033eaab276e668cb553c79990005d3330d23aaf499a514dc08cff"
|
|
11
11
|
}
|
|
@@ -942,10 +942,30 @@ extension MentraLive: CBCentralManagerDelegate {
|
|
|
942
942
|
nonisolated func centralManager(_: CBCentralManager, didConnect peripheral: CBPeripheral) {
|
|
943
943
|
DispatchQueue.main.async { [weak self] in
|
|
944
944
|
guard let self else { return }
|
|
945
|
+
let matchesActiveAttempt = self.connectingPeripheral === peripheral
|
|
946
|
+
guard MentraLiveConnectionAttemptPolicy.shouldAcceptDidConnect(
|
|
947
|
+
pairingYieldActive: self.pairingYieldActive,
|
|
948
|
+
matchesActiveAttempt: matchesActiveAttempt
|
|
949
|
+
) else {
|
|
950
|
+
Bridge.log(
|
|
951
|
+
"LIVE: Rejecting stale connection callback during pairing yield or after attempt replacement: \(peripheral.identifier)"
|
|
952
|
+
)
|
|
953
|
+
self.stopConnectionTimeout()
|
|
954
|
+
if self.connectingPeripheral === peripheral {
|
|
955
|
+
self.connectingPeripheral = nil
|
|
956
|
+
}
|
|
957
|
+
if self.connectedPeripheral === peripheral {
|
|
958
|
+
self.connectedPeripheral = nil
|
|
959
|
+
}
|
|
960
|
+
self.isConnecting = false
|
|
961
|
+
self.centralManager?.cancelPeripheralConnection(peripheral)
|
|
962
|
+
return
|
|
963
|
+
}
|
|
945
964
|
Bridge.log("Connected to GATT server, discovering services...")
|
|
946
965
|
|
|
947
966
|
self.stopConnectionTimeout()
|
|
948
967
|
self.isConnecting = false
|
|
968
|
+
self.connectingPeripheral = nil
|
|
949
969
|
self.connectedPeripheral = peripheral
|
|
950
970
|
|
|
951
971
|
// Save device name and address for future reconnection
|
|
@@ -1345,56 +1365,17 @@ class MentraLive: NSObject, SGCManager {
|
|
|
1345
1365
|
private let BLOCK_AUDIO_DUPLEX = false
|
|
1346
1366
|
private static let voiceActivityDetectionSwitchType = 8
|
|
1347
1367
|
private static let loudnessGateSwitchType = 10
|
|
1348
|
-
private
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
private let advPairingDiscoverable: UInt8 = 0x01
|
|
1356
|
-
|
|
1357
|
-
// CoreBluetooth returns manufacturer data prefixed with the 2-byte company id
|
|
1358
|
-
// (little-endian) and does NOT filter by company id itself (unlike Android's
|
|
1359
|
-
// getManufacturerSpecificData(companyId)), so every reader of this data must
|
|
1360
|
-
// verify the company id before trusting any flag/trailer byte.
|
|
1361
|
-
private func mentraManufacturerData(_ advertisementData: [String: Any]) -> Data? {
|
|
1362
|
-
guard let manufData = advertisementData[CBAdvertisementDataManufacturerDataKey] as? Data,
|
|
1363
|
-
manufData.count >= advManufCompanyIdLength
|
|
1364
|
-
else {
|
|
1365
|
-
return nil
|
|
1366
|
-
}
|
|
1367
|
-
let companyId = UInt16(manufData[0]) | (UInt16(manufData[1]) << 8)
|
|
1368
|
-
guard companyId == mentraManufacturerId else {
|
|
1369
|
-
return nil
|
|
1370
|
-
}
|
|
1371
|
-
return manufData
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
/// OS-1615 ads append `flag | version | capability | code_lo | code_hi` after the
|
|
1375
|
-
/// connected byte. Field firmware uses the same 0xB822 company id but then writes
|
|
1376
|
-
/// the XOR'd Classic MAC at those offsets. Length alone is not a pairing flag.
|
|
1377
|
-
private func hasSecurePairingTrailer(_ advertisementData: [String: Any]) -> Bool {
|
|
1378
|
-
let flagIndex = advManufCompanyIdLength + advManufPairingFlagOffset
|
|
1379
|
-
let trailerBase = flagIndex + 1
|
|
1380
|
-
guard let manufData = mentraManufacturerData(advertisementData),
|
|
1381
|
-
manufData.count >= trailerBase + 4
|
|
1382
|
-
else {
|
|
1383
|
-
return false
|
|
1384
|
-
}
|
|
1385
|
-
let version = Int(manufData[trailerBase])
|
|
1386
|
-
let capability = Int(manufData[trailerBase + 1])
|
|
1387
|
-
return (1...15).contains(version) && (capability & 0x01) != 0
|
|
1368
|
+
private func pairingAdvertisement(
|
|
1369
|
+
_ advertisementData: [String: Any]
|
|
1370
|
+
) -> MentraLivePairingAdvertisement? {
|
|
1371
|
+
MentraLivePairingAdvertisement.parse(
|
|
1372
|
+
coreBluetoothManufacturerData:
|
|
1373
|
+
advertisementData[CBAdvertisementDataManufacturerDataKey] as? Data
|
|
1374
|
+
)
|
|
1388
1375
|
}
|
|
1389
1376
|
|
|
1390
1377
|
private func isPairingDiscoverable(_ advertisementData: [String: Any]) -> Bool {
|
|
1391
|
-
|
|
1392
|
-
let manufData = mentraManufacturerData(advertisementData)
|
|
1393
|
-
else {
|
|
1394
|
-
return false
|
|
1395
|
-
}
|
|
1396
|
-
let flagIndex = advManufCompanyIdLength + advManufPairingFlagOffset
|
|
1397
|
-
return manufData[flagIndex] == advPairingDiscoverable
|
|
1378
|
+
pairingAdvertisement(advertisementData)?.pairingMode == true
|
|
1398
1379
|
}
|
|
1399
1380
|
|
|
1400
1381
|
private struct SecurePairingTrailer {
|
|
@@ -1403,24 +1384,19 @@ class MentraLive: NSObject, SGCManager {
|
|
|
1403
1384
|
let secureCapable: Bool
|
|
1404
1385
|
}
|
|
1405
1386
|
|
|
1406
|
-
/// Trailer immediately after pairing flag: version | capability | code_lo | code_hi
|
|
1407
1387
|
private func parseSecurePairingTrailer(_ advertisementData: [String: Any]) -> SecurePairingTrailer {
|
|
1408
|
-
guard
|
|
1409
|
-
let manufData = mentraManufacturerData(advertisementData)
|
|
1410
|
-
else {
|
|
1388
|
+
guard let advertisement = pairingAdvertisement(advertisementData) else {
|
|
1411
1389
|
return SecurePairingTrailer(pairingMode: false, pairingCode: nil, secureCapable: false)
|
|
1412
1390
|
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
let code = String(format: "%02X%02X", codeHi, codeLo)
|
|
1419
|
-
return SecurePairingTrailer(pairingMode: pairingMode, pairingCode: code, secureCapable: true)
|
|
1391
|
+
return SecurePairingTrailer(
|
|
1392
|
+
pairingMode: advertisement.pairingMode,
|
|
1393
|
+
pairingCode: advertisement.pairingCode,
|
|
1394
|
+
secureCapable: true
|
|
1395
|
+
)
|
|
1420
1396
|
}
|
|
1421
1397
|
|
|
1422
1398
|
private func advertisesPairingFlag(_ advertisementData: [String: Any]) -> Bool {
|
|
1423
|
-
|
|
1399
|
+
pairingAdvertisement(advertisementData) != nil
|
|
1424
1400
|
}
|
|
1425
1401
|
|
|
1426
1402
|
var connectionState: String = ConnTypes.DISCONNECTED
|
|
@@ -2914,25 +2890,20 @@ class MentraLive: NSObject, SGCManager {
|
|
|
2914
2890
|
let windowMs = max(5_000, min(180_000, json["window_ms"] as? Int ?? 120_000))
|
|
2915
2891
|
Bridge.log("LIVE: Glasses entering pairing mode — yield \(windowMs)ms (no forget)")
|
|
2916
2892
|
enterPairingYield(windowMs: windowMs)
|
|
2917
|
-
|
|
2893
|
+
let body: [String: Any] = [
|
|
2918
2894
|
"window_ms": windowMs,
|
|
2919
2895
|
"reason": json["reason"] as? String ?? "user_gesture",
|
|
2920
2896
|
]
|
|
2921
|
-
if let txn = json["txn"] {
|
|
2922
|
-
body["txn"] = txn
|
|
2923
|
-
}
|
|
2924
2897
|
Bridge.sendTypedMessage("entering_pairing_mode", body: body)
|
|
2925
2898
|
|
|
2926
2899
|
case "pairing_info":
|
|
2927
2900
|
Bridge.sendPairingInfo(
|
|
2928
2901
|
hadPreviousBond: json["had_previous_bond"] as? Bool ?? false,
|
|
2929
|
-
transferId: json["transfer_id"] as? String,
|
|
2930
2902
|
pairingCode: json["pairing_code"] as? String,
|
|
2931
2903
|
classicBondReady: json["classic_bond_ready"] as? Bool ?? false,
|
|
2932
2904
|
// Legacy firmware that omits this field is not secure-capable.
|
|
2933
2905
|
securePairingCapable: json["secure_pairing_capable"] as? Bool ?? false,
|
|
2934
|
-
protocolVersion: json["protocol_version"] as? Int ?? 1
|
|
2935
|
-
binding: json["binding"] as? String
|
|
2906
|
+
protocolVersion: json["protocol_version"] as? Int ?? 1
|
|
2936
2907
|
)
|
|
2937
2908
|
|
|
2938
2909
|
case "imu_response", "imu_stream_response", "imu_gesture_response",
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
struct MentraLivePairingAdvertisement: Equatable {
|
|
4
|
+
let pairingMode: Bool
|
|
5
|
+
let pairingCode: String
|
|
6
|
+
|
|
7
|
+
private static let manufacturerId: UInt16 = 0xB822
|
|
8
|
+
private static let companyIdLength = 2
|
|
9
|
+
private static let pairingFlagOffset = 5
|
|
10
|
+
private static let pairingDiscoverable: UInt8 = 0x01
|
|
11
|
+
private static let protocolVersionOffset = pairingFlagOffset + 1
|
|
12
|
+
private static let capabilityOffset = protocolVersionOffset + 1
|
|
13
|
+
private static let codeLowOffset = capabilityOffset + 1
|
|
14
|
+
private static let codeHighOffset = codeLowOffset + 1
|
|
15
|
+
private static let magicFirstOffset = codeHighOffset + 1
|
|
16
|
+
private static let magicSecondOffset = magicFirstOffset + 1
|
|
17
|
+
private static let protocolVersionRange = 2 ... 15
|
|
18
|
+
private static let securePairingCapability = 0x01
|
|
19
|
+
private static let magicFirst: UInt8 = 0x4D // M
|
|
20
|
+
private static let magicSecond: UInt8 = 0x50 // P
|
|
21
|
+
|
|
22
|
+
/// Parses CoreBluetooth manufacturer data, including its two-byte company-id prefix.
|
|
23
|
+
///
|
|
24
|
+
/// Legacy firmware stores an XOR'd Classic MAC where the original pairing implementation
|
|
25
|
+
/// expected version and capability bytes. Requiring the `MP` marker makes the formats
|
|
26
|
+
/// unambiguous instead of probabilistically classifying MAC bytes as a secure trailer.
|
|
27
|
+
static func parse(coreBluetoothManufacturerData data: Data?) -> MentraLivePairingAdvertisement? {
|
|
28
|
+
guard let data, data.count > companyIdLength + magicSecondOffset else {
|
|
29
|
+
return nil
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let companyId = UInt16(data[0]) | (UInt16(data[1]) << 8)
|
|
33
|
+
guard companyId == manufacturerId else {
|
|
34
|
+
return nil
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let payloadBase = companyIdLength
|
|
38
|
+
let version = Int(data[payloadBase + protocolVersionOffset])
|
|
39
|
+
let capability = Int(data[payloadBase + capabilityOffset])
|
|
40
|
+
guard protocolVersionRange.contains(version),
|
|
41
|
+
capability & securePairingCapability != 0,
|
|
42
|
+
data[payloadBase + magicFirstOffset] == magicFirst,
|
|
43
|
+
data[payloadBase + magicSecondOffset] == magicSecond
|
|
44
|
+
else {
|
|
45
|
+
return nil
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let codeLow = Int(data[payloadBase + codeLowOffset])
|
|
49
|
+
let codeHigh = Int(data[payloadBase + codeHighOffset])
|
|
50
|
+
return MentraLivePairingAdvertisement(
|
|
51
|
+
pairingMode: data[payloadBase + pairingFlagOffset] == pairingDiscoverable,
|
|
52
|
+
pairingCode: String(format: "%02X%02X", codeHigh, codeLow)
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
enum MentraLiveConnectionAttemptPolicy {
|
|
58
|
+
static func shouldAcceptDidConnect(
|
|
59
|
+
pairingYieldActive: Bool,
|
|
60
|
+
matchesActiveAttempt: Bool
|
|
61
|
+
) -> Bool {
|
|
62
|
+
!pairingYieldActive && matchesActiveAttempt
|
|
63
|
+
}
|
|
64
|
+
}
|