OpenBand BLE Bridge Library

Direct, zero-cloud, two-way Bluetooth Low Energy (BLE) communication library between Zepp OS mini-apps on Xiaomi Smart Band 7 (and compatible Huami wearables) and the OpenBand companion Android app.


Why this library?

Standard Zepp OS apps rely on the official Zepp cloud backend and a JavaScript "side service" hosted inside the proprietary Zepp app. This library enables:


Quick Start (Zepp OS Mini-App)

1. Copy openband-bridge.js to your app

Place openband-bridge.js in your app's directory (or bundle it inside your page script).

2. In your page/index.js:

// At the top of your page script
var OpenBandBridge = require('./openband-bridge.js'); // Or include directly in IIFE

DeviceRuntimeCore.Page({
  onInit: function() {
    // 1. Initialize listener for incoming phone data (temperature, HA status)
    OpenBandBridge.init({
      onMessage: function(text) {
        console.log("Phone data received:", text);
        // Update your UI widget
        myTextWidget.setProperty(hmUI.prop.TEXT, text);
      }
    });

    // 2. Create an action button
    hmUI.createWidget(hmUI.widget.BUTTON, {
      x: 12,
      y: 160,
      w: 168,
      h: 54,
      radius: 12,
      normal_color: 0x0D6EFD,
      press_color: 0x0A58CA,
      color: 0xFFFFFF,
      text: "Toggle Lights",
      click_func: function() {
        // Sends trigger to phone + provides brief haptic buzz
        OpenBandBridge.sendAction("toggle_lights");
      }
    });
  },

  onDestroy: function() {
    OpenBandBridge.destroy();
  }
});

API Reference

OpenBandBridge.init(options)

Initializes the BLE receiver on wrist. Must be called in onInit().

OpenBandBridge.sendAction(actionName, [haptic=true])

Transmits an action name to OpenBand on the phone.

OpenBandBridge.isConnected()

OpenBandBridge.destroy()

Stops any active haptic vibration and cleans up listeners. Call in onDestroy().


Repository Contents