Important: Before you run this example, make sure to program the SoftDevice.
The ANT Background Scanning Example shows how to implement a background scanning channel in combination with a master channel on a single device. It also demonstrates how to use extended messages to obtain Received Signal Strength Indication (RSSI) and channel ID information from received packets.
Background scanning channels in ANT are searching channels that never synchronize with a master. Instead of acquiring a master, ANT will pass the data to the master and continue searching. These channels allow for asynchronous topologies with other channels running independently on the same device. For more information about background scanning channels and channel parameters, see the ANT Message Protocol and Usage documentation and the ANT Channel Search application note.
This example uses two channels: one background scanning channel that can receive data from multiple devices and one master channel. The master channel in this example copies the received RSSI and channel ID information and mirrors these parameters back to the transmitting devices.
After startup or reset, each ANT node opens one background scanning channel and one master channel. The background scanning channel is configured similar to a regular slave channel, but with a special flag set to denote its function. The search time-out is set to infinity to ensure that the background scanning channel continues searching for other channels. When a packet is received, the node will indicate the BSP_INDICATE_RCV_OK state and print information about the sender (signal strength and channel ID).
The following table lists the ANT channel parameters for the master channel and the background scanning channel (numbers in parentheses denote the parameters that should be used to set the values):
Parameter | Master channel | Background scanning channel |
---|---|---|
Channel type | Master (0x10) | Slave(0x00) |
Extended assignment | N/A | EXT_PARAM_ALWAYS_SEARCH (0x01) |
Network key | Public | Public |
RF channel | 77 (2477 MHz) | 77 (2477 MHz) |
Channel period | 2048 (16 Hz) | N/A |
Device number | Serial number | Wildcard (0) |
Device type | 1 | 1 |
Transmission type | 5 | 5 |
Search time-out (high priority) | N/A | No HP search (0) |
Search time-out (low priority) | N/A | Infinite (255) |
The master channel on each device sends a single payload of data. This payload indicates the signal strength and the channel ID of the last message that was received on the background scanning channel.
The following table shows the message format of the default master message:
Byte | Description |
---|---|
0 | Page number = 1 (ANT_BEACON_PAGE) |
1 | RSSI value (signed dBm value, corresponding to the device number) |
2-3 | Device number of the last message that was received on the background scanning channel (little endian, corresponding to the RSSI value) |
4-5 | Reserved |
6 | Counter that increases with each channel period |
7 | Number of messages that were received on the background scanning channel |
You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ant\ant_background_scanning
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.
You can test the Background Scanning example in different ways:
Note that UART is not available when you use the D52 Starter Kit from Garmin Canada.
<InstallFolder>\examples\ant\ant_background_scanning\background_scanning_test.xml
. Alternatively, you can configure the device channels manually:Payload | Description |
---|---|
Received BROADCAST_DATA_0x4E :: 4e, 00-01-B6-32-00-00-00-8D-74 | Device number = 50 |
Received BROADCAST_DATA_0x4E :: 4e, 00-01-B6-32-00-00-00-8E-74 | RSSI = -74 dBm (further away) |
Received BROADCAST_DATA_0x4E :: 4e, 00-01-CB-32-00-00-00-8A-0C | RSSI = -53 dBm (closer) |