|
2 | 2 |
|
3 | 3 | /* |
4 | 4 | * 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 |
6 | 6 | * |
7 | 7 | * SPDX-License-Identifier: Apache-2.0 |
8 | 8 | */ |
@@ -1129,23 +1129,34 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, |
1129 | 1129 | if (((IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) || |
1130 | 1130 | (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en())) && |
1131 | 1131 | (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 | + } |
1135 | 1142 |
|
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)); |
1137 | 1144 |
|
1138 | | - if (cb && cb->end) { |
1139 | | - cb->end(0, cb_data); |
1140 | | - } |
| 1145 | + if (cb && cb->end) { |
| 1146 | + cb->end(0, cb_data); |
| 1147 | + } |
1141 | 1148 |
|
1142 | | - bt_mesh_net_local(); |
| 1149 | + bt_mesh_net_local(); |
| 1150 | + |
| 1151 | + err = 0; |
1143 | 1152 |
|
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)) { |
1147 | 1153 | goto done; |
| 1154 | + } else { |
| 1155 | + net_buf_slist_put(&bt_mesh.local_queue, net_buf_ref(buf)); |
| 1156 | + bt_mesh_net_local(); |
1148 | 1157 | } |
| 1158 | + |
| 1159 | + err = 0; |
1149 | 1160 | } |
1150 | 1161 |
|
1151 | 1162 | if ((bearer & BLE_MESH_ADV_BEARER) && |
|
0 commit comments