Typedef anjay_dm_list_resource_instances_t

Typedef Documentation

typedef int anjay_dm_list_resource_instances_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid, anjay_dm_list_ctx_t *ctx)

A handler that enumerates all Resource Instances of a Multiple Resource, called only if the Resource is PRESENT and is of either ANJAY_DM_RES_RM, ANJAY_DM_RES_WM or ANJAY_DM_RES_RWM kind (as returned by anjay_dm_list_resources_t).

The library will not attempt to call anjay_dm_resource_write_t or anjay_dm_resource_reset_t handlers inside the anjay_dm_emit calls performed from this handler, so the implementation is free to use iteration state that would be invalidated by such calls.

CAUTION: Aside from the note above, the library MAY call other data model handlers for the same Object from within the anjay_dm_emit call. Please make sure that your code is able to handle this - e.g. avoid calling anjay_dm_emit with a non-recursive object-scope mutex locked.

Resource instance listing handlers MUST always return Resource Instance IDs in a strictly ascending, sorted order. Failure to do so will result in an error being sent to the LwM2M server or passed down to internal routines that called this handler.

Param anjay:

Anjay object to operate on.

Param obj_ptr:

Object definition pointer, as passed to anjay_register_object .

Param iid:

Object Instance ID.

Param rid:

Resource ID.

Param ctx:

Context through which the Resource Instance IDs shall be returned, see anjay_dm_emit .

Return:

This handler should return:

  • 0 on success,

  • a negative value in case of error. If it returns one of ANJAY_ERR_ constants, the response message will have an appropriate CoAP response code. Otherwise, the device will respond with an unspecified (but valid) error code.