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 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 the button press, making this suitable for battery operated devices. For demonstration purposes, the asynchronous controller example is intended to be used in conjunction with Scan and Forward example, but can be adapted to other control applications.
The 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.
Function of LEDs on Controller is presented in table below:
| Hardware | Function |
|---|---|
| BSP_LED_0 | Turns on when continuous scanning is active |
| BSP_LED_1 | Toggles when DEVICE_STATUS_PAGE is received on continuous scanning channel |
| BSP_LED_2 | Turns on if no Nodes were found sending a DEVICE_STATUS_PAGE after continuous scanning |
Setup
You can find the source code and project file of the example in the following folder:
<InstallFolder>\examples\ant\experimental\ant_continuous_scanning_controller
Testing
You can test the Asynchronous Controller using Continuous Scanning Mode example in different ways:
Testing the example using Scan and Forward example
- Compile and program development board (Node A) with the Asynchronous Controller using Continuous Scanning Mode application.
- Compile and program other development boards (Node B – Node X) with the Scan and Forward application.
- Separate the nodes in a configuration of your choice. Distances greater than 2 meters provides the best experience.
- On the controller device (Node A), when a button is pressed, the corresponding command is sent into the network of nodes.
- On the network nodes (Node A – Node X), the LEDs will turn on or off based on the command received from the controller.
Function of Asynchronous Controller Buttons is presented in table below:
| 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
- Compile and program development board (Node A) with the Continuous Scanning Controller application.
-
Run AntWare II. Select your ANT PC dongle (for example, ANTUSB-m) from the available devices. Configure the device channel by loading the device profile configuration from the following file:
<InstallFolder>\examples\ant\experimental\ant_continuous_scanning_controller\ant_continuous_scanning_controller_test.xml. Alternatively, you can configure the device channels manually:- Set the channel assignment to master.
- Set the channel ID to "1, 1, 21".
- Set the channel period to "2048" (16 Hz).
- Set the radio frequency to "25".
- Keep the default for all other settings.
- Set the broadcast message to 20-01-00-00-00-00-00-00 (The second byte of the broadcast message matches the device number) and click Auto-Open button.
- Pressing a button on the Controller (Node A) will send a command which can be seen in the ANTware message window as an acknowledged message.