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

S120 Central Bonding with S110 peripheral

Hello,

For our application I have to set up two simultaneous connections between a S120 master device and two peripherals that use the S110 softdevice. A very short connect-time (<0.5s) is essential for our application. Therefore I try to make a bond between the master and the slaves. Encryption is not essential.

From the SDK s120 documents I understand that the connection time can be minimized if the next information is stored while bonding:

  • Device Context
  • Service Context
  • Application Context

For the master I used the ' ble_app_hrs_c' central example software as basis. However if I make a first time connection between the 'ble_app_hrs_c' central and the 'ble_app_hrs' peripheral examples I only receive the next events from the device manager central event handler :

  • DM_EVT_CONNECTION
  • DM_LINK_SECURED_IND
  • DM_EVT_SECURITY_SETUP_COMPLETE
  • DM_EVT_DEVICE_CONTEXT_STORED

The second connection I receive the next events from the event handler:

  • DM_EVT_LINK_SECURED
  • DM_EVT_DEVICE_CONTEXT_LOADED
  • DM_EVT_CONNECTION
  • DM_LINK_SECURED_IND

I added a print of all DM_EVENTS in the device manager event handler so if I am right, the service and application context are not stored. Also the Heart Rate service and its characteristics are discovered each time I make a connection. This takes a lot of time. If I am right, this would not have to be performed if the service context of the bonded peripheral is stored while making a bond.

Can anyone tell me how I could perform a 'full bond' between the central and peripheral?

Thanks in advance!

  • Hi there,

    If you want to avoid service discovery and you are not going to change the layout of the Attribute Table during the lifetime of the device, the easiest way to do that is to simply disable the Service Changed characteristic in the GATT server devices.

    To do that, simply set the option when enabling the BLE functionality:

      ble_enable_params_t en_param;
      en_param.gatts_enable_params.service_changed = 0;
      en_param.gatts_enable_params.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
      errcode = sd_ble_enable(&en_param);
    

    Then the GATT client devices do not need to perform service discovery after the first connection, since the absence of the Service Changed characteristic indicates that the layout of the server´s attribute table is never going to change. This way you can also disable encryption if you don't need it, saving some time and energy as well.

  • Hello Carles,

    Thanks for your reply. However in the 'ble_app_hrs_c' example the 'service_changed' parameter is already set at '0' and the ' attr_tab_size' parameter does not exists for the central side. If I change the gatts_enable_params for the 'ble_app_hrs' example of the peripheral side as described above. Still both services are discovered each time a new connection is made.

    With kind regards, Michiel

  • That means then that the GATT client module in the SDK is not caching the attributes. Let me ask around and get back to you

  • I'm informed of the following:

    • We don't cache attributes by default

    • To achieve that yourself, you need to use the Device Manager, in particular the following methods:

      dm_application_context_get dm_application_context_set

    • You then need to store the context of the db_discovery module using get()

    • And then restore it after connection using set() to avoid rediscovering

    If you have trouble implementing this I suggest you open a ticket with Nordic support, they will probably be able to help you further

  • Thanks for the information. I will give it a try.

Related