Skip to content

Communication

Overview

The SDK handles the communication functionality via the M2GlassesService (accessed from Evs.glassesService).

The communication with the glasses is performed over BLE 4.2 and above, whereas BLE 5 is recommended to achieve better performance and throughput.

The glasses are connectable using GATT over BLE protocol whereas the glasses act as a BLE peripheral device.

Connection States

The glasses connection follows this state machine:

                          ┌──────────────┐
                          │ BluetoothOff │
                          └──────┬───────┘
                                 │ Bluetooth enabled
┌──────────┐  connect()   ┌──────────────┐
│  Failed  │◄─────────────│ Disconnected │
└──────────┘  error       └──────┬───────┘
      │                          │ connect()
      │ connect()                ▼
      └──────────────────►┌──────────────┐
                          │  Connecting  │
                          └──────┬───────┘
                                 │ BLE link established
                          ┌──────────────┐
                          │  Connected   │
                          └──────┬───────┘
                                 │ handshake + certificate OK
                          ┌──────────────┐
                          │    Ready     │
                          └──────────────┘

The Ready state indicates the glasses are fully connected and the SDK is ready for screen rendering and service calls. Register for state changes via IM2GlassesConnectionEvents.

Configuring Maverick AI

The SDK handles all communication with the glasses through Evs.glassesService.

The glasses are discoverable when they are powered on, if no other device is currently connected to them.

Stock UI

The quickest way to get started is using the SDK's built-in scanning and configuration UI:

Evs.showUI(M2ShowUIOption.DefaultConfigure)
Evs.shared.showUI(option: M2ShowUIOption.companion.DefaultConfigure)

Scanning with M2BLEScanner

For a custom scan experience, use M2BLEScanner which handles platform-specific BLE APIs and filters for Maverick AI devices automatically:

val scanner = M2BLEScanner()

scanner.startScan { device ->
    // device.name  - e.g. "EV0080"
    // device.addr  - BLE address (Android) or peripheral UUID (iOS)
    // device.rssi  - signal strength in dBm
}

// When done:
scanner.stopScan()
let scanner = M2BLEScanner()

scanner.startScan { device in
    // device.name  - e.g. "EV0080"
    // device.addr  - peripheral UUID
    // device.rssi  - signal strength in dBm
}

// When done:
scanner.stopScan()

Native BLE Scanning

If you prefer to use platform BLE APIs directly, scan for devices advertising the Maverick AI GATT service UUID:

GATT_SERVICE_UUID = "e73f41ea-45e9-f9aa-514b-fa5349b08e50"
val serviceUuid = ParcelUuid(UUID.fromString("e73f41ea-45e9-f9aa-514b-fa5349b08e50"))
val filter = ScanFilter.Builder().setServiceUuid(serviceUuid).build()
val settings = ScanSettings.Builder()
    .setScanMode(ScanSettings.SCAN_MODE_BALANCED)
    .build()

bluetoothLeScanner.startScan(listOf(filter), settings, scanCallback)
let serviceUUID = CBUUID(string: "e73f41ea-45e9-f9aa-514b-fa5349b08e50")
centralManager.scanForPeripherals(withServices: [serviceUUID])

The glasses Bluetooth name format is: EV[GLASSES_NUMBER], for example: EV0080.

Connecting

Once you have a device (from M2BLEScanner or native scanning), configure the SDK with its address and name, then connect:

Evs.glassesService.setConfiguredDevice(device.addr, device.name)
Evs.glassesService.connect()
Evs.shared.glassesService.setConfiguredDevice(address: device.addr, name: device.name)
Evs.shared.glassesService.connect()

The SDK will maintain the connection until Evs.glassesService.disconnect() is called.

Persistent Configuration

The SDK persists the configured device address. On subsequent launches you can reconnect without re-scanning:

Evs.init(context)
if (Evs.glassesService.hasConfiguredDevice()) {
    Evs.glassesService.connect()
}
Evs.shared.doInit()
if Evs.shared.glassesService.hasConfiguredDevice() {
    Evs.shared.glassesService.connect()
}

BLE Permissions

See Starting Application Development for the full list of required BLE permissions for Android and iOS.


See Also

  • Glasses - Device info, battery, and system events
  • Simulator - Test without physical glasses
  • Display - Brightness and display control