This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE bonding

Hi,

As far as I understand, every connection establishment has to start with advertising.

Event if I have already connected and bonded to a peer, after disconnection I have to start advertising in order to connect to this peer again.

Am I right?

In that case - what is the meaning of bonding here? Shouldn't the peers connect automatically again without advertising/direct advertising? Do I have another option?

Thanks!

Parents
  • Hi,

    As far as I understand, every connection establishment has to start with advertising.

    Yes, that is correct. This is a key concept of the BLE protocol. The peripheral advertises regularly, and in case of connected advertising, it will switch the radio to Rx and listen for connection requests from a central in a short window after transmitting the advertising packet. This is how BLE connections are established.

    Event if I have already connected and bonded to a peer, after disconnection I have to start advertising in order to connect to this peer again.

    Am I right?

    Yes pairing and bonding is independent of the connection mechanism.

    In that case - what is the meaning of bonding here? Shouldn't the peers connect automatically again without advertising/direct advertising?

    No, that would not be possible. When the peripheral is not advertising or in a connection it is typically in sleep, with the radio completely turned off. So there would be no way to connect to it. Pairing is a completely different concept, which is how devices exchange encryption keys (used both for encrypting the link and optionally randomizing the address to that it cannot be tracked even though it advertises). Bonding is the same thing, the only difference is that when bonding, the peers agree to store the keys to be used for later.

    Do I have another option?

    Not really. Dependign on your use case you may not need to bond, but there is no way around advertising to initiate a connection, regardless of if bonded or not.

  • Thanks for your answer!

    I will be more specific. My use case is that I want to connect and bond my NRF device with my mobile. After turning off and on the device and mobile, I want them to connect again.

    Until now, I did it with direct advertising. I saved the mobile's address after bonding when they first connected, so I will use it for direct advertising when my NRF device is turned on again.

    The problem is that my mobile changes it's address. I read some articles about that privacy feature. Do you know that?

    What can I do about that? How can I reconnect to a mobile which changed it's address?

    Thanks!

  • Hi,

    Roei said:
    I will be more specific. My use case is that I want to connect and bond my NRF device with my mobile. After turning off and on the device and mobile, I want them to connect again.

    That makes sense.

    Roei said:
    Until now, I did it with direct advertising. I saved the mobile's address after bonding when they first connected, so I will use it for direct advertising when my NRF device is turned on again.

    You should not use directed advertising against mobile phones. Apple explicitly states that it should not be used. Since you use directed advertising I assume you only want the bonded pone to be allowed to connect. The normal way of achieving this is by using whitelisting. With that concept, you will advertise normally, but connections from non-whitelisted devices will be ignored. You can refer to for instance the Current Time Application to see an example of whitelisting.

    Roei said:
    The problem is that my mobile changes it's address. I read some articles about that privacy feature. Do you know that?

    All modern smartphones changes address regularly to avoid being tracked. This is done by deriving the MAC address form an identity resolving key (IRK), and the address is then called a Resolvable Private Address (RPA). As long as you have bonded your peripheral device also has this IRK and can use it for whitelisting. This is all implemented for you in the nRF5 SDK (and in HW which does the address resolution for you), so you do not need to think much about it other than knowing the concepts.

    Roei said:
    What can I do about that? How can I reconnect to a mobile which changed it's address?

    Use bonding and whitelisting as I have suggested above.

    I notice that all of these questions are general BLE questions, so it might be worth spending some hours reading up on BLE before proceeding. I suspect that could save you some work in the long run. If you like to get such information from books, then I could recomend Getting Started with Bluetooth Low Energy. It does not cover all the recent additions to the Bluetooth specification, but all the basics are explained in a good and simple way.

Reply
  • Hi,

    Roei said:
    I will be more specific. My use case is that I want to connect and bond my NRF device with my mobile. After turning off and on the device and mobile, I want them to connect again.

    That makes sense.

    Roei said:
    Until now, I did it with direct advertising. I saved the mobile's address after bonding when they first connected, so I will use it for direct advertising when my NRF device is turned on again.

    You should not use directed advertising against mobile phones. Apple explicitly states that it should not be used. Since you use directed advertising I assume you only want the bonded pone to be allowed to connect. The normal way of achieving this is by using whitelisting. With that concept, you will advertise normally, but connections from non-whitelisted devices will be ignored. You can refer to for instance the Current Time Application to see an example of whitelisting.

    Roei said:
    The problem is that my mobile changes it's address. I read some articles about that privacy feature. Do you know that?

    All modern smartphones changes address regularly to avoid being tracked. This is done by deriving the MAC address form an identity resolving key (IRK), and the address is then called a Resolvable Private Address (RPA). As long as you have bonded your peripheral device also has this IRK and can use it for whitelisting. This is all implemented for you in the nRF5 SDK (and in HW which does the address resolution for you), so you do not need to think much about it other than knowing the concepts.

    Roei said:
    What can I do about that? How can I reconnect to a mobile which changed it's address?

    Use bonding and whitelisting as I have suggested above.

    I notice that all of these questions are general BLE questions, so it might be worth spending some hours reading up on BLE before proceeding. I suspect that could save you some work in the long run. If you like to get such information from books, then I could recomend Getting Started with Bluetooth Low Energy. It does not cover all the recent additions to the Bluetooth specification, but all the basics are explained in a good and simple way.

Children
Related