From 48ed28e5799a18b42d45fb7e7f2a63de57edea25 Mon Sep 17 00:00:00 2001 From: Luo Xu Date: Mon, 9 Feb 2026 17:43:20 +0800 Subject: [PATCH] fix(ble_mesh): Miscellaneous fixes for blob (cherry picked from commit c3faf5559a3e815f8d09489743dd902df12a97fb) Co-authored-by: luoxu --- components/bt/esp_ble_mesh/v1.1/dfu/dfu_cli.c | 14 ++++++++------ components/bt/esp_ble_mesh/v1.1/mbt/blob_srv.c | 10 ++++++---- 2 files changed, 14 insertions(+), 10 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 21eea26d437..1a771ff0f82 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 @@ -887,15 +887,16 @@ static int handle_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx rsp->timeout_base = net_buf_simple_pull_le16(buf); rsp->blob_id = net_buf_simple_pull_le64(buf); rsp->img_idx = net_buf_simple_pull_u8(buf); - } else if (buf->len) { + } else if (buf->len == 0) { + rsp->ttl = 0U; + rsp->effect = BLE_MESH_DFU_EFFECT_NONE; + rsp->timeout_base = 0U; + rsp->blob_id = 0U; + rsp->img_idx = 0U; + } else { return -EINVAL; } - rsp->ttl = 0U; - rsp->effect = BLE_MESH_DFU_EFFECT_NONE; - rsp->timeout_base = 0U; - rsp->blob_id = 0U; - rsp->img_idx = 0U; } bt_mesh_dfu_client_cb_evt_to_btc(req->opcode, BTC_BLE_MESH_EVT_DFU_CLIENT_RECV_GET_RSP, req->dfu_cli->mod, &req->ctx, req->params, @@ -904,6 +905,7 @@ static int handle_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx bt_mesh_dfu_cli_rm_req_from_list(req); k_delayed_work_cancel(&req->timer); req_free(req); + return 0; } if (cli->op != BLE_MESH_DFU_OP_UPDATE_STATUS) { diff --git a/components/bt/esp_ble_mesh/v1.1/mbt/blob_srv.c b/components/bt/esp_ble_mesh/v1.1/mbt/blob_srv.c index 88fe61ad0bc..dc61e14c09e 100644 --- a/components/bt/esp_ble_mesh/v1.1/mbt/blob_srv.c +++ b/components/bt/esp_ble_mesh/v1.1/mbt/blob_srv.c @@ -777,9 +777,7 @@ static int handle_chunk(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, if (idx == srv->block.chunk_count - 1) { expected_size = srv->block.size % srv->state.xfer.chunk_size; - } - - if (expected_size == 0) { + } else { expected_size = srv->state.xfer.chunk_size; } @@ -804,7 +802,11 @@ static int handle_chunk(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, * complete. */ if (srv->phase == BT_MESH_BLOB_XFER_PHASE_SUSPENDED) { - phase_set(srv, BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_CHUNK); + if(missing_chunks(&srv->block)) { + phase_set(srv, BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_CHUNK); + } else { + phase_set(srv, BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_BLOCK); + } } BT_INFO("%u/%u (%u bytes)", idx + 1, srv->block.chunk_count,