|
Anjay Lite
|
Default implementation of the LwM2M Firmware Update Object (/5). More...
#include <anj/init.h>#include <stddef.h>#include <stdint.h>#include <anj/core.h>#include <anj/dm/core.h>Go to the source code of this file.
Data Structures | |
| struct | anj_dm_fw_update_handlers_t |
| struct | anj_dm_fw_update_entity_ctx_t |
Typedefs | |
| typedef anj_dm_fw_update_result_t | anj_dm_fw_update_package_write_start_t(void *user_ptr) |
| typedef anj_dm_fw_update_result_t | anj_dm_fw_update_package_write_t(void *user_ptr, const void *data, size_t data_size) |
| typedef anj_dm_fw_update_result_t | anj_dm_fw_update_package_write_finish_t(void *user_ptr) |
| typedef anj_dm_fw_update_result_t | anj_dm_fw_update_uri_write_t(void *user_ptr, const char *uri) |
| typedef int | anj_dm_fw_update_update_start_t(void *user_ptr) |
| typedef const char * | anj_dm_fw_update_get_name_t(void *user_ptr) |
| typedef const char * | anj_dm_fw_update_get_version_t(void *user_ptr) |
| typedef void | anj_dm_fw_update_reset_t(void *user_ptr) |
Functions | |
| int | anj_dm_fw_update_object_install (anj_t *anj, anj_dm_fw_update_entity_ctx_t *entity_ctx, anj_dm_fw_update_handlers_t *handlers, void *user_ptr) |
| void | anj_dm_fw_update_object_set_update_result (anj_t *anj, anj_dm_fw_update_entity_ctx_t *entity_ctx, anj_dm_fw_update_result_t result) |
| int | anj_dm_fw_update_object_set_download_result (anj_t *anj, anj_dm_fw_update_entity_ctx_t *entity_ctx, anj_dm_fw_update_result_t result) |
Default implementation of the LwM2M Firmware Update Object (/5).
Declares states, results, and handler callbacks for firmware update support. Supports both Push (Package) and Pull (Package URI) delivery modes depending on compile-time configuration.
| typedef const char * anj_dm_fw_update_get_name_t(void *user_ptr) |
Returns the name of downloaded firmware package.
The name will be exposed in the data model as the PkgName Resource. If this callback returns NULL or is not implemented at all (with the corresponding field set to NULL), PkgName Resource will contain an empty string.
It only makes sense for this handler to return non-NULL values if there is a valid package already downloaded. The library will not call this handler in any state other than Downloaded.
The library expects that the returned pointer will remain valid until the next call to this handler, or until the State Resource changes to a value other than Downloaded.
| user_ptr | Opaque pointer to user data, as passed to anj_dm_fw_update_object_install. |
NULL if it is not currently available. | typedef const char * anj_dm_fw_update_get_version_t(void *user_ptr) |
Returns the version of downloaded firmware package.
The version will be exposed in the data model as the PkgVersion Resource. If this callback returns NULL or is not implemented at all (with the corresponding field set to NULL), PkgVersion Resource will contain an empty string.
It only makes sense for this handler to return non-NULL values if there is a valid package already downloaded. The library will not call this handler in any state other than Downloaded.
The library expects that the returned pointer will remain valid until the next call to this handler, or until the State Resource changes to a value other than Downloaded.
| user_ptr | Opaque pointer to user data, as passed to anj_dm_fw_update_object_install. |
NULL if it is not currently available. | typedef anj_dm_fw_update_result_t anj_dm_fw_update_package_write_finish_t(void *user_ptr) |
Finalizes the process of writing firmware package chunks. This method is called once, after the last chunk of data hsa been passed to anj_dm_fw_update_package_write_t.
If this callback returns ANJ_DM_FW_UPDATE_RESULT_SUCCESS, the State Resource will be set to Downloaded and the library will wait for the execution of Update Resource by the LwM2M Server to proceed with the actual firmware update.
| user_ptr | Opaque pointer to user data, as passed to anj_dm_fw_update_object_install. |
| typedef anj_dm_fw_update_result_t anj_dm_fw_update_package_write_start_t(void *user_ptr) |
Initates the Push-mode download of a firmware package. The library calls this function when a LwM2M Server performs a Write on Package Resource.
If this callback returns ANJ_DM_FW_UPDATE_RESULT_SUCCESS, it will be followed by a series of calls to anj_dm_fw_update_package_write_t that pass the actual firmware package.
| user_ptr | Opaque pointer to user data, as passed to anj_dm_fw_update_object_install. |
| typedef anj_dm_fw_update_result_t anj_dm_fw_update_package_write_t(void *user_ptr, const void *data, size_t data_size) |
Passes parts of firmware package written by a LwM2M Server to the Package Resource. This method is called for each chunk of data, in order.
If this callback returns a value other than ANJ_DM_FW_UPDATE_RESULT_SUCCESS, the download process will be aborted.
| user_ptr | Opaque pointer to user data, as passed to anj_dm_fw_update_object_install. |
| data | Pointer to the data chunk. |
| data_size | Size of the data chunk. |
| typedef void anj_dm_fw_update_reset_t(void *user_ptr) |
Aborts any ongoing firmware package download process, either at the request of the server (by writing an empty value to Package or Package URI Resources), or after a failed download (indicated by returning an error value by other callbacks involved in download process).
The user should ensure that any temporary resources used during the download are released, and that any ongoing download is aborted.
| user_ptr | Opaque pointer to user data, as passed to anj_dm_fw_update_object_install. |
| typedef int anj_dm_fw_update_update_start_t(void *user_ptr) |
Schedules the actual upgrade with previously downloaded package.
Will be called at request of the server, after a package has been downloaded (by executing Update Resource when State Resource is Downloaded).
User code should initiate the actual upgrade process. If this callback returns ANJ_DM_FW_UPDATE_RESULT_SUCCESS, the State Resource will be set to Updating. The library will wait for the call to anj_dm_fw_update_object_set_update_result to set the State Resource back to Idle and set the Result Resource accordingly, to notify the server about the outcome of the upgrade.
| user_ptr | Opaque pointer to user data, as passed to anj_dm_fw_update_object_install. |
| typedef anj_dm_fw_update_result_t anj_dm_fw_update_uri_write_t(void *user_ptr, const char *uri) |
Initiates the Pull-mode download of a firmware package by providing the URI written by a LwM2M Server to the Package URI Resource.
User code should start the download of the firmware package from the given URI. If this callback returns ANJ_DM_FW_UPDATE_RESULT_SUCCESS, the State Resource will be set to Downloading and the library will wait for the call to anj_dm_fw_update_object_set_download_result to proceed.
| user_ptr | Opaque pointer to user data, as passed to anj_dm_fw_update_object_install. |
| uri | Null-terminated string containing the URI to the firmware package. |
Numeric values of the Update Result resource
Numeric values of the Firmware Update Protocol Support Resource (/5/0/8).
| Enumerator | |
|---|---|
| ANJ_DM_FW_UPDATE_STATE_IDLE | |
| ANJ_DM_FW_UPDATE_STATE_DOWNLOADING | |
| ANJ_DM_FW_UPDATE_STATE_DOWNLOADED | |
| ANJ_DM_FW_UPDATE_STATE_UPDATING | |
| int anj_dm_fw_update_object_install | ( | anj_t * | anj, |
| anj_dm_fw_update_entity_ctx_t * | entity_ctx, | ||
| anj_dm_fw_update_handlers_t * | handlers, | ||
| void * | user_ptr | ||
| ) |
Installs Firmware Update Object in data model.
| anj | Anjay object. |
| entity_ctx | Pointer to a variable that will hold the state of the Object. |
| handlers | Pointer to a set of handler functions that handle platform-specific parts of firmware update process. |
| user_ptr | Opaque pointer that will be passed to all callbacks. |
| int anj_dm_fw_update_object_set_download_result | ( | anj_t * | anj, |
| anj_dm_fw_update_entity_ctx_t * | entity_ctx, | ||
| anj_dm_fw_update_result_t | result | ||
| ) |
Sets the result of firmware download process in Pull mode.
For details on the expected usage of this function see description of anj_dm_fw_update_uri_write_t callback.
| anj | Anjay object. |
| entity_ctx | Firmware Update Object state. |
| result | Result of the download process. If the process is successful, the value must be set to ANJ_DM_FW_UPDATE_RESULT_SUCCESS. |
| void anj_dm_fw_update_object_set_update_result | ( | anj_t * | anj, |
| anj_dm_fw_update_entity_ctx_t * | entity_ctx, | ||
| anj_dm_fw_update_result_t | result | ||
| ) |
Sets the result of upgrade process.
For details on the expected usage of this function see description of anj_dm_fw_update_update_start_t callback.
| anj | Anjay object. |
| entity_ctx | Firmware Update Object state. |
| result | Result of the upgrade process. If the process is successful, the value must be set to ANJ_DM_FW_UPDATE_RESULT_SUCCESS. |