Bluetooth: Clear pairing flag if all keys have been distributed

This fixes the bug that affected pairing as peripheral.
With this patch pairing flag is cleared and timeout timer stops
if all keys has been distributed.

Change-Id: If7575197d5a42a0ca5bb158ea5607934e92abb81
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
Mariusz Skamra 2015-10-07 14:00:16 +02:00 committed by Anas Nashif
commit ab665fbe27

View file

@ -1054,7 +1054,7 @@ static void bt_smp_distribute_keys(struct bt_conn *conn)
sizeof(*info));
if (!buf) {
BT_ERR("Unable to allocate Encrypt Info buffer\n");
goto fail;
return;
}
info = bt_buf_add(buf, sizeof(*info));
@ -1066,7 +1066,7 @@ static void bt_smp_distribute_keys(struct bt_conn *conn)
sizeof(*ident));
if (!buf) {
BT_ERR("Unable to allocate Master Ident buffer\n");
goto fail;
return;
}
ident = bt_buf_add(buf, sizeof(*ident));
@ -1093,7 +1093,7 @@ static void bt_smp_distribute_keys(struct bt_conn *conn)
sizeof(*info));
if (!buf) {
BT_ERR("Unable to allocate Signing Info buffer\n");
goto fail;
return;
}
info = bt_buf_add(buf, sizeof(*info));
@ -1104,13 +1104,6 @@ static void bt_smp_distribute_keys(struct bt_conn *conn)
smp_restart_timer(smp);
}
#endif /* CONFIG_BLUETOOTH_SIGNING */
fail:
/* if all keys were distributed, pairing is done */
if (!smp->local_dist && !smp->remote_dist) {
atomic_clear_bit(&smp->flags, SMP_FLAG_PAIRING);
smp_stop_timer(smp);
}
}
static uint8_t smp_encrypt_info(struct bt_conn *conn, struct bt_buf *buf)
@ -1167,6 +1160,12 @@ static uint8_t smp_master_ident(struct bt_conn *conn, struct bt_buf *buf)
}
#endif /* CONFIG_BLUETOOTH_CENTRAL */
/* if all keys were distributed, pairing is done */
if (!smp->local_dist && !smp->remote_dist) {
atomic_clear_bit(&smp->flags, SMP_FLAG_PAIRING);
smp_stop_timer(smp);
}
return 0;
}
@ -1253,6 +1252,12 @@ static uint8_t smp_ident_addr_info(struct bt_conn *conn, struct bt_buf *buf)
}
#endif /* CONFIG_BLUETOOTH_CENTRAL */
/* if all keys were distributed, pairing is done */
if (!smp->local_dist && !smp->remote_dist) {
atomic_clear_bit(&smp->flags, SMP_FLAG_PAIRING);
smp_stop_timer(smp);
}
return 0;
}
@ -1282,6 +1287,12 @@ static uint8_t smp_signing_info(struct bt_conn *conn, struct bt_buf *buf)
}
#endif /* CONFIG_BLUETOOTH_CENTRAL */
/* if all keys were distributed, pairing is done */
if (!smp->local_dist && !smp->remote_dist) {
atomic_clear_bit(&smp->flags, SMP_FLAG_PAIRING);
smp_stop_timer(smp);
}
return 0;
}
#else
@ -1494,6 +1505,12 @@ static void bt_smp_encrypt_change(struct bt_conn *conn)
#endif /* CONFIG_BLUETOOTH_CENTRAL */
bt_smp_distribute_keys(conn);
/* if all keys were distributed, pairing is done */
if (!smp->local_dist && !smp->remote_dist) {
atomic_clear_bit(&smp->flags, SMP_FLAG_PAIRING);
smp_stop_timer(smp);
}
}
bool bt_smp_irk_matches(const uint8_t irk[16], const bt_addr_t *addr)