anjay
|
Go to the source code of this file.
Data Structures | |
struct | anjay_sw_mgmt_instance_initializer_t |
struct | anjay_sw_mgmt_handlers_t |
struct | anjay_sw_mgmt_settings_t |
Macros | |
Software update result codes | |
The following result codes may be returned from anjay_sw_mgmt_stream_write_t or anjay_sw_mgmt_stream_finish_t to control the value of Update Result resource in case of an error. Their values correspond to negated numeric values of that resource. However, attempting to use other negated value will be checked and cause a fall-back to a value default for a given handler. | |
#define | ANJAY_SW_MGMT_ERR_NOT_ENOUGH_SPACE (-(int) ANJAY_SW_MGMT_UPDATE_RESULT_NOT_ENOUGH_SPACE) |
#define | ANJAY_SW_MGMT_ERR_OUT_OF_MEMORY (-(int) ANJAY_SW_MGMT_UPDATE_RESULT_OUT_OF_MEMORY) |
#define | ANJAY_SW_MGMT_ERR_INTEGRITY_FAILURE (-(int) ANJAY_SW_MGMT_UPDATE_RESULT_INTEGRITY_FAILURE) |
#define | ANJAY_SW_MGMT_ERR_UNSUPPORTED_PACKAGE_TYPE (-(int) ANJAY_SW_MGMT_UPDATE_RESULT_UNSUPPORTED_PACKAGE_TYPE) |
Typedefs | |
typedef int | anjay_sw_mgmt_stream_open_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef int | anjay_sw_mgmt_stream_write_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx, const void *data, size_t length) |
typedef int | anjay_sw_mgmt_stream_finish_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef int | anjay_sw_mgmt_check_integrity_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef void | anjay_sw_mgmt_reset_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef const char * | anjay_sw_mgmt_get_name_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef const char * | anjay_sw_mgmt_get_version_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef int | anjay_sw_mgmt_pkg_install_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef int | anjay_sw_mgmt_pkg_uninstall_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef int | anjay_sw_mgmt_prepare_for_update_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef int | anjay_sw_mgmt_activate_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef int | anjay_sw_mgmt_deactivate_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
typedef int | anjay_sw_mgmt_get_security_config_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx, const char *download_uri, anjay_security_config_t *out_security_info) |
typedef avs_coap_udp_tx_params_t | anjay_sw_mgmt_get_coap_tx_params_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx, const char *download_uri) |
typedef avs_time_duration_t | anjay_sw_mgmt_get_tcp_request_timeout_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx, const char *download_uri) |
typedef int | anjay_sw_mgmt_add_handler_t(void *obj_ctx, anjay_iid_t iid, void **out_inst_ctx) |
typedef int | anjay_sw_mgmt_remove_handler_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Functions | |
void | anjay_sw_mgmt_pull_suspend (anjay_t *anjay) |
int | anjay_sw_mgmt_pull_reconnect (anjay_t *anjay) |
int | anjay_sw_mgmt_install (anjay_t *anjay, const anjay_sw_mgmt_settings_t *settings) |
int | anjay_sw_mgmt_get_activation_state (anjay_t *anjay, anjay_iid_t iid, bool *out_state) |
int | anjay_sw_mgmt_finish_pkg_install (anjay_t *anjay, anjay_iid_t iid, anjay_sw_mgmt_finish_pkg_install_result_t pkg_install_result) |
int | anjay_sw_mgmt_add_instance (anjay_t *anjay, const anjay_sw_mgmt_instance_initializer_t *instance_initializer) |
int | anjay_sw_mgmt_remove_instance (anjay_t *anjay, anjay_iid_t iid) |
#define ANJAY_SW_MGMT_ERR_INTEGRITY_FAILURE (-(int) ANJAY_SW_MGMT_UPDATE_RESULT_INTEGRITY_FAILURE) |
#define ANJAY_SW_MGMT_ERR_NOT_ENOUGH_SPACE (-(int) ANJAY_SW_MGMT_UPDATE_RESULT_NOT_ENOUGH_SPACE) |
#define ANJAY_SW_MGMT_ERR_OUT_OF_MEMORY (-(int) ANJAY_SW_MGMT_UPDATE_RESULT_OUT_OF_MEMORY) |
#define ANJAY_SW_MGMT_ERR_UNSUPPORTED_PACKAGE_TYPE (-(int) ANJAY_SW_MGMT_UPDATE_RESULT_UNSUPPORTED_PACKAGE_TYPE) |
typedef int anjay_sw_mgmt_activate_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Activates software package.
This callback will be called only in Installed state. The activation state does not affect the execution of this callback. If the user wants to block the execution when the package is already active, this must be done on user side. The anjay_sw_mgmt_get_activation_state function may be useful.
Some of the users will want to opt-out from ability to handle the activation state - if this callback is not implemented at all (with the corresponding field set to NULL
), executing Activate resource will always succeed. If this callback is not implemented, anjay_sw_mgmt_deactivate_t MUST NOT be implemented too.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
ANJAY_SW_MGMT_ERR_*
values will NOT cause any effect different than any other negative value. typedef int anjay_sw_mgmt_add_handler_t(void *obj_ctx, anjay_iid_t iid, void **out_inst_ctx) |
Handles server's request to create new instance of Software Management object.
This callback allows the user to set up user-specific data or to reject server's attempt to create a new object instance.
If this handler is not implemented at all (with the corresponding field set to NULL
), library won't allow creating new instances of the object.
This callback won't be called if the application adds a new instance of the object on its own.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
out_inst_ctx | Pointer in which the handler shall fill in opaque pointer to instance-specific user data. |
ANJAY_SW_MGMT_ERR_*
values will NOT cause any effect different than any other negative value. typedef int anjay_sw_mgmt_check_integrity_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Conducts integrity check of downloaded package.
If this handler is not implemented at all (with the corresponding field set to NULL
), integrity check will be entirely skipped, and the Update State resource upon finished download will change the state directly from Download started to Delivered.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
ANJAY_SW_MGMT_ERR_*
value is returned, an equivalent value will be set in the Update Result Resource. typedef int anjay_sw_mgmt_deactivate_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Deactivates software package.
This callback will be called only in Installed state. The activation state does not affect the execution of this callback. If the user wants to block the execution when the package is already deactivate, this must be done on user side. The anjay_sw_mgmt_get_activation_state function may be useful.
Some of the users will want to opt-out from ability to handle the activation state - if this callback is not implemented at all (with the corresponding field set to NULL
), executing Deactivate resource will always succeed. If this callback is not implemented, anjay_sw_mgmt_activate_t MUST NOT be implemented too.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
ANJAY_SW_MGMT_ERR_*
values will NOT cause any effect different than any other negative value. typedef avs_coap_udp_tx_params_t anjay_sw_mgmt_get_coap_tx_params_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx, const char *download_uri) |
Returns tx_params used to override default ones.
If this handler is not implemented at all (with the corresponding field set to NULL
), udp_tx_params
from anjay_t
object are used.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
download_uri | Target software URI. |
typedef const char * anjay_sw_mgmt_get_name_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Returns the name of downloaded software 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
), that Resource will have its value set to 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 call this handler in Delivered and Installed states.
The library will not attempt to deallocate the returned pointer. User code must assure that the pointer will remain valid at least until return from anjay_serve or anjay_sched_run .
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
NULL
if it is not currently available. typedef int anjay_sw_mgmt_get_security_config_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx, const char *download_uri, anjay_security_config_t *out_security_info) |
Queries security information that shall be used for an encrypted connection with a PULL-mode download server.
May be called before anjay_sw_mgmt_stream_open if the download is to be performed in PULL mode and the connection needs to use TLS or DTLS encryption.
Note that the anjay_security_config_t contains references to file paths, binary security keys, and/or ciphersuite lists. It is the user's responsibility to appropriately allocate them and ensure proper lifetime of the returned pointers. The returned security information may only be invalidated in a call to anjay_sw_mgmt_reset_t or after a call to anjay_delete .
If this handler is not implemented at all (with the corresponding field set to NULL
), anjay_security_config_from_dm will be used as a default way to get security information.
WARNING: If the aforementioned anjay_security_config_from_dm function won't find any server connection that matches the download_uri
by protocol, hostname and port triple, it'll attempt to match a configuration just by the hostname. This may cause Anjay to use wrong security configuration, e.g. in case when both CoAPS LwM2M server and HTTPS software package server have the same hostname, but require different security configs.
If no user-defined handler is provided and the call to anjay_security_config_from_dm fails (including case when no matching LwM2M Security Object instance is found, even just by the hostname), anjay_security_config_pkix will be used as an additional fallback if ANJAY_WITH_LWM2M11
is enabled and a valid trust store is available (either specified through use_system_trust_store
, trust_store_certs
or trust_store_crls
fields in anjay_configuration_t
, or obtained via /est/crts
request if est_cacerts_policy
is set to ANJAY_EST_CACERTS_IF_EST_CONFIGURED
or ANJAY_EST_CACERTS_ALWAYS
).
You may also use these functions yourself, for example as a fallback mechanism.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
download_uri | URI of the package from which a Pull-mode download is performed. |
out_security_info | Pointer in which the handler shall fill in security configuration to use for download. Note that leaving this value as empty without filling it in will result in a configuration that is valid, but very insecure: it will cause any server certificate to be accepted without validation. Any pointers used within the supplied structure shall remain valid until either a call to anjay_sw_mgmt_reset_t, or exit to the event loop (from either anjay_serve, anjay_sched_run or anjay_sw_mgmt_add_instance), whichever happens first. Anjay will not attempt to deallocate anything automatically. |
ANJAY_SW_MGMT_ERR_*
values will NOT cause any effect different than any other negative value. typedef avs_time_duration_t anjay_sw_mgmt_get_tcp_request_timeout_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx, const char *download_uri) |
Returns request timeout to be used during software download over CoAP+TCP or HTTP.
If this handler is not implemented at all (with the corresponding field set to NULL
), coap_tcp_request_timeout
from anjay_t
object will be used for CoAP+TCP, and AVS_NET_SOCKET_DEFAULT_RECV_TIMEOUT
(i.e., 30 seconds) will be used for HTTP.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
download_uri | Target software URI. |
typedef const char * anjay_sw_mgmt_get_version_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Returns the version of downloaded software 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
), that Resource will have its value set to 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 call this handler in Delivered and Installed states.
The library will not attempt to deallocate the returned pointer. User code must assure that the pointer will remain valid at least until return from anjay_serve or anjay_sched_run .
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
NULL
if it is not currently available. typedef int anjay_sw_mgmt_pkg_install_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Performs the actual installation of previously downloaded software package.
Will be called at the request of the server, after a package has been downloaded and its integrity has been checked.
Some users will want to implement software installation in a way that involves a reboot. In such case, it is expected that this callback will do either one of the following:
After rebooting, the result of the installation process may be passed to the library during initialization via the initial_state
field of anjay_sw_mgmt_instance_initializer_t .
Alternatively, if the installation can be performed without reinitializing Anjay, you can use anjay_sw_mgmt_finish_pkg_install (either from within the handler or some time after returning from it) to pass the installation result.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
ANJAY_SW_MGMT_ERR_*
values will NOT cause any effect different than any other negative value. typedef int anjay_sw_mgmt_pkg_uninstall_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Uninstalls software package.
This callback will be called only in Installed state, if the Uninstall resource was executed with no argument or argument "0".
If this callback is not implemented at all (with the corresponding field set to NULL
), uninstalling software will not be possible.
Note: in case the server requests to remove the software package which has been delivered, but not yet installed (Delivered state), anjay_sw_mgmt_reset_t callback will be used.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
ANJAY_SW_MGMT_ERR_*
values will NOT cause any effect different than any other negative value. typedef int anjay_sw_mgmt_prepare_for_update_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Prepares software package for update.
This callback will be called only in Installed state, if the Uninstall resource was executed with argument "1".
If this callback is not implemented at all (with the corresponding field set to NULL
), updating software will not be possible.
Most users will want to implement this callback as a no-op.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
ANJAY_SW_MGMT_ERR_*
values will NOT cause any effect different than any other negative value. typedef int anjay_sw_mgmt_remove_handler_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Handles server's request to remove an instance of Software Management object.
This callback allows the user to clean up user-specific data or to reject server's attempt to remove an object instance.
If this handler is not implemented at all (with the corresponding field set to NULL
), library won't allow deleting instances of the object.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
ANJAY_SW_MGMT_ERR_*
values will NOT cause any effect different than any other negative value. typedef void anjay_sw_mgmt_reset_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Resets the software installation state and performs any applicable cleanup of temporary storage if necessary.
Will be called at request of the server (upon execution of Uninstall resource in Delivered state in purpose of removing downloaded, but not yet installed software package) or after a failed download. Note that it may be called without previously calling anjay_sw_mgmt_stream_finish_t, so it shall also close the currently open download stream, if any.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
typedef int anjay_sw_mgmt_stream_finish_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Closes the download stream.
Will be called after a series of anjay_sw_mgmt_stream_write_t calls after the whole package is downloaded.
The intended way of implementing this handler is to e.g. call fclose()
on the downloaded file. After that, package might also be uncompressed, decrypted and checked for integrity in anjay_sw_mgmt_check_integrity_t . The exact split of responsibility between these two methods is not clearly defined and up to implementor.
Note that regardless of the return value, the stream is considered to be closed. That is, upon successful return, the Update State resource is considered to be either in the Downloaded state, and upon returning an error - in the Initial state, with appropriate Update Result set.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
ANJAY_SW_MGMT_ERR_*
value is returned, an equivalent value will be set in the Update Result Resource. typedef int anjay_sw_mgmt_stream_open_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx) |
Opens the stream that will be used to write the software package to.
The intended way of implementing this handler is to open a temporary file using fopen()
or allocate some memory buffer that may then be used to store the downloaded data in. The library will not attempt to call anjay_sw_mgmt_stream_write_t without having previously called anjay_sw_mgmt_stream_open_t . Please see anjay_sw_mgmt_handlers_t for more information about state transitions.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
ANJAY_SW_MGMT_ERR_*
values will NOT cause any effect different than any other negative value. typedef int anjay_sw_mgmt_stream_write_t(void *obj_ctx, anjay_iid_t iid, void *inst_ctx, const void *data, size_t length) |
Writes data to the download stream.
May be called multiple times after anjay_sw_mgmt_stream_open_t, once for each consecutive chunk of downloaded data.
obj_ctx | Opaque pointer to object-wide user data, as passed to anjay_sw_mgmt_settings_t . |
iid | ID of Software Management object instance. |
inst_ctx | Opaque pointer to instance-specific user data, as passed to anjay_sw_mgmt_instance_initializer_t or out_inst_ctx parameter of anjay_sw_mgmt_add_handler_t . |
data | Pointer to a chunk of the software package being downloaded. Guaranteed to be non-NULL . |
length | Number of bytes in the chunk pointed to by data . Guaranteed to be greater than zero. |
ANJAY_SW_MGMT_ERR_*
value is returned, an equivalent value will be set in the Update Result Resource. Possible values that control package state after installation.
Enumerator | |
---|---|
ANJAY_SW_MGMT_FINISH_PKG_INSTALL_SUCCESS_INACTIVE | Corresponds to the "Installed" Update State, "Installed" Update Result and Activation State set to false. |
ANJAY_SW_MGMT_FINISH_PKG_INSTALL_SUCCESS_ACTIVE | Corresponds to the "Installed" Update State, "Installed" Update Result and Activation State set to true. WARNING: Setting the Activation State to true via anjay_sw_mgmt_finish_pkg_install breaks the specifications. Activation should be done on the server side. However, there are known cases in which such behavior is required. |
ANJAY_SW_MGMT_FINISH_PKG_INSTALL_FAILURE | Corresponds to the "Delivered" Update State, "Installation failure" Update Result and Activation State set to false. |
Possible values that control Update State, Update Result and Activation State resources at the time of initialization of the Software Management object.
Enumerator | |
---|---|
ANJAY_SW_MGMT_INITIAL_STATE_IDLE | Corresponds to the "Initial" Update State and "Initial" Update Result. Shall be used for software instances which are not yet downloaded. Note: "Initial" Update State and "Initial" Update Result can be also caused by preparing installed software for update process (by executing Uninstall resource with "1" argument), although, in case of a reboot, it is recommended to revert back to "Installed" Update State by initializing the object instance with ANJAY_SW_MGMT_INITIAL_STATE_INSTALLED_DEACTIVATED or ANJAY_SW_MGMT_INITIAL_STATE_INSTALED_ACTIVATED . Software Management Object in its current state is not able to differentiate these two situations. |
ANJAY_SW_MGMT_INITIAL_STATE_DOWNLOADED | Corresponds to the "Downloaded" Update State and "Initial" Update Result. Shall be used when the device unexpectedly rebooted when the software package has already been downloaded into some non-volatile memory and integrity check wasn't performed yet. |
ANJAY_SW_MGMT_INITIAL_STATE_DELIVERED | Corresponds to the "Delivered" Update State and "Initial" Update Result. Shall be used when the device unexpectedly rebooted when the software package has already been downloaded into some non-volatile memory and integrity check was performed. |
ANJAY_SW_MGMT_INITIAL_STATE_INSTALLING | Corresponds to the "Delivered" Update State and "Initial" Update Result. Shall be used when the device has rebooted as a part of installation process, which hasn't completed yet. The application should call anjay_sw_mgmt_finish_pkg_install to set the result to success or failure after the installation process is complete. |
ANJAY_SW_MGMT_INITIAL_STATE_INSTALLED_DEACTIVATED | Corresponds to the "Installed" Update State, "Installed" Update Result and Activation State set to false. Shall be used when given software instance is installed, but deactivated. |
ANJAY_SW_MGMT_INITIAL_STATE_INSTALLED_ACTIVATED | Corresponds to the "Installed" Update State, "Installed" Update Result and Activation State set to true. Shall be used when given software instance is installed and activated. |
Numeric values of the Update Result resource. See LwM2M specification related to object 9 for details.
int anjay_sw_mgmt_add_instance | ( | anjay_t * | anjay, |
const anjay_sw_mgmt_instance_initializer_t * | instance_initializer | ||
) |
Adds an instance of Software Management object.
This method will not cause anjay_sw_mgmt_add_handler_t to be called, as this method creates a new instance of the object on application's request.
anjay | Anjay object for which the Software Management Object is installed. |
instance_initializer | Information about the state to initialize the Software Management object instance in. |
int anjay_sw_mgmt_finish_pkg_install | ( | anjay_t * | anjay, |
anjay_iid_t | iid, | ||
anjay_sw_mgmt_finish_pkg_install_result_t | pkg_install_result | ||
) |
Marks delivered software package as installed and optionally activated, making transition to Installed state or reports installation error.
WARNING: Calling this function is only valid in Delivered state, directly in the anjay_sw_mgmt_pkg_install_t handler, or in some later point of time, possibly after a reboot, as explained in anjay_sw_mgmt_pkg_install_t .
NOTE: Setting activation state with this function does NOT mean that activation ( anjay_sw_mgmt_activate_t ) or deactivation ( anjay_sw_mgmt_deactivate_t ) software package handler will be called. Setting activation state to true after installation breaks the specifications, but there are known cases when this behavior is required.
NOTE: If this function is called inside anjay_sw_mgmt_pkg_install_t handler with pkg_install_result
set to ANJAY_SW_MGMT_FINISH_PKG_INSTALL_SUCCESS_INACTIVE or ANJAY_SW_MGMT_FINISH_PKG_INSTALL_SUCCESS_ACTIVE , the handler is expected to return 0. Otherwise, returning nonzero value will cause the result set by this function being overwritten.
anjay | Anjay object for which the Software Management Object is installed. |
iid | ID of Software Management object instance. |
pkg_install_result | Result of the installation process. |
int anjay_sw_mgmt_get_activation_state | ( | anjay_t * | anjay, |
anjay_iid_t | iid, | ||
bool * | out_state | ||
) |
Checks if the instance state is Installed and return the activation state via out_state
argument. Can be used in anjay_sw_mgmt_activate_t or anjay_sw_mgmt_deactivate_t to check if we want to proceed with current activation state with the code responsible for activation/deactivation the package.
anjay | Anjay object for which the Software Management Object is installed. |
iid | ID of Software Management object instance. |
out_state | Activation state of Software Management object instance. |
int anjay_sw_mgmt_install | ( | anjay_t * | anjay, |
const anjay_sw_mgmt_settings_t * | settings | ||
) |
Installs the Software Management object in an Anjay object.
The Software Management module does not require explicit cleanup; all resources will be automatically freed up during the call to anjay_delete.
Specific instances of Software Management object shall be created using anjay_sw_mgmt_add_instance . It is desirable to create all instances expected by the server before the first call to anjay_event_loop_run , anjay_serve or anjay_sched_run , to make sure that they are present from the beginning of the device registration.
anjay | Anjay object for which the Software Management Object is installed. |
settings | Configuration of Software Management module, see anjay_sw_mgmt_settings_t for details. |
int anjay_sw_mgmt_pull_reconnect | ( | anjay_t * | anjay | ) |
Reconnects any ongoing PULL-mode downloads in the Software Management module. Which could be disconnected due to connection loss or deliberate suspend. In the latter case, when PULL-mode downloads are suspended (see anjay_sw_mgmt_pull_suspend), resumes normal operation.
If an ongoing PULL-mode download exists, this will call anjay_download_reconnect internally, so you may want to reference the documentation of that function for details.
anjay | Anjay object to operate on. |
anjay
does not have the Software Management object installed or the latest non-zero error code returned by anjay_download_reconnect . void anjay_sw_mgmt_pull_suspend | ( | anjay_t * | anjay | ) |
Suspends the operation of PULL-mode downloads in the Software Management module.
This will have the effect of suspending any ongoing downloads (see anjay_download_suspend for details), as well as preventing new downloads from being started.
When PULL-mode downloads are suspended, anjay_sw_mgmt_stream_open_t will NOT be called when a download request is issued. However, anjay_sw_mgmt_get_security_config_t, anjay_sw_mgmt_get_coap_tx_params_t and anjay_sw_mgmt_get_tcp_request_timeout_t will be called. You may call anjay_sw_mgmt_pull_reconnect from one of these functions if you decide to accept the download immediately after all.
anjay | Anjay object to operate on. |
int anjay_sw_mgmt_remove_instance | ( | anjay_t * | anjay, |
anjay_iid_t | iid | ||
) |
Remove an instance of Software Management object.
This method will not cause anjay_sw_mgmt_remove_handler_t to be called, as this method deletes a instance of the object on application's request.
CAUTION: Calling this function inside any Software Management module handler with the same iid
as passed to the handler, will result in an error code with value 1. This function shouldn't be called from any module handler. In multi-threaded scenarios, it should be expected that this function can also return an error code with value 1, in case one thread calls this function when another thread is executing one of the module's handler associated with the instance with the same iid
as the one passed to this function. In this case, the user should wait a while and call this function again.
anjay | Anjay object for which the Software Management Object is installed. |
iid | ID of Software Management object instance. |
iid
as the one passed to this function is currently being executed; a negative value in case of error