anjay
attr_storage.h File Reference
#include <avsystem/commons/avs_stream.h>
#include <anjay/dm.h>

Go to the source code of this file.

Functions

bool anjay_attr_storage_is_modified (anjay_t *anjay)
 
void anjay_attr_storage_purge (anjay_t *anjay)
 
avs_error_t anjay_attr_storage_persist (anjay_t *anjay, avs_stream_t *out_stream)
 
avs_error_t anjay_attr_storage_restore (anjay_t *anjay, avs_stream_t *in_stream)
 
int anjay_attr_storage_set_object_attrs (anjay_t *anjay, anjay_ssid_t ssid, anjay_oid_t oid, const anjay_dm_oi_attributes_t *attrs)
 
int anjay_attr_storage_set_instance_attrs (anjay_t *anjay, anjay_ssid_t ssid, anjay_oid_t oid, anjay_iid_t iid, const anjay_dm_oi_attributes_t *attrs)
 
int anjay_attr_storage_set_resource_attrs (anjay_t *anjay, anjay_ssid_t ssid, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, const anjay_dm_r_attributes_t *attrs)
 
int anjay_attr_storage_set_resource_instance_attrs (anjay_t *anjay, anjay_ssid_t ssid, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, const anjay_dm_r_attributes_t *attrs)
 

Detailed Description

Automatic Attribute Storage module.

This feature is enabled using the ANJAY_WITH_ATTR_STORAGE compile-time feature macro. It makes it possible to automatically manage attributes for LwM2M Objects, their instances and resources.

In accordance to the LwM2M specification, there are three levels on which attributes may be stored:

If at least one of either read or write handlers is provided in a given object for a given level, attribute handling on that level will not be altered, but instead any calls will be directly forwarded to the original handlers.

If both read and write handlers are left as NULL in a given object for a given level, attribute storage will be handled by the Attribute Storage module instead, implementing both handlers.

Function Documentation

◆ anjay_attr_storage_is_modified()

bool anjay_attr_storage_is_modified ( anjay_t anjay)

Checks whether the attribute storage has been modified since last successful call to anjay_attr_storage_persist or anjay_attr_storage_restore.

◆ anjay_attr_storage_persist()

avs_error_t anjay_attr_storage_persist ( anjay_t anjay,
avs_stream_t *  out_stream 
)

Dumps all set attributes to the out_stream.

Parameters
anjayAnjay instance.
out_streamStream to write to.
Returns
AVS_OK in case of success, or an error code.

◆ anjay_attr_storage_purge()

void anjay_attr_storage_purge ( anjay_t anjay)

Removes all attributes from all entities, leaving the Attribute Storage in an empty state.

Parameters
anjayAnjay instance.

◆ anjay_attr_storage_restore()

avs_error_t anjay_attr_storage_restore ( anjay_t anjay,
avs_stream_t *  in_stream 
)

Attempts to restore attribute storage from specified in_stream.

Note: before attempting restoration, the Attribute Storage is cleared, so no previously set attributes will be retained. In particular, if restore fails, then the Attribute Storage will be completely cleared and anjay_attr_storage_is_modified will return true.

Parameters
anjayAnjay instance.
in_streamStream to read from.
Returns
AVS_OK in case of success, or an error code.

NOTE: if restorations fails, then the Attribute Storage will be untouched.

◆ anjay_attr_storage_set_instance_attrs()

int anjay_attr_storage_set_instance_attrs ( anjay_t anjay,
anjay_ssid_t  ssid,
anjay_oid_t  oid,
anjay_iid_t  iid,
const anjay_dm_oi_attributes_t attrs 
)

Sets Instance level attributes for the specified ssid.

Parameters
anjayAnjay object to operate on.
ssidSSID for which given Attributes shall be set (must be a valid SSID corresponding to one of the non-Bootstrap LwM2M Servers).
oidObject ID for which given Attributes shall be set.
iidInstance ID for which given Attributes shall be set.
attrsAttributes to be set (MUST NOT be NULL).

NOTE: This function will fail if the object has instance_read_default_attrs or instance_write_default_attrs handler implemented.

Returns
0 on success, negative value in case of an error.

◆ anjay_attr_storage_set_object_attrs()

int anjay_attr_storage_set_object_attrs ( anjay_t anjay,
anjay_ssid_t  ssid,
anjay_oid_t  oid,
const anjay_dm_oi_attributes_t attrs 
)

Sets Object level attributes for the specified ssid.

Parameters
anjayAnjay object to operate on.
ssidSSID for which given Attributes shall be set (must be a valid SSID corresponding to one of the non-Bootstrap LwM2M Servers).
oidObject ID for which given Attributes shall be set.
attrsAttributes to be set (MUST NOT be NULL).

NOTE: This function will fail if the object has object_read_default_attrs or object_write_default_attrs handler implemented.

Returns
0 on success, negative value in case of an error.

◆ anjay_attr_storage_set_resource_attrs()

int anjay_attr_storage_set_resource_attrs ( anjay_t anjay,
anjay_ssid_t  ssid,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid,
const anjay_dm_r_attributes_t attrs 
)

Sets Resource level attributes for the specified ssid.

Parameters
anjayAnjay object to operate on.
ssidSSID for which given Attributes shall be set (must be a valid SSID corresponding to one of the non-Bootstrap LwM2M Servers).
oidObject ID owning the specified Instance.
iidInstance ID owning the specified Resource.
ridResource ID for which given Attributes shall be set.
attrsAttributes to be set (MUST NOT be NULL).

NOTE: This function will fail if the object has resource_read_attrs or resource_write_attrs handler implemented.

Returns
0 on success, negative value in case of an error.

◆ anjay_attr_storage_set_resource_instance_attrs()

int anjay_attr_storage_set_resource_instance_attrs ( anjay_t anjay,
anjay_ssid_t  ssid,
anjay_oid_t  oid,
anjay_iid_t  iid,
anjay_rid_t  rid,
anjay_riid_t  riid,
const anjay_dm_r_attributes_t attrs 
)

Sets Resource Instance level attributes for the specified ssid.

Parameters
anjayAnjay object to operate on.
ssidSSID for which given Attributes shall be set (must be a valid SSID corresponding to one of the non-Bootstrap LwM2M Servers).
oidObject ID owning the specified Instance.
iidInstance ID owning the specified Resource.
ridResource ID owning the specified Resource Instance.
riidResource Instance ID for which given Attributes shall be set.
attrsAttributes to be set (MUST NOT be NULL).

NOTE: This function will fail if the object has resource_read_attrs or resource_write_attrs handler implemented.

Returns
0 on success, negative value in case of an error.