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

Unknown blank time in connection event in combination with connecting.

Hello DevZone.

For my project I am using up to 6 connected peripherals to my central and I was watching the behavior of the link when one of the 6 devices disconnected and reconnected and I stumbled upon something I cannot explain. 

I am using sdk 7.0.2 and I am using the sd_ble_gap_conn_evt_trigger_start function to trigger a EGU3 task per connection handle. In this task I set and clear a GPIO pin to visualize this on my logic analyzer.

Connection event is every 15ms and the GAP length is set to 2. 

A color legend from my image:

White is the central triggering every time a peripheral is asserted. 

Brown to blue are connected peripherals.

I disconnect one peripheral and after my set time of 500ms timeout I can see that the central has detected that the peripheral is missing. (red markers)

After x amount of time the central stops completely with generating connection events for a random amount of time. In my case here its 200ms (blue markers) before it starts again and this time with all 6 devices.

Can someone guestimate or explain what causes this drop in connection events?

Parents
  • Hi,

    Without knowing more my gut feeling would be that you send too much data, and in an event handler you repeatedly try to send BLE data in a loop if the Tx buffer is full, blocking all other BLE events (which has the same priority) from being processed during this time. This is just a shot in the dark, though.

    Some questions first in order to better understand the situation:

    • Is it so that the connections are still maintained, but you suddenly do not get any more events for the connections?
    • What events are you expecting/missing?
    • Do you still see this with a lower number of connections?
    • Could it be that some high priority interrupt/event handler takes a long time, blocking SoftDevice for some time? This could also be a SoftDevice event taking long time to process, thereby blocking others.
  • you send too much data,

    I am sending no data, I am just keeping the link active with empty PDU's

    Is it so that the connections are still maintained, but you suddenly do not get any more events for the connections?

    I have to figure this out if the connections to other peripherals is still maintained for this period, I will test this to figure out if it still is maintained. I am disconnecting one peripheral by pressing the reset button on a dev kit.

    What events are you expecting/missing?

    I am expecting the central to continue with generating connection events for all other connected devices instead of stopping for a period

    Could it be that some high priority interrupt/event handler takes a long time,

    I only have one interrupt at priority 5 which is one lower than what the SoftDevice is using.

  • T IJ said:
    I am expecting the central to continue with generating connection events

    I am still not sure what this is. Can you specify exactly which events you are expecting? You will not get events from the SoftDevice for empty PDUs. So if nothing happens after the connection is established you will not get any other events after the BLE_GAP_EVT_CONNECTED event. I understand you do get some events that suddenly stop coming though, but without knowing which events we are talking about it is not easy to say more.

Reply
  • T IJ said:
    I am expecting the central to continue with generating connection events

    I am still not sure what this is. Can you specify exactly which events you are expecting? You will not get events from the SoftDevice for empty PDUs. So if nothing happens after the connection is established you will not get any other events after the BLE_GAP_EVT_CONNECTED event. I understand you do get some events that suddenly stop coming though, but without knowing which events we are talking about it is not easy to say more.

Children
  • Here is a zoomed in section of the connection events from the cental when one peripheral disconnects. As you can see from this image one interval is skipped due to the missing link. 

    When the central tries to re connect to the disconnected peripheral I see this.

    What I expected to happen is that the connection events generated by the other devices would continue instead of halting completely.

    In my BLE_GAP_EVT_CONNECTED event I execute the following code.

    ble_gap_conn_event_trigger_t trigger_params;
    
    trigger_params.ppi_ch_id = p_gap_evt->conn_handle;
    trigger_params.task_endpoint = (uint32_t)&NRF_EGU3->TASKS_TRIGGER[p_gap_evt->conn_handle];
    trigger_params.conn_evt_counter_start = 1;
    trigger_params.period_in_events = 1;
    sd_ble_gap_conn_evt_trigger_start(p_gap_evt->conn_handle, &trigger_params);
    

    In my BLE_GAP_EVT_DISCONNECTED event I execute the following code.

    sd_ble_gap_conn_evt_trigger_stop(p_gap_evt->conn_handle);

    Each connection handle gets its own PPI channel (just to be sure) and each handle gets its own EGU3 event (just to be sure again)

    I do not see the reason for stopping the other events other than the SoftDevice being busy with setting up the connection, and thus stalling the other events.

    Edit:

    I have tested to see if a link with another peripheral actually stops for that brief moment and it does.

  • Hi,

    OK, now I see. This could be scanning. I assume the central starts to scan again after the disconnect? And if none of the links are close to timeout, scanning will be done even if that means dropping connection events.  See SoftDevice timing-activities and priorities.

  • I shall dive into this and try to mess around with the scan settings, I'll get back in a bit.

    Edit:

    Thanks this was indeed the case, I had my scan interval and window set both to a size of 2,5ms.

    I have increased the interval to 10 times what I had and the scan window to 3 times what I had and it fixed the problem.

    I was hoping I could modify the scanner so it would only scan in the period the other device was disconnected but I guess this is not working as how I wanted it to work. I'll verify the answer in a minute, I'll wait for your reply, maybe you have a trick on how to implement my wish if that is possible in the first place.

Related