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.
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.
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 |
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.
You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ant\ant_async_transmitter
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 SoftDevice ANT event handler configuration.
<InstallFolder>\examples\ant\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