Skip to content

Latest commit

 

History

History
17 lines (10 loc) · 1.32 KB

README.md

File metadata and controls

17 lines (10 loc) · 1.32 KB

simble

A node.js module for simple access to ble (Bluetooth Low Energy = Bluetooth 4.x) devices.

This module is a wrapper for the noble package, using Promises instead of callbacks and providing a somewhat different API.

Usage example

The following code scans for a nearby Bluetooth LE peripheral that advertises the "Heart Rate" Service (ID: 0x180D). If such a peripheral is found, it requests the peripheral's "Heart Rate Measurement" Characteristic (ID: 0x2A37) (the peripheral will auto-connect, since a connection is required for accessing/requesting a Characteristic). It then subscribes to that characteristic; whenever updates arrive, it will print the current heart rate (byte 1 in the data) to the console.

require('simble').subscribe_to_characteristic(0x180D, 0x2A37, (heart_rate_data) => {
  console.log(`Heart rate: ${data[1]} bpm`);
});

API

Unfortunately, the API is not documented yet, so there's very little reason for others to use it yet. I published it because other node.js modules of mine require it.