Skip to content

Commit e8ea882

Browse files
committed
tests: bluetooth: tester: Add support for pairing failed event
This event is sent if pairing failed. Signed-off-by: Szymon Janc <[email protected]>
1 parent 4c32c86 commit e8ea882

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/bluetooth/tester/src/bttester.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,13 @@ struct gap_bond_lost_ev {
373373
uint8_t address[6];
374374
} __packed;
375375

376+
#define GAP_EV_PAIRING_FAILED 0x8c
377+
struct gap_bond_pairing_failed_ev {
378+
uint8_t address_type;
379+
uint8_t address[6];
380+
uint8_t reason;
381+
} __packed;
382+
376383
/* GATT Service */
377384
/* commands */
378385
#define GATT_READ_SUPPORTED_COMMANDS 0x01

tests/bluetooth/tester/src/gap.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,19 @@ enum bt_security_err auth_pairing_accept(struct bt_conn *conn,
825825
return BT_SECURITY_ERR_SUCCESS;
826826
}
827827

828+
void auth_pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
829+
{
830+
struct gap_bond_pairing_failed_ev ev;
831+
const bt_addr_le_t *addr = bt_conn_get_dst(conn);
832+
833+
memcpy(ev.address, addr->a.val, sizeof(ev.address));
834+
ev.address_type = addr->type;
835+
ev.reason = reason;
836+
837+
tester_send(BTP_SERVICE_ID_GAP, GAP_EV_PAIRING_FAILED, CONTROLLER_INDEX,
838+
(uint8_t *)&ev, sizeof(ev));
839+
}
840+
828841
static void set_io_cap(const uint8_t *data, uint16_t len)
829842
{
830843
const struct gap_set_io_cap_cmd *cmd = (void *) data;
@@ -862,6 +875,7 @@ static void set_io_cap(const uint8_t *data, uint16_t len)
862875
}
863876

864877
cb.pairing_accept = auth_pairing_accept;
878+
cb.pairing_failed = auth_pairing_failed;
865879

866880
if (bt_conn_auth_cb_register(&cb)) {
867881
status = BTP_STATUS_FAILED;

0 commit comments

Comments
 (0)