Example #1
0
/**@brief Function for decoding HRM message.
 *
 * @note Assume to be call each time when Rx window will occur.
 */
static void disp_message_decode(ant_hrm_profile_t * p_profile, uint8_t * p_message_payload)
{
    const ant_hrm_message_layout_t * p_hrm_message_payload =
        (ant_hrm_message_layout_t *)p_message_payload;

    LOG_HRM("HRM RX Page Number:               %u\n\r", p_hrm_message_payload->page_number);

    ant_hrm_page_0_decode(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_decode(p_hrm_message_payload->page_payload, &(p_profile->page_1));
            break;

        case ANT_HRM_PAGE_2:
            ant_hrm_page_2_decode(p_hrm_message_payload->page_payload, &(p_profile->page_2));
            break;

        case ANT_HRM_PAGE_3:
            ant_hrm_page_3_decode(p_hrm_message_payload->page_payload, &(p_profile->page_3));
            break;

        case ANT_HRM_PAGE_4:
            ant_hrm_page_4_decode(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);
}
Example #2
0
/**@brief Function for encoding HRM message.
 *
 * @note Assume to be call each time when Rx window will occur.
 */
static void decode_hrm_rx_message(ant_hrm_profile_t * p_profile, uint8_t * p_message_payload)
{
    const ant_hrm_message_layout_t * p_hrm_message_payload  = (ant_hrm_message_layout_t *)p_message_payload;

    LOG_ANT("HRM RX Page Number:               %u\r\n", p_hrm_message_payload->page_number);

    ant_hrm_page_0_decode(p_hrm_message_payload->page_payload, &(p_profile->page_0)); // Page 0 is present in each message

    printf("@HRM=%u\n\r", (unsigned int)p_profile->page_0.computed_heart_rate);

    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_decode(p_hrm_message_payload->page_payload, &(p_profile->page_1));
        break;

    case ANT_HRM_PAGE_2:
        ant_hrm_page_2_decode(p_hrm_message_payload->page_payload, &(p_profile->page_2));
        break;

    case ANT_HRM_PAGE_3:
        ant_hrm_page_3_decode(p_hrm_message_payload->page_payload, &(p_profile->page_3));
        break;

    case ANT_HRM_PAGE_4:
        ant_hrm_page_4_decode(p_hrm_message_payload->page_payload, &(p_profile->page_4));
        break;

    default:
        break;
    }
    LOG_ANT("\r\n");
}