Anjay Lite
|
Go to the source code of this file.
Data Structures | |
struct | anj_dm_res_struct |
struct | anj_dm_obj_inst_struct |
struct | anj_dm_obj_struct |
struct | anj_dm_handlers_struct |
Enumerations | |
enum | anj_dm_res_operation_t { ANJ_DM_RES_R , ANJ_DM_RES_RM , ANJ_DM_RES_W , ANJ_DM_RES_WM , ANJ_DM_RES_RW , ANJ_DM_RES_RWM , ANJ_DM_RES_E } |
typedef struct anj_dm_handlers_struct anj_dm_handlers_t |
typedef int anj_dm_inst_create_t(anj_t *anj, const anj_dm_obj_t *obj, anj_iid_t iid) |
A handler that creates a new Object Instance.
This function is called when a LwM2M Create operation is requested for the given Object. The handler is responsible for allocating and initializing a new Object Instance with the specified iid
and inserting it into the obj->insts
array. The array must remain sorted in ascending order of instance IDs after insertion.
If the operation fails later (i.e., anj_dm_transaction_end_t is called with a failure result), the user is responsible for restoring the previous state of the Instances array by removing the newly added instance.
anj | Anjay object to operate on. |
obj | Object definition pointer. |
iid | New object Instance ID. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. typedef int anj_dm_inst_delete_t(anj_t *anj, const anj_dm_obj_t *obj, anj_iid_t iid) |
A handler that deletes an Object Instance.
This function is called when a LwM2M Delete operation is requested for the given Object. The handler is responsible for removing the Object Instance with the specified iid
from the obj->insts
array. The array must remain sorted in ascending order of instance IDs after the removal.
If the operation fails later (i.e., anj_dm_transaction_end_t is called with a failure result), the user is responsible for restoring the deleted instance and reinserting it into the Instances array at the correct position.
anj | Anjay object to operate on. |
obj | Pointer to the object definition. |
iid | Object Instance ID to be deleted. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. typedef int anj_dm_inst_reset_t(anj_t *anj, const anj_dm_obj_t *obj, anj_iid_t iid) |
A handler that resets an Object Instance to its default (post-creation) state.
This handler is used during the LwM2M Write Replace operation. It should remove all writable Resource Instances belonging to the specified Object Instance. After the reset, new Resource values will be provided by subsequent write calls.
anj | Anjay object to operate on. |
obj | Pointer to the object definition. |
iid | Object Instance ID to reset. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. typedef struct anj_dm_obj_inst_struct anj_dm_obj_inst_t |
A struct defining an Object Instance.
typedef struct anj_dm_obj_struct anj_dm_obj_t |
A struct defining an Object.
typedef int anj_dm_res_execute_t(anj_t *anj, const anj_dm_obj_t *obj, anj_iid_t iid, anj_rid_t rid, const char *execute_arg, size_t execute_arg_len) |
A handler that performs the Execute action on given Resource, called only if the Resource is ANJ_DM_RES_E kind.
anj | Anjay object to operate on. |
obj | Object definition pointer. |
iid | Object Instance ID. |
rid | Resource ID. |
execute_arg | Payload provided in Execute request, NULL if not present. |
execute_arg_len | Execute payload length. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. typedef int anj_dm_res_inst_create_t(anj_t *anj, const anj_dm_obj_t *obj, anj_iid_t iid, anj_rid_t rid, anj_riid_t riid) |
A handler called to create a new Resource Instance within a multi-instance Resource.
This function is called when a LwM2M Write operation requires creating a new Resource Instance. The handler is responsible for initializing the new instance with the specified riid
and inserting its ID into the res->insts
array. The array must remain sorted in ascending order of Resource Instance IDs.
If the operation fails later (i.e., anj_dm_transaction_end_t is called with a failure result), the user is responsible for removing the newly added instance and restoring the array to its previous state.
anj | Anjay object to operate on. |
obj | Pointer to the object definition. |
iid | Object Instance ID. |
rid | Resource ID. |
riid | New Resource Instance ID. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. typedef int anj_dm_res_inst_delete_t(anj_t *anj, const anj_dm_obj_t *obj, anj_iid_t iid, anj_rid_t rid, anj_riid_t riid) |
A handler called to delete a Resource Instance from a multi-instance Resource.
The handler is responsible for removing the Resource Instance with the specified riid
from the res->insts
array and marking its ID as ANJ_ID_INVALID. The array must remain sorted in ascending order of Resource Instance IDs after the removal.
If the deletion succeeds but the overall transaction is later marked as failed by anj_dm_transaction_end_t, the user is responsible for restoring the removed Resource Instance to its previous state.
anj | Anjay object to operate on. |
obj | Pointer to the object definition. |
iid | Object Instance ID. |
rid | Resource ID. |
riid | Resource Instance ID to be deleted. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. typedef int anj_dm_res_read_t(anj_t *anj, const anj_dm_obj_t *obj, anj_iid_t iid, anj_rid_t rid, anj_riid_t riid, anj_res_value_t *out_value) |
A handler that reads the value of a Resource or Resource Instance.
This function is called only for Resources of the following types: ANJ_DM_RES_R, ANJ_DM_RES_RW, ANJ_DM_RES_RM, or ANJ_DM_RES_RWM.
For values of type ANJ_DATA_TYPE_BYTES, you must set both the data pointer and anj_bytes_or_string_value_t::chunk_length in out_value
.
For values of type ANJ_DATA_TYPE_STRING, do not modify any additional fields in out_value
— only the data pointer should be provided.
For values of type ANJ_DATA_TYPE_EXTERNAL_BYTES and ANJ_DATA_TYPE_EXTERNAL_STRING, you must set anj_res_value_t::get_external_data callback. anj_res_value_t::open_external_data and anj_res_value_t::close_external_data callbacks are optional. If the external data source needs initialization, it should be performed in the anj_res_value_t::open_external_data callback. This handler should do nothing more than assign the relevant addresses to the pointers in the anj_res_value_t::external_data structure.
anj | Anjay object to operate on. | |
obj | Object definition pointer. | |
iid | Object Instance ID. | |
rid | Resource ID. | |
riid | Resource Instance ID, or ANJ_ID_INVALID in case of a Single Resource. | |
[out] | out_value | Returned Resource value. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. typedef struct anj_dm_res_struct anj_dm_res_t |
Main Resource struct.
typedef int anj_dm_res_write_t(anj_t *anj, const anj_dm_obj_t *obj, anj_iid_t iid, anj_rid_t rid, anj_riid_t riid, const anj_res_value_t *value) |
A handler that writes the Resource or Resource Instance value, called only if the Resource or Resource Instance is PRESENT and is one of the ANJ_DM_RES_W, ANJ_DM_RES_RW, ANJ_DM_RES_WM, ANJ_DM_RES_RWM.
For values of type ANJ_DATA_TYPE_BYTES and ANJ_DATA_TYPE_STRING, in case of the block operation, handler can be called several times, with consecutive chunks of value - offset value in anj_bytes_or_string_value_t will be changing.
IMPORTANT: For value of type ANJ_DATA_TYPE_STRING always use chunk_length
to determine the length of the string, never use the strlen()
function - pointer to string data points directly to CoAP message payload.
anj | Anjay object to operate on. |
obj | Object definition pointer. |
iid | Object Instance ID. |
rid | Resource ID. |
riid | Resource Instance ID, or ANJ_ID_INVALID in case of a Single Resource. |
value | Resource value. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. typedef int anj_dm_transaction_begin_t(anj_t *anj, const anj_dm_obj_t *obj) |
A handler called at the beginning of a transactional operation that may modify the Object.
This function is invoked when the LwM2M server sends a request involving this Object that may alter its state — specifically for Create, Write, or Delete operations. It marks the beginning of a transaction.
anj | Anjay object to operate on. |
obj | Object definition pointer. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. typedef void anj_dm_transaction_end_t(anj_t *anj, const anj_dm_obj_t *obj, int result) |
A handler called at the end of a transactional operation.
This function is invoked after handling a Create, Write, or Delete request from the LwM2M server. If result
is non-zero value, the user is responsible for restoring the Object to its previous state.
anj | Anjay object to operate on. |
obj | Object definition pointer. |
result | Result of the operation. Non-zero value indicates failure. In case of failure, this value will either be:
|
typedef int anj_dm_transaction_validate_t(anj_t *anj, const anj_dm_obj_t *obj) |
A handler called after a transaction is finished, but before it is finalized.
This function is used to validate whether the operation can be safely completed. It is invoked for transactional operations that may modify the Object (i.e., Create, Write, and Delete) after all handler calls have completed, but before anj_dm_transaction_end_t is called.
anj | Anjay object to operate on. |
obj | Object definition pointer. |
ANJ_DM_ERR_*
constants, an appropriate CoAP error code will be used in the response. Otherwise, the device will respond with ANJ_COAP_CODE_INTERNAL_SERVER_ERROR. Resource operation types.