Gatttool is a NodeJS wrapper for a BlueZ tool gatttool
. You can easily connect, read, write and listen to notifiacations from your Bluetooth Low Energy device.
Installation
npm i gatttool
or
yarn add gatttool
Example usage
Below is one example from the ./examples
folder .
const gatttool = ;const Writable = ; const ble = objectMode: true { console; ; }; const handleData = console; { gatttoolstart onData: handleData stream: ble ; const btAddress = await gatttool; console; if btAddress ; ; ; ; };
What makes it different?
This wrapper has no depedencies on the buggy D-Bus or HCI socket implementations. Which leaves you with a pure joy of using Bluetooth Low Energy devices on your Linux-based host machines.
gatttool vs noble
The most popular BLE (central mode) library for NodeJS is noble. It's great but it has its limiations. Below is a table that shows differences between bluezjs and noble.
Feature | noble | gatttool |
---|---|---|
NodeJS 10 and later | No | Yes |
gatttool (more stable) | No | Yes |
Central mode | Yes | Yes |
Peripheral mode | No | Yes |
Raspberry Pi | Yes | Yes |
Linux | Yes | Yes |
MacOS | Yes | No |
Windows | Yes | No |