Multiple pair support but no simultaneous connection

Hello everyone,

I'm using the Bluetooth peripheral sample and I'm in a scenario where I want to connect to my board from only one device at a time, meaning I don't want multiple simultaneous connections. However, I also have pairing activated. So, I set my parameters in the .conf file like this:

CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1

I'm not interested in bonding devices to the flash, so I commented out the following parameters:

# CONFIG_SETTINGS=y
# CONFIG_BT_SETTINGS=y
# CONFIG_FLASH=y
# CONFIG_FLASH_PAGE_LAYOUT=y
# CONFIG_FLASH_MAP=y
# CONFIG_NVS=y

The issue is, when my board is ON and I try to connect to it from my phone, I can connect and pair. But when I switch to another phone, I can connect but not pair. So, I changed the settings to:

CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=128

Now, I have no simultaneous connections, but I can pair with any device (assuming I don't exceed the maximum).

Can someone confirm if this is a good solution? I think it's just a workaround, and I might be missing something.

Thank you for your help!

Iheb

  • Hi,

    I found that the following parameter helped me to overwrite the keys:

    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y

    Is there any other solution that allows for multi-pairing devices ( without overwriting the keys ) but with only one active connection at a time?

  • Hello,

    # CONFIG_SETTINGS=y
    # CONFIG_BT_SETTINGS=y
    # CONFIG_FLASH=y
    # CONFIG_FLASH_PAGE_LAYOUT=y
    # CONFIG_FLASH_MAP=y
    # CONFIG_NVS=y

    Yes, if you don't want to support bonding, but only pairing, you can comment these. In addition, you should add CONFIG_BT_BONDABLE=n to your configuration file to prevent bonding.

    The BT_KEYS_OVERWRITE_OLDEST setting is only relevant when bonding is supported. CONFIG_BT_MAX_PAIRED should also be left at the default value ('1').

  • With bondable set to 'no', when I pair and then disconnect and reconnect, my board forgets the keys, and I must pair again. I want to retain the keys to remember my device while my board remains powered on (it's acceptable for the keys to be lost once rebooted or unplugged)

  • Have you considered if this may have implications on the user experience? If a bond is deleted on the device but not on the phone, you may need to prompt the user to manually delete the bond on the phone before reconnecting.

  • As I'm testing with nRF Connect for Mobile on two different Android devices, I found that I don't have to delete the bond on the phones because the device requests pairing again when switching between phones.

    With :

    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y

    Phone A connects and pairs with the device, and when disconnected and reconnected from A, the device recognizes it.

    Now, I disconnect from Phone A and use Phone B.

    Phone B connects and pairs with the device, and when disconnected and reconnected using Phone B, the device recognizes it.

    When I switch back to Phone A, it will ask to pair again because i was paired with phone B.

    Do you think if I change nRF Connect Mobile to another application, the user would still need to manually unbond? because i don't see a problem with that with nrf connect for mobile..

    What do you think ?

    Thanks in advance Vidar

Related