| 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 Continuous Scanning Controller
This example requires the following SoftDevice: S212

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

The Continuous Scanning Controller example demonstrates how to use continuous scanning to asynchronously send a message to the nearest device. In the image below, the controller (Node A) is in range to receive messages from nodes C, D, and E. When the user presses a button on the controller, it uses continuous scanning mode to identify the node with the strongest RSSI and then it sends back a command message to that node in the reverse direction. The continuous scanning mode is only active for a short period of time after pressing the button, making this suitable for battery-operated devices. For demonstration purposes, the asynchronous controller example is intended to be used in conjunction with ANT Scan and Forward example, but can be adapted to other control applications.

This example can be used with two or more development boards or one development board and one ANT USB stick attached to a PC running ANTware II.

ANT Continuous Scanning Controller example topology

Refer to the following table for functioning pattern of the LEDs on the controller:

LED | Function
--- | ---
BSP_LED_0 | Turns on when continuous scanning is active.
BSP_LED_1 | Toggles when DEVICE_STATUS_PAGE is received on a channel in continuous scanning mode.
BSP_LED_2 | Turns on if no nodes were found that are sending a DEVICE_STATUS_PAGE after continuous scanning.

# Setup

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

# 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.

You can test the Continuous Scanning Controller example in different ways:

- Testing the example using the Scan and Forward example
- Testing the example using ANTware II

## Testing the example using the Scan and Forward example

1. Compile and program a development board (Node A) with the Continuous Scanning Controller application.
2. Compile and program other development boards (Node B – Node X) with the ANT Scan and Forward application.
3. Separate the nodes in a configuration of your choice. Distances greater than two meters provide the best experience.
4. On the controller device (Node A), when a button is pressed, the corresponding command is sent into the network of nodes.
5. On the network nodes (Node A – Node X), the LEDs will turn on or off based on the command received from the controller.

Refer to the following table for functioning pattern of the asynchronous controller buttons:

Button | Command
--- | ---
BSP_BUTTON_0 | Closest node – LED on.
BSP_BUTTON_1 | Closest node – LED off.
BSP_BUTTON_2 | All nodes – LED on.
BSP_BUTTON_3 | All nodes – LED off.

## Testing the example using ANTware II

1. Compile and program a development board (Node A) with the Continuous Scanning Controller application.
2. Run ANTware II. From the available devices, select your ANT PC dongle (for example, ANTUSB-m). Configure the device channel by loading the device profile configuration from the following file: `<InstallFolder>\examples\ant\ant_continuous_scanning_controller\ant_continuous_scanning_controller_test.xml`. Alternatively, you can configure the device channels manually:
   1. Set the channel assignment to master.
   2. Set the channel ID to 1, 1, 21.
   3. Set the channel period to 2048 (16 Hz).
   4. Set the radio frequency to 25.
   5. Keep the default values for all other settings.
3. Set the broadcast message to 20-01-00-00-00-00-00-00, where the second byte of the broadcast message matches the device number. Click Auto-Open.
4. Pressing a button on the controller (Node A) will send a command that can be seen as an acknowledged message in the ANTware message window.