Bluetooth: Mesh: fix dfu srv applying phase
Commit fixes bug if dfu server failed to deliver apply response it gets stuck in applying phase. In this phase it skips all further client attempts to apply image again. Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
This commit is contained in:
parent
f80e53dcc8
commit
0015ab0f77
1 changed files with 8 additions and 5 deletions
|
@ -78,7 +78,9 @@ static void apply_rsp_sent(int err, void *cb_params)
|
|||
struct bt_mesh_dfu_srv *srv = cb_params;
|
||||
|
||||
if (err) {
|
||||
LOG_WRN("Apply response failed, wait for retry");
|
||||
/* return phase back to give client one more chance. */
|
||||
srv->update.phase = BT_MESH_DFU_PHASE_VERIFY_OK;
|
||||
LOG_WRN("Apply response failed, wait for retry (err %d)", err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,15 +89,18 @@ static void apply_rsp_sent(int err, void *cb_params)
|
|||
if (!srv->cb->apply || srv->update.idx == UPDATE_IDX_NONE) {
|
||||
srv->update.phase = BT_MESH_DFU_PHASE_IDLE;
|
||||
store_state(srv);
|
||||
LOG_DBG("Prerequisites for apply callback are wrong");
|
||||
return;
|
||||
}
|
||||
|
||||
store_state(srv);
|
||||
|
||||
err = srv->cb->apply(srv, &srv->imgs[srv->update.idx]);
|
||||
if (err) {
|
||||
srv->update.phase = BT_MESH_DFU_PHASE_IDLE;
|
||||
store_state(srv);
|
||||
LOG_DBG("Application apply callback failed (err %d)", err);
|
||||
}
|
||||
|
||||
store_state(srv);
|
||||
}
|
||||
|
||||
static void apply_rsp_sending(uint16_t duration, int err, void *cb_params)
|
||||
|
@ -418,8 +423,6 @@ static int handle_apply(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx
|
|||
* case it triggers a reboot:
|
||||
*/
|
||||
srv->update.phase = BT_MESH_DFU_PHASE_APPLYING;
|
||||
store_state(srv);
|
||||
|
||||
update_status_rsp(srv, ctx, BT_MESH_DFU_SUCCESS, &send_cb);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue