Bluetooth: Mesh: Fix recovery of WAITING_FOR_START BLOB Server state

If device running BLOB Server called `bt_mesh_blob_srv_recv`,
but rebooted before it received `XFER_START` message from BLOB Client,
it was wrongly "recovered" into Suspended phase, which would lead to
Server try to resume transfer on `XFER_START`. It would not be possible,
because `srv->state.xfer` was not set with acual values yet.

Set phase again to BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_START, which will
allow to accept new transfer.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
This commit is contained in:
Krzysztof Kopyściński 2023-04-07 10:35:24 +02:00 committed by Carles Cufí
commit 0d5c33b045

View file

@ -844,10 +844,19 @@ static int blob_srv_settings_set(struct bt_mesh_model *mod, const char *name,
return 0;
}
phase_set(srv, BT_MESH_BLOB_XFER_PHASE_SUSPENDED);
/* If device restarted before it handled `XFER_START` server we restore state into
* BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_START phase, so `XFER_START` can be accepted
* as it would before reboot
*/
if (srv->state.cli == BT_MESH_ADDR_UNASSIGNED) {
LOG_DBG("Transfer (id=%llu) waiting for start", srv->state.xfer.id);
phase_set(srv, BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_START);
} else {
phase_set(srv, BT_MESH_BLOB_XFER_PHASE_SUSPENDED);
LOG_DBG("Recovered transfer from 0x%04x (%llu)", srv->state.cli,
srv->state.xfer.id);
LOG_DBG("Recovered transfer from 0x%04x (%llu)", srv->state.cli,
srv->state.xfer.id);
}
return 0;
}