Skip to content

Commit

Permalink
fix unexpected paring attempts, remove user phy update request
Browse files Browse the repository at this point in the history
  • Loading branch information
TychoVrahe committed Nov 12, 2024
1 parent c7c0491 commit 6fa999d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 22 additions & 20 deletions app/src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ void connected(struct bt_conn *conn, uint8_t err)
//
// bt_conn_le_param_update(conn, &params);

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();
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();

}

Expand Down

0 comments on commit 6fa999d

Please sign in to comment.