| 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 BPWR simulator
This information applies to the following SoftDevices: S212, S332

This module simulates data for the BPWR Sensor. The API for this module is available here: ANT BPWR simulator

The module uses the Sensor Data Simulator to simulate automatic changes of the cadence value.

# Initialization

Use the following command to initialize the module:

const ant_bpwr_simulator_cfg_t simulator_cfg =
{
.p_profile = &m_ant_bpwr,
.sensor_type = (ant_bpwr_torque_t)(SENSOR_TYPE),
};

If you want the cadence to be changed automatically, add the following statement:

ant_bpwr_simulator_init(&m_ant_bpwr_simulator, &simulator_cfg, true);

If you want to be able to change the cadence manually, add the following statement:

ant_bpwr_simulator_init(&m_ant_bpwr_simulator, &simulator_cfg, false);

# Including the module in an application

Periodically call the BPWR simulator in the application to prepare data for each TX event occurrence. The following snippet shows how to do this:

void ant_bpwr_evt_handler(ant_bpwr_profile_t * p_profile, ant_bpwr_evt_t event)
{
switch (event)
{
case ANT_BPWR_PAGE_1_UPDATED:
/* fall through */
case ANT_BPWR_PAGE_16_UPDATED:
/* fall through */
case ANT_BPWR_PAGE_17_UPDATED:
/* fall through */
case ANT_BPWR_PAGE_18_UPDATED:
/* fall through */
case ANT_BPWR_PAGE_80_UPDATED:
/* fall through */
case ANT_BPWR_PAGE_81_UPDATED:
ant_bpwr_simulator_one_iteration(&m_ant_bpwr_simulator, event);
break;
default:
break;
}
}

The following snippet shows how to change the cadence manually:

void bsp_evt_handler(bsp_event_t event)
{
switch (event)
{
case BSP_EVENT_KEY_0:
ant_bpwr_simulator_increment(&m_ant_bpwr_simulator);
break;
case BSP_EVENT_KEY_1:
ant_bpwr_simulator_decrement(&m_ant_bpwr_simulator);
break;
case BSP_EVENT_KEY_2:
ant_bpwr_calib_response(&m_ant_bpwr);
break;
default:
break;
}
}