Skip to content
/ ant-ws Public

A simple server for relaying ANT+ messages over websockets

Notifications You must be signed in to change notification settings

chadj/ant-ws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ANT-WS

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.

Prerequisites

The usb module is included as a dependency and may have special prerequisites depending on your platform.

Windows

On Windows please follow the instructions in the wiki.

Mac OS

No special steps are required on Mac OS.

Linux

On Linux, you'll need libudev to build the usb module. On Ubuntu/Debian: sudo apt-get install build-essential libudev-dev.

Installation

  1. Install Node.js
  2. Download and unpack the ANT-WS zip file
  3. Open a command prompt and switch directory to the unzipped folder (the folder containing the antws.js file)
  4. Run the command npm install
  5. Start the server with node antws.js

Command line help

$ 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

Client Usage

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"
}

About

A simple server for relaying ANT+ messages over websockets

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published