I am writing a program by moving the contents of twi_master_using_nrf_twi_mngr based on the ble_app_uart project.
The source code is as follows.
void read_all_cb(ret_code_t result, void * p_user_data)
{
if (result != NRF_SUCCESS)
{
NRF_LOG_WARNING("read_all_cb - error: %d", (int)result);
return;
}
uint8_t update = m_buffer[0];
uint8_t temp_L = m_buffer[1];
uint8_t tepm_H = m_buffer[2];
uint8_t gyroscope_X_L = m_buffer[3];
uint8_t gyroscope_X_H = m_buffer[4];
uint8_t gyroscope_Y_L = m_buffer[5];
uint8_t gyroscope_Y_H = m_buffer[6];
uint8_t gyroscope_Z_L = m_buffer[7];
uint8_t gyroscope_Z_H = m_buffer[8];
uint8_t accelerometer_X_L = m_buffer[9];
uint8_t accelerometer_X_H = m_buffer[10];
uint8_t accelerometer_Y_L = m_buffer[11];
uint8_t accelerometer_Y_H = m_buffer[12];
uint8_t accelerometer_Z_L = m_buffer[13];
uint8_t accelerometer_Z_H = m_buffer[14];
if (!LSM6DSO_DATA_IS_VALID(update))
{
update = m_prev_update;
}
// Show current average values every time sample index rolls over (for RTC
// ticking at 32 Hz and 16 samples it will be every 500 ms) or when tilt
// status changes.
if (m_sample_idx == 0 || (m_prev_update && m_prev_update != update))
{
//NRF_LOG_RAW_INFO("Temp: " NRF_LOG_FLOAT_MARKER " | X: %3d, %3d, Y: %3d, %3d, Z: %3d, %3d,",
//NRF_LOG_FLOAT((float)((m_sum.temp * 0.125) / NUMBER_OF_SAMPLES)),
printf( "STATUS_REG : %1d ", update);
printf( "TEMP : %1d %1d \r\n", tepm_H, temp_L);
printf( "gyroscope X: %3d, %3d, Y: %3d, %3d, Z: %3d, %3d, \r\n",
// m_buffer[0],
gyroscope_X_H, gyroscope_X_L, gyroscope_Y_H, gyroscope_Y_L, gyroscope_Z_H, gyroscope_Z_L);
printf( "accelerometer X: %3d, %3d, Y: %3d, %3d, Z: %3d, %3d, \r\n",
// m_buffer[0],
accelerometer_X_H, accelerometer_X_L, accelerometer_Y_H, accelerometer_Y_L, accelerometer_Z_H, accelerometer_Z_L);
static uint8_t data_array[BLE_NUS_MAX_DATA_LEN]= "Send Message\n";
uint32_t err_code;
static uint8_t index = 0;
uint16_t length = (uint16_t)index;
err_code = ble_nus_data_send(&m_nus, data_array, &length, 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);
}
m_prev_update = update;
}
}
Please tell me how to use ble_nus_data_send in PRINTF format.