| 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
Stride Based Speed and Distance Monitor
This information applies to the following SoftDevices: S212, S332

This module implements the Stride Based Speed and Distance Monitor ANT+ device profile. The API for this module is available here: Stride Based Speed and Distance Monitor profile

During initialization, the module configures the selected channel and resets the profile data.

This module uses the ANT page request controller to handle page data requests.

# Compile time configuration options

The module traces profile-specific information to UART using the logger.

The following configuration options are available at compile time to assist in the development phase of the SDM Receiver implementation:

- TRACE_SDM_GENERAL_ENABLE: Output page number of the current page.
- TRACE_SDM_PAGE_1_ENABLE: Output page 1 data.
- TRACE_SDM_PAGE_2_ENABLE: Output page 2 data.
- TRACE_SDM_PAGE_3_ENABLE: Output page 3 data.
- TRACE_SDM_PAGE_16_ENABLE: Output page 16 data.
- TRACE_SDM_PAGE_22_ENABLE: Output page 22 data.
- TRACE_COMMON_PAGE_80_ENABLE: Output page 80 data.
- TRACE_COMMON_PAGE_81_ENABLE: Output page 81 data.

The above macros must be defined on the project settings level.

# SDM Receiver

The following code snippets show how to initialize the SDM Receiver:

void ant_sdm_evt_handler(ant_sdm_profile_t * p_profile, ant_sdm_evt_t event);
SDM_DISP_CHANNEL_CONFIG_DEF(m_ant_sdm,
SDM_CHANNEL_NUMBER,
WILDCARD_TRANSMISSION_TYPE,
WILDCARD_DEVICE_NUMBER,
ANTPLUS_NETWORK_NUMBER,
SDM_MSG_PERIOD_4Hz);
SDM_DISP_PROFILE_CONFIG_DEF(m_ant_sdm,
ant_sdm_evt_handler);
static ant_sdm_profile_t m_ant_sdm;
uint32_t err_code;
err_code = ant_sdm_disp_init(&m_ant_sdm,
SDM_DISP_CHANNEL_CONFIG(m_ant_sdm),
SDM_DISP_PROFILE_CONFIG(m_ant_sdm));
APP_ERROR_CHECK(err_code);
err_code = ant_sdm_disp_open(&m_ant_sdm);
APP_ERROR_CHECK(err_code);
err_code = ant_state_indicator_channel_opened();
APP_ERROR_CHECK(err_code);

After opening the profile instance channel, the module keeps the profile structure updated.

Two different message periods are supported:

- SDM_MSG_PERIOD_4Hz
- SDM_MSG_PERIOD_2Hz

The sample application that uses the SDM Receiver is available here: Receiver

# SDM Transmitter

The following code snippets show how to initialize the SDM Transmitter:

void ant_sdm_evt_handler(ant_sdm_profile_t * p_profile, ant_sdm_evt_t event);
SDM_SENS_CHANNEL_CONFIG_DEF(m_ant_sdm,
SDM_CHANNEL_NUMBER,
CHAN_ID_TRANS_TYPE,
CHAN_ID_DEV_NUM,
ANTPLUS_NETWORK_NUMBER);
SDM_SENS_PROFILE_CONFIG_DEF(m_ant_sdm,
ANT_SDM_PAGE_2,
ant_sdm_evt_handler);
static ant_sdm_profile_t m_ant_sdm;
uint32_t err_code;
err_code = ant_sdm_sens_init(&m_ant_sdm,
SDM_SENS_CHANNEL_CONFIG(m_ant_sdm),
SDM_SENS_PROFILE_CONFIG(m_ant_sdm));
APP_ERROR_CHECK(err_code);
// fill manufacturer's common data page.
m_ant_sdm.page_80 = ANT_COMMON_page80(SDM_HW_REVISION,
SDM_MANUFACTURER_ID,
SDM_MODEL_NUMBER);
// fill product's common data page.
m_ant_sdm.page_81 = ANT_COMMON_page81(SDM_SW_REVISION_MAJOR,
SDM_SW_REVISION_MINOR,
SDM_SERIAL_NUMBER);
// fill capabilities.
m_ant_sdm.SDM_PROFILE_capabilities.cadency_is_valid = true;
m_ant_sdm.SDM_PROFILE_capabilities.speed_is_valid = true;
m_ant_sdm.SDM_PROFILE_capabilities.calorie_is_valid = true;
m_ant_sdm.SDM_PROFILE_capabilities.time_is_valid = true;
m_ant_sdm.SDM_PROFILE_capabilities.latency_is_valid = true;
m_ant_sdm.SDM_PROFILE_capabilities.distance_is_valid = true;
// fill status.
m_ant_sdm.SDM_PROFILE_status.state = ANT_SDM_USE_STATE_ACTIVE;
m_ant_sdm.SDM_PROFILE_status.health = ANT_SDM_HEALTH_OK;
m_ant_sdm.SDM_PROFILE_status.battery = ANT_SDM_BATTERY_STATUS_GOOD;
m_ant_sdm.SDM_PROFILE_status.location = ANT_SDM_LOCATION_ANKLE;
err_code = ant_sdm_sens_open(&m_ant_sdm);
APP_ERROR_CHECK(err_code);
err_code = ant_state_indicator_channel_opened();
APP_ERROR_CHECK(err_code);

After opening the profile instance channel, the module broadcasts the data from the profile structure. The user application should keep this structure updated.

Users can configure which supplementary data page is used (page 2 or 3). Choosing data page 1 will disable this feature.

The sample application that uses the SDM Transmitter is available here: Transmitter

Note
  The application must propagate ANT stack events to the ANT Stride Based Speed and Distance Monitor module by calling ant_sdm_tx_evt_handle() or ant_sdm_rx_evt_handle() from the ant_event_handler callback.

Warning
  The ant_event_handler is called from an interrupt. Therefore, the profile structure is changed asynchronously.