Skip to content

Omi Glass: dynamic MTU negotiation and audio packet fragmentation #8452

Open

Description

@thesohamdatta

1. The user experience

Omi Glass is designed to stream microphone audio over Bluetooth Low Energy. Currently, the firmware is hardcoded to a maximum MTU size of 517 bytes.

If a connecting client (like an older Android phone or Windows PC) fails to negotiate this MTU size and drops it to the default 185 bytes, the firmware will attempt to notify the characteristic with raw buffers exceeding the limit, causing packet drops or firmware crashes. We need to support dynamic MTU negotiation and split audio packets when they exceed the limit, ensuring stable connections on all host devices.


2. Technical architecture

The firmware must dynamically adjust the transmitted packet size to match the negotiated MTU of the active Bluetooth connection.

graph TD
    A[I2S Mic Audio] -->|Raw PCM| B[Opus Compressor]
    B -->|Compressed Opus Frame| C[MTU Check]
    C -->|Frame <= Max Payload| D[Send Single Packet]
    C -->|Frame > Max Payload| E[Fragment Frame]
    E -->|Loop Chunk| F[Send Packet with Sub-Index]
Loading

Affected files

  • Modify: omiGlass/firmware/src/app.cpp
  • Modify: omiGlass/firmware/src/config.h

3. Implementation steps

Step 1: Set up the BLE Server MTU callback

Register a server callback on the BLE Server to track the negotiated connection MTU dynamically whenever the link updates. Store this value in a global configuration variable.

Step 2: Implement dynamic packet fragmentation

In the audio broadcast function, subtract GATT overheads and custom headers from the negotiated MTU to find the safe payload limit. If the Opus frame size is within the limit, transmit it directly. If it exceeds the limit, split the frame and send the chunks sequentially, prefixing each with a sub-index header byte so the client-side app can stitch them back together.


4. Verification benchmarks

  • BLE server logs successful MTU updates over Serial.
  • Firmware successfully fragment-transmits audio packets on connections with smaller MTUs.

Activity

  1. added
    p3
    firmware
    capture
    p2
    help-wanted
    and removed
    p3
    on Jul 2, 2026
  2. gianluca-disanto commented on Sep 11, 2026

    @gianluca-disanto
    Contributor

    Hi @thesohamdatta, @beastoin, @kodjima33,

    I would like to request to lock this issue for a fair $50 bounty as an active contributor (my first PR #13389 is
    merged, and I recently contributed the BLE MTU notification bounds for CV1 on #13342 and DevKit on #13388).

    Proposed Implementation Plan:

    1. Dynamic MTU Tracking (app.cpp, config.h):
      • Implement onMTUChange(uint16_t MTU, ble_gap_conn_desc* desc) inside ServerHandler
        (NimBLEServerCallbacks) to track the negotiated ATT MTU dynamically.
      • Maintain connection-state MTU initialized to default BLE minimum (23 bytes) and clamp safely against
        connection drops.
    2. Audio Packet Fragmentation (broadcastAudioPacket):
      • Compute safe_payload = current_mtu - ATT_OVERHEAD (3 bytes) - AUDIO_PACKET_HEADER_SIZE (3 bytes).
      • If frame fits within safe_payload, notify as a single packet with sub_index = 0.
      • If frame exceeds safe_payload, chunk the Opus payload across sequential notifications sharing the same
        audioPacketIndex and incrementing sub_index (0, 1, 2...) so client receivers can assemble them without dropping
        data.
    3. Verification:
      • Serial log verification for negotiated MTU events.
      • Host harness / test suite ensuring fragmentation logic and boundary conditions (standard 23-byte MTU, 185-
        byte, and 517-byte links).

    Looking forward to your approval so I can proceed with the PR. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    capturefirmwarehelp-wantedp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions