How to know that the device disconnected due to an authentication failure

Hi,

I configured for using security BT_SECURITY_L2 for a device that I had previously configured for using BT_SECURITY_L4. When I try to connect with an Android phone that was previously paired when configured for BT_SECURITY_L4, it prints "SMP does not allow a pairing failure at this point. Known issue. Disconnecting instead." to the log and then disconnects.

From this question [here], for solving this issue I need to call bt_unpair(...) to erase bonding information.

How can I know, inside the callback disconnected, that the connection was closed with BT_HCI_ERR_AUTH_FAIL? I always receive reason 22 (BT_HCI_ERR_LOCALHOST_TERM_CONN).

BR

Related