Skip to content

Commit 5c39705

Browse files
committed
fix(ble_mesh): fixed BLEMESH24-76
1 parent e0991fa commit 5c39705

File tree

1 file changed

+23
-12
lines changed
  • components/bt/esp_ble_mesh/core

1 file changed

+23
-12
lines changed

components/bt/esp_ble_mesh/core/net.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/*
44
* SPDX-FileCopyrightText: 2017 Intel Corporation
5-
* SPDX-FileContributor: 2018-2022 Espressif Systems (Shanghai) CO LTD
5+
* SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD
66
*
77
* SPDX-License-Identifier: Apache-2.0
88
*/
@@ -1129,23 +1129,34 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
11291129
if (((IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) ||
11301130
(IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en())) &&
11311131
(bt_mesh_fixed_group_match(tx->ctx->addr) || bt_mesh_elem_find(tx->ctx->addr))) {
1132-
if (cb && cb->start) {
1133-
cb->start(0, 0, cb_data);
1134-
}
1132+
/**
1133+
* If the target address isn't a unicast address, then the callback function
1134+
* will be called by `adv task` in place of here, to avoid the callback function
1135+
* being called twice.
1136+
* See BLEMESH24-76 for more details.
1137+
*/
1138+
if (BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) {
1139+
if (cb && cb->start) {
1140+
cb->start(0, 0, cb_data);
1141+
}
11351142

1136-
net_buf_slist_put(&bt_mesh.local_queue, net_buf_ref(buf));
1143+
net_buf_slist_put(&bt_mesh.local_queue, net_buf_ref(buf));
11371144

1138-
if (cb && cb->end) {
1139-
cb->end(0, cb_data);
1140-
}
1145+
if (cb && cb->end) {
1146+
cb->end(0, cb_data);
1147+
}
11411148

1142-
bt_mesh_net_local();
1149+
bt_mesh_net_local();
1150+
1151+
err = 0;
11431152

1144-
err = 0;
1145-
/* If it is a group address, it still needs to be relayed */
1146-
if (BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) {
11471153
goto done;
1154+
} else {
1155+
net_buf_slist_put(&bt_mesh.local_queue, net_buf_ref(buf));
1156+
bt_mesh_net_local();
11481157
}
1158+
1159+
err = 0;
11491160
}
11501161

11511162
if ((bearer & BLE_MESH_ADV_BEARER) &&

0 commit comments

Comments
 (0)