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

Max interval between BLE data send

Hi,

I use NRF51822 + S130 + SDK12 platform, my device work in CENTRAL mode, I want send data to peripheral every 10ms, code like this:

while (1)
{
   while (m_free_tx_packet_count == 0)
   {
         //wait free send packet
         //m_free_tx_packet_count will increase when BLE_EVT_TX_COMPLETE event received 
      
         if (timeout)
         {
                break;
         }
   }       

   if (m_free_tx_packet_count != 0)   
    {
        if(NRF_SUCCESS == ble_nus_c_string_send(...))  //send some datas
        {
            m_free_tx_packet_count--;
        }
    }
    
    nrf_delay_ms(10);
}

My system is a realtime system, the peripheral need data received at least once every 300 milliseconds, so I measure the max interval of two ble_nus_c_string_send function call, then I found sometimes i must wait free send packet more than 400ms, this will cause my system not work well.

So,is there any way to reduce the time between two BLE data send oprator? Or how can i build a real-time system use BLE?

  • Well start with disabling all other code and just send arbitrary (random or some static pre-defined hardcoded string) data over NUS like that. It should go through very fast (if you are really using <25ms connection interval and some decent bandwidth setting). So the bug doesn't need to come from the way how you use BLE layers but it can easily be in the way you occupy MCU by other tasks or in the way how you acquire the data you want to send over... so many options, no one can tell you without seeing what exactly you are doing in your code (and if it's large project no one will spend the time even if you show it to us, the debugging is unfortunately yours... and the procedure is always pretty much the same although the way can be painful: isolate the code which does one thing perfectly as you want. Then go by very simple steps and see where it breaks.

  • Yes I agree with you and I was going to do that, i even wanna try another peer(maybe a Cypress demo board or Nordic NUC demo) if when i disabling all other code and the problem still exists.

    Anyway, I'll do some test and debugging later as yo say. Thank's a lot for your help and patience.

Related