Anjay Lite
|
Core data model API: object management, read/write helpers, bootstrap. More...
Go to the source code of this file.
Macros | |
#define | ANJ_DM_ERR_BAD_REQUEST (-(int) ANJ_COAP_CODE_BAD_REQUEST) |
#define | ANJ_DM_ERR_UNAUTHORIZED (-(int) ANJ_COAP_CODE_UNAUTHORIZED) |
#define | ANJ_DM_ERR_NOT_FOUND (-(int) ANJ_COAP_CODE_NOT_FOUND) |
#define | ANJ_DM_ERR_METHOD_NOT_ALLOWED (-(int) ANJ_COAP_CODE_METHOD_NOT_ALLOWED) |
#define | ANJ_DM_ERR_INTERNAL (-(int) ANJ_COAP_CODE_INTERNAL_SERVER_ERROR) |
#define | ANJ_DM_ERR_NOT_IMPLEMENTED (-(int) ANJ_COAP_CODE_NOT_IMPLEMENTED) |
#define | ANJ_DM_ERR_SERVICE_UNAVAILABLE (-(int) ANJ_COAP_CODE_SERVICE_UNAVAILABLE) |
Functions | |
int | anj_dm_add_obj (anj_t *anj, const anj_dm_obj_t *obj) |
int | anj_dm_remove_obj (anj_t *anj, anj_oid_t oid) |
int | anj_dm_res_read (anj_t *anj, const anj_uri_path_t *path, anj_res_value_t *out_value) |
int | anj_dm_write_bytes_chunked (const anj_res_value_t *value, uint8_t *buffer, size_t buffer_len, size_t *out_bytes_len, bool *out_is_last_chunk) |
int | anj_dm_write_string_chunked (const anj_res_value_t *value, char *buffer, size_t buffer_len, bool *out_is_last_chunk) |
Core data model API: object management, read/write helpers, bootstrap.
Provides error codes for data model handlers, functions to add/remove objects, read resources, handle chunked writes, and perform bootstrap cleanup.
int anj_dm_add_obj | ( | anj_t * | anj, |
const anj_dm_obj_t * | obj | ||
) |
Adds an Object to the data model and validates its structure.
obj
parameter is not copied; the user must ensure that it remains valid for the entire lifetime of the anj
object or until it is removed using anj_dm_remove_obj.
NDEBUG
macro is not defined). In release builds, internal consistency checks are skipped.obj
structure must be stored in ascending order by their oid
.anj | Anjay object. |
obj | Pointer to the Object definition struct. |
Removes Object from the data model.
anj | Anjay object. |
oid | ID number of the Object to be removed. |
int anj_dm_res_read | ( | anj_t * | anj, |
const anj_uri_path_t * | path, | ||
anj_res_value_t * | out_value | ||
) |
Reads the value of the Resource or Resource Instance.
anj | Anjay object. | |
path | Resource or Resource Instance path. | |
[out] | out_value | Resource value. |
int anj_dm_write_bytes_chunked | ( | const anj_res_value_t * | value, |
uint8_t * | buffer, | ||
size_t | buffer_len, | ||
size_t * | out_bytes_len, | ||
bool * | out_is_last_chunk | ||
) |
Handles writing of a opaque data in the anj_dm_res_write_t handler.
This function assists in collecting binary data that may arrive in multiple chunks during the LwM2M Write operation. It copies a single chunk of data from the anj_res_value_t structure into the specified target buffer
at the automatically tracked offset - for this reason, buffer
is expected to be the same across multiple invocations of this function.
This function does not add a terminator — it is intended for binary (non-null-terminated) content.
value | Resource value to be written. | |
[out] | buffer | Target buffer to write into. |
buffer_len | Size of the target buffer. | |
[out] | out_bytes_len | Set to total data length if the current chunk is the last one. |
[out] | out_is_last_chunk | Optional parameter. Set to true if this is the last chunk of data. |
int anj_dm_write_string_chunked | ( | const anj_res_value_t * | value, |
char * | buffer, | ||
size_t | buffer_len, | ||
bool * | out_is_last_chunk | ||
) |
Handles writing of a string value in the anj_dm_res_write_t handler.
This function assists in collecting strings that may arrive in multiple chunks during the LwM2M Write operation. It copies a single chunk of data from the anj_res_value_t structure into the specified target buffer
at the automatically tracked offset - for this reason, buffer
is expected to be the same across multiple invocations of this function.
When the final chunk is received, a null terminator ('\0'
) is additionally written into the buffer
.
value | Resource value to be written. | |
[out] | buffer | Target buffer to write the data into. |
buffer_len | Size of the target buffer (must include space for the null terminator). | |
[out] | out_is_last_chunk | Optional parameter. Set to true if this is the last chunk of data. |