Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Bonding configuration

Hi,

I need to properly configure peer manager. The peripheral device, which I develop haven't any buttons and screen, only sensors are embedded. Also accelerometers, but their interrupts used only for wakeup. This device connects to smartphone (central) through the BLE and perform data exchange. High security level is not required for my system, but fast connection without discovering of the services and ability to save subscribtions for each peer on necessary characteristics is very welcome. 

Thus, I setup Peer Manager as Just Works without Low Energy Security Connection. Now, device is able to connect, pair and bond with smartphone. Smartphone can initiate connection and both smartphone and device can initiate the pairing and consequently bonding. Services are not discovering per each connection and subscription are saved.

But the problem of bonding, is that if bonding information will be removed on one side, other side will not know it. For example, if potential user will remove bonding information from the smartphone (through the smartphone settings, not through my application), the device will force disconnect, when pairing failed. To overcome this problem I delete peer data, when PM_EVT_CONN_SEC_FAILED occurs, by adding the following code to pm_evt_handler:

static void pm_evt_handler(pm_evt_t const * p_evt)
{
    pm_handler_on_pm_evt(p_evt);
    //pm_handler_disconnect_on_sec_failure(p_evt);
    pm_handler_flash_clean(p_evt);

    switch (p_evt->evt_id)
    {
        case PM_EVT_PEERS_DELETE_SUCCEEDED:
            scan_start();
            advertising_start();
            break;
        case PM_EVT_CONN_SEC_FAILED:
            pm_peer_delete(p_evt->peer_id);
            break;

        default:
            break;
    }


Thereby, if bonding information removed from the central but remains on the peripheral, then during first attempt to connect PM_EVT_CONN_SEC_FAILED event will occure and peer data wlll be removed from peripheral device, then peripheral will force disconnect, but next connection will be successfull. But I want to be able to stay connected during first connection.

So, I summarazed a few questions:

1) Which type of connection I need to have fastest connection step without necessity for discovering services and characteristics and subscribing on the characteristics each time? Without security requirements.

2) I assume that "Just Work" is suitable for 1st question, If yes, I have another question. If central and peripheral are bonded and then on one side bonding information will be removed, how can other side know that bonding information was removed and handle this without disconnection?

3) How information about subsribtions is stored? Is it possible that on the smartphone only this information will be removed (not all bonding data), but on device it remains?

I will also be grateful for useful links, where one can find more details about protected connections, pairing and bodning. I pretty familiar with BLE generaly, but not good enough with abovementoined.

I use nRF52840, SDK17.0.0, softdevice s140 7.0.1

Thank you in advance

Parents
  • Hi Arsenii,

    1) Which type of connection I need to have fastest connection step without necessity for discovering services and characteristics and subscribing on the characteristics each time? Without security requirements.

     You can use Just Works bonding. See Heart Rate Application. You can enable nRFConnect AutoConnect. It will autoconnect when the device is powered on/off if the nRFConnect keeps the services and characteristics in the device cache. 

    2) I assume that "Just Work" is suitable for 1st question, If yes, I have another question. If central and peripheral are bonded and then on one side bonding information will be removed, how can other side know that bonding information was removed and handle this without disconnection?

    You will get the error coming from the peer manager when one side lost the bonding information if you don't handle it like delete peer data or allow repairing. When one side deletes the bond information, it will cause the disconnection. That's cannot avoid. 

     

    3) How information about subsribtions is stored? Is it possible that on the smartphone only this information will be removed (not all bonding data), but on device it remains?

    I don't understand the question. Please elaborate on more detail. 

    -Amanda H.

Reply
  • Hi Arsenii,

    1) Which type of connection I need to have fastest connection step without necessity for discovering services and characteristics and subscribing on the characteristics each time? Without security requirements.

     You can use Just Works bonding. See Heart Rate Application. You can enable nRFConnect AutoConnect. It will autoconnect when the device is powered on/off if the nRFConnect keeps the services and characteristics in the device cache. 

    2) I assume that "Just Work" is suitable for 1st question, If yes, I have another question. If central and peripheral are bonded and then on one side bonding information will be removed, how can other side know that bonding information was removed and handle this without disconnection?

    You will get the error coming from the peer manager when one side lost the bonding information if you don't handle it like delete peer data or allow repairing. When one side deletes the bond information, it will cause the disconnection. That's cannot avoid. 

     

    3) How information about subsribtions is stored? Is it possible that on the smartphone only this information will be removed (not all bonding data), but on device it remains?

    I don't understand the question. Please elaborate on more detail. 

    -Amanda H.

Children
Related