This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Device manager DM_EVT_SECURITY_SETUP_COMPLETE error

I'm using s110 softdevice 6.1 SDK. I do bonding in my application the same way as in the ble_app_hrs example (bond, no_mitm). I have a charactarestic set to SEC_MODE_SET_ENC_NO_MITM. I use writing into this characteristic initially to trigger the bonding process.

  1. If I do not clear persistent data during startup and unpair the device in iOS: the iOS device re-requests pairing, but on the nordic chip I get an error: DM_DEVICE_CONTEXT_FULL with the DM_EVT_SECURITY_SETUP_COMPLETE. Previously I get both DM_EVT_SECURITY_SETUP and DM_EVT_LINK_SECURED. As a result iOS and the nrf chip fail to communicate.

  2. If I clear persistent data for the device manager, and don't unpair the device in iOS. The iOS application connects, but doesn't re-request bonding. I get no error, but the devices are still unable to communicate. I cannot unpair programmatically in iOS. Android handles this by re-initializing the bonding process, but it doesn't seem to happen on iOS.

The 2) is probably unsolvable. For 1) is there a way to detect if the peer device was unbonded and delete the old bonding information and restart the process?

    1. I think you will only get DM_DEVICE_CONTEXT_FULL when the device context memory is full. You will receive this error from device_instance_allocate() when the BLE_GAP_EVT_AUTH_STATUS event is handled in dm_ble_evt_handler().

    Have you set DEVICE_MANAGER_MAX_BONDS to 1? You could try to increase it. If you have space in the device context memory I believe the device manager will just look at the iOS device as a new device and create a new bond. Lets say you set it to 8, then you will be able to bond with 8 different devices, or if you delete the bonding information in iOS, have up to 8 bonds with the same device. The device manager allows you to delete bonds, so you could have some kind of mechanism that ensures that there always is device context memory available when a new device tries to bond.

    To detect if a central device has been unbonded you need some way of identifying it. The device address changes, but maybe you can use IRK to achieve it. So what event in the bonding process will give you the IRK? You will not get the IRK when you get the BLE_GAP_EVT_CONNECTED event(if you don't use whitelisting), and you will not get it with the BLE_GAP_EVT_SEC_PARAMS_REQUEST or the BLE_GAP_EVT_CONN_SEC_UPDATE events. You will get it with the BLE_GAP_EVT_AUTH_STATUS event.

    To get a list of IRKs of the bonded devices you can use dm_whitelist_create(). So in ble_evt_dispatch() you can look for the BLE_GAP_EVT_AUTH_STATUS event, get the list, run through it, and delete the bonded devices with dm_device_delete_all() if you get a match.

    I haven't tested this, it is just an idea. Also, I cannot guarantee that the central device will use the same IRK.

    1. The devices are still connected, and they are still able to communicate, but you will only be able to access characteristic values and descriptors that doesn't require encryption, but usually the app doesn't try to access these. Please see this question for a bit more information.

    Edit 22.05.2015 Added a suggestion on how to identify an unbonded central.

    1. MAX_BONDS is set to 7, and only 1 device connected to it. The application functions as activity tracker and delivers notifications to the user. We need bonding because we also use ANCS client. Without bonding ANCS doesn't work.
    2. I found no way to get a list of stored bonded centrals with device manager and the documentation to it is rather brief and confusing. Could you point me to an example code, where this is implemented?
  • I'll try to reproduce this tomorrow. What iOS version and device are you using? You are using SDK 6.1.0 with SoftDevice S110 v7.1.0?

  • The only theoretical solution that comes in my mind to delete all bond information after the LINK_SECURED event if pairing is in progress. Given it is safe to assume that device manager doesn't store device information somewhere before this. But this way only one bounded device would be supported and a solution for your 2) problem would be required.

  • I just tested this now. SoftDevice S110 v7.1.0, SDK6.1.0, iOS 8.3, ble_app_hrs with BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&hrs_init.hrs_hrm_attr_md.cccd_write_perm); With DEVICE_MANAGER_MAX_BONDS 7 I don't get DM_DEVICE_CONTEXT_FULL, but with DEVICE_MANAGER_MAX_BONDS 1 I get it. Could it be that you have bonded 7 times without deleting the bond information? Please help me reproduce this.

Related