(BLE advertising) nRF automatically connect to my phone and prevent it from other device

Hi, 
I'm build an application that my nRF advertising and my phone (I can call it is phone A), and my friend's phone (phone B)
1.  phone A and phone B can connect automaticially to nRF when nRF start advertising and phone A and B turn on Bluetooth.

2. When another phone (phone C, D...) tries to connect nRF. my nRF will prevent connection from them. They must be added by my nRF like phone A and phone B were added before (I think "whitelist" but I'm not sure about this, I'm new to this)

=> So how can I set up automatic connection and add another device (phone C, phone D) with the same function as phone A, phone B.
Thank you so much !

  • Hi Tam, 

    The most common way of adding such feature as you described is to use a whitelist. 

    When a device advertises in whitelist, it won't allow the connect request from the centrals that are outside of the whitelist. 

    So in your case if A and B is in the whitelist but not C and D then it would work exactly as you described. 

    Some of our examples (e.g ble_app_ancs_c, mouse, keyboard etc ) supporta whitelist by default. A device is automatically added to whitelist after it's bonded. 

    However, the difference here is that we defined a button (BSP_EVENT_WHITELIST_OFF) to turn off the whitelist. So if you want to add a new device to the whitelist, you need to press the button to allow "normal" advertising. This will make it possible for C and D to connect and join the whitelist. 

    We currently don't have the code to allow adding C and D via A and B. You would need to make your own mechanism to send the data about C and D from A/B down to the node and update the whitelist. The advertising module has an event that request the application to provide the whitelist , have a look here and please refer to the examples I mentioned above. 
    Your task is to find a way to send either address of C/D or their IRK to the node to update to the whitelist. 

Related