File size: 70,890 Bytes
be462b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 | ---
title: "API Reference"
description: "Lifecycle, status, commands, events, and shared types for the Mentra Bluetooth SDK."
icon: "book"
---
The Mentra Bluetooth SDK exposes the same core glasses lifecycle across Android, iOS, and React Native:
- Scan for a supported glasses model.
- Connect to a discovered `Device` or an app-restored default device.
- Read typed lifecycle state through the public surface for your platform.
- Subscribe to typed hardware events.
- Send camera, stream, audio, Wi-Fi, hotspot, LED, and settings commands for Mentra Live.
## Packages And Imports
| Platform | Install package | Import |
| --- | --- | --- |
| Android | `com.mentraglass:bluetooth-sdk` | `import com.mentra.bluetoothsdk.*` |
| iOS | `MentraBluetoothSDK` Swift package | `import MentraBluetoothSDK` |
| React Native / Expo | `@mentra/bluetooth-sdk` | `import BluetoothSdk, {DeviceModels} from '@mentra/bluetooth-sdk'` |
| React Native hooks | `@mentra/bluetooth-sdk` | `import {useMentraBluetooth} from '@mentra/bluetooth-sdk/react'` |
| React Native photo receiver | `@mentra/bluetooth-sdk` | `import MentraPhotoReceiver from '@mentra/bluetooth-sdk/photo-receiver'` |
Only documented imports are part of the supported app developer API. Undocumented package subpaths or symbols with a leading underscore can change without notice.
## Lifecycle
<Tabs>
<Tab title="React Native">
```tsx
import {useBluetoothEvent, useMentraBluetooth} from "@mentra/bluetooth-sdk/react"
function DeviceScreen() {
const mentra = useMentraBluetooth()
useBluetoothEvent("button_press", (event) => {
console.log(event.buttonId, event.pressType)
})
console.log(mentra.glasses.connection.state)
}
```
</Tab>
<Tab title="Android">
```kotlin
val sdk = MentraBluetoothSdk.create(
context = applicationContext,
config = MentraBluetoothSdkConfig(),
listener = listener,
)
sdk.close()
```
</Tab>
<Tab title="iOS">
```swift
let sdk = MentraBluetoothSDK(configuration: .default)
sdk.delegate = delegate
sdk.invalidate()
```
</Tab>
</Tabs>
Keep one SDK instance per active app session. The SDK owns Bluetooth connection state, native event delivery, and cleanup. Your app owns user identity, UI state, and whether a default device record is persisted across app restarts.
## Mentra SDK Usage Analytics
The SDK reports anonymous usage events to Mentra's PostHog project by default
so Mentra can understand SDK adoption, glasses connections, and how Mentra Live
features are used:
| Event | Fires When |
| --- | --- |
| `bluetooth_sdk_started` | Once per app runtime after the native SDK starts. |
| `bluetooth_sdk_glasses_connected` | When SDK status transitions from not connected to connected. Failed scans and failed connection attempts are not counted. |
| `bluetooth_sdk_glasses_identified` | Once per connection after the glasses report a valid manufacturing serial, and once per new reporting day (`America/Los_Angeles`) while that connection stays up (`event_kind=glasses_heartbeat`). Carries `glasses_device_id` (the hardware serial, not a user or phone id) and the glasses-side firmware versions of identified glasses. |
| `bluetooth_sdk_glasses_disconnected` | When a connection that was reported as connected ends. Carries `session_duration_ms`, `disconnect_reason` (`user_disconnect`, `forget`, `cancel`, `bluetooth_off`, `link_lost`, or `unknown`), and the battery levels seen during the connection. |
| `bluetooth_sdk_photo_taken` | When a `requestPhoto` call settles, or a photo taken with the glasses button fails. Carries `trigger`, `success`, `error_code`, `latency_ms`, the requested size, mode, compression, gallery save and transfer method, and `file_size_bytes` when known. |
| `bluetooth_sdk_video_recorded` | When a recording (app- or button-started) stops or fails. Carries `trigger`, `success`, `error_code`, `duration_ms`, requested resolution and frame rate, gallery save, maximum duration, and `stopped_by_app`. |
| `bluetooth_sdk_stream_started` | When a `startStream` call settles. Carries `success`, `error_code`, `protocol` (`rtmp`, `srt`, `whip`, or `unknown`, from the URL scheme only), requested video settings, `capture_audio`, `glasses_network`, and `latency_ms`. |
| `bluetooth_sdk_stream_ended` | When that stream ends. Carries `protocol`, `duration_ms`, `end_state`, `stopped_by_app`, `reconnect_attempts`, `error_code`, and the last reported bitrate, frame rate, dropped frames, and temperature when the stream reported statistics. |
| `bluetooth_sdk_mic_session` | When the active microphone turns off or changes. Carries `duration_ms`, `mic_source`, and `local_transcription`. |
| `bluetooth_sdk_wifi_setup`, `bluetooth_sdk_hotspot_started` | When `sendWifiCredentials` or `setHotspotState(true)` settles. Carry `success`, `error_code`, and `latency_ms`. |
| `bluetooth_sdk_ota_finished` | When a glasses software update completes or fails. Carries `success`, the failed step and error, `total_steps`, `duration_ms`, and the glasses versions the update started from. |
| `bluetooth_sdk_request_failed` | When a glasses command times out (`error_code=request_timeout`), with the command as `operation`. At most 100 per SDK start. |
Every event carries the host app's `app_version`, `app_build`, `app_build_type`
(`debug` / `release`), and `app_install_source` (`play_store`, `app_store`,
`testflight`, `adhoc_or_dev`, `simulator`, `sideload`, a named third-party
store, `other_store`, or `unknown` when the platform gave no usable evidence).
Apps that ship one package id through several lanes can add `app_environment`
through the `analytics.environment` plugin option, the
`com.mentra.bluetoothsdk.analytics.environment` Android metadata, or the
`MentraBluetoothSdkAnalyticsEnvironment` `Info.plist` key (trimmed and
lowercased; must start with a letter or digit, then `[a-z0-9_-]`, at most 32
characters). Mentra treats an install as production only when
`app_install_source` is `app_store` or `play_store`, `app_build_type` is
`release`, and, when the host declares a lane, `app_environment` is `prod`;
store installs without a declared lane are reported as an unclassified cohort.
Analytics delivery never blocks Bluetooth SDK behavior: events are submitted
asynchronously. A failed upload is kept in a small on-device queue (at most 100
events, 7 days) and retried on the next successful send or SDK start (payloads
PostHog rejects outright are dropped); each event carries its own id and
capture time, so retries never double count.
Mentra's PostHog project API key is embedded in the SDK as a public analytics
write token, not a private PostHog personal API key. Apps do not need to
configure PostHog to send these Mentra SDK usage events.
<Tabs>
<Tab title="React Native">
Disable analytics before native SDK startup through the Expo config plugin:
```json
{
"expo": {
"plugins": [
[
"@mentra/bluetooth-sdk",
{
"analytics": false
}
]
]
}
}
```
</Tab>
<Tab title="Android">
```kotlin
val sdk = MentraBluetoothSdk.create(
context = applicationContext,
config = MentraBluetoothSdkConfig(
analytics = BluetoothSdkAnalyticsConfig.disabled()
),
listener = listener,
)
```
Android apps can also set application metadata before SDK startup:
```xml
<meta-data
android:name="com.mentra.bluetoothsdk.analytics.disabled"
android:value="true" />
```
</Tab>
<Tab title="iOS">
```swift
let sdk = MentraBluetoothSDK(
configuration: MentraBluetoothSDKConfiguration(
analytics: .disabled
)
)
```
iOS apps can also set `MentraBluetoothSdkAnalyticsDisabled` to `true` in
`Info.plist` before SDK startup.
</Tab>
</Tabs>
Apps do not configure the analytics destination; these SDK usage events are
always sent to Mentra's PostHog project unless analytics are disabled.
### Update check
Separately from analytics, the SDK checks for a newer SDK release every time it
starts, whether or not analytics are disabled. The check is one HTTPS request
to `core.mentraglass.com` carrying the SDK install id, the app identifier, the
app version and build facts listed above, the SDK version, platform and
surface, and the OS version. Mentra records each check.
When a newer release exists, the SDK prints a warning with the update command
to the developer console: Logcat on Android, the Xcode console on iOS, and a
`console.warn` in React Native (a LogBox warning in debug builds). It repeats
every 15 minutes while the SDK runs. Nothing is shown in your app's UI. A
network that blocks `core.mentraglass.com` loses only the warning; SDK behavior
is unchanged.
Captured properties are intentionally narrow:
| Property | Meaning |
| --- | --- |
| `event_source` | Always `mentra_bluetooth_sdk`. |
| `sdk_platform` | Native platform that sends the event: `android` or `ios`. |
| `sdk_surface` | Public SDK surface: `react_native`, `android`, or `ios`. |
| `sdk_version` | Bluetooth SDK version. |
| `app_package` / `app_bundle_identifier` | Consuming app identifier. |
| `os_platform`, `os_version` | Phone OS metadata. |
| `event_kind` | `sdk_started`, `glasses_connected`, `glasses_identified`, or `glasses_disconnected`. |
| `phone_manufacturer`, `phone_model`, `locale`, `timezone` | Phone hardware model, language and time zone. |
| `app_version`, `app_build`, `app_build_type`, `app_install_source`, `app_environment` | Host build facts described above (`app_installer_package` on Android carries the raw installer package). |
| `fully_booted` | Connection and identification events; whether the connected status already reports fully booted. |
| `glasses_model`, `glasses_is_simulated` | Connection and identification events; the model is included only when the SDK has a non-empty value. |
| `glasses_device_id`, `glasses_device_id_type` | Identification event only; the glasses manufacturing serial (`manufacturing_serial`). |
| `glasses_firmware_version`, `glasses_bes_firmware_version`, `glasses_mtk_firmware_version`, `glasses_android_version`, `glasses_app_version`, `glasses_build_number` | Identification event only; included when known. |
| `glasses_model`, `glasses_device_id`, `glasses_build_number` on usage events | Photo, video, stream, mic, setup, OTA and timeout events carry the connected glasses' model, serial and build when known. |
Apart from the glasses manufacturing serial, the SDK does not upload BLE MAC
addresses, CoreBluetooth identifiers, Bluetooth device names, user ids, tokens,
Wi-Fi names or credentials, stream, webhook or upload URLs, microphone data,
photos, videos, or transcripts, and it never reads device location. Error
details have URLs removed before they are sent. PostHog derives an approximate
location (country, region, city) from the IP address each event is sent from. It stores a locally generated
anonymous SDK install id and sends it as PostHog `distinct_id`; events include
`$process_person_profile: false` so PostHog does not create person profiles for
these SDK usage pings.
## Connection
<Tabs>
<Tab title="React Native">
```ts
const devices = await BluetoothSdk.scan(DeviceModels.MentraLive, {
timeoutMs: 10_000,
onResults: (nextDevices) => renderDevicePicker(nextDevices),
})
const device = await chooseDevice(devices)
await BluetoothSdk.connect(device, {saveAsDefault: false})
await BluetoothSdk.setDefaultDevice(device)
async function reconnectSavedDevice() {
const defaultDevice = await BluetoothSdk.getDefaultDevice()
if (defaultDevice) {
await BluetoothSdk.connectDefault()
}
}
async function clearSavedDevice() {
await BluetoothSdk.clearDefaultDevice()
}
async function stopConnection() {
await BluetoothSdk.cancelConnectionAttempt()
await BluetoothSdk.disconnect()
await BluetoothSdk.forget()
}
```
</Tab>
<Tab title="Android">
```kotlin
val devices = mutableListOf<Device>()
val scanSession = sdk.scan(DeviceModel.MENTRA_LIVE, timeoutMs = 10_000) { nextDevices ->
devices.clear()
devices.addAll(nextDevices)
renderDevicePicker(nextDevices, onSelect = { device ->
sdk.connect(device)
sdk.setDefaultDevice(device)
})
}
fun reconnectSavedDevice() {
val defaultDevice = sdk.getDefaultDevice()
if (defaultDevice != null) {
sdk.connectDefault()
}
}
fun clearSavedDevice() {
sdk.clearDefaultDevice()
}
fun stopConnection() {
sdk.cancelConnectionAttempt()
sdk.disconnect()
sdk.forget()
}
```
For an explanation when a scan completes empty, use the callback overload:
```kotlin
sdk.scan(
model = DeviceModel.MENTRA_LIVE,
callback = object : MentraBluetoothScanCallback() {
override fun onResults(devices: List<Device>) {
renderDevicePicker(devices)
}
override fun onDiagnostic(diagnostic: ScanDiagnostic) {
showScanHint(diagnostic.message)
}
override fun onComplete(devices: List<Device>) {
finishDevicePicker(devices)
}
},
)
```
`onDiagnostic` is advisory and runs before `onComplete`; it does not call
`onError`. The `device_connected_on_phone` hint means a device
matching the scanned model is already connected to this phone. Neither platform
identifies the owning app, so another app is a possible explanation, not a
confirmed cause. This check cannot see connections held by another phone.
Diagnostics are skipped for cancelled or nonempty scans, simulated devices,
known SDK connections or connection attempts, and unavailable Bluetooth access.
Existing `ScanCallback` implementations keep their original completion behavior;
implement `ScanDiagnosticCallback` or extend `MentraBluetoothScanCallback` to
receive hints. iOS uses CoreBluetooth service-filtered connected peripherals;
models without a supported service filter or a matching identity stay silent.
</Tab>
<Tab title="iOS">
```swift
var devices: [Device] = []
let scanSession = try sdk.scan(model: .mentraLive, timeout: 10) { nextDevices in
devices = nextDevices
renderDevicePicker(nextDevices) { device in
do {
try sdk.connect(to: device)
sdk.setDefaultDevice(device)
} catch {
handleConnectionError(error)
}
}
}
func reconnectSavedDevice() throws {
if sdk.getDefaultDevice() != nil {
try sdk.connectDefault()
}
}
func clearSavedDevice() {
sdk.clearDefaultDevice()
}
func stopConnection() {
sdk.cancelConnectionAttempt()
sdk.disconnect()
sdk.forget()
}
```
</Tab>
</Tabs>
Prefer connecting to a `Device` returned by SDK scan callbacks. If your app wants `connectDefault()` to work after restart, persist a small default-device record in app storage and restore it with `setDefaultDevice()` before calling `connectDefault()`.
Optional empty-scan hints are also available on React Native and iOS:
```ts
await BluetoothSdk.scan(DeviceModels.MentraLive, {
onResults: renderDevicePicker,
onDiagnostic: hint => showScanHint(hint.message),
})
// React hooks expose the same advisory as useBluetoothScan().diagnostic
// or useMentraBluetooth().scan.diagnostic.
```
```swift
let session = try sdk.scan(
model: .mentraLive,
timeout: 10,
onResults: renderDevicePicker,
onDiagnostic: { hint in showScanHint(hint.message) }
)
```
The React Native promise still resolves to an empty device list; hints do not
reject the scan. Hosts using an older native binary simply omit the hint until
rebuilt with this SDK. Clear the displayed hint when retrying, changing models,
connecting, or receiving results. The Mentra App and Starter Kit examples show
these hints alongside their retry controls.
Use `scan()` for user-facing device pickers. The progressive result callback is for UI: render the nearby-device list every time it changes during scanning. The returned final result is for control flow: after the timeout/completion, choose a device from the last list and connect. In multi-device environments, do not auto-connect to the first nearby glasses; present an explicit picker.
Mentra Live connections on iOS require Apple Notification Center Service
(ANCS) authorization by default. Apps that do not use notification relay can
set `requiresAncs: false` in the `connect` or `connectDefault` options to skip
that system authorization requirement. The option defaults to `true` and is an
intentional no-op on Android. Native iOS callers pass
`ConnectOptions(requiresAncs: false)`.
## Device Identity
`Device.id` is the stable app-facing key for a scan result, within the limits of the platform identifier available to the SDK. Use it as a list key, selected-device key, and persisted default-device key.
Do not parse `id` for model, name, or address information. Use the typed fields instead:
| Field | Meaning |
| --- | --- |
| `model` | Glasses family reported by the SDK, expected to be Mentra Live in these flows. |
| `name` | Bluetooth name reported during scan. |
| `address` / `identifier` | Platform device handle when available. Android commonly provides a Bluetooth address. iOS commonly provides a CoreBluetooth identifier. React Native exposes this value as `address`. |
| `rssi` | Optional signal strength from scan results. It may be undefined at first discovery and appear in a later scan update when the platform reports RSSI metadata. |
When the platform does not provide an address or identifier, the SDK falls back to a `model:name` key.
Do not require `rssi` for picker rows. Use SDK-provided stable discovery order by default, and treat RSSI as supplemental signal-strength metadata when it is present.
## Status
<Tabs>
<Tab title="React Native">
```tsx
import {useMentraBluetooth} from "@mentra/bluetooth-sdk/react"
const mentra = useMentraBluetooth()
```
React Native exposes `mentra.glasses.connection` as a discriminated union:
```ts
type GlassesConnectionStatus =
| {state: "disconnected"}
| {state: "scanning"}
| {state: "connecting"}
| {state: "bonding"}
| {state: "connected"; fullyBooted: boolean}
```
Use `mentra.glasses.connection.state` for link-layer progress. `fullyBooted` only exists when `state === 'connected'`. The hook exposes the React app state as `glasses`, `sdk`, and `scan`.
</Tab>
<Tab title="Android">
```kotlin
val state = sdk.getState()
val glasses = sdk.getGlasses()
val sdkState = sdk.getSdkState()
val scan = sdk.getScanState()
```
Android exposes `GlassesRuntimeState` as `Connected` or `Disconnected`. The full state is grouped as `MentraBluetoothState(glasses, sdk, scan)`.
</Tab>
<Tab title="iOS">
```swift
let state = sdk.state
let glasses = sdk.glasses
let sdkState = sdk.sdkState
let scan = sdk.scanState
```
iOS exposes `GlassesRuntimeState` as `.connected(...)` or `.disconnected(...)`. The full state is grouped as `MentraBluetoothState(glasses, sdk, scan)`.
</Tab>
</Tabs>
Status snapshots are safe to read at any time. For continuous subsystems, keep UI state derived from status callbacks or hook state. Request/response commands document their exact promise resolution and error criteria below.
Public status is grouped the same way across platforms:
| Field | Meaning |
| --- | --- |
| `glasses` | Connected-glasses runtime state. Includes connection/readiness, connected device identity, battery, firmware, Wi-Fi, hotspot, and signal metadata when connected. |
| `sdk` | Phone-side SDK runtime state. Includes default device, gallery mode, microphone route, mic ranking, Wi-Fi scan results, scan activity, system mic availability, other Bluetooth audio status, and recent SDK log lines. |
| `scan` | User-facing scan state. Includes whether a scan is active, whether controller scanning is active, and the stable-order discovered `Device[]` list. |
Use `glasses.connected` / `mentra.glasses.connected` before reading connected-only fields. Native Android uses `GlassesRuntimeState.Connected`; native iOS uses `GlassesRuntimeState.connected(...)`; React Native exposes `mentra.glasses` with the same grouped concepts in React-friendly objects.
## Mentra Live pairing
<Warning>
`confirmReplaceOwner()` and `confirm_replace_owner_result` are removed. `owner_replaced` is deprecated and is never emitted. Move to `GlassesStatus.pairingState`. This break ships in the unpublished `3.3.0` SDK (`package.json`); the podspec and Gradle module read that version. npm still publishes `3.2.1`. The SDK package includes the same steps in `MIGRATION.md`, next to its README.
</Warning>
Supported Mentra Live firmware opens one pairing window when the power button is pressed three times. The window lasts 120 seconds, and the glasses speak a 4-character code. A second triple-press cancels it. After a timeout or a cancel, the phone that was already paired reconnects automatically. If another phone pairs during the window, the previous phone stops reconnecting.
Read `GlassesStatus.pairingState` from `getGlassesStatus()` or `subscribeGlassesStatus()`. It is absent on other glasses models. `useMentraBluetooth().glasses` does not include this field.
```ts
type MentraLivePairingState =
| {state: "normal"}
| {state: "pairing_mode"; windowId: number; endsAtMs: number}
| {state: "pairing_rejected"}
```
| State | Meaning |
| --- | --- |
| `normal` | No pairing window. Automatic reconnect is allowed. |
| `pairing_mode` | A pairing window is open. `windowId` identifies it and survives an app restart. Automatic reconnect stays paused until `endsAtMs`, the window length plus a 30-second margin. |
| `pairing_rejected` | The glasses no longer accept this phone (another phone paired, or repeated authentication rejections on secure-pairing firmware). Reconnect has stopped. Show Pair Again. Cleared only by a successful explicit `connect()` / `connectDefault()`, or by `forget()`. |
`pairing_state_changed` carries the new `MentraLivePairingState` when the value changes. Android and iOS glasses-status snapshots include the same map. On those native SDKs the pairing events below arrive as raw events (`onRawEvent` on Android, `BluetoothEvent.raw` on iOS), except `pair_failure`, which is the pairing error callback and includes `failureCode`.
| Event | Payload | When it fires |
| --- | --- | --- |
| `entering_pairing_mode` | `window_ms`, optional `window_id`, optional `reason`, optional `owner_retained` | The connected glasses opened a window. `window_id` matches `pairingState.windowId`. `owner_retained` means the glasses kept their bonds when the window opened; bonds change only if another phone pairs. |
| `pairing_mode_ended` | `reason`: `"paired"` \| `"cancelled"` \| `"timeout"`, optional `window_id` | The glasses closed the window and this phone is still accepted. The previous phone does not receive this when another phone takes over; it moves to `pairing_rejected`. |
| `pairing_state_changed` | `PairingStateChangedEvent` | `pairingState` changed. The payload's `state` field is a `MentraLivePairingState`. |
| `pairing_info` | Includes `auto_audio` | Session facts after a pair. `auto_audio` is true when the glasses derive Classic audio from the LE pair (CTKD); the SDK uses it for `audioSetup`. `awaiting_confirm` and `retained_owner_link` are no longer sent. |
| `pair_failure` | `error`, optional `code` | Bluetooth pairing failed. `code: "ios_forget_pairing"` means iOS holds a stale Bluetooth pairing for these glasses during an explicit attempt. Open Settings > Bluetooth, choose Forget This Device, then pair again. |
User-facing copy for `pairing_rejected` should say "Pair Again". Do not use the word "owner" in that copy.
## Glasses audio setup
`GlassesStatus.audioSetup` says whether the user has to do anything to get glasses audio working. The SDK decides it for every glasses model; render it without adding audio timers or platform checks. `audio_setup_changed` (`{state}`) fires on every change, and Android and iOS glasses-status snapshots include the same map.
```ts
type GlassesAudioSetupState =
| {state: "idle"}
| {state: "not_applicable"}
| {state: "connecting"}
| {state: "connected"}
| {state: "needs_user"; action: "connect_in_settings"}
```
| State | Meaning |
| --- | --- |
| `idle` | No glasses session. |
| `not_applicable` | No audio step. Android attaches Classic audio from the BLE bond, and glasses without Classic audio have nothing to set up. |
| `connecting` | The glasses are connected and audio is expected to come up on its own. |
| `connected` | Classic audio (A2DP or HFP) to the glasses is up. |
| `needs_user` | Audio did not come up on its own. Ask the user to connect the glasses in Settings > Bluetooth. The state moves to `connected` as soon as audio comes up. |
On iPhone the SDK waits up to 8 seconds after a pair on firmware that brings audio up from the BLE pair, reports `needs_user` at once on older firmware, and waits 10 seconds after a reconnect. Mentra Live firmware that reports its own audio link is preferred over the phone's audio route.
## React Native Public Surface
These are the supported React Native app developer entrypoints:
| Area | Methods |
| --- | --- |
| Status and subscriptions | `useMentraBluetooth`, `useBluetoothScan`, and `useBluetoothEvent` for React components; `addListener` is available as the lower-level non-React subscription API |
| Default device | `getDefaultDevice`, `setDefaultDevice`, `clearDefaultDevice` |
| Connection | `scan`, `startScan`, `stopScan`, `connect`, `connectDefault`, `cancelConnectionAttempt`, `disconnect`, `forget` |
| Display | `displayText`, `clearDisplay`, `setDashboardContent`, `showDashboard`, `setDashboardPosition`, `setHeadUpAngle`, `setScreenDisabled` |
| Wi-Fi and hotspot | `requestWifiScan`, `getSavedWifiNetworks`, `sendWifiCredentials`, `forgetWifiNetwork`, `setHotspotState` |
| Camera and gallery | `requestPhoto`, `warmUpCamera`, `stopCameraWarmUp`, `queryGalleryStatus`, `setGalleryModeEnabled`, `setPhotoCaptureDefaults` (deprecated), `setVideoRecordingDefaults`, `setMaxVideoRecordingDuration`, `setCameraFov`, `setCameraFovOverride`, `releaseCameraFovOverride`, `startVideoRecording`, `stopVideoRecording`, `queryVideoRecordingStatus` |
| Streaming | `startStream`, `stopStream` |
| Audio | `setMicState`, `setVoiceActivityDetectionEnabled`, `setLoudnessGateEnabled`, `setPreferredMic`, `setOwnAppAudioPlaying`, `getGlassesMediaVolume`, `setGlassesMediaVolume` |
| LED, version, and OTA | `rgbLedControl`, `requestVersionInfo`, `checkForOtaUpdate`, `startOtaUpdate` |
React Native helper exports include `DeviceModels`, `WifiForgetResult`, `WifiForgetOutcome`, `SavedWifiNetworksResult`, `SavedWifiNetworksOutcome`, `isConnectedGlassesConnectionStatus`, `isReadyGlassesConnectionStatus`, `isBusyGlassesConnectionStatus`, `isConnectedWifiStatus`, and `isEnabledHotspotStatus`. The React subpath exports `useMentraBluetooth`, `useBluetoothScan`, and `useBluetoothEvent`.
For React Native status UI, use `useMentraBluetooth()` from `@mentra/bluetooth-sdk/react`. It returns `mentra.glasses`, `mentra.sdk`, and `mentra.scan` for connection, battery, Wi-Fi, hotspot, scan, and SDK runtime state.
Important defaults:
- `scan(model, options)` reports progressive results through `options.onResults`, resolves with the final matching `Device[]`, and times out after 15 seconds unless `options.timeoutMs` is set.
- `connect` and `connectDefault` default `saveAsDefault`, `cancelExistingConnectionAttempt`, and `requiresAncs` to `true`. `requiresAncs` only changes Mentra Live connections on iOS; Android accepts it as a no-op.
- `setDashboardContent(content)` keeps the standard time, date, and battery header. It stores content for the current SDK session and renders it immediately only when the contextual dashboard is visible; otherwise it appears on the next head-up. Pass the exact empty string to restore the status-only dashboard.
- `setMicState(enabled)` defaults to glasses microphone on, transcript events off, and LC3 events off. Microphone audio events are continuous while capture is enabled. Use `setVoiceActivityDetectionEnabled(...)` for glasses-side Voice Activity Detection and `setLoudnessGateEnabled(...)` for Mentra Live's center-microphone loudness gate ("Barrier"). With Barrier enabled, quiet input is replaced with silence while the glasses speaker plays, and audio frames continue. The standalone public Bluetooth SDK defaults are VAD disabled and Barrier enabled, and both settings are reapplied after reconnect. The Mentra App manages separate persisted OS-level microphone preferences. `voice_activity_detection_status` reports whether VAD is enabled, and `speaking_status` reports speaking/not-speaking when supported. Microphone audio events include the latest `voiceActivityDetectionEnabled` value.
- `requestPhoto({authToken, ...})` omits the `Authorization` header when `authToken` is `null` or empty.
- `requestPhoto(...)` and `warmUpCamera(...)` generate unique request IDs when `requestId` is omitted or blank. Pass an explicit `requestId` only when your app needs to know it before the response, for example to poll a predictable upload-status URL.
- `requestPhoto({exposureTimeNs, ...})` uses auto exposure when `exposureTimeNs` is omitted or `null`; pass a positive nanosecond value for one-shot manual exposure.
- `requestPhoto({exposureTimeNs, iso, ...})` uses `iso` only when `exposureTimeNs` enables one-shot manual exposure. Omit `iso` / pass `null` for auto ISO selection.
- `requestPhoto(...)` capture fields apply to that one request. `setPhotoCaptureDefaults(...)` is deprecated; it still persists gallery-mode action-button photo defaults, but prefer per-request `requestPhoto(...)` options (e.g. `mode: "text"`) instead.
- `warmUpCamera({requestId, size, exposureTimeNs, durationMs})` opens/configures Mentra Live's camera and holds it warm without capturing or uploading media. Holds default to 15 seconds and are capped at 60 seconds. Use an explicit request ID when the owner may need to call `stopCameraWarmUp(requestId)` during teardown. The promise resolves on `camera_status.state === "ready"`; the later `stopped` event marks lease expiry/teardown for listeners and does not settle the already-resolved promise.
- Request/response commands now resolve from the glasses response rather than only updating local SDK state. React Native returns success-only values for commands whose raw events can also carry errors: `requestPhoto(...)` returns terminal `PhotoSuccessResponseEvent` after capture and delivery finish, `startVideoRecording(...)` returns `VideoRecordingStartedStatusEvent`, `stopVideoRecording(...)` returns `VideoRecordingStoppedStatusEvent`, and `rgbLedControl(...)` returns `RgbLedControlSuccessResponseEvent`. When `stopVideoRecording(...)` includes a webhook URL, the promise resolves after the video upload succeeds. The corresponding raw events still include error variants for listeners.
- `setCameraFov({fov, roiPosition})` clamps `fov` to 62-118 degrees and accepts `roiPosition` as `"center"`, `"bottom"`, or `"top"`. You can also call `setCameraFov({preset: "narrow" | "standard" | "wide"})`; presets map to 82, 102, and 118 degrees with center ROI. On Mentra Live this persists the setting, restarts the camera, and resolves with `CameraFovResult` only after the ASG client reports the setting was applied to camera hardware after the restart cooldown. The promise rejects if the glasses report an error, persist the setting without hardware application, or time out. Treat FOV as a framing/ROI control; output resolution and effective detail can vary by capture path, firmware, and camera mode.
- `startStream` optional `video` and `audio` configs are omitted unless supplied, so the connected glasses use their model defaults. Stream video input fields are `width`, `height`, `bitrate`, and `fps`; stream status reports the resolved effective frame rate as `resolvedConfig.video.fps`. The SDK sends stream keep-alives automatically and reports timeout/error state through `stream_status`.
- Photo capture, video recording, and streaming always enable the camera light as a privacy indicator.
- The SDK sends `set_system_time` once shortly after each glasses connection becomes ready, after the initial command burst has drained. The guard resets on disconnect, so reconnecting synchronizes again. There is no periodic clock correction during a long-lived connection; compare `requestVersionInfo().systemTimeMs` with the phone clock if your app needs to monitor later skew.
## Head-Up Dashboard Content
Use `setDashboardContent` to place persistent, glanceable text below the standard
dashboard status header. The SDK keeps the raw status placeholders and expands
them every time the dashboard renders, so time, date, and battery
remain current. The call does not force the dashboard open. If the contextual
dashboard is hidden, the content appears on the next head-up.
<Tabs>
<Tab title="React Native">
```ts
await BluetoothSdk.setDashboardContent('Next meeting at 2 PM');
await BluetoothSdk.setDashboardContent('');
```
</Tab>
<Tab title="Android">
```kotlin
sdk.setDashboardContent("Next meeting at 2 PM")
sdk.setDashboardContent("")
```
</Tab>
<Tab title="iOS">
```swift
await sdk.setDashboardContent("Next meeting at 2 PM")
await sdk.setDashboardContent("")
```
</Tab>
</Tabs>
Only the exact empty string resets the custom content; whitespace and newlines
are otherwise preserved. Dashboard content lasts for the current SDK process.
Persist it in the host app and reapply it after launch when it must survive an
app restart. Gate this API by display capability because Mentra Live does not
have a display.
## Promise Results And Errors
One-shot commands resolve only after the matching ASG client response arrives. They reject/throw when the ASG response is an error, when the SDK cannot send the command, when an incompatible command is already in flight, or when the matching response times out. Keep listeners for streaming progress and status; use the returned value for the one-shot decision.
React Native exposes the narrowest return types for clear branching after `await`. Android and iOS async APIs throw `BluetoothException` / `BluetoothError` for the same error cases, so successful calls return the success payload even when the native event struct can also represent raw listener errors.
| API | Resolves With | Rejection / Throw Criteria |
| --- | --- | --- |
| `requestWifiScan()` | Final `WifiSearchResult[]` from `wifi_scan_result` where `scanComplete: true`, including `[]` when no networks are found. | Scan response timeout, send failure, or another Wi-Fi scan already in flight. |
| `getSavedWifiNetworks()` | `SavedWifiNetworksResult`. `outcome: "confirmed"` includes exact saved SSIDs from a reliable enumeration backend. `outcome: "unsupported"` includes `networks: []` on K900 and legacy firmware. Whitespace is preserved so a returned SSID can be passed back to `forgetWifiNetwork`. Capability-unknown calls wait for `version_info_1`; negotiation and response share one 15-second deadline. Only protocol version 1 is supported. | Capability-negotiation timeout, request timeout, session reset/disconnect, send failure, or another saved-list request in flight. Glasses-reported `unsupported` and `failed` are typed results, not transport exceptions. |
| `sendWifiCredentials(ssid, password)` | `WifiStatusChangeEvent` whose state is `connected` for the requested SSID. Success typically resolves within a few seconds. | Glasses-reported provisioning failure, with the reason as the error code: `wrong_password` (typically ~7s), `connect_timeout` (~12s, network unreachable or join never completed), or `connected_to_other_network` (the glasses ended up on a different SSID than requested). Also request timeout, send failure, or another Wi-Fi status command in flight. Routine `disconnected` events during association do **not** reject — the glasses briefly report disconnected while switching networks. Glasses running older software never send failure reasons; failed attempts there surface as request timeouts. |
| `forgetWifiNetwork(ssid)` | `WifiForgetResult` with `outcome` of `confirmed`, `dispatched`, `not_found`, `unsupported`, `failed`, or `legacy_unverified`. Capability-unknown calls wait for `version_info_1`; negotiation and response share one 15-second deadline. A discovery timeout never selects legacy. Modern results are correlated by request ID, glasses session ID, protocol version, and exact requested SSID; `wifi_status_change` cannot settle them. K900 returns `dispatched`, meaning its asynchronous SystemUI broadcast was queued, not that removal was verified. `connected` is an optional diagnostic snapshot and is omitted, rather than fabricated as `false`, if ASG cannot read link state. Legacy firmware returns `legacy_unverified` immediately after accepted native dispatch, without a fabricated link snapshot. Transport correlation remains internal. This return type intentionally replaces the previous `WifiStatusChangeEvent`. | Empty SSID, capability-negotiation timeout, request timeout, session reset/disconnect, send failure, or another Wi-Fi status command in flight. Glasses-reported semantic failures are typed results. |
| `setHotspotState(enabled)` | `HotspotStatusChangeEvent` matching the requested enabled/disabled state. | `hotspot_error`, timeout, send failure, or another hotspot command in flight. |
| `requestVersionInfo()` | `VersionInfoResult` from the ASG `version_info` response. | Timeout, send failure, or another version query in flight. |
| Gallery capture settings | `SettingsAckSuccessEvent` with a non-failure status such as `applied` or `ready`; the SDK local settings store updates only after this ASG ack resolves. | `settings_ack.status` of `error`, `failed`, `failure`, or `rejected`; timeout; or send failure. |
| `setCameraFov(...)` | `CameraFovResult` with `fov`, `roiPosition`, `requestId`, and `timestamp` after the ASG client reports the setting was applied to camera hardware after the restart cooldown; the SDK local FOV setting updates only after this result resolves. | Glasses-side FOV/settings error, persist-only/no hardware-application ack, timeout, or send failure. |
| `queryGalleryStatus()` | `GalleryStatusEvent`, including `cameraBusy` and optional `cameraBusyReason`. | Timeout, send failure, or another gallery status query in flight. |
| `requestPhoto(...)` | Terminal response after capture and delivery finish: React Native `PhotoSuccessResponseEvent`; Android/iOS successful `PhotoResponseEvent`. The success includes `uploadUrl`, and may include webhook-returned `photoUrl`, `statusUrl`, `contentType`, or `fileSizeBytes`. Progress follows through `photo_status`. | Raw `photo_response.state === "error"` from glasses/phone, fallback upload failure, terminal response timeout, or send failure. |
| `warmUpCamera(...)` | `CameraStatusEvent` whose `state` is `ready`, meaning the camera is open/configured and held warm for the requested TTL. Progress follows through `camera_status`; `stopped` is a listener-only lifecycle event after `ready`. | `camera_status.state === "error"` such as `camera_busy`, `camera_restart_cooldown`, `photo_capture_in_progress`, `ble_transfer_in_progress`, `media_capture_service_unavailable`, or `camera_warm_up_failed`; timeout; or send failure. |
| `startVideoRecording(...)` | React Native `VideoRecordingStartedStatusEvent` with `status: "recording_started"`; Android/iOS successful `VideoRecordingStatusEvent` with `status: "recording_started"`. | `success: false` statuses such as `already_recording`, timeout, send failure, or duplicate request ID. |
| `stopVideoRecording(requestId, webhookUrl?, authToken?)` | React Native `VideoRecordingStoppedStatusEvent` with `status: "recording_stopped"`; Android/iOS successful `VideoRecordingStatusEvent` with `status: "recording_stopped"`. When `webhookUrl` is supplied, the promise waits for the video upload to finish successfully. | `success: false` statuses such as `not_recording`, video upload failure, timeout, send failure, or duplicate request ID. |
| `queryVideoRecordingStatus(requestId)` | `VideoRecordingStatusEvent` with `status: "recording_status"`, the current `data.recording` value, and elapsed `data.duration_ms` when available. | Disconnected glasses, timeout, send failure, or a duplicate video request ID. |
| `startStream(...)` | `StreamStatusEvent` for the requested stream once `status` is `streaming`. | `stream_status` error/reconnect failure, timeout, or send failure. |
| `stopStream()` | `StreamStatusEvent` once `status` is `stopped`; an already-stopped / not-streaming glasses reply resolves as a normalized stopped event. | Real stop error, timeout, send failure, or another stream stop in flight. |
| `rgbLedControl(...)` | React Native `RgbLedControlSuccessResponseEvent`; Android/iOS successful `RgbLedControlResponseEvent`. | Raw `rgb_led_control_response.state === "error"`, timeout, or send failure. |
| `checkForOtaUpdate()` | `boolean`, true when the configured OTA manifest has an ASG APK, MTK, or BES update for the connected glasses; false only when the manifest was checked successfully and no update is available. | Rejects when the glasses are disconnected, version info is unavailable, the manifest cannot be fetched, or the manifest response is invalid/missing required ASG app version fields. |
| `startOtaUpdate()` | `OtaStartAckEvent` from `ota_start_ack`. | Known glasses battery below 5% (`battery_low` before ack), start-ack timeout, send failure, or another OTA start in flight. |
## Gallery Mode
Mentra Live has a gallery mode for the right action button. When gallery mode is enabled, a short press takes a photo, a long press starts video recording, and a short press stops the active video recording. Button and touch events are still reported to the SDK.
Use `setGalleryModeEnabled(true)` to enable local button capture, and `setGalleryModeEnabled(false)` to report button events without triggering local gallery capture while the glasses are connected. These setting calls return `SettingsAckSuccessEvent` from the ASG client and reject on failure statuses. Raw `settings_ack` listeners still receive `SettingsAckEvent` because listener events can include both success and failure statuses. The SDK can also configure the capture settings used by gallery mode:
| Setting | API |
| --- | --- |
| Photo capture defaults (deprecated) | `setPhotoCaptureDefaults(...)` — prefer per-request `requestPhoto(...)` |
| Video resolution and frame rate | `setVideoRecordingDefaults({width, height, fps})` |
| Maximum local video length | `setMaxVideoRecordingDuration(minutes)` |
| Camera field of view | `setCameraFov(...)` |
`requestPhoto(...)` accepts optional `requestId` plus `size`, `webhookUrl`, `authToken`, `compress`, `save`, `sound`, `exposureTimeNs`, `iso`, `aeExposureDivisor`, `isoCap`, `zsl`, `mfnr`, `noiseReduction`, `edgeEnhancement`, `ispDigitalGain`, and `ispAnalogGain`. ZSL buffering and MFNR still capture are independent flags, both enabled by default; pass `zsl: false` and/or `mfnr: false` to opt out. Photo, video, and stream capture always enable the camera light as a privacy indicator. Manual `iso` is used only when `exposureTimeNs` enables manual exposure.
`warmUpCamera(...)` accepts optional `requestId` plus `size`, `exposureTimeNs`, and `durationMs`. Omit or pass a non-positive `durationMs` for the default 15 second warm hold; values above 60 seconds are capped. `camera_status` reports `warming`, `ready`, `stopped`, or `error`; the method resolves on `ready` and rejects on `error`. Call `stopCameraWarmUp(requestId)` to release a known lease. Cancelling before `ready` rejects the pending warm-up with `camera_warm_up_cancelled`; cancelling after `ready` emits `stopped`. Compatible ready leases share the camera and expire independently.
`setPhotoCaptureDefaults(...)` is **deprecated**. It still accepts `size`, `zsl`, `mfnr`, `noiseReduction`, `edgeEnhancement`, `ispDigitalGain`, `ispAnalogGain`, `aeExposureDivisor`, `isoCap`, `compress`, `sound`, and `resetCaptureTuning`, but prefer per-request `requestPhoto(...)` options (for example `mode: "text"` for text sensor size/crop, or explicit `aeExposureDivisor`) instead of sticky button-photo presets. Its independent `zsl` and `mfnr` values are persisted for physical camera-button photos; when either is omitted, that field inherits the corresponding global device default. Omitted fields leave existing action-button photo defaults unchanged. `resetCaptureTuning: true` clears the optional action-button tuning overrides without changing global ZSL/MFNR settings or photo size unless `size` is also provided.
## Common Commands
| Area | Commands |
| --- | --- |
| Connection | `scan`, `startScan`, `stopScan`, `connect`, `connectDefault`, `disconnect`, `forget` |
| Display | `displayText`, `clearDisplay`, `setDashboardContent`, `showDashboard`, dashboard position, and head-up angle |
| Wi-Fi and hotspot | `requestWifiScan`, `getSavedWifiNetworks`, `sendWifiCredentials`, `forgetWifiNetwork`, `setHotspotState` |
| Camera | `requestPhoto`, gallery mode, photo capture defaults, video recording defaults, camera field of view |
| Streaming | `startStream`, `stopStream` |
| Audio | `setMicState`, Voice Activity Detection setting and events, audio callbacks, local transcription, media volume |
| Settings | Gallery mode, camera options, microphone route, Wi-Fi, hotspot, and OTA |
| LEDs | `rgbLedControl` on supported glasses |
| System | `requestVersionInfo`, `checkForOtaUpdate`, `startOtaUpdate` |
Mentra Live has camera, microphone, speaker, Wi-Fi, LED, and OTA capabilities. Gate UI by connection readiness, permissions, and the latest SDK status.
## OTA Updates
Each Bluetooth SDK release has a matching Mentra Live glasses software release with the same version number. When your app checks for an update, the SDK uses the OTA manifest for its own release. For the current `{{release-version}}` software and complete installation instructions, see [Update Mentra Live](/bluetooth-sdk/software-update).
For React Native apps, use Mentra Engine instead of assembling these primitives
yourself. `MentraLiveOtaFlow` supplies the exact Mentra App pages, and
`useMentraLiveOta` supports custom presentation over the same tested
coordinator. See [Update Mentra Live](/bluetooth-sdk/software-update#add-the-ota-requirement-to-your-app).
The APIs below are low-level building blocks used by native Android/iOS apps
and by Mentra Engine. They are not a second React Native OTA coordinator.
Mentra Live OTA installation is glasses-owned. The SDK checks its release-specific manifest on the phone, then sends `ota_start` with that same manifest URL when the user accepts the update:
| API | Purpose |
| --- | --- |
| `checkForOtaUpdate()` | Fetch the configured manifest and resolve `true` when an ASG APK, MTK, or BES update is available. |
| `startOtaUpdate()` | Send `ota_start` with the configured manifest URL after your app presents the update and the user accepts it. Resolves with `OtaStartAckEvent` from the ASG client. |
| `queryOtaStatus()` | Query and return the active OTA session status after a reconnect or interrupted response. React Native only. |
Use the boolean check result for update prompts and keep `ota_status` listeners/delegates for install progress and terminal `complete` / `failed` state. Availability is exposed through `checkForOtaUpdate()` rather than a public event; React Native receives `ota_start_ack` and `ota_status` events during the install flow. Android listeners receive `onOtaStartAck` and `onOtaStatus`; iOS delegates receive `.otaStartAck` and `.otaStatus` through `BluetoothEvent`.
OTA requires Mentra Live glasses firmware that supports the ASG OTA protocol and network access from the glasses. During install, normal BLE traffic can be interrupted and the glasses may restart; keep the app connected and avoid sending unrelated commands until `ota_status.status` is `complete` or `failed`.
Treat `complete` as terminal even though the connection may drop immediately after it: when the final step of an update is the BES firmware, the glasses power-cycle right after emitting `complete`, so no further `ota_status` follows. If the BES firmware transfer step stalls on the glasses side, it aborts itself after about 30 seconds and surfaces as `failed`; the APK and MTK steps use their own timeout paths. On such an abort the BES stays on its current firmware — earlier APK or MTK steps of the same update may already have completed — and retrying the whole update from the app is the intended recovery.
## Events
React Native components should use `useBluetoothEvent()` for hardware events. The hook keeps the callback typed and removes the native subscription when the component unmounts. Native apps receive the same event categories through listener/delegate methods:
<Tabs>
<Tab title="React Native">
```tsx
import {useBluetoothEvent} from "@mentra/bluetooth-sdk/react"
export function HardwareEventLogger() {
useBluetoothEvent("button_press", (event) => console.log(event))
useBluetoothEvent("touch_event", (event) => console.log(event))
useBluetoothEvent("photo_status", (event) => console.log(event.status, event.resolvedConfig))
useBluetoothEvent("stream_status", (event) => console.log(event.resolvedConfig?.video?.fps))
useBluetoothEvent("ota_status", (event) => console.log(event.overall_percent))
useBluetoothEvent("speaking_status", (event) => console.log(event.speaking))
useBluetoothEvent("mic_pcm", (event) => {
console.log(event.sampleRate, event.bitsPerSample, event.channels, event.encoding)
console.log(event.pcm)
})
return null
}
```
</Tab>
<Tab title="Android">
```kotlin
class GlassesEvents : MentraBluetoothSdkCallback() {
override fun onButtonPress(event: ButtonPressEvent) {
Log.d("Mentra", "${event.buttonId} ${event.pressType}")
}
override fun onPhotoResponse(event: PhotoResponseEvent) {
Log.d("Mentra", "Photo request ${event.requestId}: ${event.response.state}")
}
override fun onMicPcm(event: MicPcmEvent) {
Log.d("Mentra", "${event.sampleRate} Hz ${event.bitsPerSample}-bit PCM")
}
override fun onOtaStatus(event: OtaStatusEvent) {
Log.d("Mentra", "OTA ${event.status}: ${event.overallPercent}%")
}
}
```
</Tab>
<Tab title="iOS">
```swift
final class GlassesEvents: MentraBluetoothSDKDelegate {
func mentraBluetoothSDK(_ sdk: MentraBluetoothSDK, didReceive event: BluetoothEvent) {
switch event {
case let .buttonPress(button):
print("\(button.buttonId) \(button.pressType)")
case let .photoResponse(photo):
print("Photo request \(photo.requestId): \(photo.response.state.rawValue)")
case let .otaStatus(status):
print("OTA \(status.status): \(status.overallPercent)%")
default:
break
}
}
func mentraBluetoothSDK(_ sdk: MentraBluetoothSDK, didReceiveMicPcm event: MicPcmEvent) {
print("\(event.sampleRate) Hz \(event.bitsPerSample)-bit PCM")
}
}
```
</Tab>
</Tabs>
For non-React modules, `BluetoothSdk.addListener(...)` is the low-level subscription API. Keep the returned subscription and call `remove()` when the listener is no longer needed.
The React Native event surface is typed through `BluetoothSdkEventMap`. These are the public event names accepted by `useBluetoothEvent()` and `BluetoothSdk.addListener()`:
| Event name | Payload type | When it fires |
| --- | --- | --- |
| `log` | `LogEvent` | SDK diagnostic log line. |
| `device_discovered` | `Device` | A supported glasses device is discovered during scan. |
| `default_device_changed` | `{device?: Device}` | The SDK default device changes. |
| `glasses_not_ready` | `GlassesNotReadyEvent` | A command needs ready glasses but the connected device is not ready. |
| `button_press` | `ButtonPressEvent` | Glasses button press. |
| `touch_event` | `TouchEvent` | Glasses touch or swipe gesture. |
| `head_up` | `HeadUpEvent` | Head-up state changes. |
| `voice_activity_detection_status` | `VoiceActivityDetectionStatusEvent` | Glasses-side Voice Activity Detection is enabled or disabled. |
| `speaking_status` | `SpeakingStatusEvent` | Glasses-side Voice Activity Detection reports speaking or not speaking. |
| `battery_status` | `BatteryStatusEvent` | Battery update from glasses. |
| `local_transcription` | `LocalTranscriptionEvent` | SDK local transcription text update. |
| `wifi_status_change` | `WifiStatusChangeEvent` | Glasses Wi-Fi connection state changes. When the event is the verdict of a failed `sendWifiCredentials` attempt it carries an `error` reason (`wrong_password`, `connect_timeout`, `connected_to_other_network`); the reason describes the attempt, not the link, so `connected_to_other_network` arrives on a `connected` state. Routine link updates carry no `error`. |
| `wifi_scan_result` | `WifiScanResultEvent` | Wi-Fi scan results. Intermediate events can have `scanComplete: false`; the final event has `scanComplete: true` and is what `requestWifiScan()` awaits. |
| `wifi_forget_result` | `WifiForgetResultEvent` | Discriminated raw result union. `mode: "modern"` is session-correlated and carries semantic `outcome`; K900 `outcome: "dispatched"` does not prove the asynchronous vendor receiver removed the credential. `mode: "legacy"` preserves an older frame's `dispatched` boolean without inventing missing correlation fields. In either mode, optional `connected` is omitted when the wire frame has no diagnostic link snapshot. Delivery is at least once; raw listeners should deduplicate modern retries by `(requestId, sid)`. Promise APIs ignore duplicates after the first matching terminal result. |
| `saved_wifi_networks` | `SavedWifiNetworksEvent` | Session-correlated saved-SSID result from a backend that advertised support. Delivery is at least once; raw listeners should deduplicate retries by `requestId` and `sid`. Promise APIs ignore duplicates after the first matching terminal result. |
| `version_info` | `VersionInfoEvent` | Glasses version metadata response. `version_info_1` can include `wifiForgetResultVersion` and `savedWifiNetworksVersion`; absent/0 means unsupported for that glasses session. Also returned by `requestVersionInfo()`. |
| `hotspot_status_change` | `HotspotStatusChangeEvent` | Glasses hotspot state changes. |
| `hotspot_error` | `HotspotErrorEvent` | Hotspot operation fails. |
| `photo_response` | `PhotoResponseEvent` | Terminal photo result. Success means capture and webhook delivery completed; error means the glasses or phone rejected/failed the request. `requestPhoto(...)` resolves with the success case and rejects on the error case; progress follows through `photo_status`. |
| `photo_status` | `PhotoStatusEvent` | Photo capture progress changes. May include `resolvedConfig`, `requestedCaptureConfig`, `meteredPreview`, or `captureMetadata` depending on status. |
| `camera_status` | `CameraStatusEvent` | Camera warm-up lifecycle. `warmUpCamera(...)` resolves on `ready`, rejects on `error`, and listeners can observe `warming` and `stopped` progress. `stopped` is emitted after `ready` when the lease expires or the camera closes; pending warm-ups receive `error` instead if teardown happens before `ready`. |
| `video_recording_status` | `VideoRecordingStatusEvent` | Video recording start/stop succeeds or fails, or a status query reports `status: "recording_status"` with `data.recording`. `startVideoRecording(...)` resolves from `recording_started`; `stopVideoRecording(...)` resolves from `recording_stopped` unless a webhook upload was requested, in which case it waits for upload success. |
| `media_success` / `media_error` | `MediaUploadEvent` | Raw glasses media upload completion events. Video webhook stops use these events to resolve or reject the `stopVideoRecording(...)` promise after recording has stopped. |
| `gallery_status` | `GalleryStatusEvent` | Gallery content/camera-busy status changes. `cameraBusyReason` is included when the glasses report a busy camera reason such as `video` or `stream`. |
| `settings_ack` | `SettingsAckEvent` | Raw gallery/button/FOV setting acknowledgements from the glasses. Gallery and button setting methods return `SettingsAckSuccessEvent` and reject failure statuses; `setCameraFov(...)` resolves a friendlier `CameraFovResult` after the raw ack reports camera hardware application. |
| `compatible_glasses_search_stop` | `CompatibleGlassesSearchStopEvent` | Compatible-glasses search stops for a model. |
| `swipe_volume_status` | `SwipeVolumeStatusEvent` | Swipe-volume setting changes. |
| `switch_status` | `SwitchStatusEvent` | Glasses switch status changes. |
| `rgb_led_control_response` | `RgbLedControlResponseEvent` | RGB LED command succeeds or fails. `rgbLedControl(...)` resolves with the success case and rejects on the error case. |
| `pair_failure` | `PairFailureEvent` | Bluetooth pairing fails. Optional `code`. `"ios_forget_pairing"` means iOS holds a stale Bluetooth pairing for these glasses during an explicit attempt; the user must Forget This Device in Settings > Bluetooth, then pair again. |
| `pairing_info` | `PairingInfoEvent` | Mentra Live pairing session facts. `auto_audio` is true when Classic audio should connect on its own after the LE pair. `awaiting_confirm` and `retained_owner_link` are not sent. |
| `entering_pairing_mode` | `EnteringPairingModeEvent` | The connected Mentra Live glasses opened a pairing window (three power-button presses). Includes `window_ms` and `window_id`. The SDK pauses automatic reconnect for the window plus a 30-second margin and keeps the saved device. |
| `pairing_mode_ended` | `PairingModeEndedEvent` | The glasses closed the pairing window and this phone is still accepted. `reason` is `"paired"`, `"cancelled"`, or `"timeout"`. Optional `window_id`. |
| `pairing_state_changed` | `PairingStateChangedEvent` | `GlassesStatus.pairingState` changed. `pairing_rejected` means the glasses no longer accept this phone: reconnect has stopped, so show Pair Again. |
| `audio_setup_changed` | `AudioSetupChangedEvent` | `GlassesStatus.audioSetup` changed. Show the Settings step for `needs_user`. |
| `owner_replaced` | `OwnerReplacedEvent` | Deprecated. Never emitted. Use `pairing_state_changed` and render Pair Again for `pairing_rejected`. |
| `audio_pairing_needed` | `AudioPairingNeededEvent` | The phone needs Bluetooth audio pairing for the device. |
| `audio_connected` | `AudioConnectedEvent` | Bluetooth audio connects. |
| `audio_disconnected` | `AudioDisconnectedEvent` | Bluetooth audio disconnects. |
| `mic_pcm` | `MicPcmEvent` | PCM microphone frame arrives. |
| `mic_lc3` | `MicLc3Event` | LC3 microphone frame arrives. |
| `mic_health` | `MicHealthEvent` | Native LC3 processing detects a `sequence_gap` or `decode_failure`. Includes cumulative current-connection counters and last LC3/PCM receipt timestamps. |
| `stream_status` | `StreamStatusEvent` | Camera stream lifecycle, reconnect, or error state changes. May include `resolvedConfig` with effective stream settings: encoded output size in `video.width` / `video.height`, native camera capture size in `video.captureWidth` / `video.captureHeight`, video bitrate and `fps`, plus audio bitrate, sample rate, echo cancellation, and noise suppression. |
| `ota_start_ack` | `OtaStartAckEvent` | Mentra Live acknowledges `startOtaUpdate()`. Also returned by `startOtaUpdate()`. |
| `ota_status` | `OtaStatusEvent` | OTA step, phase, status, progress, or error changes. |
For request/response commands, prefer the returned value from the method, such as the `PhotoSuccessResponseEvent` returned by React Native `requestPhoto(...)` or the operation-specific video result returned by React Native `startVideoRecording(...)` / `stopVideoRecording(...)` / `queryVideoRecordingStatus(...)`. `requestPhoto(...)` waits for the terminal `photo_response`: it resolves after the photo is captured and delivered to the webhook, and rejects if the glasses reject the request, the phone-side fallback upload fails, or the terminal response times out. `stopVideoRecording(...)` keeps the same end-to-end shape for video webhook stops: it waits for recording stop plus upload success, and rejects on upload failure. Photo capture/upload/Bluetooth fallback progress follows through `photo_status`; raw video upload completion arrives through `media_success` and `media_error` for listeners that need the glasses event stream directly. Use event listeners for ongoing hardware streams and status updates: for example, `useBluetoothEvent('mic_pcm', ...)` receives a `MicPcmEvent`. `MicPcmEvent` includes `sampleRate`, `bitsPerSample`, `channels`, `encoding`, and `voiceActivityDetectionEnabled`; `MicLc3Event` includes `sampleRate`, `channels`, `encoding`, `frameDurationMs`, `frameSizeBytes`, `bitrate`, `packetizedFromGlasses`, and `voiceActivityDetectionEnabled`. `mic_health` reports native sequence/decode failures that cannot be reconstructed from PCM and includes `sequenceGapEvents`, `decodeFailures`, `lastLc3ReceivedAt`, and `lastPcmProducedAt`. `speaking_status` is separate from microphone audio frames so apps can use continuous audio while still reacting to speech activity.
Public React Native event payload fields usually use camelCase. OTA events intentionally mirror the glasses firmware field names, such as `overall_percent` and `version_name`. For example, touch events expose `deviceModel` and `gestureName`, successful photo responses expose `uploadUrl` and may include webhook-returned `photoUrl`, `statusUrl`, `contentType`, and `fileSizeBytes`, successful media upload events expose `requestId`, `mediaUrl`, and `mediaType`, hotspot errors expose `errorMessage`, Wi-Fi scan events expose `scanComplete`, and gallery status exposes `hasContent`, `cameraBusy`, and optional `cameraBusyReason`.
### Photo Status Metadata
`PhotoStatusEvent` reports progress through capture and transfer. Capture metadata is attached to the stage where the glasses know that data:
| Status | Optional field | Description |
| --- | --- | --- |
| `configuring` | `resolvedConfig` | Effective JPEG dimensions, quality, requested size, source (`sdk` or `button`), transfer method, compression, and manual exposure fields when present. |
| `capturing` | `requestedCaptureConfig` | Camera2 still request values submitted to the HAL, such as exposure time, ISO, frame duration, AE mode, AE lock, exposure compensation, target FPS range, AF mode, and ZSL. |
| `capturing` | `meteredPreview` | Latest preview auto-exposure estimate before the still capture, including exposure time, ISO, and a light proxy when available. |
| `captured` | `captureMetadata` | Actual still capture result returned by the HAL, including applied exposure time, ISO, frame duration, AE state/name, noise reduction mode, edge mode, sensor timestamp, and MFNR hint when available. |
Transport statuses such as `uploading`, `compressing`, `ble_fallback_compression`, `ready_for_transfer`, and `transferring` describe upload or BLE progress only and do not carry capture metadata. `ble_fallback_compression` means the direct Wi-Fi/webhook upload failed and the glasses are compressing the already-captured photo for Bluetooth fallback delivery. Apps should read actual capture values from `event.captureMetadata` on the `captured` status, not from upload statuses.
Local action-button photos emitted by the glasses use the same `photo_status` shape when the phone SDK is connected. Those local captures set `resolvedConfig.source` to `button` and `resolvedConfig.transferMethod` to `local`.
Android and iOS expose typed callbacks/delegate methods instead of the React Native string event API. Android uses `MentraBluetoothSdkListener` methods such as `onStateChanged`, `onGlassesChanged`, `onSdkStateChanged`, `onScanChanged`, `onDeviceDiscovered`, `onButtonPress`, `onSpeakingStatus`, `onPhotoResponse`, `onPhotoStatus`, `onMicPcm`, `onMicHealth`, `onStreamStatus`, and `onOtaStatus`. iOS uses `MentraBluetoothSDKDelegate` methods such as `mentraBluetoothSDK(_:didUpdate:)`, `mentraBluetoothSDK(_:didUpdateGlasses:)`, `mentraBluetoothSDK(_:didUpdateSdkState:)`, `mentraBluetoothSDK(_:didUpdateScan:)`, `mentraBluetoothSDK(_:didDiscover:)`, `mentraBluetoothSDK(_:didReceive:)`, `mentraBluetoothSDK(_:didReceiveMicPcm:)`, and `mentraBluetoothSDK(_:didReceiveMicLc3:)`; microphone health arrives through `didReceive` as `.micHealth`, while OTA install progress arrives as `.otaStartAck` or `.otaStatus`. Microphone audio callbacks use `MicPcmEvent` and `MicLc3Event` objects with the same metadata as React Native.
| Event area | Examples |
| --- | --- |
| Input | Button press, touch, swipe, head-up |
| Device state | Battery, case, Wi-Fi, hotspot, connection, RSSI |
| Camera | Photo request result, camera warm-up state, gallery state, camera settings |
| Streaming | Stream initializing, active, stopped, error |
| OTA | Update available, start acknowledged, step/progress status |
| Audio | Microphone PCM, LC3, local transcription, audio route state |
| Diagnostics | SDK log events |
### Combined JavaScript and Native Logs
The React Native SDK automatically forwards Android and iOS SDK diagnostics to
the JavaScript console after import. Native entries are prefixed with
`[native:android]` or `[native:ios]` and appear alongside your app's JS logs.
The `log` event remains available for custom consumers; an additional listener
that calls `console.log` will duplicate the SDK's automatic output.
Credential-bearing messages are redacted before console output, and each native
message is capped at 16,384 characters. The Mentra App attaches this combined
console stream to incident reports using its existing phone log buffer and
retention limits. Native console output remains available too.
On Android, forwarding to JavaScript is capped at 100 messages per second. Each
forwarded message holds a JNI global reference until the JavaScript thread drains
it, so an unbounded log source can exhaust the process-wide reference table and
abort the app rather than merely slow it down. Messages above the cap are withheld
from the JavaScript stream only — they are still written to the native console —
and the next forwarded message is preceded by a notice saying how many were
withheld. Per-frame microphone payload events are not traced at all; audio faults
are still reported through the `mic_health` event.
This covers SDK-owned diagnostics while the JavaScript runtime is active. It does
not collect arbitrary OS or third-party native logs or replay logs from before
the subscription. Rebuild the native app to pick up the routing changes.
## Version Fields
Call `requestVersionInfo()` after connection when your app wants the glasses to refresh version metadata. Updated values arrive through the normal glasses-status callback and are also available in the next status snapshot.
| Field | Meaning |
| --- | --- |
| `firmwareVersion` | Generic glasses firmware version when the connected model reports one. |
| `deviceFirmwareVersion` | Device firmware version for models that report device info as a structured payload. |
| `leftFirmwareVersion` / `rightFirmwareVersion` | Per-side firmware versions for glasses that report left/right firmware separately. |
| `besFirmwareVersion` | Mentra Live BES firmware version. |
| `mtkFirmwareVersion` | Mentra Live MTK/system OTA firmware version. |
| `appVersion` | Glasses-side companion app version. On Mentra Live this is the ASG client APK version, not firmware. |
| `androidVersion` | Android OS version on Android-based glasses. This is not firmware. |
Different glasses models expose different version fields, so apps should prefer the generic firmware field when present, then fall back to model-specific firmware fields. Keep app and OS versions visibly labeled as app/OS versions.
|