Bluetooth: Mesh: Ignore duplicate OOB upload request

If a Fw Distribution Client sends the Upload OOB Start message, but the
application layer didn't call bt_mesh_dfd_srv_oob_check_complete yet,
we have no other option other than ignore the message. The next phase
in this case could be Transfer Active, Transfer Success or Failed and it
will be set only after Check Firmware OOB procedure completes.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
Pavel Vasilyev 2023-10-10 10:52:46 +02:00 committed by Johan Hedberg
commit 7154f356af
2 changed files with 12 additions and 1 deletions

View file

@ -228,6 +228,7 @@ struct bt_mesh_dfd_srv {
struct bt_mesh_blob_srv blob; struct bt_mesh_blob_srv blob;
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD #ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
bool is_oob; bool is_oob;
bool is_pending_oob_check;
struct { struct {
uint8_t uri_len; uint8_t uri_len;
uint8_t uri[CONFIG_BT_MESH_DFU_URI_MAXLEN]; uint8_t uri[CONFIG_BT_MESH_DFU_URI_MAXLEN];

View file

@ -586,6 +586,11 @@ static int handle_upload_start_oob(struct bt_mesh_model *mod, struct bt_mesh_msg
#endif #endif
upload_status_rsp(srv, ctx, BT_MESH_DFD_ERR_BUSY_WITH_UPLOAD); upload_status_rsp(srv, ctx, BT_MESH_DFD_ERR_BUSY_WITH_UPLOAD);
return 0; return 0;
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
} else if (srv->upload.is_oob && srv->upload.is_pending_oob_check) {
/* Ignore the request if we didn't confirm the previous one. */
return 0;
#endif
} }
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD #ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
@ -618,6 +623,8 @@ static int handle_upload_start_oob(struct bt_mesh_model *mod, struct bt_mesh_msg
if (status != BT_MESH_DFD_SUCCESS) { if (status != BT_MESH_DFD_SUCCESS) {
upload_status_rsp(srv, ctx, status); upload_status_rsp(srv, ctx, status);
bt_mesh_dfu_slot_release(srv->upload.slot); bt_mesh_dfu_slot_release(srv->upload.slot);
} else {
srv->upload.is_pending_oob_check = true;
} }
#else #else
upload_status_rsp(srv, ctx, BT_MESH_DFD_ERR_URI_NOT_SUPPORTED); upload_status_rsp(srv, ctx, BT_MESH_DFD_ERR_URI_NOT_SUPPORTED);
@ -1211,13 +1218,16 @@ int bt_mesh_dfd_srv_oob_check_complete(struct bt_mesh_dfd_srv *srv,
int err; int err;
if (slot != srv->upload.slot || !srv->upload.is_oob || if (slot != srv->upload.slot || !srv->upload.is_oob ||
srv->upload.phase == BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_ACTIVE) { srv->upload.phase == BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_ACTIVE ||
!srv->upload.is_pending_oob_check) {
/* This should not happen, unless the application calls the function with a /* This should not happen, unless the application calls the function with a
* "wrong" pointer or at a wrong time. * "wrong" pointer or at a wrong time.
*/ */
return -EINVAL; return -EINVAL;
} }
srv->upload.is_pending_oob_check = false;
if (status != BT_MESH_DFD_SUCCESS) { if (status != BT_MESH_DFD_SUCCESS) {
bt_mesh_dfu_slot_release(srv->upload.slot); bt_mesh_dfu_slot_release(srv->upload.slot);
upload_status_rsp(srv, &srv->upload.oob.ctx, status); upload_status_rsp(srv, &srv->upload.oob.ctx, status);