net: lwm2m: Publicize firmware block context

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>
This commit is contained in:
Kyle Sun 2019-05-17 21:08:00 -07:00 committed by Carles Cufí
commit a9b926414c
2 changed files with 17 additions and 0 deletions

View file

@ -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

View file

@ -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;
}