Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
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

protential bug in id_manager.c

Hi Nordic,

I am using SDK 15.3. While I am working on a central, which connects 2 periperial devices simultaneously, I found a id_manager.c issue, protentially a bug I guess. Any suggestions would be great, thanks.

1. variable not initialised.

See the following declaration in id_manager.c:

static im_connection_t m_connections[IM_MAX_CONN_HANDLES];

I can not find initialization code for it. As a result, if I call the following code in BLE_GAP_EVT_CONNECTED event, status.bonded will return true.

err_code = pm_conn_sec_status_get(p_gap_evt->conn_handle, &status);

if (status.bonded)
{
NRF_LOG_DEBUG("incorrect condition!");
}

By initializing m_connections.peer_id to PM_PEER_ID_INVALID in pm_init() resolves the problem.

2. invalid status

When I have first periperal device connected(conn_handle = 0x00, peer_id = 0x00), then disconnect, then second periperal device connects(conn_handle = 0x00), m_connections contains invalid data, index 0 value is not PM_PEER_ID_INVALID, as a result, Peer Manager still think it is a bonded peer(peer_id = 0). Call pm_conn_secure(conn_handle,false) will do a encryption procedure not a bonding procedure.

I am willing to do a value set(m_connections[0].peer_id = PM_PEER_ID_INVALID; in BLE_GAP_EVT_DISCONNECTED event. But not sure whether it is the right way. Would you please suggest? thanks!

NINE-FOX

Related