Skip to content

Commit 98d3225

Browse files
trond-snekviknashif
authored andcommitted
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 <[email protected]>
1 parent 3a42ff9 commit 98d3225

File tree

1 file changed

+7
-23
lines changed
  • subsys/bluetooth/host/mesh

1 file changed

+7
-23
lines changed

subsys/bluetooth/host/mesh/prov.c

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
enum {
109109
REMOTE_PUB_KEY, /* Remote key has been received */
110110
LINK_ACTIVE, /* Link has been opened */
111-
SEND_CONFIRM, /* Waiting to send Confirm value */
112111
WAIT_NUMBER, /* Waiting for number input from user */
113112
WAIT_STRING, /* Waiting for string input from user */
114113
LINK_INVALID, /* Error occurred during provisioning */
@@ -823,6 +822,7 @@ static void send_input_complete(void)
823822
if (prov_send(&buf)) {
824823
BT_ERR("Failed to send Provisioning Input Complete");
825824
}
825+
link.expect = PROV_CONFIRM;
826826
}
827827

828828
int bt_mesh_input_number(u32_t num)
@@ -837,10 +837,6 @@ int bt_mesh_input_number(u32_t num)
837837

838838
send_input_complete();
839839

840-
if (atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
841-
send_confirm();
842-
}
843-
844840
return 0;
845841
}
846842

@@ -856,10 +852,6 @@ int bt_mesh_input_string(const char *str)
856852

857853
send_input_complete();
858854

859-
if (atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
860-
send_confirm();
861-
}
862-
863855
return 0;
864856
}
865857

@@ -902,8 +894,11 @@ static void send_pub_key(const u8_t dhkey[32])
902894
return;
903895
}
904896

905-
atomic_set_bit(link.flags, SEND_CONFIRM);
906-
link.expect = PROV_CONFIRM;
897+
if (atomic_test_bit(link.flags, WAIT_NUMBER) || atomic_test_bit(link.flags, WAIT_STRING)) {
898+
link.expect = 0xff; /* Don't expect any packets until after input */
899+
} else {
900+
link.expect = PROV_CONFIRM;
901+
}
907902
}
908903

909904
static void prov_dh_key_gen(void)
@@ -968,18 +963,7 @@ static void prov_confirm(const u8_t *data)
968963

969964
memcpy(link.conf, data, 16);
970965

971-
if (atomic_test_bit(link.flags, WAIT_NUMBER) ||
972-
atomic_test_bit(link.flags, WAIT_STRING)) {
973-
/* Clear retransmit timer */
974-
#if defined(CONFIG_BT_MESH_PB_ADV)
975-
prov_clear_tx();
976-
#endif
977-
return;
978-
}
979-
980-
if (atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
981-
send_confirm();
982-
}
966+
send_confirm();
983967
}
984968

985969
static void prov_random(const u8_t *data)

0 commit comments

Comments
 (0)