From 6fa999d009ebbc48c003365e92e11fb0f3100c97 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Tue, 12 Nov 2024 16:20:12 +0100 Subject: [PATCH] fix unexpected paring attempts, remove user phy update request --- app/prj.conf | 1 + app/src/connection.c | 42 ++++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/prj.conf b/app/prj.conf index c970228..9697a4f 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -44,6 +44,7 @@ CONFIG_BT_LL_SW_SPLIT=y #CONFIG_BT_DEBUG_SMP=y #PHY update needed for updating PHY request +CONFIG_BT_PHY_UPDATE=y CONFIG_BT_USER_PHY_UPDATE=y # HCI ACL buffers size diff --git a/app/src/connection.c b/app/src/connection.c index 9fde2bf..7dd6859 100644 --- a/app/src/connection.c +++ b/app/src/connection.c @@ -40,10 +40,10 @@ void connected(struct bt_conn *conn, uint8_t err) // // bt_conn_le_param_update(conn, ¶ms); - err = bt_conn_le_phy_update(current_conn, BT_CONN_LE_PHY_PARAM_2M); - if (err) { - LOG_ERR("Phy update request failed: %d", err); - } + // err = bt_conn_le_phy_update(current_conn, BT_CONN_LE_PHY_PARAM_2M); + // if (err) { + // LOG_ERR("Phy update request failed: %d", err); + // } send_status_event(); } @@ -84,17 +84,21 @@ void disconnect(void){ void num_comp_reply(bool accept) { - if (accept) { - bt_conn_auth_passkey_confirm(auth_conn); - LOG_INF("Numeric Match, conn %p", (void *)auth_conn); - } else { - bt_conn_auth_cancel(auth_conn); - LOG_INF("Numeric Reject, conn %p", (void *)auth_conn); - bt_conn_disconnect(auth_conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN); - } - bt_conn_unref(auth_conn); - auth_conn = NULL; + + if (auth_conn != NULL) { + if (accept) { + bt_conn_auth_passkey_confirm(auth_conn); + LOG_INF("Numeric Match, conn %p", (void *)auth_conn); + } else { + bt_conn_auth_cancel(auth_conn); + LOG_INF("Numeric Reject, conn %p", (void *)auth_conn); + bt_conn_disconnect(auth_conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN); + } + + bt_conn_unref(auth_conn); + auth_conn = NULL; + } } void passkey_to_str(uint8_t buf[6], unsigned int passkey) { @@ -125,13 +129,11 @@ void auth_passkey_confirm(struct bt_conn *conn, unsigned int passkey) bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); -// num_comp_reply(true); - - uint8_t passkey_str[6]; - passkey_to_str(passkey_str, passkey); - send_pairing_request_event(passkey_str, 6); + uint8_t passkey_str[6]; + passkey_to_str(passkey_str, passkey); + send_pairing_request_event(passkey_str, 6); - send_status_event(); + send_status_event(); }