Function anj_dm_write_string_chunked

Function Documentation

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.

Note

This function must be used only for Resources of type ANJ_DATA_TYPE_STRING. For binary values, use anj_dm_write_bytes_chunked instead.

Parameters:
  • value – Resource value to be written.

  • buffer[out] Target buffer to write the data into.

  • buffer_len – Size of the target buffer (must include space for the null terminator).

  • 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.