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

Issue when creating whitelist using device manager

I'm using nRF51822 and SDK 10 , Softdevice S110 . I enabled whitelist option in my application its working as expected, but when after device is resetting peer device data is loosing so after reset the firmware peered device wont able to connect(but when i delete bond information from peered phone then it can able to connect). I found the issue is because while initializing device_manager_init(true) , clear persistent data in flash so the bonding information also erasing.

Now in device_manager_init function I'm not clearing persistent data. I'm not passing true as argument in device_manager_init. So it works

1. Is there any other issue if device manager is not clearing persistent data ??

2. What are the data will erasing while initializing device manager ??

3. This is the correct method for creating whitelist using dm ??

Parents
  • Hi,

    1. Is there any other issue if device manager is not clearing persistent data ??

    If you are bonding with many devices, you could run out of storage for new bonds at some point. The DM module will notify the application of DM_DEVICE_CONTEXT_FULL when DEVICE_MANAGER_MAX_BONDS  = number of bonds, and the application needs to handle this event. An approach could then be to erase the oldest bond, here is an example on how to do that. (note that the example is for SDK 9, but the approach is the same)

    2. What are the data will erasing while initializing device manager ??

    If clear_persistent_data is set to true, the bond information will be erased.

    This is the correct method for creating whitelist using dm ??

    Yes.

  • Thanks siugrs.

    I am using only one device to bond and other two devices irk key hard code to the application because that two device i use as a master phone. so total 3 device.

    In my first application i used clear_persistent_data is set to true. so if the device firmware restart the bonded phone cant able to connect ( because bond info cleared). To solve this issue i delete bond information from phone side once it bonded, after it will work perfectly. there is no any issue, only problem is i need to delete bond info from  the phone once its bonded .

    But now i changed clear_persistent_data  to false. so i wont need to delete bond info from phone. Now i can connect to device after reset the firmware also its working fine . But now  device is disconnecting frequently when sending data to phone. But in old case there is no disconnection issue.

    1.Why the device is disconnecting frequently (error 61(0x3d) Unknown) while sending data?? i sending data continuously.

    when i deleting bond information from phone then its not disconnecting at all. connection is smooth while data sending

    2.Is it because of not using peer manager ??

    This is whitelist code section--

    ---------------------------------------------------------------------------------

               ble_gap_whitelist_t      whitelist;
                ble_gap_irk_t*              p_whitelist_irk[2];
                ble_gap_addr_t*          p_whitelist_addr[2];
                static ble_gap_irk_t     masterdevice1 = {{0x04,0x6F,0xA4,0x2E,0xED,0x12,0x17,0x40,0x3B,0xBA,0xED,0x95,0x43,0x57,0xB4,0x54}};
                static ble_gap_irk_t    masterdevice2 = {{0x02,0xD5,0xEC,0xC4,0x13,0xD0,0x95,0x31,0x2A,0x81,0x93,0x51,0xE1,0x80,0x15,0x77}};


                whitelist.addr_count = 2;
                whitelist.irk_count  = 2;
                whitelist.pp_addrs   = p_whitelist_addr;
                whitelist.pp_irks    = p_whitelist_irk;

                err_code = dm_whitelist_create(&m_app_handle, &whitelist);
                APP_ERROR_CHECK(err_code);

                if (whitelist.irk_count >=1)
                {
                    p_whitelist_irk[1]      = &masterdevice1;
                    whitelist.addr_count = 1;
                    whitelist.irk_count = 2;
                    whitelist.pp_addrs = p_whitelist_addr;
                    whitelist.pp_irks = p_whitelist_irk;


                }
                else if (whitelist.addr_count ==1)
                {
                    p_whitelist_irk[0]      = &masterdevice1;
                    whitelist.addr_count = 1;
                    whitelist.irk_count = 1;
                    whitelist.pp_addrs = p_whitelist_addr;
                    whitelist.pp_irks = p_whitelist_irk;
                }

                err_code = ble_advertising_whitelist_reply(&whitelist);
                APP_ERROR_CHECK(err_code);

  • Hi,

    Why the device is disconnecting frequently (error 61(0x3d) Unknown) while sending data?? i sending data continuously.

    If you are getting 0x3D(BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE) as disconnect reason, then this could indicate that you are using incorrect encryption keys when you try to encrypt the link with a bonded device. Try to remove the bond on both the phone and the nRF, and bond again. 

    2.Is it because of not using peer manager ??

    No, the device manager is able to handle bonding and peer identification.

  • Thanks siugrs.

    1.If the encryption key is incorrect then it wont send any data,  right??

    But in my case data is sending , after sending some amount of data it become disconnect and again i need to reconnect to start sending again. If i'm sending 5min data continuously it become disconnect around more than 20times. but when i delete bond info from phone it  sending smoothly.

    2.How can i fix this ?? In my application i need maximum throughput. so i need to fix this issue?

    3. if encryption key is incorrect how can able to check the key ??

    4. How the key become incorrect , is it because of firmware issue ?

    i tried delete bond information on both side and again bonded but issue is not solved.

Reply
  • Thanks siugrs.

    1.If the encryption key is incorrect then it wont send any data,  right??

    But in my case data is sending , after sending some amount of data it become disconnect and again i need to reconnect to start sending again. If i'm sending 5min data continuously it become disconnect around more than 20times. but when i delete bond info from phone it  sending smoothly.

    2.How can i fix this ?? In my application i need maximum throughput. so i need to fix this issue?

    3. if encryption key is incorrect how can able to check the key ??

    4. How the key become incorrect , is it because of firmware issue ?

    i tried delete bond information on both side and again bonded but issue is not solved.

Children
  • 1.If the encryption key is incorrect then it wont send any data,  right??

    No, not if the characteristics does not require encryption, then data can be exchanged without encryption.

    2.How can i fix this ?? In my application i need maximum throughput. so i need to fix this issue?

    It disconnect's with BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE after 5 min? is it always 5 min?

    Could you provide a sniffer log

    What phone are you using ? It could be some issue with the phone, e.g. like in this case. (phone was expecting to do service discovery before it can handle parameter update request)

    What security parameters for the device manager are you using ? Something like this ?

    uint32_t                   retval;
    dm_application_param_t     param;
    dm_application_instance_t  appl_id;
    // Set notification callback in registration parameter.
    param.ntf_cb = example_cm_event_handler;
    // Indicate no service type being used by application.
    param.service_type = DM_PROTOCOL_CNTXT_NONE;
    // Set security parameters to be used for establishing bond with peer.
    memset (&param.sec_param, 0, sizeof(ble_gap_sec_params_t));
    param.sec_param.bond         = 1;                    // Bonding set to 1, meaning bond should be established.
    param.sec_param.mitm         = 1;                    // MITM protection needed.
    param.sec_param.io_caps      = BLE_GAP_IO_CAPS_NONE; // No Input, No Output.
    param.sec_param.oob          = 0;                    // No out of band information used.
    param.sec_param.min_key_size = 16;                   // Minimum key size.
    param.sec_param.max_key_size = 16;                   // Maximum key size.
    param.sec_param.kdist_periph.enc = 1;                // Exchange encryption information of peripheral. (Parameter is applicable only for GAP Central role.)
    param.sec_param.kdist_periph.id  = 1;                // Exchange identification information of peripheral.(Parameter is applicable only for GAP Central role.)
    // Request registration with device manager.
    retval = dm_register(&param);
    if(retval == NRF_SUCCESS)
    {
        // Successfully registered with module.
        // 'appl_id' identifies the application, to be remembered for subsequent procedures.
    }
    else
    {
        // Registration failed. Take corrective action.
    }

Related