Metadata handling

group Metadata handling

Handle JSON-formatted metadata.

Enums

enum jsdrv_meta_flag_e

Metadata flag bits (mirrors minibitty’s mb_pubsub_meta_flags_e).

Values:

enumerator JSDRV_META_FLAG_RO

Topic is read-only; cannot be updated by the host.

enumerator JSDRV_META_FLAG_HIDE

Topic should not appear in the user interface.

enumerator JSDRV_META_FLAG_DEV

Developer option; not for production use.

Functions

int32_t jsdrv_meta_syntax_check(const char *meta)

Check the JSON metadata syntax.

Parameters:

meta – The JSON metadata.

Returns:

0 or error code.

int32_t jsdrv_meta_dtype(const char *meta, uint8_t *dtype)

Get the data type.

Parameters:
  • meta – The JSON metadata.

  • dtype[out] The jsdrv_union_e data type.

Returns:

0 or error code.

int32_t jsdrv_meta_default(const char *meta, struct jsdrv_union_s *value)

Get the default value.

Parameters:
  • meta – The JSON metadata.

  • value[out] The parsed default value.

Returns:

0 or error code.

int32_t jsdrv_meta_value(const char *meta, struct jsdrv_union_s *value)

Validate a parameter value using the metadata.

Parameters:
  • meta – The JSON metadata.

  • value[inout] The value, which is modified in place.

Returns:

0 or error code.

int32_t jsdrv_meta_flags(const char *meta, uint32_t *flags)

Get the flags bitmask from the metadata.

Parses the “flags” key from the JSON metadata, which is a list of string tokens: “ro”, “hide”, “dev”. Returns a bitmask of jsdrv_meta_flag_e. If “flags” is absent, *flags is set to 0.

Parameters:
  • meta – The JSON metadata.

  • flags[out] The resulting bitmask.

Returns:

0 or error code.