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:
- 100% Offline & Local: Direct BLE connection between band and phone.
- Instant Wrist Triggers: Trigger Home Assistant, local webhooks (
127.0.0.1), or phone sirens with $\sim 11\text{ ms}$ latency. - Live On-Wrist Data: Push live temperatures, sensor readings, or status text from Android directly to widgets on your wrist.
- Zero Dependencies: Pure standard JavaScript for Zepp OS 1.0+ and pure Java standard Android SDK for the phone.
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().
options.onMessagefunction(text): Callback invoked when the phone pushes text/data.options.autoHapticboolean(optional, default false): Iftrue, vibrates the wrist on data arrival.
OpenBandBridge.sendAction(actionName, [haptic=true])
Transmits an action name to OpenBand on the phone.
actionNamestring: Identifier (e.g."living_room_light","find_phone","gate_open").hapticboolean(optional, default true): Whether to trigger a short medium haptic pulse (scene: 24).
OpenBandBridge.isConnected()
- Returns
boolean: Whether the Bluetooth Low Energy link to the phone is currently active.
OpenBandBridge.destroy()
Stops any active haptic vibration and cleans up listeners. Call in onDestroy().
Repository Contents
openband-bridge.js: The Zepp OS client library.PROTOCOL.md: Low-level GATT protocol reverse-engineering document (packet format, 11-byte Little-Endian chunk header, UUIDs).examples/: Example Zepp OS mini-app pages.android/: Reference Android Java GATT bridge controller (BandBridgeController.java).