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

Data displaying incomplete in termite from nrf52840 and nrftoolbox uart using ble_uart example

  int i;
                            char buf[42];

                        for (i = 0; i < 20; i++) {
                      snprintf(buf,42, "A%dBBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX", i);         
                       // puts string into buffer
                       printf("%s\n", buf); 
                       // outputs so you can see it

                          
                           uint16_t length2 = sizeof(buf);

                           err_code = ble_nus_data_send(&m_nus,buf, &length2, m_conn_handle);


                       }

A%dBBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX = 40bytes

1) In Termite:

Data is complete and in sequence when until 6 only. 

A0BBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX
A1BBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX
A2BBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX
A3BBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX
A4BBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX
A5BBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX
A6BBCCDDEEA

Data only displaying until A6BBCCDDEEA even though I tried to loop until 20. Why ??

2) In uart apps Android, I managed to receive the data incomplete like above but until 6 only. When it is above 6, the sequence is not in order and some data not received . Last data received in apps is A19BBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX . How can I get the data loop for 19 if termite is not displaying it ?

Parents
  • Hi!

    Which SDK version are you using? And where in the ble_app_uart example are you adding your code?

    I will try to recreate your error at my office to see what the problem is. 

    Best regards,

    Heidi

  • Hi Heidi,

    I am using SDK_16.0.0_98a08e2. In the ble_uar_app i put the code in the uart_event_handle. This is the example code of the function

       
    
    void uart_event_handle(app_uart_evt_t * p_event)
    {
        static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
        static uint8_t index = 0;
        uint32_t       err_code;
       uint16_t length = (uint16_t)index;
    
    
        switch (p_event->evt_type)
        {
            case APP_UART_DATA_READY:
                UNUSED_VARIABLE(app_uart_get(&data_array[index]));
                index++;
    
                if ((data_array[index - 1] == '\n') ||
                    (data_array[index - 1] == '\r') ||
                    (index >= m_ble_nus_max_data_len))
                {
                    if (index > 1)
                    {
    
                        NRF_LOG_DEBUG("Ready to send data over BLE NUS");
                        NRF_LOG_HEXDUMP_DEBUG(data_array, index);
    
                        do
                        {
                         
                            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);
                            }
                        } while (err_code == NRF_ERROR_RESOURCES);
          
    
                          }
                          
                          //null
                    if(index==1){
    
                        NRF_LOG_DEBUG("Ready to send data over BLE NUS");
                        NRF_LOG_HEXDUMP_DEBUG(data_array, index);
    
                        do
                        {
                           
                              int i;
                         
                           char buf[42];
                            for (i = 0; i < 3; i++) {
                          snprintf(buf,42, "A%dBBCCDDEEAABBCCDDEEAABBCCDDEEAABBCCDDXX", i);         
                          // puts string into buffer
                           printf("%s\n", buf); // outputs so you can see it
    
                                                          
                               uint16_t length2 = sizeof(buf);
          
                               err_code = ble_nus_data_send(&m_nus,buf, &length2, 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);
                            }
                        } while (err_code == NRF_ERROR_RESOURCES);
    
    
    
                                 }
    
                  
    
                    index = 0;
                }
                break;
    
            case APP_UART_COMMUNICATION_ERROR:
                APP_ERROR_HANDLER(p_event->data.error_communication);
                break;
    
            case APP_UART_FIFO_ERROR:
                APP_ERROR_HANDLER(p_event->data.error_code);
                break;
    
            default:
                break;
        }
    }
    
    
    

  • Unfortunately, I can't reproduce your issue. Could you just .zip your whole working directory and send it?

Reply Children
Related