Hi,
I found a bug in ble_app_gls example from SDK_12.3.0 / s130.
If user enters a wrong passkey, the app ends in a app_error_fault_handler
exception and the central keeps connected until BLE connection timeout.
This comes from a call to sd_ble_gap_disconnect
with an invalid connection handle in pm_evt_handler
function.
Current code is :
case PM_EVT_CONN_SEC_FAILED:
{
NRF_LOG_INFO("Failed to secure connection. Disconnecting.\r\n");
m_conn_handle = BLE_CONN_HANDLE_INVALID;
err_code = sd_ble_gap_disconnect(m_conn_handle,
BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK(err_code);
} break;
handle should be set to invalid after disconnecting the central. With the fix below, handle of wrong passkey works fine :
case PM_EVT_CONN_SEC_FAILED:
{
NRF_LOG_INFO("Failed to secure connection. Disconnecting.\r\n");
err_code = sd_ble_gap_disconnect(m_conn_handle,
BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
m_conn_handle = BLE_CONN_HANDLE_INVALID;
APP_ERROR_CHECK(err_code);
} break;
This bug also seems to exist in SDK_3.0.0
Best regards, Joris