Bluetooth master-slave start scan failed

I have written a master-slave program based on NCS 2.2.0 and use nRF52840 board.

Firstly, I turned on two broadcast frames and set the scan timeout to 0. This successfully enabled scanning. Here is my configuration.

CONFIG_BT=y
CONFIG_BT_CENTRAL=y
CONFIG_LOG=y
CONFIG_LOG_PRINTK=y
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=5122

CONFIG_BT_EXT_ADV=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_LL_SW_SPLIT=y

CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
CONFIG_BT_MAX_CONN=2

But when I set the scan timeout to 2s, the scan fails to start. 

At this point if I set CONFIG_BT_EXT_ADV_MAX_ADV_SET to 3, I can successfully start the scan.

What I can't understand is what scanning has to do with CONFIG_BT_EXT_ADV_MAX_ADV_SET? Or there is some other reason why the scan failed to start?

Attached is my test sample

3124.central.zip

  • Hi,

    Just to clarify:

    • Scan timeout = 0
      CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
      CONFIG_BT_MAX_CONN=2
    • Scan timeout = 2
      CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
      CONFIG_BT_MAX_CONN=2

    These configurations does not work?

    • Scan timeout = 2
      CONFIG_BT_EXT_ADV_MAX_ADV_SET=3
      CONFIG_BT_MAX_CONN=2

    This configuration does work?

    It looks like that there could be an implied dependency that increases BT_MAX_CONN to 3 if BT_EXT_ADV_MAX_ADV_SET is set to 3 which might be why the scanning starts with the last configuration.

    Let me know about the clarification question above, and I'll have a closer look

    Kind regards,
    Andreas

  • AHaug said:

    Just to clarify:

    • Scan timeout = 0
      CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
      CONFIG_BT_MAX_CONN=2
    • Scan timeout = 2
      CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
      CONFIG_BT_MAX_CONN=2

    These configurations does not work?

    • Scan timeout = 2
      CONFIG_BT_EXT_ADV_MAX_ADV_SET=3
      CONFIG_BT_MAX_CONN=2

    Hi,

    Yes, my samp do run like this.

  • 1. These configurations can run:

    Scan timeout = 0
    CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
    CONFIG_BT_MAX_CONN=2

    2. These configurations cannot run:

    Scan timeout = 2
    CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
    CONFIG_BT_MAX_CONN=2

    3. These configurations can run:

    Scan timeout = 2
    CONFIG_BT_EXT_ADV_MAX_ADV_SET=3
    CONFIG_BT_MAX_CONN=2

  • AHaug said:
    It looks like that there could be an implied dependency that increases BT_MAX_CONN to 3 if BT_EXT_ADV_MAX_ADV_SET is set to 3 which might be why the scanning starts with the last configuration.

    It looks like this is correct. 

    From what I have seen in other similar cases and discussion, the fix is to either increase the CONFIG_BT_MAX_CONN=3 or disable BT_CENTRAL, which should give you two advertising sets and one scan. When you set the number of slave connections to 2, you will need to disable the central role support or to increase the maximum allowed BT_CONN. Having both Central and peripheral support = 2 connections. If you add scanning this will require BT_MAX_CONN = 3 to run.

    Could you try with the following configuration and report back to me what you see?

    Scan timeout = 2
    CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
    CONFIG_BT_MAX_CONN=3

    Kind regards,
    Andreas

  • AHaug said:
    Scan timeout = 2
    CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
    CONFIG_BT_MAX_CONN=3

    I have tested it in two situations and it does not work.

    1. Use Zephyr Controller: Scanning failed to start

    2. Use Nordic Controller: Failed to start advertiser

    AHaug said:
    It looks like that there could be an implied dependency that increases BT_MAX_CONN to 3 if BT_EXT_ADV_MAX_ADV_SET is set to 3 which might be why the scanning starts with the last configuration.

    When CONFIG_BT_EXT_ADV_MAX_ADV_SET=3, after compilation, CONFIG_BT_MAX_CONN is not increased to 3

    AHaug said:
    Having both Central and peripheral support = 2 connections. If you add scanning this will require BT_MAX_CONN = 3 to run.

    Scan timeout = 0
    CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
    CONFIG_BT_MAX_CONN=2

    What I can't understand is that the above configuration works fine when the scan timeout is 0. According to you, doesn't it need to set CONFIG_BT_EXT_ADV_MAX_ADV_SET or CONFIG_BT_MAX_CONN to 3?

Related