Reverse Engineering Report: Zepp / Mi Band Watchface Sync Engine

This document details the reverse engineering of the Mi Band watchface installer (com.weaponoid.miband6 v4.5.5) extracted from OnePlus PLU110.


1. How the App Connects via Zepp App

The third-party installer app does NOT use internal file replacement in Zepp's private directory or Zepp root access. Instead, it leverages Android's Bluetooth LE connection multiplexing:

  1. Prerequisite: The Mi Band is paired and actively connected to the phone via Zepp Life (Mi Fit) (com.xiaomi.hm.health) or Zepp / Mi Fitness (com.xiaomi.wearable).
  2. Connection Discovery:
    • The app gets the system BluetoothManager:
      val bluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
      val connectedGattDevices = bluetoothManager.getConnectedDevices(BluetoothProfile.GATT)
      
    • It filters the connected devices by device name prefix (e.g. "Mi Smart Band 6", "Xiaomi Smart Band 7", "Mi Smart Band 5").
  3. Transparent GATT Multiplexing:
    • Because Zepp maintains an active encrypted BLE ACL link with the band in the background, our app calls device.connectGatt(...).
    • Android opens an independent client GATT handle over the already authenticated and active link.
    • The band accepts DFU commands without requiring re-authentication or pairing keys (which are only needed if initiating a raw BLE pairing from scratch).

2. BLE GATT Service & Characteristics (Huami DFU)

For Mi Band 4, 5, 6, and 7, the sync engine uses the proprietary Huami DFU service:


3. Watchface Binary Structure


4. DFU Protocol State Machine

All commands and responses are communicated over characteristicFirmware (00001531) with notifications enabled. Responses start with opcode 0x10 (16).

sequenceDiagram
    autonumber
    participant App as ZeppInstaller App
    participant Band as Mi Band (GATT)

    Note over App, Band: 1. Initialization
    App->>Band: Enable Notifications on 0x1531
    App->>Band: Write [0xD0] (-48) to 0x1531
    Band-->>App: Notify [0x10, 0xD0, 0x01, chunk_lo, chunk_hi, ...]
    Note over App: Parse negotiated chunk size (e.g. 1024 or 2048)

    Note over App, Band: 2. Pre-transfer Header (Mi Band 6)
    App->>Band: Write [0x39, 0x00, file_size(4B), watchface_id(4B)] to 0x0003

    Note over App, Band: 3. Firmware / Watchface Metadata
    App->>Band: Write [0xD2, 0x08, file_size(4B), crc32(4B), chunk_size(2B), 0x00, 0x00, 0x01, file_size(4B)] to 0x1531
    Band-->>App: Notify [0x10, 0xD2, 0x01]

    Note over App, Band: 4. Start Transfer Handshake
    App->>Band: Write [0xD3, 0x01] to 0x1531
    Band-->>App: Notify [0x10, 0xD3, 0x01]

    Note over App, Band: 5. Data Streaming (Offset = 0)
    loop Send Chunks
        App->>Band: Write chunk data (MTU-split) to 0x1532 (WRITE_NO_RESPONSE)
        Band-->>App: Notify [0x10, 0xD4, offset_b0, offset_b1, offset_b2, offset_b3]
        Note over App: Update progress % and stream next chunk
    end

    Note over App, Band: 6. Finalization
    App->>Band: Write [0xD5] to 0x1531
    Band-->>App: Notify [0x10, 0xD5, 0x01]
    App->>Band: Write [0xD6] to 0x1531
    Band-->>App: Notify [0x10, 0xD6, 0x01]
    Note over App: Watchface applied! Disconnect GATT.

5. Status & Error Codes