| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ANT Asynchronous Transmitter
This example requires the following SoftDevice: S212

Important: Before you run this example, make sure to program the SoftDevice.

The purpose of this example is to demonstrate how to configure a channel as an asynchronous transmitter to implement a remote control application that transmits data immediately after a button is pressed. Fast channel initiation is used together with the asynchronous transmission to ensure that data is transmitted as quickly as possible. Since transmissions are only performed as a response to user-initiated events, the remote control is able to sleep for extended periods of time, reducing its power consumption.

# Description

This example sends the control command as an acknowledged message, retrying up to a maximum number of times to ensure that it has reached its destination. The use of fast channel initiation and sporadic transmissions increases the risk of overlapping transmissions between multiple remotes. To address this, this example implements an application-level random backoff scheme to limit over-the-air collisions between multiple asynchronous transmitters.

An asynchronous transmitter must be paired with a node in continuous scanning mode in the receiving end. In this example, the asynchronous transmitter is paired with an ANT USB stick and the ANTware II PC application that is configured in continuous scanning mode.

Asynchronous Transmitter paired with an ANT USB stick

After startup, the asynchronous transmitter node configures an ANT master channel using the extended assignment to set it up as an asynchronous transmitter with fast channel initiation. The channel is configured with the following parameters:

Parameter | Value
--- | ---
Channel type | Master (0x10)
Extended assignment | EXT_PARAM_ASYNC_TX_MODE | EXT_PARAM_FAST_INITIATION_MODE
Network key | Public
RF channel | 66 (2466 MHz)
Device number | Serial number
Device type | 2
Transmission type | 1

# Message format

The channel is never opened. Instead, on a button press, the node sends a single acknowledged message over the channel that is configured in asynchronous mode. The message is transmitted immediately. If the acknowledgement fails, the node will retry after a randomly generated time, using a timer to trigger the next transmission. A sequence number is used to differentiate between transmitted messages.

The format of messages used in this example is presented below:

Byte | Description
--- | ---
0 | Command Page (0x01)
1-5 | Reserved (0xFF)
6 | Sequence number
7 | Command ID: 0x10 = Command 0 0x11 = Command 1

Command 0 is transmitted when BSP_BUTTON_0 is pressed. Command 1 is transmitted when BSP_BUTTON_1 is pressed.

# Setup

You can find the source code and the project file of the example in the following folder: `<InstallFolder>\examples\ant\ant_async_transmitter`

# Testing

Note: You can use a custom channel or encryption when running any of the ANT examples. When adding a new channel or encryption, remember to update ANT stack configuration.

1. Compile and program the Asynchronous Transmitter application.
2. Run ANTware II. From the available devices, select your ANT PC dongle (for example, ANTUSB-m). Configure the device channels by loading the device profile configuration from the following file: `<InstallFolder>\examples\ant\ant_async_transmitter\ant_async_transmitter_test.xml`. Alternatively, you can configure the device channels manually:
   1. Set the channel assignment to slave.
   2. Set the channel ID to 0, 2, 1.
   3. Keep the default values for all other settings.
3. Select the Advanced tab in ANTware II. Click Open in Scan Mode.
4. Press BSP_BUTTON_0 and then BSP_BUTTON_1. Observe the received payload in ANTware II:

       Received ACKNOWLEDGED_DATA_0x4F
         :: 4f, 00-01-FF-FF-FF-FF-FF-00-10
       Received ACKNOWLEDGED_DATA_0x4F
         :: 4f, 00-01-FF-FF-FF-FF-FF-01-11