A node.js module for ANT+
Libusb is included as a submodule. On Linux, you'll need libudev to build libusb. On Ubuntu/Debian: sudo apt-get install build-essential libudev-dev
Use Zadig to install the WinUSB driver for your USB device. Otherwise you will get LIBUSB_ERROR_NOT_SUPPORTED
when attempting to open devices.
On macOS (tested on High Sierra and Mojave), installing ant-plus
will also
install the required libusb
.
Make sure that Garmin Express is not running,
because it will attach to the ANT+ stick and prevent ant-plus
from doing so.
npm install ant-plus
var Ant = require('ant-plus');
var stick = new Ant.GarminStick3;
var sensor = new Ant.HeartRateSensor(stick);
sensor.on('hbData', function (data) {
console.log(data.DeviceID, data.ComputedHeartRate);
});
stick.on('startup', function () {
sensor.attach(0, 0);
});
if (!stick.open()) {
console.log('Stick not found!');
}
sensor.on('hbData', function (data) {
console.log(data.DeviceID, data.ComputedHeartRate);
});
stick.on('startup', function () {
sensor.scan();
);
if (!stick.open()) {
console.log('Stick not found!');
}
GarminStick2 is the driver for ANT+ sticks with a USB product ID of 0x1008
.
As well as the old Garmin USB2 ANT+ stick, this works with many of the common off-brand clones.
GarminStick3 is the driver for the mini Garmin ANT+ stick
which has a USB product ID of 0x1009
.
The maximum number of channels that this stick supports; valid only after startup event fired.
Checks if the stick is present. Returns true if it is, false otherwise.
Tries to open the stick. Returns false on failure.
Tries to open the stick, waiting for it if not available right now. Returns a cancellation token with a method cancel
you can use to stop waiting.
callback
is a function accepting a single Error
parameter and it will be called when the stick is open (with the parameter undefined) or in case of failure (with the parameter set to the error).
Closes the stick.
Fired after the stick is correctly initialized.
Fired after the stick is correctly closed.
Attaches the sensors, using the specified channel and deviceId (use 0 to connect to the first device found).
Detaches the sensor.
Fired after the sensor is correctly attached.
Fired after the sensor is correctly detached.
Attaches the sensors and starts scanning for data from every devices in range.
Detaches the sensor.
Fired after the sensor is correctly attached.
Fired after the sensor is correctly detached.
Fired when new heartbeat data is received.
Calibrates the speed sensor. Defaults to a wheel with diameter of 70cm (= 2.199).
Fired when a new wheel speed is calculated.
Fired when a new pedal cadence is calculated.
Fired when new data been calculated.
Fired when new power has been calculated.
Fired when new data is received.
Fired when data is received.
The state.EventCount
value can be used to tell when a new measurement has been made by the sensor -
it's value will have been incremented.