/**@brief Function for encoding HRM message. * * @note Assume to be call each time when Tx window will occur. */ static void sens_message_encode(ant_hrm_profile_t * p_profile, uint8_t * p_message_payload) { ant_hrm_message_layout_t * p_hrm_message_payload = (ant_hrm_message_layout_t *)p_message_payload; ant_hrm_sens_cb_t * p_hrm_cb = p_profile->_cb.p_sens_cb; p_hrm_message_payload->page_number = next_page_number_get(p_profile); p_hrm_message_payload->toggle_bit = p_hrm_cb->toggle_bit; LOG_HRM("HRM TX Page number: %u\n\r", p_hrm_message_payload->page_number); ant_hrm_page_0_encode(p_hrm_message_payload->page_payload, &(p_profile->page_0)); // Page 0 is present in each message switch (p_hrm_message_payload->page_number) { case ANT_HRM_PAGE_0: // No implementation needed break; case ANT_HRM_PAGE_1: ant_hrm_page_1_encode(p_hrm_message_payload->page_payload, &(p_profile->page_1)); break; case ANT_HRM_PAGE_2: ant_hrm_page_2_encode(p_hrm_message_payload->page_payload, &(p_profile->page_2)); break; case ANT_HRM_PAGE_3: ant_hrm_page_3_encode(p_hrm_message_payload->page_payload, &(p_profile->page_3)); break; case ANT_HRM_PAGE_4: ant_hrm_page_4_encode(p_hrm_message_payload->page_payload, &(p_profile->page_4)); break; default: LOG_HRM("\r\n"); return; } LOG_HRM("\r\n"); p_profile->evt_handler(p_profile, (ant_hrm_evt_t)p_hrm_message_payload->page_number); }
/**@brief Function for encoding HRM message. * * @note Assume to be call each time when Tx window will occur. */ static void encode_tx_message(ant_hrm_profile_t * p_profile, uint8_t * p_message_payload) { ant_hrm_message_layout_t * p_hrm_message_payload = (ant_hrm_message_layout_t *)p_message_payload; ant_hrm_tx_cb_t * p_hrm_cb = (ant_hrm_tx_cb_t *)p_profile->p_cb; ASSERT(p_hrm_cb != NULL); if (p_hrm_cb->message_counter == (BACKGROUND_DATA_INTERVAL)) { p_hrm_message_payload->page_number = p_hrm_cb->ext_page_number; p_hrm_cb->message_counter = 0; p_hrm_cb->ext_page_number++; if (p_hrm_cb->ext_page_number > ANT_HRM_PAGE_3) { p_hrm_cb->ext_page_number = p_hrm_cb->page_1_present ? ANT_HRM_PAGE_1 : ANT_HRM_PAGE_2; } } else { p_hrm_message_payload->page_number = p_hrm_cb->main_page_number; } if (p_hrm_cb->message_counter % TX_TOGGLE_DIVISOR == 0) { p_hrm_cb->toggle_bit ^= 1; } p_hrm_cb->message_counter++; p_hrm_message_payload->toggle_bit = p_hrm_cb->toggle_bit; LOG_ANT("HRM TX Page number: %u\r\n", p_hrm_message_payload->page_number); ant_hrm_page_0_encode(p_hrm_message_payload->page_payload, &(p_profile->page_0)); // Page 0 is present in each message switch (p_hrm_message_payload->page_number) { case ANT_HRM_PAGE_0: // No implementation needed break; case ANT_HRM_PAGE_1: ant_hrm_page_1_encode(p_hrm_message_payload->page_payload, &(p_profile->page_1)); break; case ANT_HRM_PAGE_2: ant_hrm_page_2_encode(p_hrm_message_payload->page_payload, &(p_profile->page_2)); break; case ANT_HRM_PAGE_3: ant_hrm_page_3_encode(p_hrm_message_payload->page_payload, &(p_profile->page_3)); break; case ANT_HRM_PAGE_4: ant_hrm_page_4_encode(p_hrm_message_payload->page_payload, &(p_profile->page_4)); break; default: APP_ERROR_HANDLER(NRF_ERROR_NOT_FOUND); break; } LOG_ANT("\r\n"); }