This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to send float value using Heart Rate Monitor example code and nrf51 DK

Hi, I am using Heart Rate rate monitor code to send floating value instead of unit16_t.

I am using the heart rate service to send the data. Instead of using simulated sensor function, I have explicitly declared the heart rate to be 5.29. I eventually want to send ADC value using this service which will have floating numbers. App ( Heart Rate App in nRF toolbox) still shows 5 instead of 5.29. Where else should I make a change?

static void heart_rate_meas_timeout_handler(void * p_context){
   static uint32_t cnt = 0;
   uint32_t        err_code;
   double       heart_rate;     //Changed from unit16_t

UNUSED_PARAMETER(p_context);

heart_rate = 5.29;           //instead simulated sensor data
cnt++;
err_code = ble_hrs_heart_rate_measurement_send(&m_hrs, heart_rate);
if ((err_code != NRF_SUCCESS) &&
    (err_code != NRF_ERROR_INVALID_STATE) &&
    (err_code != BLE_ERROR_NO_TX_BUFFERS) &&
    (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
    )
{
    APP_ERROR_HANDLER(err_code);
}

// Disable RR Interval recording every third heart rate measurement.
// NOTE: An application will normally not do this. It is done here just for testing generation
//       of messages without RR Interval measurements.
m_rr_interval_enabled = ((cnt % 3) != 0);

}

Related