Bluetooth: Mesh: Prov confirm tx after confirm rx

According to Mesh Profile Specification 1.0.1 Figure 5.17, the
unprovisioned device should send its confirmation value after the
provisioner sends theirs. Previously, the confirmation value would be
sent immediately after OOB input complete. Now it first waits for the
input data, then from confirmation from the provisioner before sending
the confirmation.

Fixes: #18178.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This commit is contained in:
Trond Einar Snekvik 2019-08-16 10:56:51 +02:00 committed by Johan Hedberg
parent 7ea5ec8baf
commit d408f4afe5

View file

@ -108,7 +108,6 @@
enum {
REMOTE_PUB_KEY, /* Remote key has been received */
LINK_ACTIVE, /* Link has been opened */
SEND_CONFIRM, /* Waiting to send Confirm value */
WAIT_NUMBER, /* Waiting for number input from user */
WAIT_STRING, /* Waiting for string input from user */
LINK_INVALID, /* Error occurred during provisioning */
@ -823,6 +822,7 @@ static void send_input_complete(void)
if (prov_send(&buf)) {
BT_ERR("Failed to send Provisioning Input Complete");
}
link.expect = PROV_CONFIRM;
}
int bt_mesh_input_number(u32_t num)
@ -837,10 +837,6 @@ int bt_mesh_input_number(u32_t num)
send_input_complete();
if (atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
send_confirm();
}
return 0;
}
@ -856,10 +852,6 @@ int bt_mesh_input_string(const char *str)
send_input_complete();
if (atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
send_confirm();
}
return 0;
}
@ -902,8 +894,11 @@ static void send_pub_key(const u8_t dhkey[32])
return;
}
atomic_set_bit(link.flags, SEND_CONFIRM);
link.expect = PROV_CONFIRM;
if (atomic_test_bit(link.flags, WAIT_NUMBER) || atomic_test_bit(link.flags, WAIT_STRING)) {
link.expect = 0xff; /* Don't expect any packets until after input */
} else {
link.expect = PROV_CONFIRM;
}
}
static void prov_dh_key_gen(void)
@ -968,18 +963,7 @@ static void prov_confirm(const u8_t *data)
memcpy(link.conf, data, 16);
if (atomic_test_bit(link.flags, WAIT_NUMBER) ||
atomic_test_bit(link.flags, WAIT_STRING)) {
/* Clear retransmit timer */
#if defined(CONFIG_BT_MESH_PB_ADV)
prov_clear_tx();
#endif
return;
}
if (atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
send_confirm();
}
send_confirm();
}
static void prov_random(const u8_t *data)