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

sending a char using ble_nus_data_send

Hi ,
I want to send a char data through bleutouth using ble nus 
I am using this method 

void sendble(char data)
{
uint8_t x = atoi(data);
uint16_t length1 ;
length1=strlen(data);
 ret_code_t ret1 = ble_nus_data_send(&m_nus,
                x,
                &length1,
                m_conn_handle);
  if (ret1 == NRF_SUCCESS) {
    NRF_LOG_RAW_INFO(" send ble success  %s",x);
  }
}

I don't have any error but I don't receive any information on my android application (NRF Toolbox).

Is there somthing wrong or I must use another command to send char value  using ble_nus send?

Parents
  • Hello,

    I don't have any error

    You are only ever checking if your call to ble_nus_data_send is returning successfully - you will not be informed in the case that the call fails. Please pass the returned error code to an APP_ERROR_CHECK, and make sure to have DEBUG defined in your preprocessor defines, like shown in the included image:

    This will make the logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.

    Furthermore, the second argument of the ble_nus_data_send call should be a uint8_t pointer, not a uint8_t value, please change rectify this.

    Best regards,
    Karl

Reply
  • Hello,

    I don't have any error

    You are only ever checking if your call to ble_nus_data_send is returning successfully - you will not be informed in the case that the call fails. Please pass the returned error code to an APP_ERROR_CHECK, and make sure to have DEBUG defined in your preprocessor defines, like shown in the included image:

    This will make the logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.

    Furthermore, the second argument of the ble_nus_data_send call should be a uint8_t pointer, not a uint8_t value, please change rectify this.

    Best regards,
    Karl

Children
Related