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 <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
parent
4d59868397
commit
9641864a20
1 changed files with 25 additions and 7 deletions
|
@ -342,9 +342,10 @@ static int handle_apply(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void upload_status_rsp(struct bt_mesh_dfd_srv *srv,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
enum bt_mesh_dfd_status status)
|
||||
static void upload_status_rsp_with_progress(struct bt_mesh_dfd_srv *srv,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
enum bt_mesh_dfd_status status,
|
||||
uint8_t progress)
|
||||
{
|
||||
BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_DFD_OP_UPLOAD_STATUS,
|
||||
DFD_UPLOAD_STATUS_MSG_MAXLEN);
|
||||
|
@ -361,14 +362,13 @@ static void upload_status_rsp(struct bt_mesh_dfd_srv *srv,
|
|||
|
||||
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
|
||||
if (srv->upload.is_oob) {
|
||||
net_buf_simple_add_u8(&rsp,
|
||||
srv->cb->oob_progress_get(srv, srv->upload.slot) | BIT(7));
|
||||
net_buf_simple_add_u8(&rsp, progress | BIT(7));
|
||||
net_buf_simple_add_mem(&rsp, srv->upload.oob.current_fwid,
|
||||
srv->upload.oob.current_fwid_len);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
net_buf_simple_add_u8(&rsp, bt_mesh_blob_srv_progress(&srv->upload.blob));
|
||||
net_buf_simple_add_u8(&rsp, progress);
|
||||
net_buf_simple_add_mem(&rsp, srv->upload.slot->fwid,
|
||||
srv->upload.slot->fwid_len);
|
||||
}
|
||||
|
@ -376,6 +376,24 @@ static void upload_status_rsp(struct bt_mesh_dfd_srv *srv,
|
|||
bt_mesh_model_send(srv->mod, ctx, &rsp, NULL, NULL);
|
||||
}
|
||||
|
||||
static void upload_status_rsp(struct bt_mesh_dfd_srv *srv,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
enum bt_mesh_dfd_status status)
|
||||
{
|
||||
uint8_t progress;
|
||||
|
||||
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
|
||||
if (srv->upload.is_oob) {
|
||||
progress = srv->cb->oob_progress_get(srv, srv->upload.slot);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
progress = bt_mesh_blob_srv_progress(&srv->upload.blob);
|
||||
}
|
||||
|
||||
upload_status_rsp_with_progress(srv, ctx, status, progress);
|
||||
}
|
||||
|
||||
static int handle_upload_get(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -400,7 +418,7 @@ static inline int set_upload_fwid(struct bt_mesh_dfd_srv *srv, struct bt_mesh_ms
|
|||
case -EEXIST: /* Img with this fwid already is in list */
|
||||
srv->upload.phase = BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_SUCCESS;
|
||||
bt_mesh_dfu_slot_release(srv->upload.slot);
|
||||
upload_status_rsp(srv, ctx, BT_MESH_DFD_SUCCESS);
|
||||
upload_status_rsp_with_progress(srv, ctx, BT_MESH_DFD_SUCCESS, 100);
|
||||
break;
|
||||
case 0:
|
||||
srv->upload.phase = BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_ACTIVE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue