Function anj_dm_write_bytes_chunked

Function Documentation

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.

Note

This function must be used only for Resources of type ANJ_DATA_TYPE_BYTES. For string values, use anj_dm_write_string_chunked instead.

Parameters:
  • value – Resource value to be written.

  • buffer[out] Target buffer to write into.

  • buffer_len – Size of the target buffer.

  • out_bytes_len[out] Set to total data length if the current chunk is the last one.

  • out_is_last_chunk[out] Optional parameter. Set to true if this is the last chunk of data.

Returns:

0 on success, a non-zero value in case of an error.