how to send data over ble using NUS service

Hi nordic family,

I want to send this data to nrf Connect app.

void send_data_via_nus(float X, float Y, ble_nus_t nus_service)
{
uint8_t data[8];
memcpy(data, &X, sizeof(X));
memcpy(data + sizeof(X), &Y, sizeof(Y));

uint16_t length = sizeof(X) + sizeof(Y);
ret_code_t err_code;
err_code = ble_nus_data_send(&m_nus, data, &length, m_conn_handle);
if ((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_NOT_FOUND))
{
APP_ERROR_CHECK(err_code);
}

}
 

 I am using ble_uart_example but I can't figure how to move forward in these specific parts nus_data_handler and in uart_event_handle, with this data 

Nrf SDK 16.00, S132, nrf52832

Parents
  • int iii = 35;
    float fff = 0.123456789;
    
    uint8_t nus_string[50];
    bytes_to_send = sprintf(nus_string, "int = %d, float = %f\r\n",iii,fff);
    
    err_code = ble_nus_data_send(&m_nus, nus_string, &bytes_to_send, m_conn_handle);
    
    if ((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_NOT_FOUND))
    {
        APP_ERROR_CHECK(err_code);
    }

    This is what I found, if anyone is struggling with same problem can take a look

Reply
  • int iii = 35;
    float fff = 0.123456789;
    
    uint8_t nus_string[50];
    bytes_to_send = sprintf(nus_string, "int = %d, float = %f\r\n",iii,fff);
    
    err_code = ble_nus_data_send(&m_nus, nus_string, &bytes_to_send, m_conn_handle);
    
    if ((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_NOT_FOUND))
    {
        APP_ERROR_CHECK(err_code);
    }

    This is what I found, if anyone is struggling with same problem can take a look

Children
No Data
Related