Bluetooth: Host: Add error to security changed callback

Add security error to security_changed callback. Call this callback when
security has failed and provide current security level and error.
Reason for failure can be.
 - Pairing procedure failed, pairing aborted before link encryption.
 - Link encrypt procedure failed
 - Link key refresh procedure failed.

Fix missing bt_conn_unref on encryption key refresh with error status.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2019-08-19 16:20:59 +02:00 committed by Carles Cufí
commit 6d4b842a10
8 changed files with 59 additions and 32 deletions

View file

@ -442,8 +442,10 @@ struct bt_conn_cb {
*
* @param conn Connection object.
* @param level New security level of the connection.
* @param err Security error. Zero for success, non-zero otherwise.
*/
void (*security_changed)(struct bt_conn *conn, bt_security_t level);
void (*security_changed)(struct bt_conn *conn, bt_security_t level,
enum bt_security_err err);
#endif /* defined(CONFIG_BT_SMP) || defined(CONFIG_BT_BREDR) */
struct bt_conn_cb *_next;
};