From 63ba58e9a80aac5cb725c46b303e95e83f030c7b Mon Sep 17 00:00:00 2001 From: Liu Linyan Date: Tue, 20 Feb 2024 16:27:41 +0800 Subject: [PATCH] fix(ble_mesh): Fix compiling error when PB-ADV is disabled Closes https://github.com/espressif/esp-idf/issues/13203 --- components/bt/esp_ble_mesh/core/prov_common.c | 12 ++++++++++++ components/bt/esp_ble_mesh/core/prov_node.c | 6 ------ components/bt/esp_ble_mesh/lib/ext.c | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/components/bt/esp_ble_mesh/core/prov_common.c b/components/bt/esp_ble_mesh/core/prov_common.c index db3ee869a4..655c4712f2 100644 --- a/components/bt/esp_ble_mesh/core/prov_common.c +++ b/components/bt/esp_ble_mesh/core/prov_common.c @@ -141,6 +141,11 @@ bool bt_mesh_prov_pdu_check(uint8_t type, uint16_t length, uint8_t *reason) #define XACT_SEG_DATA(link, _seg) (&link->rx.buf->data[20 + (((_seg) - 1) * 23)]) #define XACT_SEG_RECV(link, _seg) (link->rx.seg &= ~(1 << (_seg))) +static uint8_t bt_mesh_prov_buf_type_get(struct net_buf_simple *buf) +{ + return buf->data[PROV_BUF_HEADROOM]; +} + uint8_t node_next_xact_id(struct bt_mesh_prov_link *link) { if (link->tx.id != 0 && link->tx.id != 0xFF) { @@ -677,6 +682,13 @@ int bt_mesh_prov_send(struct bt_mesh_prov_link *link, struct net_buf_simple *buf #endif /* CONFIG_BLE_MESH_PB_GATT */ #if CONFIG_BLE_MESH_PB_ADV + if (bt_mesh_prov_buf_type_get(buf) == PROV_FAILED) { + /* For case MESH/NODE/PROV/BV-10-C, Node must send Transaction + * ACK before Provisioning Failed message is transmitted. + */ + bt_mesh_gen_prov_ack_send(link, link->rx.id); + } + return bt_mesh_prov_send_adv(link, buf); #endif /* CONFIG_BLE_MESH_PB_ADV */ diff --git a/components/bt/esp_ble_mesh/core/prov_node.c b/components/bt/esp_ble_mesh/core/prov_node.c index bf6bb3cb85..4871a1cb1e 100644 --- a/components/bt/esp_ble_mesh/core/prov_node.c +++ b/components/bt/esp_ble_mesh/core/prov_node.c @@ -179,12 +179,6 @@ static void prov_send_fail_msg(uint8_t err) { PROV_BUF(buf, 2); - /** - * For the case MESH/NODE/PROV/BV-10-C, Node must send Transaction ACK - * before Provisioning Failed message is transmitted. - */ - bt_mesh_gen_prov_ack_send(&prov_link, prov_link.rx.id); - bt_mesh_prov_buf_init(&buf, PROV_FAILED); net_buf_simple_add_u8(&buf, err); diff --git a/components/bt/esp_ble_mesh/lib/ext.c b/components/bt/esp_ble_mesh/lib/ext.c index 3208ebb72a..ca77996076 100644 --- a/components/bt/esp_ble_mesh/lib/ext.c +++ b/components/bt/esp_ble_mesh/lib/ext.c @@ -1311,13 +1311,13 @@ void bt_mesh_ext_prov_clear_tx(void *link, bool cancel) uint8_t bt_mesh_ext_prov_node_next_xact_id(void *link) { -#if CONFIG_BLE_MESH_NODE +#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_ADV extern uint8_t node_next_xact_id(struct bt_mesh_prov_link *link); return node_next_xact_id(link); #else assert(0); return 0; -#endif /* CONFIG_BLE_MESH_NODE */ +#endif /* CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_ADV */ } void *bt_mesh_ext_prov_node_get_link(void)