Skip to content

Commit 5515278

Browse files
PavelVPVrlubos
authored andcommitted
[nrf fromtree] Bluetooth: Mesh: Fix Upload Progress for already received fw
In OOB upload, when Check Firmware OOB procedure completes successfully and the firmware is already received, we send Firmware Distribution Upload Status message with update Phase set to Transfer Success. In this case, we must set Upload Progress to 100%. This can't be done through the callback as the application layer doesn't yet know that the firmware is already received. This will happen by the exist from bt_mesh_dfd_srv_oob_check_complete function, which will return error code -EEXIST. Signed-off-by: Pavel Vasilyev <[email protected]> (cherry picked from commit 9641864)
1 parent 8513132 commit 5515278

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

subsys/bluetooth/mesh/dfd_srv.c

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,10 @@ static int handle_apply(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx,
342342
return 0;
343343
}
344344

345-
static void upload_status_rsp(struct bt_mesh_dfd_srv *srv,
346-
struct bt_mesh_msg_ctx *ctx,
347-
enum bt_mesh_dfd_status status)
345+
static void upload_status_rsp_with_progress(struct bt_mesh_dfd_srv *srv,
346+
struct bt_mesh_msg_ctx *ctx,
347+
enum bt_mesh_dfd_status status,
348+
uint8_t progress)
348349
{
349350
BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_DFD_OP_UPLOAD_STATUS,
350351
DFD_UPLOAD_STATUS_MSG_MAXLEN);
@@ -361,21 +362,38 @@ static void upload_status_rsp(struct bt_mesh_dfd_srv *srv,
361362

362363
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
363364
if (srv->upload.is_oob) {
364-
net_buf_simple_add_u8(&rsp,
365-
srv->cb->oob_progress_get(srv, srv->upload.slot) | BIT(7));
365+
net_buf_simple_add_u8(&rsp, progress | BIT(7));
366366
net_buf_simple_add_mem(&rsp, srv->upload.oob.current_fwid,
367367
srv->upload.oob.current_fwid_len);
368368
} else
369369
#endif
370370
{
371-
net_buf_simple_add_u8(&rsp, bt_mesh_blob_srv_progress(&srv->upload.blob));
371+
net_buf_simple_add_u8(&rsp, progress);
372372
net_buf_simple_add_mem(&rsp, srv->upload.slot->fwid,
373373
srv->upload.slot->fwid_len);
374374
}
375375

376376
bt_mesh_model_send(srv->mod, ctx, &rsp, NULL, NULL);
377377
}
378378

379+
static void upload_status_rsp(struct bt_mesh_dfd_srv *srv,
380+
struct bt_mesh_msg_ctx *ctx,
381+
enum bt_mesh_dfd_status status)
382+
{
383+
uint8_t progress;
384+
385+
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
386+
if (srv->upload.is_oob) {
387+
progress = srv->cb->oob_progress_get(srv, srv->upload.slot);
388+
} else
389+
#endif
390+
{
391+
progress = bt_mesh_blob_srv_progress(&srv->upload.blob);
392+
}
393+
394+
upload_status_rsp_with_progress(srv, ctx, status, progress);
395+
}
396+
379397
static int handle_upload_get(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx,
380398
struct net_buf_simple *buf)
381399
{
@@ -400,7 +418,7 @@ static inline int set_upload_fwid(struct bt_mesh_dfd_srv *srv, struct bt_mesh_ms
400418
case -EEXIST: /* Img with this fwid already is in list */
401419
srv->upload.phase = BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_SUCCESS;
402420
bt_mesh_dfu_slot_release(srv->upload.slot);
403-
upload_status_rsp(srv, ctx, BT_MESH_DFD_SUCCESS);
421+
upload_status_rsp_with_progress(srv, ctx, BT_MESH_DFD_SUCCESS, 100);
404422
break;
405423
case 0:
406424
srv->upload.phase = BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_ACTIVE;

0 commit comments

Comments
 (0)