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 push. 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.
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 back-off scheme to limit over-the-air collisions between multiple asynchronous transmitters.
An asynchronous transmitter needs to 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 PC application configured in continuous scanning mode.
After start up, the asynchronous transmitter node will configure 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 {0, 0, 0, 0, 0, 0, 0, 0} |
RF channel | 66 (2466 MHz) |
Device number | Serial number |
Device type | 2 |
Transmission type | 1 |
The channel is never opened. Instead, on a button press, the node will send a single acknowledged message over the channel configured in asynchronous mode; the message will be 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 by this example is detailed 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, while Command 1 is transmitted when BSP_BUTTON_1 is pressed.
You can find the source code and project file of the example in the following folder: <InstallFolder>\examples\ant\experimental\ant_async_transmitter
<InstallFolder>\examples\ant\experimental\ant_async_transmitter\ant_async_transmitter_test.xml
. Alternatively, you can configure the device channels manually: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