ANT-WS is a simple server written in javascript for Node.js that when combined with an ANT+ usb stick can relay all ant+ messages in range over a websocket to browser based clients. ANT-WS relies upon the ant-plus Node.js package for handling low level serial communication with the ant+ usb stick.
The usb module is included as a dependency and may have special prerequisites depending on your platform.
On Windows please follow the instructions in the wiki.
No special steps are required on Mac OS.
On Linux, you'll need libudev to build the usb module. On Ubuntu/Debian: sudo apt-get install build-essential libudev-dev
.
- Install Node.js
- Download and unpack the ANT-WS zip file
- Open a command prompt and switch directory to the unzipped folder (the folder containing the antws.js file)
- Run the command
npm install
- Start the server with
node antws.js
$ node antws.js --help
Usage: node antws.js --ssl --port 4430
Options:
-h, --help Command line usage
-p, --port Port to listen on
-v, --verbose Verbose ant+ message logging
--ssl Enable SSL
ANT-WS uses Faye as the underlying transport to relay ANT+ messages to browser based clients.
Include the client script from the ANT-WS server at: https://localhost:4430/client.js
<script type="text/javascript" src="https://localhost:4430/client.js"></script>
Subscribe to and receive ant messages
var client = new Faye.Client('https://localhost:4430/');
client.subscribe('/bike_power', msg => {
const ant = JSON.parse(msg.text);
}
The following topics are exposed and correspond to an ANT+ device type:
- hr
- bike_power
- speed_cadence
- fitness_equipment
- stride_speed_distance
An example ANT+ messages:
{
"offset":0,
"DeviceID":1,
"Cadence":165,
"AccumulatedPower":50374,
"Power":283,
"type":"bike_power",
"eventName":"powerData"
}