Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vshymanskyy/miband-js
MiBand 2 JS library for Node.JS and HTML5 (WebBluetooth)
https://github.com/vshymanskyy/miband-js
miband miband2 nodejs webbluetooth xiaomi
Last synced: 5 days ago
JSON representation
MiBand 2 JS library for Node.JS and HTML5 (WebBluetooth)
- Host: GitHub
- URL: https://github.com/vshymanskyy/miband-js
- Owner: vshymanskyy
- License: gpl-3.0
- Created: 2018-03-27T11:42:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-14T15:23:51.000Z (over 2 years ago)
- Last Synced: 2024-04-14T18:08:00.822Z (7 months ago)
- Topics: miband, miband2, nodejs, webbluetooth, xiaomi
- Language: JavaScript
- Size: 621 KB
- Stars: 339
- Watchers: 22
- Forks: 71
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine)
[![NPM version](https://img.shields.io/npm/v/miband.svg)](https://www.npmjs.com/package/miband)
[![NPM download](https://img.shields.io/npm/dm/miband.svg)](https://www.npmjs.com/package/miband)
[![GitHub issues](https://img.shields.io/github/issues/vshymanskyy/miband-js.svg)](https://github.com/vshymanskyy/miband-js/issues)
[![GitHub license](https://img.shields.io/github/license/vshymanskyy/miband-js.svg)](https://github.com/vshymanskyy/miband-js)# Mi Band 2 JS library
A clean implementation of [**Mi Band 2**](http://www.mi.com/en/miband2/) library for Browsers and Node.js, using WebBluetooth API.
![demo](https://github.com/vshymanskyy/miband-js/raw/master/public/demo.png)## Setting up
It's best to unbind your Mi Band 2 from MiFit App first.
You should be able to bind it back again, but no guaranee here ;)### Browser
[![LIVE DEMO](https://github.com/vshymanskyy/miband-js/raw/master/public/live-demo-btn.png)](https://tiny.cc/miband-js)
You need a browser with [WebBluetooth support](https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md). Tested with:
- Chrome on OS X (Yosemite or later)
- Chrome on Android (6.0 Marshmallow or later)
- Chrome on Linux (the `chrome://flags/#enable-experimental-web-platform-features` flag must be enabled)### Node.js
```sh
npm install miband -g
miband-test
```This should work on Windows, Linux and OSX.
On Linux, you need to grant Bluetooth access for Node.js:
```sh
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
```## Features
- Authentication
- Device info: time, battery status, hw/sw versions, etc.
- Button tap event
- Notifications: message, phone, vibrate
- Heart Rate Monitor
- Realtime data (soon)## API usage example
```js
const MiBand = require('miband');const device = await bluetooth.requestDevice({
filters: [
{ services: [ MiBand.advertisementService ] }
],
optionalServices: MiBand.optionalServices
});const server = await device.gatt.connect();
let miband = new MiBand(server);
await miband.init();log('Notifications demo...')
await miband.showNotification('message');
```Here you can find [more API examples](https://github.com/vshymanskyy/miband-js/blob/master/src/test.js)
---
## ContributingPlease check out [DEVELOPMENT.md](https://github.com/vshymanskyy/miband-js/blob/master/DEVELOPMENT.md)