AntPlus Class Library Overview
The AntPlus class library supports a number of ANT+ device profiles as defined by Garmin/Dynastream. All device profiles are based on the abstract class AntDevice. Common data pages and timeout options are provided to support the device profiles. The following device profiles are supported -
Asset Tracker
Bicycle Power
Crank Torque Frequency Sensor
Standard Power Sensor
Standard Crank Torque Sensor
Standard Wheel Torque Sensor
Bike Speed and Cadence
Bike Cadence Sensor
Bike Speed Sensor
Combined Speed and Cadence Sensor
Fitness Equipment
Climber
Elliptical
Nordic Skier
Rower
Trainer/Stationary Bike
Treadmill
Geocache
Heart Rate
Muscle Oxygen
Stride Based Speed and Distance Monitor
Unknown
See SmallEarthTech.AntPlus.DeviceProfiles for specific device details.
AntDevice
This abstract class provides events, properties and methods common to all ANT devices. These are some of the key features of this class that are used by the derived ANT device classes -
The virtual Parse method handles resetting the device timeout each time a message is received. Derived classes should override this method to parse messages received from the ANT device. Be sure to call the base Parse method to reset the device timeout.
The RequestDataPage method sends a data page request to the ANT device. The derived classes typically provide a public method that calls this method with the appropriate data page number for the request.
The SendExtAcknowledgedMessage method sends commands/requests to the ANT device. The derived classes typically provide public methods that call this method with the appropriate data page number and payload for the command/request.
The DeviceOffline event is raised when the ANT device timeout is reached. The timeout options are configured in the AntDeviceCollection class.
The UnknownDataPageReceived event is raised when a data page is received that is not defined in the library. This allows applications to receive custom data pages or data pages that supported by the library.
CommonDataPages
CommonDataPages are typically added to derived AntDevice classes as a read-only property if the ANT device supports common data pages.
public CommonDataPages CommonDataPages { get; }The AntDevice constructor will create and assign the CommonDataPages class. Here's an example from the BikeRadar class -
public BikeRadar(ChannelId channelId, IAntChannel antChannel, ILogger<BikeRadar> logger, TimeoutOptions? options)
: base(channelId, antChannel, logger, options)
{
CommonDataPages = new CommonDataPages(logger);
for (int i = 0; i < 8; i++) { RadarTargets.Add(new RadarTarget()); }
}AntDeviceCollection
This is a thread-safe observable collection of ANT devices. The constructor will initialize the ANT radio for continuous scan mode and direct all messages received from the ANT radio to a private handler. This handler will select an ANT device from the collection or create a new ANT device and add it to the collection. The message is then passed to the ANT device parser for handling by the device.
TimeoutOptions
Set either Timeout in milliseconds or MissedMessages to the number of missed messages before signaling device offline. Prefer MissedMessages as this scales the timeout to the ANT device broadcast message rate. Set Timeout to -1 to disable ANT device timeouts.