mirror of
https://github.com/espressif/esp-idf.git
synced 2026-06-07 05:36:32 +03:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user