Skip to content

Developer's Guide

Curtis Malainey edited this page Oct 9, 2017 · 2 revisions

Basic Profile Flow

  1. Create the ant-arduino callback driver instance
  2. Create the antplus-arduino router instance
  3. Register the driver with the router
  4. Create the profile instance
  5. Register the profile with the router
  6. Register the profile callbacks
  7. Call begin on the profile
  8. Call loop on the router continuously

Detailed Flow

This section goes into the details of why everything is done, and will hopefully allow you to better grasp how the framework is designed so you can use it to the fullest.

  1. Create the ant-arduino callback driver instance

This is pretty straightforward, the framework needs a way to talk to the ANT radio, and the driver provides this functionality. The reason for a callback variant is so that the user does not have to manually pass all messages created by the driver back to the router.

  1. Create the antplus-arduino router instance

The router is brains of the framework. It handles all the messages from the driver and dispatches them to other callbacks or to profiles for further handling.

  1. Register the driver with the router

This allows the router to register its callbacks with the driver and to reset the radio back to its default state. DO NOT TOUCH THE RADIO DRIVER AFTER THIS POINT.

  1. Create the profile instance

Profiles are synonymous with ANT+ profile implementations. You can instantiate any number of profiles. The profiles handle everything from broadcast patterns to message parsing.

  1. Register the profile with the router

By registering the profile with the router, the router will configure the radio to handle the profile and start handling message parsing. The configuration is not actually pushed to the radio until you call start on the profile.

  1. Register the profile callbacks

This allows the profile to call your code with the parsed messages from the device. Any messages that require acting upon (typically just a response) will be handled by the profile. Any message generation (for transmission) done by the profile can be overridden with another callback that allows the developer to populate the fields.

  1. Call begin on the profile

This pushes the channel configuration to the radio and opens the corresponding channel(s) for transmission.

  1. Call loop on the router continuously

This is will allow the framework to run callbacks and handle events. Do not call this inside in a callback. Not only could you run into a recursion problem, but it would also likely destroy the data for the message in the current callback context. See the ant-arduino callback headers for more information on the issue.