# Hardware Integration

> Handle Mentra Live capabilities and status-driven hardware behavior.

Source: https://docs.glassly.ai/bluetooth-sdk/hardware/

Mentra Live is the camera glasses model supported by this SDK tab. Apps should still treat hardware features as status-driven because firmware version, permissions, and connection state affect what is available at any moment.

## Recommended Flow

1. Ask the user which glasses model they are pairing.
2. Call `scan()` for that model.
3. Present typed discovered devices from the progressive scan results.
4. Connect using the discovered device or default-device helper.
5. Read shaped glasses state, firmware fields, and hardware-related status before enabling advanced features.
6. Keep app UI derived from SDK status rather than from command success alone.

**React Native**

```ts
import BluetoothSdk, {DeviceModels} from '@glassly/bluetooth-sdk';

const devices = await BluetoothSdk.scan(DeviceModels.MentraLive, {
  timeoutMs: 10_000,
  onResults: (nextDevices) => renderDevicePicker(nextDevices),
});

await BluetoothSdk.connect(await chooseDevice(devices));
```

**Android**

```kotlin
sdk.scan(DeviceModel.MENTRA_LIVE, timeoutMs = 10_000) { nextDevices ->
    renderDevicePicker(nextDevices, onSelect = { device ->
        sdk.connect(device)
    })
}
```

**iOS**

```swift
try sdk.scan(model: .mentraLive, timeout: 10) { nextDevices in
    renderDevicePicker(nextDevices) { device in
        do {
            try sdk.connect(to: device)
        } catch {
            handleConnectionError(error)
        }
    }
}
```

In multi-device environments, keep the picker explicit. Do not auto-connect to the first scan result; let the user choose the glasses they expect.

## Capability Areas

- Input: button, touch, head position (`head_up` / `head_down` touch gestures), and switch events.
- Audio: PCM, LC3, audio pairing, preferred microphone, speaker playback, and local transcription.
- Camera: photo, gallery, video recording, and streaming.
- Network: Wi-Fi scan, credentials, and hotspot state.
- Maintenance: Mentra Live version info and OTA status.

## Mentra Live Hardware

Mentra Live is built for visual capture, streaming, and audio-first interactions.

- Camera: 1080p with streaming support.
- Microphone: yes.
- Speaker: yes.
- Buttons: yes, including press, double press, and long press events.
- LEDs: RGB feedback plus white privacy light.
- Wi-Fi: yes.

```ts
{
  modelName: "Mentra Live",
  hasCamera: true,
  hasMicrophone: true,
  hasSpeaker: true,
  hasButton: true,
  hasLight: true,
  hasWifi: true
}
```

Unsupported operations are recoverable SDK errors. Reconcile command failures with the latest status snapshot before showing destructive UI.

## Other Glasses

`DeviceModels` lists further glasses families; their model-specific calls are in the [API Reference](https://docs.glassly.ai/bluetooth-sdk/api-reference.md#additional-methods). The SDK bundles a Glassly custom firmware (CFW) for two of them:

| Glasses | `DeviceModels` key | Model-specific behavior |
| --- | --- | --- |
| Even Realities G1 | `G1` | Text walls, brightness, head-up angle and dashboard position on the stock firmware; bitmaps are not supported there. [Firmware flash](https://docs.glassly.ai/bluetooth-sdk/api-reference.md#firmware-flash) between the bundled stock image (1.6.3) and the Glassly CFW (G1CFW/50) over MCUmgr SMP, one temple at a time. On the Glassly CFW the SDK drives a 640x200 to 640x380 scene canvas, set by `dashboard_size` (default 340 rows; 640x200 before G1CFW/49) with the firmware's own primitives (text with grey levels, filled and outlined rects, circles, arcs, pies, lines, triangles, quads, beziers, filled SVG paths, 1-bit images, per-element depth) and its retained objects, so a moved, resized, recoloured, restroked or rotated shape or path glides between frames on the glasses, reports `single_tap`, `double_tap`, `triple_tap` and `long_press` from the temples' touch pads, runs the microphone through the CFW's capture session, maps dashboard height and depth onto the firmware's view offsets, and puts the panel to sleep for silent mode; the panel itself follows wear in the firmware. |
| Even Realities G2 | `G2` | Head-up angle and on-glass notifications. [Firmware flash](https://docs.glassly.ai/bluetooth-sdk/api-reference.md#firmware-flash) between the bundled stock image and the Glassly CFW (revision 53). The CFW adds the BLE keyboard bridge (revision 39+), the microphone volume gate (revision 40+, `volumeGate` in the glasses status), and [head position](https://docs.glassly.ai/bluetooth-sdk/api-reference.md#touch-gestures) as `head_up` (revision 45+) and `head_down` (revision 46+) while a Glassly page is on screen. |
| RayNeo iO | `RayNeoIO` | On-glass notifications, which the glasses read from an iPhone themselves once they run the Glassly CFW. [Firmware flash](https://docs.glassly.ai/bluetooth-sdk/api-reference.md#firmware-flash) between the bundled stock image and the Glassly CFW (revision 9) needs 50% glasses battery. Touch gestures arrive only on the Glassly CFW; those made with the physical button also arrive as `button_press` (`main`, `short` or `long`). The glasses report no head position, so on either firmware the SDK sends one `head_up` when the link comes up. |

## Connection Resilience

- Subscribe to status callbacks before connecting.
- Retry scans manually from the UI instead of scanning forever in the background.
- On mobile OS background transitions, expect Bluetooth behavior to vary by platform.
- Provide a visible "forget device" path that clears both the SDK default device and any app-persisted default-device record.
- If your app persists a default device, restore it with `setDefaultDevice()` before calling `connectDefault()`.
