fix(ble_mesh): fix blob transfer failure handling and chunk processing

- Fix DFU server transfer error state ordering to ensure proper callback delivery
- Add validation to discard chunks when blob server is not in busy state
- Prevent chunk processing when server is not in active transfer state


(cherry picked from commit f959884b2f)

Co-authored-by: luoxu <luoxu@espressif.com>
This commit is contained in:
Luo Xu
2026-02-09 17:43:21 +08:00
parent af56fc5332
commit 7a82ca0e39
2 changed files with 11 additions and 1 deletions

View File

@@ -530,8 +530,13 @@ static void blob_end(struct bt_mesh_blob_srv *b, uint64_t id, bool success)
BT_DBG("success: %u", success);
if (!success) {
srv->update.phase = BLE_MESH_DFU_PHASE_TRANSFER_ERR;
/**
* Changed by Espressif,
* The xfer_failed must be executed before updating the state;
* otherwise, the end_cb inside xfer_failed will never be delivered.
*/
xfer_failed(srv);
srv->update.phase = BLE_MESH_DFU_PHASE_TRANSFER_ERR;
return;
}

View File

@@ -751,6 +751,11 @@ static int handle_chunk(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx,
chunk.data = net_buf_simple_pull_mem(buf, chunk.size);
chunk.offset = idx * srv->state.xfer.chunk_size;
if (!bt_mesh_blob_srv_is_busy(srv)) {
BT_ERR("Discord chunk(%d), because the blob server is not busy(%d)", idx, srv->phase);
return -EINVAL;
}
if (srv->phase == BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_BLOCK ||
srv->phase == BT_MESH_BLOB_XFER_PHASE_COMPLETE) {
// This Block is already complete received.