Skip to content

Commit

Permalink
net: lwm2m: Publicize firmware block context
Browse files Browse the repository at this point in the history
This change is to allow access to the firmware block context in order to
give the firmware update callback implementation an indication of when
to reset the flash context. Additionally, it allows for a validity check
between the total expected size downloaded and the actual size
downloaded. A simple implementation can check if the block context's
current downloaded blocks is equal to the expected block size in order
to determine if the flash context needs to be reset. This approach
seemed the simplest, and knowing the firmware block context can have
other purposes. This has been tested by accessing the block context
during the update in the block received callback and confirming that the
callback had information regarding the current downloaded bytes.

Fixes #16122

Signed-off-by: Kyle Sun <yaomon18@yahoo.com>
  • Loading branch information
yaomon authored and carlescufi committed Apr 9, 2020
1 parent db40071 commit a9b9264
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/net/lwm2m.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@ void lwm2m_firmware_set_update_cb(lwm2m_engine_user_cb_t cb);
* @return A registered callback function to receive the execute event.
*/
lwm2m_engine_user_cb_t lwm2m_firmware_get_update_cb(void);

/**
* @brief Get the block context of the current firmware block.
*
* @param[out] ctx A buffer to store the block context.
*/
struct coap_block_context *lwm2m_firmware_get_block_context();
#endif
#endif

Expand Down
10 changes: 10 additions & 0 deletions subsys/net/lib/lwm2m/lwm2m_obj_firmware_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,13 @@ int lwm2m_firmware_start_transfer(char *package_uri)

return 0;
}

/**
* @brief Get the block context of the current firmware block.
*
* @return A pointer to the firmware block context
*/
struct coap_block_context *lwm2m_firmware_get_block_context()
{
return &firmware_block_ctx;
}

0 comments on commit a9b9264

Please sign in to comment.