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 Reply Children
  • this is what the function return :

    uint32_t ble_nus_data_send(ble_nus_t * p_nus,
                               uint8_t   * p_data,
                               uint16_t  * p_length,
                               uint16_t    conn_handle)
    {
        ret_code_t                 err_code;
        ble_gatts_hvx_params_t     hvx_params;
        ble_nus_client_context_t * p_client;
    
        VERIFY_PARAM_NOT_NULL(p_nus);
    
        err_code = blcm_link_ctx_get(p_nus->p_link_ctx_storage, conn_handle, (void *) &p_client);
        VERIFY_SUCCESS(err_code);
    
        if ((conn_handle == BLE_CONN_HANDLE_INVALID) || (p_client == NULL))
        {
            return NRF_ERROR_NOT_FOUND;
        }
    
        if (!p_client->is_notification_enabled)
        {
            return NRF_ERROR_INVALID_STATE;
        }
    
        if (*p_length > BLE_NUS_MAX_DATA_LEN)
        {
            return NRF_ERROR_INVALID_PARAM;
        }
    
        memset(&hvx_params, 0, sizeof(hvx_params));
    
        hvx_params.handle = p_nus->tx_handles.value_handle;
        hvx_params.p_data = p_data;
        hvx_params.p_len  = p_length;
        hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
    
        return sd_ble_gatts_hvx(conn_handle, &hvx_params);
    }
    

  • nikola said:
    this is what the function return :

    This is the source code of the function, yes.
    At the bottom, it returns the NRF_ERROR_NOT_FOUND error code, returned from the call to sd_ble_gatts_hvx. Please check this function's API Reference to see why it returned this error code.

    Best regards,
    Karl

Related