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

Connection Parameter Selection for Central Device with 10 Peripheral Simultaneous Connections

Hi,

I am developing both Central and Peripheral devices with nRF52840. For consistency, both are using SDK 15.3.0 and S140 V7.

I am able to connect to peripherals and negotiate MTU ATT size of 247 and I am able to negotiate 2 Mbps phy. Logging on both peripheral and central devices confirm this is working.

My challenge is getting notification data from my peripherals to my central. If I set up (for example) 2 peripherals to notify my central device every 500 mSec with approx 160 bytes of data, all data comes into the BLE event handler (BLE_GATTC_EVT_HVX) within my central device just fine. If I double the data speed on peripherals (ie. 160 bytes every 250 mSec from each of the 2 devices), I only get BLE_GATTC_EVT_HVX events notifying me of incoming data from the first peripheral only.

I believe that I am not getting correct connection service intervals setup after peripheral connection.

For a scenario where a central is talking to 10 peripherals and getting notification data from each every 250 mSec, what would good connection interval, slave latency values be? I cannot seem to find a good reference for setup of connection intervals for multiple simultaneous peripheral connections to a central device - where each peripheral is notifying the central independently.

Note that my connection event length is 6 x 1.25 mSec or 7.5 mSec. This should be plenty long enough to get an MTU of 247 bytes transferred.

I have been using default min and max connection intervals of 7.5 and 30 mSec respectively and a slave latency of 0 (for both central and peripheral devices).

Suggestions for my scenario would be much appreciated.

Thanks in advance,

Mark J

Parents
  • I have not looked at a Softdevice spec for a long time and was pleasantly surprised to find this very helpful page showing simple connection timing when no scanning occurs:

    Connection timing as a Central

    and this one with the addition of scanning:

    Primary channel scanner timing

    My requirements are to send a 160 byte notification from EACH of 10 peripherals every 250 mSec. Because I am setup for MTU size of 247 bytes, I can assume 1 packet will support this notification. I will also need to be able to scan when connected with reasonable reliability over a 10-20 sec scan, so I will setup a scan window that is 50 percent of my scan interval.

    I can see from this online resource that (at 2 Mbps phy) I should be able to use an event time of 2.5 mSec for each connection event.:

    Bluetooth 5 speed: How to achieve maximum throughput for your BLE application 

    So, I set my NRF_SDH_BLE_GAP_EVENT_LENGTH (within sdk_config.h) to "2" (2 x 1.25 = 2.5 mSec).

    The Primary channel scanner timing ref suggests that the scan interval should be set to match the connection interval when scanning occurs in sequence with connection events. So, I will setup both as the interval that includes servicing of:

    - each of 10 connections for 2.5 mSec each or 25 mSec total for 10 connections.

    - scan window that will be 50% of the scan interval / connection interval. If I use 30 mSec - I will use a scan interval and connection interval of 60 mSec.

    - scan interval / connection interval of 60 mSec (ie. I set both scan interval and connection interval to 60 mSec). This will support 25 mSec for 10 events with length 2.5 mSec each plus 5 mSec for other things that occur between connection events and scanning and my 30 mSec scan window.

    Using these settings (and confirming the connection parameter update is completing on each peripheral via a BLE_GAP_EVT_CONN_PARAM_UPDATE event on the central for each peripheral connection), I am noticing 2 issues when testing with only 2 peripherals...

    1. Setting the NRF_SDH_BLE_GAP_EVENT_LENGTH to 2 (2.5 mSec) causes problems with sd_ble_gattc_write(). Periodically - it is returning BLE_ERROR_INVALID_CONN_HANDLE - even though this handle (0x0000) is successfully used before the sd_ble_gattc_write() call that fails (ie. it works for some time and then fails) Not sure how the NRF_SDH_BLE_GAP_EVENT_LENGTH could effect a handle validity. Softdevice Bug? If I use a NRF_SDH_BLE_GAP_EVENT_LENGTH value of 6 - I never see this issue. I also see it when using a valud of 3 (3.75 mSec).

    2. Even when I do NOT see the first issue (1 above) I am not able to consistently get all notifications to my BLE event handler (BLE_GATTC_EVT_HVX event). I do get all notifications from both peripherals sometimes, but during most tests I only get notifications from 1 peripheral device. On occasion, I do not get notifications from either peripheral device.

    I may misunderstand what the NRF_SDH_BLE_GAP_EVENT_LENGTH represents. I see that it can be set as high as 320 (400 mSec) in the ble_app_hrs_c example. This seems huge for the amount of time to spend on a connection. My understanding is that it is the amount of time to service each connection. If a single packet (even 256 bytes) is transferred on a 1 Mbps link (default) this should only take less than couple of mSec. Perhaps far more packets are read/written during a connection event? If I am only getting notification from each peripheral with < 200 bytes and I have confirmed an MTU of 247 bytes, how long do I need the event length to be? To service more connections and each of those connections faster, I would expect this NRF_SDH_BLE_GAP_EVENT_LENGTH should be as low as possible.

    Perhaps I misunderstand what the connection interval means for multiple connections. I expect it to be the time taken to service ALL connections plus the scan window. So, if each connection needs 7.5 mSec (if event time is 7.5 mSec) and I have 10 connections, I will need 75 mSec to handle all connection events and then more time for scanning before the connection interval has completed. Is this understanding correct?

    Thanks,

    Mark J

Reply
  • I have not looked at a Softdevice spec for a long time and was pleasantly surprised to find this very helpful page showing simple connection timing when no scanning occurs:

    Connection timing as a Central

    and this one with the addition of scanning:

    Primary channel scanner timing

    My requirements are to send a 160 byte notification from EACH of 10 peripherals every 250 mSec. Because I am setup for MTU size of 247 bytes, I can assume 1 packet will support this notification. I will also need to be able to scan when connected with reasonable reliability over a 10-20 sec scan, so I will setup a scan window that is 50 percent of my scan interval.

    I can see from this online resource that (at 2 Mbps phy) I should be able to use an event time of 2.5 mSec for each connection event.:

    Bluetooth 5 speed: How to achieve maximum throughput for your BLE application 

    So, I set my NRF_SDH_BLE_GAP_EVENT_LENGTH (within sdk_config.h) to "2" (2 x 1.25 = 2.5 mSec).

    The Primary channel scanner timing ref suggests that the scan interval should be set to match the connection interval when scanning occurs in sequence with connection events. So, I will setup both as the interval that includes servicing of:

    - each of 10 connections for 2.5 mSec each or 25 mSec total for 10 connections.

    - scan window that will be 50% of the scan interval / connection interval. If I use 30 mSec - I will use a scan interval and connection interval of 60 mSec.

    - scan interval / connection interval of 60 mSec (ie. I set both scan interval and connection interval to 60 mSec). This will support 25 mSec for 10 events with length 2.5 mSec each plus 5 mSec for other things that occur between connection events and scanning and my 30 mSec scan window.

    Using these settings (and confirming the connection parameter update is completing on each peripheral via a BLE_GAP_EVT_CONN_PARAM_UPDATE event on the central for each peripheral connection), I am noticing 2 issues when testing with only 2 peripherals...

    1. Setting the NRF_SDH_BLE_GAP_EVENT_LENGTH to 2 (2.5 mSec) causes problems with sd_ble_gattc_write(). Periodically - it is returning BLE_ERROR_INVALID_CONN_HANDLE - even though this handle (0x0000) is successfully used before the sd_ble_gattc_write() call that fails (ie. it works for some time and then fails) Not sure how the NRF_SDH_BLE_GAP_EVENT_LENGTH could effect a handle validity. Softdevice Bug? If I use a NRF_SDH_BLE_GAP_EVENT_LENGTH value of 6 - I never see this issue. I also see it when using a valud of 3 (3.75 mSec).

    2. Even when I do NOT see the first issue (1 above) I am not able to consistently get all notifications to my BLE event handler (BLE_GATTC_EVT_HVX event). I do get all notifications from both peripherals sometimes, but during most tests I only get notifications from 1 peripheral device. On occasion, I do not get notifications from either peripheral device.

    I may misunderstand what the NRF_SDH_BLE_GAP_EVENT_LENGTH represents. I see that it can be set as high as 320 (400 mSec) in the ble_app_hrs_c example. This seems huge for the amount of time to spend on a connection. My understanding is that it is the amount of time to service each connection. If a single packet (even 256 bytes) is transferred on a 1 Mbps link (default) this should only take less than couple of mSec. Perhaps far more packets are read/written during a connection event? If I am only getting notification from each peripheral with < 200 bytes and I have confirmed an MTU of 247 bytes, how long do I need the event length to be? To service more connections and each of those connections faster, I would expect this NRF_SDH_BLE_GAP_EVENT_LENGTH should be as low as possible.

    Perhaps I misunderstand what the connection interval means for multiple connections. I expect it to be the time taken to service ALL connections plus the scan window. So, if each connection needs 7.5 mSec (if event time is 7.5 mSec) and I have 10 connections, I will need 75 mSec to handle all connection events and then more time for scanning before the connection interval has completed. Is this understanding correct?

    Thanks,

    Mark J

Children
No Data
Related