Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/bluetooth/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,9 @@ enum bt_security_err {
/** Invalid parameters. */
BT_SECURITY_ERR_INVALID_PARAM,

/** Distributed Key Rejected */
BT_SECURITY_ERR_KEY_REJECTED,

/** Pairing failed but the exact reason could not be specified. */
BT_SECURITY_ERR_UNSPECIFIED,
};
Expand Down
2 changes: 2 additions & 0 deletions subsys/bluetooth/host/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ static enum bt_security_err security_err_get(uint8_t smp_err)
return BT_SECURITY_ERR_PAIR_NOT_ALLOWED;
case BT_SMP_ERR_INVALID_PARAMS:
return BT_SECURITY_ERR_INVALID_PARAM;
case BT_SMP_ERR_KEY_REJECTED:
return BT_SECURITY_ERR_KEY_REJECTED;
case BT_SMP_ERR_UNSPECIFIED:
default:
return BT_SECURITY_ERR_UNSPECIFIED;
Expand Down
1 change: 1 addition & 0 deletions subsys/bluetooth/host/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct bt_smp_hdr {
#define BT_SMP_ERR_NUMERIC_COMP_FAILED 0x0c
#define BT_SMP_ERR_BREDR_PAIRING_IN_PROGRESS 0x0d
#define BT_SMP_ERR_CROSS_TRANSP_NOT_ALLOWED 0x0e
#define BT_SMP_ERR_KEY_REJECTED 0x0f

#define BT_SMP_IO_DISPLAY_ONLY 0x00
#define BT_SMP_IO_DISPLAY_YESNO 0x01
Expand Down
7 changes: 7 additions & 0 deletions tests/bluetooth/tester/src/bttester.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,13 @@ struct gap_bond_lost_ev {
uint8_t address[6];
} __packed;

#define GAP_EV_PAIRING_FAILED 0x8c
struct gap_bond_pairing_failed_ev {
uint8_t address_type;
uint8_t address[6];
uint8_t reason;
} __packed;

/* GATT Service */
/* commands */
#define GATT_READ_SUPPORTED_COMMANDS 0x01
Expand Down
14 changes: 14 additions & 0 deletions tests/bluetooth/tester/src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,19 @@ enum bt_security_err auth_pairing_accept(struct bt_conn *conn,
return BT_SECURITY_ERR_SUCCESS;
}

void auth_pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
{
struct gap_bond_pairing_failed_ev ev;
const bt_addr_le_t *addr = bt_conn_get_dst(conn);

memcpy(ev.address, addr->a.val, sizeof(ev.address));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Typically when ignoring return values, we cast to void:

Suggested change
memcpy(ev.address, addr->a.val, sizeof(ev.address));
(void)memcpy(ev.address, addr->a.val, sizeof(ev.address));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjanc - please update

ev.address_type = addr->type;
ev.reason = reason;

tester_send(BTP_SERVICE_ID_GAP, GAP_EV_PAIRING_FAILED, CONTROLLER_INDEX,
(uint8_t *)&ev, sizeof(ev));
}

static void set_io_cap(const uint8_t *data, uint16_t len)
{
const struct gap_set_io_cap_cmd *cmd = (void *) data;
Expand Down Expand Up @@ -862,6 +875,7 @@ static void set_io_cap(const uint8_t *data, uint16_t len)
}

cb.pairing_accept = auth_pairing_accept;
cb.pairing_failed = auth_pairing_failed;

if (bt_conn_auth_cb_register(&cb)) {
status = BTP_STATUS_FAILED;
Expand Down