From 10bffaebf1fa232761ad593edf500bb696a81686 Mon Sep 17 00:00:00 2001 From: lly Date: Mon, 2 Sep 2019 15:03:42 +0800 Subject: [PATCH] ble_mesh: fix resending segments on correct bearer --- components/bt/esp_ble_mesh/mesh_core/net.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/bt/esp_ble_mesh/mesh_core/net.c b/components/bt/esp_ble_mesh/mesh_core/net.c index 79d27c70d6..4e3cac55c7 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.c +++ b/components/bt/esp_ble_mesh/mesh_core/net.c @@ -731,6 +731,7 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, { const u8_t *enc, *priv; u32_t seq; + u16_t dst; int err; BT_DBG("net_idx 0x%04x new_key %u len %u", sub->net_idx, new_key, @@ -757,6 +758,9 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, buf->data[3] = seq >> 8; buf->data[4] = seq; + /* Get destination, in case it's a proxy client */ + dst = DST(buf->data); + err = bt_mesh_net_encrypt(enc, &buf->b, BLE_MESH_NET_IVI_TX, false); if (err) { BT_ERR("%s, Encrypt failed (err %d)", __func__, err); @@ -769,7 +773,12 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, return err; } - bt_mesh_adv_send(buf, cb, cb_data); + if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY) && + bt_mesh_proxy_relay(&buf->b, dst)) { + net_buf_unref(buf); + } else { + bt_mesh_adv_send(buf, cb, cb_data); + } if (!bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS) && bt_mesh.seq > IV_UPDATE_SEQ_LIMIT) { -- 2.40.0