nRF5 SDK v11.0.0
Bicycle Power Monitor
This information applies to the following SoftDevices: S212, S332

This module implements the Bicycle Power ANT+ device profile. The API for this module is available here: Bicycle Power profile

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

Compile time configuration options

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

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

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

Bicycle Power Receiver (display)

This module covers the full receiver implementation (PWR):

The following code snippets show how to initialize the profile:

void ant_bpwr_evt_handler(ant_bpwr_profile_t * p_profile, ant_bpwr_evt_t event);
BPWR_CHANNEL_NUMBER,
WILDCARD_TRANSMISSION_TYPE,
WILDCARD_DEVICE_NUMBER,
ANTPLUS_NETWORK_NUMBER);
ant_bpwr_evt_handler);
ant_bpwr_profile_t m_ant_bpwr;
uint32_t err_code;
err_code = ant_bpwr_disp_init(&m_ant_bpwr,
BPWR_DISP_CHANNEL_CONFIG(m_ant_bpwr),
BPWR_DISP_PROFILE_CONFIG(m_ant_bpwr));
APP_ERROR_CHECK(err_code);
err_code = ant_bpwr_disp_open(&m_ant_bpwr);
APP_ERROR_CHECK(err_code);
APP_ERROR_CHECK(err_code);

The following snippet shows how to propagate ANT events to the profile's event handler:

void ant_evt_dispatch(ant_evt_t * p_ant_evt)
{
ant_bpwr_disp_evt_handler(&m_ant_bpwr, p_ant_evt);
}

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

The sample application that uses the Bicycle Power Profile to implement a display is available here: Receiver

Bicycle Power Transmitter (sensor)

This module implements the power and torque sensor features:

You can configure which type of sensor is implemented: power-only sensor, torque sensor at wheel, or torque sensor at crank.

The following code snippets show how to initialize the profile:

void ant_bpwr_evt_handler(ant_bpwr_profile_t * p_profile, ant_bpwr_evt_t event);
void ant_bpwr_calib_handler(ant_bpwr_profile_t * p_profile, ant_bpwr_page1_data_t * p_page1);
BPWR_CHANNEL_NUMBER,
BPWR_TRANSMISSION_TYPE,
BPWR_DEVICE_NUMBER,
ANTPLUS_NETWORK_NUMBER);
(ant_bpwr_torque_t)(SENSOR_TYPE),
ant_bpwr_calib_handler,
ant_bpwr_evt_handler);
ant_bpwr_profile_t m_ant_bpwr;
uint32_t err_code;
err_code = ant_bpwr_sens_init(&m_ant_bpwr,
BPWR_SENS_CHANNEL_CONFIG(m_ant_bpwr),
BPWR_SENS_PROFILE_CONFIG(m_ant_bpwr));
APP_ERROR_CHECK(err_code);
// fill manufacturer's common data page.
m_ant_bpwr.page_80 = ANT_COMMON_page80(HW_REVISION,
MANUFACTURER_ID,
MODEL_NUMBER);
// fill product's common data page.
m_ant_bpwr.page_81 = ANT_COMMON_page81(SW_REVISION_MAJOR,
SW_REVISION_MINOR,
SERIAL_NUMBER);
m_ant_bpwr.BPWR_PROFILE_auto_zero_status = ANT_BPWR_AUTO_ZERO_OFF;
err_code = ant_bpwr_sens_open(&m_ant_bpwr);
APP_ERROR_CHECK(err_code);
APP_ERROR_CHECK(err_code);

The following snippet shows how to propagate ANT events to the profile's event handler:

void ant_evt_dispatch(ant_evt_t * p_ant_evt)
{
ant_bpwr_sens_evt_handler(&m_ant_bpwr, p_ant_evt);
}

The following snippet shows how to handle calibration request:

void ant_bpwr_calib_handler(ant_bpwr_profile_t * p_profile, ant_bpwr_page1_data_t * p_page1)
{
switch (p_page1->calibration_id)
{
m_ant_bpwr.BPWR_PROFILE_calibration_id = ANT_BPWR_CALIB_ID_MANUAL_SUCCESS;
m_ant_bpwr.BPWR_PROFILE_general_calib_data = CALIBRATION_DATA;
break;
m_ant_bpwr.BPWR_PROFILE_calibration_id = ANT_BPWR_CALIB_ID_MANUAL_SUCCESS;
m_ant_bpwr.BPWR_PROFILE_auto_zero_status = p_page1->auto_zero_status;
m_ant_bpwr.BPWR_PROFILE_general_calib_data = CALIBRATION_DATA;
break;
m_ant_bpwr.BPWR_PROFILE_calibration_id = ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS;
memcpy(m_ant_bpwr.BPWR_PROFILE_custom_calib_data, p_page1->data.custom_calib,
sizeof (m_ant_bpwr.BPWR_PROFILE_custom_calib_data));
break;
m_ant_bpwr.BPWR_PROFILE_calibration_id = ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS;
memcpy(m_ant_bpwr.BPWR_PROFILE_custom_calib_data, p_page1->data.custom_calib,
sizeof (m_ant_bpwr.BPWR_PROFILE_custom_calib_data));
break;
default:
break;
}
}

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

The sample application that uses the Bicycle Power Profile to implement a sensor is available here: Sensor

Note
The application must propagate ANT stack events to the ANT Bicycle Power module by calling ant_bpwr_sensor_evt_handle() or ant_bpwr_display_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.

Documentation feedback | Developer Zone | Updated