Skip to content

Commit a14b830

Browse files
sjanccfriedt
authored andcommitted
test/bluetooth/tester: Re-pair on lost bond
If IUT is acting as a central device and peer lost bond we need to re-pair to restore bond. PTS is not sending any WID for this so bonding needs to be initiated implicitly by IUT. This was affecting GAP/SEC/AUT/BV-25-C qualification test case. Signed-off-by: Szymon Janc <[email protected]>
1 parent 644ebe5 commit a14b830

File tree

1 file changed

+17
-4
lines changed
  • tests/bluetooth/tester/src

1 file changed

+17
-4
lines changed

tests/bluetooth/tester/src/gap.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static void le_security_changed(struct bt_conn *conn, bt_security_t level,
159159
const bt_addr_le_t *addr = bt_conn_get_dst(conn);
160160
struct gap_sec_level_changed_ev sec_ev;
161161
struct gap_bond_lost_ev bond_ev;
162+
struct bt_conn_info info;
162163

163164
switch (err) {
164165
case BT_SECURITY_ERR_SUCCESS:
@@ -171,11 +172,23 @@ static void le_security_changed(struct bt_conn *conn, bt_security_t level,
171172
CONTROLLER_INDEX, (uint8_t *) &sec_ev, sizeof(sec_ev));
172173
break;
173174
case BT_SECURITY_ERR_PIN_OR_KEY_MISSING:
174-
memcpy(bond_ev.address, addr->a.val, sizeof(bond_ev.address));
175-
bond_ev.address_type = addr->type;
175+
/* for central role this means that peer have no LTK when we
176+
* started encryption procedure
177+
*
178+
* This means bond is lost and we restart pairing to re-bond
179+
*/
180+
if (bt_conn_get_info(conn, &info) == 0 &&
181+
info.role == BT_CONN_ROLE_CENTRAL) {
182+
LOG_DBG("Bond lost");
183+
184+
(void)memcpy(bond_ev.address, addr->a.val, sizeof(bond_ev.address));
185+
bond_ev.address_type = addr->type;
176186

177-
tester_send(BTP_SERVICE_ID_GAP, GAP_EV_BOND_LOST,
178-
CONTROLLER_INDEX, (uint8_t *) &bond_ev, sizeof(bond_ev));
187+
tester_send(BTP_SERVICE_ID_GAP, GAP_EV_BOND_LOST,
188+
CONTROLLER_INDEX, (uint8_t *)&bond_ev, sizeof(bond_ev));
189+
190+
(void)bt_conn_set_security(conn, BT_SECURITY_L2 | BT_SECURITY_FORCE_PAIR);
191+
}
179192
break;
180193
default:
181194
break;

0 commit comments

Comments
 (0)