Hello!
I am having 3 nrf5340 devices; 2 Gateways and 1 Headset. I am trying to achieve the scenario where I can allow the Headset connects to selectively one of the 2 Gateways using a button on the headset as an interface for the user, and if the user presses on the button, the connection is shifted to the other Gateway.
Based on my observation in BIS, I noticed that the connection is established using the MAC Random Address, and since the Random Address keeps changing every time, my current solution is to store the random address of the Gateway that connects first to the headset and once the user presses on the button (i.e. to change the connection to a different Gateway), the headset keeps scanning until it receives another Random address, and using the function API bt_addr_le_cmp(const bt_addr_le_t *a, const bt_addr_le_t *b), I compare the newly arrived address with Gateway address that is stored previously. If both addresses match, the headset scans again for another random address, and if the addresses are different, it indicates that a new device has been found and thus connects to the new address and also stores its address (as in Gateway1 previously) for future comparisons. That way I can assure to connect to a new Gateway every time the user presses on the button on the Headset.
However, I do not think that solution is optimized enough because sometimes the scanning keeps receiving the same random address over and over again and thus taking so much time until it randomly picks up the new address. I would like to hear from you on how I can optimize this connection process. I am still new to the Nordic nrf 5340 development, and your advice is highly appreciated!