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.
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!');
}
- never attach a sensor before receiveing the startup event
- never attach a new sensor before receiving the attached or detached event of the previous sensor
- never detach a sensor before receiving the attached or detached event of the previous sensor
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 cancelation token with a method cancel
you can use to stop waiting.
callback
is a funcion 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 an ~ 700c wheel, 2.118
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.