What cause the empty PDU

Dear Support Team

I use the nRF5 SDK's ble_app_uart_c sample and ble_app_uart sample to test peripheral send data to central. On the application layer, I called ble_nus_data_send() founction to send one packet which 10bytes per 20ms and the BLE connection interval I set is 20ms. Below is my 20ms callback function implementation.

static void Test_20ms_founction(void * p_context) 
{
  ret_code_t err_code;
  if((SEND_RDY == 1) && (CONN_RDY == 1))
  {  
     call_counter_start = 1;
     do
        {
            uint8_t Test_array[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xaa, 0xbb};
            uint16_t Test_lenght = sizeof(Test_array);
            err_code = ble_nus_data_send(&m_nus, Test_array, &Test_lenght, 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);
        SEND_RDY = 0;
        packet_counter++;
        NRF_LOG_INFO("packet_counter = %d, SEND_RDY = %d", packet_counter, CONN_RDY);
        if(packet_counter == 0xffff) packet_counter = 0;
  }
  if(call_counter_start == 1)
  {
    call_counter++;
    if(call_counter == 0xffff) call_counter = 0;
    NRF_LOG_INFO("Test_20ms_founction call time:%d",call_counter)
  }
}

But I used the Sniffer to catch the packet on the air, But there are empty PDUs in some connection event like picture below, I would like to know what cause this and how to void these empty packet. Because l would like to send one packet per 20ms on the air but in fact it send one packet per 40ms .

The enclosed file is my code. many thanks.

4466.ble_app_uart_c.7z

Parents Reply
  • Hi Håkon

    Many thanks for the detail explanation.

    Is there any other way to avoid or reduce the empty PDU in some connection? In our application, we would like to send 10bytes a packet to the peer every 20ms accurately to control the motor, and the connection interval I set is 20ms, so it requires that a packet must be sent in every connection. Is there any way to achieve this? Many thanks.

Children
Related