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

S130: Simultaneous connecting to multiple peripherals

Hi,

the S130 supports multiple connections for the Central role. Is it possible to connect to multiple devices at the same time? E.g. calling sd_ble_gap_connect() asynchronously multiple times with different peer addresses before a timeout or a connection event has occured.

My goal is to have multiple central services/profiles that handle their connections independently of each other. Is this possible? Or will I need to use some kind of connection manager that synchronizes GAP access between the services?

Also, we will have an Observer running in background. Will it be possible to keep scanning during connection establishment to peripheral devices? In the past, it seems I had to call sd_ble_gap_scan_stop() before calling sd_ble_gap_connect().

  • You can only connect to one device at the time. You can do this by either providing a peer address, or you can provide a whitelist with multiple addresses/IRKs. If you provide a whitelist, it will try to connect to the first advertisment that get a match with the whitelist. Then you will have to call sd_ble_gap_connect() again to connect to a second device, and so on.

    If you are scanning, and you call sd_ble_gap_connect() the "old" scan will be stopped. This had to be done manually with the S120 I believe. So the SoftDevice doesn't allow you to observe while you are trying to connect. If this is an important feature, it may be possible to implement the observer with the timeslot API.

  • "My goal is to have multiple central services/profiles that handle their connections independently of each other." Could you elaborate on the meaning of this?

  • We have device A that implements a Dual Role or rather Triple Role (Peripheral, Central and Observer). Then we have several slave devices B, C and D (maybe more in the future) running in Peripheral mode that each implement different functionality a different Bluetooth profile. At startup, device A shall connect to devices B, C and D. Also, it shall reconnect if the connection is lost and it shall connect if A, B or C becomes available only after A has already started. This is the background functionality we need. Further, there are devices X, Y, Z, also running in peripheral mode, which implement the same profile but send different advertising data. Upon a trigger event, device A scans for advertising packets and depending on the advertising data connects to one of X, Y, Z etc. This is the main functionality. But connection to the slave devices (B, C, D etc.) should be kept and (re-) established at the same time. I already have a coarse Idea about how to implement this, based on your answer.

  • Thanks, then the whitelist might be something that helps us doing a clean implementation. So stopping the scanning manually is not needed on the S130 stack? My current strategy for the scenario described above would be as follows:

    1. In idle mode, try to connect to B, C and D using the whitelist
    2. When the trigger event is detected, stop connecting from 1) and enter scan mode. Find the correct device (X, Y, Z) and connect to it. After the connection is established, continue with whitelist connecting to B, C and D, just like in 1).
  • Scanning is automatically stopped with the S130. Your implementation idea sounds good.

Related