Hello,
I am using nRF52840-devkit with NCS SDK V1.4.0.
In "Central_Uart" example, there is a filtering method which is used to filter devices in the environment with a specific UUID. The "connect_if_match" is set to 1, so that if the filters are matched with a specific device then it connects automatically. But there is a limitation in the code provided in "scan.c" where filters are checked and device gets connected.
Here's the limitation: In "scan_connect_with_target" function, they call "bt_scan_stop" in order to stop scanning and then connect to the first device with which it matches the filter. This means that it will connect to just 1 device at a time.
My question is, what if after filtering the devices in the environment, I get 3 devices which are having the same UUID. In that case, instead of connecting to all 3 (which I want), it will just connect to 1 device. This is assuming I set CONFIG_BT_MAX_CONN to 3.
Finally, I found this API "bt_conn_le_create_auto" which does auto connection to all available devices in whitelist, and it doesn’t stop scanning after connect. But as that says, it’s an auto connect to a whitelist only.
Question 1: Why does the Central UART sample, or for that matter any BLE sample, allow for multiple connections (if you set CONFIG_BT_MAX_CONN >1) when they also use scan filters? It seems the scan filters stop scanning, preventing more than one connection unless you manually restart the scan. And I don’t see that the samples restart the scan after a connection. In particular, the Throughput sample comes configured with MAX_CONN=2. I tried getting two Throughput peripherals to connect to a Throughput central, but was only able to get one to connect. Of course, only was able to connect one device because scanning stopped after the first connection.
Question 2: If I want my project to use a scan filter with auto connect, how can I achieve more than one connection if the scan is going to stop after each connection? Do I have to have my own code restart the scan after each connection?
I found a similar example on DevZone https://devzone.nordicsemi.com/f/nordic-q-a/49136/multicentral-zephyr-development-examples-or-documentation but it did not provide the solution.