Skip to content

Commit

Permalink
Bluetooth: Mesh: Use system workqueue for dhkey gen
Browse files Browse the repository at this point in the history
Since the default process dhkey gen in bt rx, will block send
Trans Ack, cause peer device send more package.

Signed-off-by: Lingao Meng <[email protected]>
  • Loading branch information
LingaoM authored and carlescufi committed Oct 20, 2023
1 parent 141467a commit 1b22324
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion subsys/bluetooth/mesh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ config BT_MESH_PB_ADV_TRANS_PDU_RETRANSMIT_COUNT

config BT_MESH_PB_ADV_TRANS_ACK_RETRANSMIT_COUNT
int "Link Ack and Transaction Ack retransmit count"
default 2
default 0
range 0 7
help
Controls the number of retransmissions of original Link Open and Transaction Acknowledgment PDU,
Expand Down
9 changes: 8 additions & 1 deletion subsys/bluetooth/mesh/prov_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@ static void prov_dh_key_gen(void)
}
}

static void prov_dh_key_gen_handler(struct k_work *work)
{
prov_dh_key_gen();
}

static K_WORK_DEFINE(dh_gen_work, prov_dh_key_gen_handler);

static void prov_pub_key(const uint8_t *data)
{
LOG_DBG("Remote Public Key: %s", bt_hex(data, PUB_KEY_SIZE));
Expand Down Expand Up @@ -385,7 +392,7 @@ static void prov_pub_key(const uint8_t *data)
PDU_LEN_PUB_KEY);
}

prov_dh_key_gen();
k_work_submit(&dh_gen_work);
}

static void notify_input_complete(void)
Expand Down
11 changes: 10 additions & 1 deletion subsys/bluetooth/mesh/provisioner.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "common/bt_str.h"

#include "host/long_wq.h"

#include "crypto.h"
#include "adv.h"
#include "mesh.h"
Expand Down Expand Up @@ -450,6 +452,13 @@ static void prov_dh_key_gen(void)
send_confirm();
}

static void prov_dh_key_gen_handler(struct k_work *work)
{
prov_dh_key_gen();
}

static K_WORK_DEFINE(dh_gen_work, prov_dh_key_gen_handler);

static void prov_pub_key(const uint8_t *data)
{
LOG_DBG("Remote Public Key: %s", bt_hex(data, PUB_KEY_SIZE));
Expand All @@ -460,7 +469,7 @@ static void prov_pub_key(const uint8_t *data)
memcpy(bt_mesh_prov_link.conf_inputs.pub_key_device, data, PUB_KEY_SIZE);
bt_mesh_prov_link.bearer->clear_tx();

prov_dh_key_gen();
k_work_submit(&dh_gen_work);
}

static void notify_input_complete(void)
Expand Down

0 comments on commit 1b22324

Please sign in to comment.