mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-11 17:52:00 +03:00
fix(ble_mesh): resolve issues in long packet mode
- Fix ignored extended advertising parameters from application - Fix incorrect filtering of extended advertising reports - Fix segmentation logic errors in long packet mode
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -32,6 +32,27 @@ static inline void btc_ble_mesh_set_client_common_param(esp_ble_mesh_client_comm
|
||||
output->ctx.send_cred = input->ctx.send_cred;
|
||||
output->ctx.send_tag = input->ctx.send_tag;
|
||||
output->msg_timeout = input->msg_timeout;
|
||||
if (input->ctx.enh.adv_cfg_used) {
|
||||
output->ctx.enh.adv_cfg_used = input->ctx.enh.adv_cfg_used;
|
||||
output->ctx.enh.adv_cfg.adv_cnt = input->ctx.enh.adv_cfg.adv_cnt;
|
||||
output->ctx.enh.adv_cfg.adv_itvl = input->ctx.enh.adv_cfg.adv_itvl;
|
||||
output->ctx.enh.adv_cfg.channel_map = input->ctx.enh.adv_cfg.channel_map;
|
||||
}
|
||||
#if CONFIG_BLE_MESH_EXT_ADV
|
||||
if (input->ctx.enh.ext_adv_cfg_used) {
|
||||
output->ctx.enh.ext_adv_cfg_used = input->ctx.enh.ext_adv_cfg_used;
|
||||
output->ctx.enh.ext_adv_cfg.primary_phy = input->ctx.enh.ext_adv_cfg.primary_phy;
|
||||
output->ctx.enh.ext_adv_cfg.secondary_phy = input->ctx.enh.ext_adv_cfg.secondary_phy;
|
||||
output->ctx.enh.ext_adv_cfg.include_tx_power = input->ctx.enh.ext_adv_cfg.include_tx_power;
|
||||
output->ctx.enh.ext_adv_cfg.tx_power = input->ctx.enh.ext_adv_cfg.tx_power;
|
||||
}
|
||||
#if CONFIG_BLE_MESH_LONG_PACKET
|
||||
if (input->ctx.enh.long_pkt_cfg_used) {
|
||||
output->ctx.enh.long_pkt_cfg_used = input->ctx.enh.long_pkt_cfg_used;
|
||||
output->ctx.enh.long_pkt_cfg = input->ctx.enh.long_pkt_cfg;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -430,6 +430,9 @@ static void bt_mesh_scan_cb(struct bt_mesh_adv_report *adv_rpt)
|
||||
#endif
|
||||
adv_rpt->adv_type != BLE_MESH_ADV_NONCONN_IND &&
|
||||
adv_rpt->adv_type != BLE_MESH_ADV_IND
|
||||
#if CONFIG_BLE_MESH_EXT_ADV
|
||||
&& adv_rpt->adv_type != BLE_MESH_EXT_ADV_NONCONN_IND
|
||||
#endif
|
||||
#if CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_RPR_SRV_ACTIVE_SCAN
|
||||
&& adv_rpt->adv_type != BLE_MESH_ADV_SCAN_RSP
|
||||
#endif
|
||||
|
||||
@@ -800,16 +800,19 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg,
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_LONG_PACKET
|
||||
if (tx->ctx->enh.long_pkt_cfg_used == true &&
|
||||
(tx->ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_FORCE ||
|
||||
tx->ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_PREFER) &&
|
||||
msg->len > BLE_MESH_EXT_SDU_UNSEG_MAX) {
|
||||
if (tx->ctx->enh.long_pkt_cfg_used == true) {
|
||||
if (tx->ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_FORCE &&
|
||||
msg->len > BLE_MESH_EXT_SDU_UNSEG_MAX) {
|
||||
tx->ctx->send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
} else if (tx->ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_PREFER &&
|
||||
msg->len > BLE_MESH_SDU_UNSEG_MAX) {
|
||||
tx->ctx->send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
} else {
|
||||
if (msg->len > BLE_MESH_SDU_UNSEG_MAX) {
|
||||
tx->ctx->send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (msg->len > BLE_MESH_SDU_UNSEG_MAX) {
|
||||
tx->ctx->send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (msg->len > BLE_MESH_SDU_UNSEG_MAX) {
|
||||
tx->ctx->send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
|
||||
@@ -1151,11 +1151,14 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg,
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_LONG_PACKET
|
||||
if (tx->ctx->enh.long_pkt_cfg_used == true &&
|
||||
(tx->ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_FORCE ||
|
||||
tx->ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_PREFER) &&
|
||||
msg->len > BLE_MESH_EXT_SDU_UNSEG_MAX) {
|
||||
tx->ctx->send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
if (tx->ctx->enh.long_pkt_cfg_used == true) {
|
||||
if (tx->ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_FORCE &&
|
||||
msg->len > BLE_MESH_EXT_SDU_UNSEG_MAX) {
|
||||
tx->ctx->send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
} else if (tx->ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_PREFER &&
|
||||
msg->len > BLE_MESH_SDU_UNSEG_MAX) {
|
||||
tx->ctx->send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
}
|
||||
} else {
|
||||
if (msg->len > BLE_MESH_SDU_UNSEG_MAX) {
|
||||
tx->ctx->send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -183,12 +183,28 @@ static int32_t bt_mesh_client_calc_timeout(struct bt_mesh_msg_ctx *ctx,
|
||||
{
|
||||
int32_t seg_rtx_to = 0, duration = 0, time = 0;
|
||||
uint8_t seg_count = 0, seg_rtx_num = 0;
|
||||
bool need_seg = false;
|
||||
bool need_seg = bt_mesh_tag_send_segmented(ctx->send_tag);
|
||||
uint8_t mic_size = 0;
|
||||
|
||||
if (msg->len > BLE_MESH_SDU_UNSEG_MAX ||
|
||||
bt_mesh_tag_send_segmented(ctx->send_tag)) {
|
||||
need_seg = true; /* Needs segmentation */
|
||||
if (!need_seg) {
|
||||
#if CONFIG_BLE_MESH_LONG_PACKET
|
||||
if (ctx->enh.long_pkt_cfg_used == true) {
|
||||
if ((ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_FORCE &&
|
||||
msg->len > BLE_MESH_EXT_SDU_UNSEG_MAX) ||
|
||||
(ctx->enh.long_pkt_cfg == BLE_MESH_LONG_PACKET_PREFER &&
|
||||
msg->len > BLE_MESH_SDU_UNSEG_MAX)) {
|
||||
need_seg = true; /* Needs segmentation */
|
||||
}
|
||||
} else {
|
||||
if (msg->len > BLE_MESH_SDU_UNSEG_MAX) {
|
||||
need_seg = true; /* Needs segmentation */
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (msg->len > BLE_MESH_SDU_UNSEG_MAX) {
|
||||
need_seg = true; /* Needs segmentation */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
mic_size = (need_seg && ctx->send_szmic == BLE_MESH_SEG_SZMIC_LONG &&
|
||||
|
||||
Reference in New Issue
Block a user