Function anjay_new_from_core_persistence
Defined in File core.h
Function Documentation
-
anjay_t *anjay_new_from_core_persistence(const anjay_configuration_t *config, avs_stream_t *in_stream)
Creates a new Anjay object restoring core library state from the specified
stream. If the stream is empty the function will fail and return NULL.The “core library state” includes information that is necessary to resume previously existing registrations with LwM2M Servers without sending the Register message again. This also includes the Observe information.
USE CASE: This method (along with anjay_delete_with_core_persistence()) could be used on devices which have aggressive power saving modes and even disable the main memory chip.
The restored Registration state will be used (if possible) to potentially resume the DTLS session, avoiding costly re-registrations. Of course, if the Lifetime of the Server account expires, then the client will re-register. WARNING: It is necessary to have realtime clock working properly at this stage.
The restored Observation state will be used (if possible) to maintain previous Observation requests all LwM2M Servers started.
CAUTION: After successful restore from the stream, the user SHOULD clear the persistence data source. It is not strictly necessary, but highly RECOMMENDED. The idea behind doing that is to avoid a situation where the Server is confused, because at some point in time the Client happened to spuriously restore its previous (stale state) potentially causing its behavior to be different than the Server would normally expect from a conformant LwM2M Client.
NOTE: The registration and observation state persistence make sense only if you restore the actual data model state (including registered Objects and data contained within them; this especially includes the LwM2M Server and Security objects) before entering the main loop. Otherwise the registration states are going to be cleaned up (and forgotten), as they would have no correlation with the server accounts; the observe states are also going to be cleaned up, as they have no correlation with the data model.
- Parameters:
config – Initial configuration. For details, see anjay_configuration_t .
in_stream – Readable stream from which restoring shall be performed.
- Returns:
Created Anjay object on success, NULL in case of error.