-
Notifications
You must be signed in to change notification settings - Fork 26
Developer's Guide
- Create the ant-arduino callback driver instance
- Create the antplus-arduino router instance
- Register the driver with the router
- Create the profile instance
- Register the profile with the router
- Register the profile callbacks
- Call begin on the profile
- Call loop on the router continuously
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Call begin on the profile
This pushes the channel configuration to the radio and opens the corresponding channel(s) for transmission.
- 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.