Keiser Air eChip WebUSB Library
This library handles communication with the Keiser eChip as a means of collecting workout information from Keiser Strength and Functional equipment. The library is written in TypeScript and supports modern browsers with WebUSB support.
For additional information about this project visit the Keiser Developer Zone.
Required Hardware: USB to 1-Wire/iButton Adapter (DS9490)
Required Drivers: 1-Wire/iButton Drivers for Windows
Install with npm:
npm install @keiser/echip-webusb
Import singleton instance from module using preferred module loading technique.
ChipReaderWatcher handles permissions and USB connection events. On first load, the browser will not have provided a grant to the site to access the USB device, so the
ChipReaderWatcher.start() method must be called by an event that originates from a user action. This may only be required once on the first visit to the site, or it may be required each time the site is loaded based on browser vendors preferred implementation.
ChipReaderWatcher.start() method has been called the class will prompt the browser for permission and begin watching for devices matching the Chip Readers device signature. To be alerted when a device is found, pass a function to the
ChipReaderWatcher.onConnect() will pass in a
ChipReader object which is the object bound to the physical device connected. This library is capable of handling multiple Chip Reader devices simultaneously, so the
onConnect() method has potential for returning multiple
ChipReader devices over the course of the application's life.
ChipReader object has an
onDisconnect() method which will alert when the Chip Reader has been disconnected for some reason. Once a
ChipReader object has been disconnected, it is disposed and cannot be used again. The next time the device is connected, a new
ChipReader object will be returned.
ChipReader object also has an
onChipDetect() method which will alert when a valid chip has been placed into the reader. The event passes in a
Chip object that can be used to interact with the chip data directly. Just like the
ChipReaderWatcher.onConnect() method, the
ChipReader.onChipDetect() method can be called multiple times for multiple chips all being handled concurrently. Once a chip is disconnected, the
Chip object is disposed and cannot be reused.
Full example usage:
A single eChip is capable of holding 200 workout sets worth of data from 24 distinct machines. If the eChip is full, machines will replace the oldest workout record on the eChip with new data. It is recommended to completely clear the eChip between uses and to only write the data required for targeting during the current workout session.
ChipReaderWatcher is a singleton class which handles the USB device monitoring and permissions handling. There can be only one
ChipReaderWatcher instance created within a
window scope, so the library instantiates the class during import and preserves a single instance for all imports.
||Indicates if the browser supports WebUSB.|
||Adds an event listener for when a Chip Reader device is connected. Callback method will be passed the new
||Initializes the watcher by first requesting permissions and then doing a hardware search. This method must be triggered by a user action such as a click event or the permission request will be denied.|
||Closes all active connections.|
ChipReader instance is passed into the
onConnect callback function and is the interface to the connected Chip Reader device.
||Promise indicating if the USB device interface has been claimed.|
||Indicates if the device connection has been severed and the class instance disposed.|
||Adds an event listener for when a chip is connected to the Chip Reader device. Callback method will be passed the new
||Adds an event listener for when this Chip Reader device becomes disconnected. The instance will be disposed following this event.|
BaseChip instance is passed into the
onChipDetect callback function and is the interface to the connected chip device. There are several different extensions to the base
BaseChip object that can identified by doing a
instanceOf check or looking at the
||Indicates if the eChip connection has been severed and the class instance disposed.|
||Generic object with the current data from the chip.|
||UUID string of the eChip.|
||Called to disconnect the eChip device.|
||Adds an event listener for when this chip becomes disconnected. The instance will be disposed following this event.|
||Adds an event listener for when the chip data has changed.|
TZChip and RTCChip
RTCChip are class extensions on the
BaseChip class. They add no additional properties or methods, but allow the identification of chip type and will perform chip set operations automatically when detected. An event issued on the
onData event indicates that the chips data has been successfully updated.
DataChip class extension on the
BaseChip class adds additional properties and methods specific to the data chip.
||Method clears the data on the chip and resolve the promise on successful write. An
||Method sets the data on the chip according to the data passed into the method. The method accepts an object with
Copyright and License
Copyright © 2020 Keiser Corporation.
The Keiser eChip WebUSB Library source code and library package are made available through the MIT license.
Using any of this library in connection with any Keiser eChip enabled equipment make you subject to the following agreements. Please read all documents in their entirety as they govern your use of the APIs.