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

How do I send float data via nus_data_send() function

Hi, 

I know that the NUS service ble_data_send() can send string and integer data via BLE to an app, but can it be used to transmit 24 bit float data
If not, what other way would you suggest that I display my data up to 4 decimal places in the NRF Toolbox logging app? 

This is what I'm doing right now: 

m_rx_buf [3] ;  

// m_rx_buf received 3 BYTE HEX data via SPI communication from an ADC
// m_rx_buf shows data in format "0A207E" , follows ADC output data format 
// The fullscale value of ADC is 7FFFFF. Following is processing of ADC digital data to analog value
 float sensordata = 0; 
    uint24_t fullscale = 0x7FFFFF; 
      sensordata = float((m_rx_buf/fullscale)*gain);
      
      
      // How do I change ble_nus_data_send() so that I can replace m_rx_buf with float type sensordata?
      
      
      if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
      {

          err_code = ble_nus_data_send(&m_nus, m_rx_buf, &ble_buff_len, m_conn_handle);
          if ((err_code != NRF_ERROR_INVALID_STATE) &&
              (err_code != NRF_ERROR_RESOURCES) &&
              (err_code != NRF_ERROR_NOT_FOUND))
          {
              APP_ERROR_CHECK(err_code);
          }

Thank you. 


Related