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,

     

    Sorry for not seeing this earlier, but the SEND_RDY flag is the reason why you're seeing every other payload. 

    When your function is called, you are effectively queueing one payload to the SoftDevice, and for an ACK (ie. evt BLE_NUS_EVT_TX_RDY occurs, which sets SEND_RDY=1 again), that will happen when a notification has completed.

    When receiving GATT event "BLE_GATTS_EVT_HVN_TX_COMPLETE", which is the same as BLE_NUS_EVT_TX_RDY, it means that the TX has successfully occurred. This comes with a count field, which shows how many packets has been successfully sent in this specific interval, as described by my colleague here:  RE: Missing BLE_GATTS_EVT_HVN_TX_COMPLETE events 

     

    Kind regards,

    Håkon

Children
Related