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

When to call pm_conn_secure()

I am making a central application which connects to a peripheral and uses Peer Manager. The first time I connect, I have to call pm_conn_secure() to secure the link, basically any time after connecting, but before reading a (protected) characteristic, that works fine.

When the peer has already bonded before, then Peer manager automatically secures the link and I do not have to call pm_conn_secure(). That also works fine with the function commented out. If I call pm_conn_secure() it looks like the security proceduer is executed twice (I get the PM_EVT_CONN_SEC_SUCCEEDED event twice, on the central and on the peripheral).

Now I wonder how to handle these different cases, so that the procedure is executed only once. What would be the best event to start pm_conn_secure() only when needed?

Related