This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2642R: Set Scan window/interval in multi role app

Part Number: CC2642R
Other Parts Discussed in Thread: SYSCONFIG

Hi All
I developed an app from multi role example.
My app alternates between central and peripheral roles until a connection is established.
If the connection is requested by a central, my app remains peripheral, and stops advertising.
If a peripheral was found, it automatically connects to it and continue scanning until 4 peripherals are connected, in that case, it remains as a central, no longer alternating to peripheral role.

I found that depending on the peripherals around, it sometimes has trouble to connect to the third or fourth peripheral.
I'm using a low connection interval from 7.5min to 15ms max.

I'd like to play with Scan window/interval to optimize connection to multiple peripherals.
When setting Scan window/interval in Sysconfig (under the observer section), I can see the changes in ti_ble_config.h

// Default scan interval (in 625 us ticks)

#define DEFAULT_SCAN_INTERVAL                   24

// Default scan window   (in 625 us ticks)

#define DEFAULT_SCAN_WINDOW                     16

Anyway I cannot find anywhere in the code where those defines are used ?
I was expecting to find somewhere in multirole.c

GAP_SetParamValue(TGAP_GEN_DISC_SCAN_INT, DEFAULT_SCAN_INTERVAL);
GAP_SetParamValue(TGAP_GEN_DISC_SCAN_WIND, DEFAULT_SCAN_WINDOW);  

But I do not see where those define are used in multirole app ?
Thanks

  • Hi Jerome,

    Two parts in your question: the first one is talking about the difficulty to establish the 3rd and 4th connection, the second one is about modifying the scanning parameters.

    First of all, let me remind you that the CC2642 (like all the other devices of the CC26xx/CC13xx family) has only one radio. It means the radio has to be shared across the time between the different RF operations (i.e. scanning, maintaining connections, advertising).

    In your case, when you have already two connections established, you need to keep the connection opened (i.e. one radio operation per connection every 7.5ms - more if some actual data is exchanged). In the remaining time you need to scan. This is very little time and the scheduler (an internal component of the BLE stack) will probably have to skip some scans to avoid missing some connection events.

    In my opinion, you won't solve your issue by increasing the scanning time. Would it rather be possible to leverage a connection parameters update? It means you establish the connection with a fairly long connection interval (let's say 100ms) then once all the peripherals are ready you decrease it to 7.5ms through this connection parameters update.

    jerome d. said:
    Anyway I cannot find anywhere in the code where those defines are used ?
    I was expecting to find somewhere in multirole.c

    GAP_SetParamValue(TGAP_GEN_DISC_SCAN_INT, DEFAULT_SCAN_INTERVAL);
    GAP_SetParamValue(TGAP_GEN_DISC_SCAN_WIND, DEFAULT_SCAN_WINDOW);  

    It looks like something is not totally right with our implementation... Actually we are not using the parameters set in SysConfig but some other default parameters. You can definitely modify this:

    Here is the code we have in multi_role_scanInit() (in multi_role.c):

      // Set Scan PHY parameters
      GapScan_setPhyParams(DEFAULT_SCAN_PHY, SCAN_TYPE_ACTIVE,
                           SCAN_PARAM_DFLT_INTERVAL, SCAN_PARAM_DFLT_WINDOW);
    

    In order to use the parameters set in SysConfig, you could replace it by :

      // Set Scan PHY parameters
      GapScan_setPhyParams(DEFAULT_SCAN_PHY, DEFAULT_SCAN_TYPE,
                           DEFAULT_SCAN_INTERVAL, DEFAULT_SCAN_WINDOW);
    

    Thank you for noticing this - I will open an internal ticket to get this corrected.

    I hope this will help,

  • Thanks Clément for such detailed response.

    My problem is that I do not know the number of peripherals around, there could be one to four.
    I want to keep connection interval as low as possible in all situations, I'm doing MIDI over BLE and latency is the most important part, it should be as low as possible.

    I was thinking I could play with those scan settings and keep interval at 15ms  

  • Hi,

    jerome d. said:
    I was thinking I could play with those scan settings and keep interval at 15ms  

    Yes, you could do this too. I let you test the different possibilities an find the balance between connection establishment time and connection latency.

    Best regards,