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

How to correct use dm_device_delete_all

Hi All ! I was read many posts about this function and do not understand how to check if all data is deleted.

In my situation I do:

  1. Start advertising for bonded divices

  2. Unexpectedly in advertising state, I need create a new pairing and I call:

    • dm_device_delete_all - for deleting information about all bonded peers
    • sd_ble_gap_adv_start - start advertising whith new params.

The dm_device_delete_all return NRF_SUCCESS, but data not clear.

Is the true to check

DM_CLEAR_OPERATION_ID == p_event->event_id

in device_manager_evt_handler(...) or is there another solution ?

Thanks!!!

Parents
  • In device_manager.h, above declaration of function dm_device_delete_all is writed: "If this API returns NRF_SUCCESS, DM_EVT_DEVICE_CONTEXT_DELETED event is notified to the application for each device that is deleted from the data base"

    I simply add code:

    case DM_EVT_DEVICE_CONTEXT_DELETED:
    

    in device_manager_evt_handler(...) and hook clearing result.

    Attension: if DM "white list" is empy, that event is not occur.

  • //where do you need:

    static ble_gap_whitelist_t  whitelist;
    
    whitelist.addr_count = 1;
    whitelist.irk_count  = 1;
    whitelist.pp_addrs   = p_whitelist_addr;
    whitelist.pp_irks    = p_whitelist_irk;
    uint32_t err_code = dm_whitelist_create(&m_app_handle, &whitelist);
    if ((whitelist.addr_count != 0) || (whitelist.irk_count != 0))
    {
       dm_device_delete_all(&m_app_handle);
    }
    

    and in device_manager_evt_handler:

    static uint32_t device_manager_evt_handler(...)
    {
    case DM_EVT_DEVICE_CONTEXT_DELETED:		//Indicates that device context is deleted
    	{
    		//DM_EVT_DEVICE_CONTEXT_DELETED event is notified to the application 
    		// **for each device** that is deleted from the data base.
    		//Event result notified along with the event indicates success or failure of this procedure.
    		
    		**//!!! ANY YOU CODE !!!**
    		break;
    	}
    
Reply
  • //where do you need:

    static ble_gap_whitelist_t  whitelist;
    
    whitelist.addr_count = 1;
    whitelist.irk_count  = 1;
    whitelist.pp_addrs   = p_whitelist_addr;
    whitelist.pp_irks    = p_whitelist_irk;
    uint32_t err_code = dm_whitelist_create(&m_app_handle, &whitelist);
    if ((whitelist.addr_count != 0) || (whitelist.irk_count != 0))
    {
       dm_device_delete_all(&m_app_handle);
    }
    

    and in device_manager_evt_handler:

    static uint32_t device_manager_evt_handler(...)
    {
    case DM_EVT_DEVICE_CONTEXT_DELETED:		//Indicates that device context is deleted
    	{
    		//DM_EVT_DEVICE_CONTEXT_DELETED event is notified to the application 
    		// **for each device** that is deleted from the data base.
    		//Event result notified along with the event indicates success or failure of this procedure.
    		
    		**//!!! ANY YOU CODE !!!**
    		break;
    	}
    
Children
No Data
Related