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

Parents Reply Children
  • 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

  • It is not so much about which app your are using, but more with the Bluetooth framework you are working with. Have you tried this on iOS as well?

  • Ih3b said:
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y

    I don't foresee any problems with using the above configuration if central devices always prompt the user to pair again after detecting that the bonding information has been cleared on the peripheral. However, this is not what I'm seeing when testing with my iPhone here.

    Here is an example where the iPhone is bonded with the peripheral, but the bond has been cleared on the peripheral, so it responds with "PIN or Key missing" when the phone tries to secure the connection with the previously exchanged key. 

    Could you maybe double check that your iphone was indeed bonded with your peripheral when you tested this (i.e. that the peripheral is still listed under "My devices" in Settings->Bluetooth after disconnecting).

Related