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

Device manager: What is similar event to PM_EVT_CONN_SEC_FAILED in a device_manage_central?

Hi,

I use nrf52832QFAA, SDK 11.0.0, Softdevice 132 v2.0.0. I need to add a device_manager_central to my project (in my project it's easier and faster than adding a peer_manager).

The peer_manager have event "PM_EVT_CONN_SEC_FAILED". This event I can use to identify that bonding was not enabled on the remote peer.
What event can I use for understand that a pairing or encryption procedure has failed if I use the device_manager_central?

  • What information do I need add to get answer for this question?

  • Hi!

    The information you need can be found here:
    Device Manager Events.

    Be sure to let me know if you have any further questions.

    Best regards,
    Joakim.

  • I saw this link before asked my question.
    The device manager has events:

    DM_EVT_CONNECTION
    DM_EVT_DISCONNECTION
    DM_EVT_SECURITY_SETUP
    DM_EVT_SECURITY_SETUP_COMPLETE
    DM_EVT_LINK_SECURED
    DM_EVT_SECURITY_SETUP_REFRESH

    But the peer manager has more events:
    PM_EVT_BONDED_PEER_CONNECTED,
    PM_EVT_CONN_SEC_START,
    PM_EVT_CONN_SEC_SUCCEEDED,
    PM_EVT_CONN_SEC_FAILED,
    PM_EVT_CONN_SEC_CONFIG_REQ,
    PM_EVT_STORAGE_FULL,
    PM_EVT_ERROR_UNEXPECTED,
    PM_EVT_PEER_DATA_UPDATE_SUCCEEDED,
    PM_EVT_PEER_DATA_UPDATE_FAILED,
    PM_EVT_PEER_DELETE_SUCCEEDED,
    PM_EVT_PEER_DELETE_FAILED,
    PM_EVT_PEERS_DELETE_SUCCEEDED,
    PM_EVT_PEERS_DELETE_FAILED,
    PM_EVT_LOCAL_DB_CACHE_APPLIED,
    PM_EVT_LOCAL_DB_CACHE_APPLY_FAILED,
    PM_EVT_SERVICE_CHANGED_IND_SENT,
    PM_EVT_SERVICE_CHANGED_IND_CONFIRMED,

    So I asked: "what device manager event is the same as PM_EVT_CONN_SEC_FAILED, or how repcale it?"

    I use this way to resolve my problem:

    static ret_code_t device_manager_event_handler( const dm_handle_t * p_handle,
                                                    const dm_event_t * p_event,
                                                    const ret_code_t event_result)
    {
        /* user code
        ...
        */
        switch (p_event->event_id)
        {
            /* user code
            ...
            */
            case DM_EVT_SECURITY_SETUP_COMPLETE:
            {
                NRF_LOG_PRINTF(">> DM_EVT_SECURITY_SETUP_COMPLETE\r\n");
    			if (event_result != BLE_GAP_SEC_STATUS_SUCCESS)
    			{
    				NRF_LOG_PRINTF("event_resuls = 0x %x\r\n",event_result);
    				sec_failed(p_event->event_param.p_gap_param->conn_handle, event_result); // user error handler
    				break;
    			}
    			dm_security_status_t dm_status;
    			dm_security_status_req(&m_dm_device_handle, &dm_status);
    			switch (dm_status)
    			{
    				case NOT_ENCRYPTED:          	/**< The link is not secured. */
    					NRF_LOG_PRINTF("NOT_ENCRYPTED\r\n");
    				    /* user code 
    				     ... NOT_ENCRYPTED handler (if it need)
    				    */
    					break;
    				case ENCRYPTION_IN_PROGRESS: 	/**< Link security is being established.*/
    					NRF_LOG_PRINTF("ENCRYPTION_IN_PROGRESS\r\n");
    					break;
    				case ENCRYPTED:               	/**< The link is secure.*/
    					NRF_LOG_PRINTF("ENCRYPTED\r\n");
    					break;
    			}
                NRF_LOG_PRINTF("<< DM_EVT_SECURITY_SETUP_COMPLETE\r\n");
                break;
            }
            /* user code
            ...
            */   
        }
    }

  • Hi!

    As you can see from the list of events, there is no event that is equal to the PM_EVT_CONN_SEC_FAILED.

    "Event result associated with the event is provided along with the event in the callback to provide more details of whether a procedure succeeded or failed and assist the application in decision making of how to proceed."

    I haven't tested it myself, but can't see anything wrong with the way you solved it. If it works for you I don't see any reason to why you should change it.

    Best regards.

Related