The Stride and Distance Monitor minimal example TX (Master).
More...
The Stride and Distance Monitor (SDM) master implements all of the features, which are required for the transmitter to be compliant with the ANT+ SDM profile, as defined by the ANT+ SDM specification:
- Must transmit the minimum dataset:
- Transmit byte 6 of page 1 (stride count).
- Transmit common page 80 and 81.
- Common page will be transmitted every 65th message.
- All pages will be transmitted two times in sequence in order to support 2.xx Hz ANT products.
- Silently discard page request 70.
- Update stride data every 1 second.
The process flow of the SDM TX example is illustrated below:
SDM TX flowchart
- Logging
For logging UART will be the primary display. Data will be printed after broadcast data is set. Depending on the page transmitted, the following data will be logged:
- Current stride count.
- Device status byte.
- Manufacturer identification.
- Product information.
The logging with UART will be enabled by default in the project file. This can be deactivated by removing TRACE_UART from the compiler flags.
As UART will use some extra current, a low power alternative is also available, using GPIO. By default the GPIO pins are connected to LEDs when using the PCA10003 ev-kit board or with nRF6310 with setup A. Also GPIO logging is enabled by default by the project file. This can be deactivated by removing TRACE_GPIO from the compiler flags. The GPIO pins to be used can be changed by editing the GPIO defines.
When GPIO logging is enabled the following GPIO will toggle:
- SDM_GPIO_0 will toggle for every data page sent.
- SDM_GPIO_1 will toggle for every common page sent.
- Note
- The ANT+ Network Key is available for ANT+ Adopters. Please refer to http://thisisant.com to become an ANT+ Adopter and access the key.
#define CHANNEL_0_TX_CHANNEL_PERIOD 8134u |
#define CHANNEL_0_ANT_EXT_ASSIGN 0x00 |
#define CHANNEL_0_FREQUENCY 57u |
#define NETWORK_0_KEY {0, 0, 0, 0, 0, 0, 0, 0} |
#define CHANNEL_0_CHAN_ID_DEV_TYPE 0x7Cu |
#define CHANNEL_0_CHAN_ID_DEV_NUM 0xAAAAu |
#define CHANNEL_0_CHAN_ID_TRANS_TYPE 0x05u |
#define ANT_EVENT_MSG_BUFFER_MIN_SIZE 32u |
Minimum size of ANT event message buffer.
#define BROADCAST_DATA_BUFFER_SIZE 8u |
Size of the broadcast data buffer.
void softdevice_assert_callback |
( |
uint32_t |
pc, |
|
|
uint16_t |
line_num, |
|
|
const uint8_t * |
p_file_name |
|
) |
| |
- Parameters
-
[in] | pc | The value of the program counter. |
[in] | line_num | Line number where the error occurred. |
[in] | p_file_name | Pointer to the file name. |
void app_error_handler |
( |
uint32_t |
error_code, |
|
|
uint32_t |
line_num, |
|
|
const uint8_t * |
p_file_name |
|
) |
| |
Function for error handling, which is called when an error has occurred.
- Parameters
-
[in] | error_code | Error code supplied to the handler. |
[in] | line_num | Line number where the handler is called. |
[in] | p_file_name | Pointer to the file name. |
static void ant_channel_sdm_tx_setup |
( |
void |
| ) |
|
|
static |
Issues the following commands:
- set network key
- assign channel
- set channel ID
- set channel frequency
- set channel period
- open channel
void sdm_main_loop |
( |
void |
| ) |
|
The main loop will try to sleep as much as possible. Every time a protocol event occours, the application will be woken up, polling the ANT stack event queue. When finished processing all events, the application will go back to sleep.
void sdm_data_timer_callback |
( |
void |
| ) |
|
This function will call sdm module to update its stride and distance data according to what features SDM TX module has implemented.
for application main entry, does not return.
The main function will do all necessary initalization. This includes sdm tx module, timer and softdevice.
Primary data transmit buffer.
ANT network key for SDM example.