From cf8a676ab6b680018c909f5cdfcfde28340fc85f Mon Sep 17 00:00:00 2001 From: Luo Xu Date: Mon, 9 Feb 2026 17:43:16 +0800 Subject: [PATCH] fix(ble_mesh): ensure blob client/server work correctly with varying chunk sizes (cherry picked from commit 3a8851422ff0068c7eafe865151444313e9638a3) Co-authored-by: luoxu --- components/bt/esp_ble_mesh/v1.1/dfu/dfu_cli.c | 15 ++++++++++++++- components/bt/esp_ble_mesh/v1.1/mbt/blob_cli.c | 7 +++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/components/bt/esp_ble_mesh/v1.1/dfu/dfu_cli.c b/components/bt/esp_ble_mesh/v1.1/dfu/dfu_cli.c index 1a771ff0f82..bee0ecacdd7 100644 --- a/components/bt/esp_ble_mesh/v1.1/dfu/dfu_cli.c +++ b/components/bt/esp_ble_mesh/v1.1/dfu/dfu_cli.c @@ -341,8 +341,21 @@ static void blob_caps(struct bt_mesh_blob_cli *b, } cli->xfer.blob.block_size_log = caps->max_block_size_log; +#if CONFIG_BLE_MESH_LONG_PACKET + if (cli->xfer.blob.chunk_enh_params.long_pkt_cfg_used) { + cli->xfer.blob.chunk_size = MIN(caps->max_chunk_size, BLOB_TX_CHUNK_SIZE); + } else { +#if CONFIG_BLE_MESH_ALIGN_CHUNK_SIZE_TO_MAX_SEGMENT || \ + CONFIG_BLE_MESH_TX_BLOB_CHUNK_SIZE > BLOB_CHUNK_SIZE_MAX(BLE_MESH_EXT_TX_SDU_MAX) + cli->xfer.blob.chunk_size = MIN(caps->max_chunk_size, BLOB_CHUNK_SIZE_MAX(BLE_MESH_TX_SDU_MAX)); +#else + cli->xfer.blob.chunk_size = MIN(caps->max_chunk_size, + CONFIG_BLE_MESH_TX_BLOB_CHUNK_SIZE); +#endif + } +#else cli->xfer.blob.chunk_size = caps->max_chunk_size; - +#endif /* If mode is not already set and server reported it supports all modes * default to PUSH, otherwise set value reported by server. If mode * was set and server supports all modes, keep old value; set diff --git a/components/bt/esp_ble_mesh/v1.1/mbt/blob_cli.c b/components/bt/esp_ble_mesh/v1.1/mbt/blob_cli.c index 435ef3b5bcf..985c46b92ac 100644 --- a/components/bt/esp_ble_mesh/v1.1/mbt/blob_cli.c +++ b/components/bt/esp_ble_mesh/v1.1/mbt/blob_cli.c @@ -656,8 +656,11 @@ static void xfer_start_tx(struct bt_mesh_blob_cli *cli, uint16_t dst) net_buf_simple_add_le32(&buf, cli->xfer->size); net_buf_simple_add_u8(&buf, cli->xfer->block_size_log); #if CONFIG_BLE_MESH_LONG_PACKET - /* todo: could let user select methold */ - net_buf_simple_add_le16(&buf, BLE_MESH_EXT_TX_SDU_MAX); + if (cli->xfer->chunk_enh_params.long_pkt_cfg_used) { + net_buf_simple_add_le16(&buf, BLE_MESH_EXT_TX_SDU_MAX); + } else { + net_buf_simple_add_le16(&buf, BLE_MESH_TX_SDU_MAX); + } #else net_buf_simple_add_le16(&buf, BLE_MESH_TX_SDU_MAX); #endif