From 1b22324317ceafc4fc3d1243eba0be371af22e2d Mon Sep 17 00:00:00 2001 From: Lingao Meng Date: Thu, 7 Sep 2023 16:04:00 +0800 Subject: [PATCH] Bluetooth: Mesh: Use system workqueue for dhkey gen 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 --- subsys/bluetooth/mesh/Kconfig | 2 +- subsys/bluetooth/mesh/prov_device.c | 9 ++++++++- subsys/bluetooth/mesh/provisioner.c | 11 ++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/subsys/bluetooth/mesh/Kconfig b/subsys/bluetooth/mesh/Kconfig index f9d4d3bcf98be4..667e80f45ab7a2 100644 --- a/subsys/bluetooth/mesh/Kconfig +++ b/subsys/bluetooth/mesh/Kconfig @@ -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, diff --git a/subsys/bluetooth/mesh/prov_device.c b/subsys/bluetooth/mesh/prov_device.c index 992bf6562022ed..6e56519eefb5bc 100644 --- a/subsys/bluetooth/mesh/prov_device.c +++ b/subsys/bluetooth/mesh/prov_device.c @@ -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)); @@ -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) diff --git a/subsys/bluetooth/mesh/provisioner.c b/subsys/bluetooth/mesh/provisioner.c index 717cdbee610f19..6bf759272dd4fe 100644 --- a/subsys/bluetooth/mesh/provisioner.c +++ b/subsys/bluetooth/mesh/provisioner.c @@ -20,6 +20,8 @@ #include "common/bt_str.h" +#include "host/long_wq.h" + #include "crypto.h" #include "adv.h" #include "mesh.h" @@ -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)); @@ -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)