25#if defined(__clang__) && !defined(ARDUINO)
26# pragma clang diagnostic push
27# pragma ide diagnostic ignored "OCUnusedMacroInspection"
28# pragma ide diagnostic ignored "UnreachableCallsOfFunction"
33double nan(
const char *tag);
37#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
38# define __attribute__(x)
43#define __NYX_NOTNULL__ \
46#define __NYX_NULLABLE__ \
49#define __NYX_ZEROABLE__ \
52#define __NYX_UNUSED__ \
53 __attribute__ ((unused))
55#define __NYX_INLINE__ \
56 __attribute__ ((always_inline)) static inline
68#define BUFF_t const void *
71#define STR_t const char *
102 __NYX_NULLABLE__
buff_t buff
112 __NYX_ZEROABLE__
size_t size
122 __NYX_NULLABLE__
buff_t buff,
123 __NYX_ZEROABLE__
size_t size
133 __NYX_NULLABLE__
STR_t s
143 __NYX_NULLABLE__
STR_t s,
144 __NYX_ZEROABLE__
size_t n
154 __NYX_NULLABLE__
BUFF_t b,
155 __NYX_ZEROABLE__
size_t n
201void __attribute__((format(printf, 5, 6))) nyx_log(
219#define NYX_LOG_FATAL(fmt, ...) \
220 do { nyx_log(NYX_LOG_LEVEL_FATAL, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(1)
230#define NYX_LOG_ERROR(fmt, ...) \
231 do { nyx_log(NYX_LOG_LEVEL_ERROR, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
241#define NYX_LOG_WARN(fmt, ...) \
242 do { nyx_log(NYX_LOG_LEVEL_WARN, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
252#define NYX_LOG_INFO(fmt, ...) \
253 do { nyx_log(NYX_LOG_LEVEL_INFO, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
263#define NYX_LOG_DEBUG(fmt, ...) \
264 do { nyx_log(NYX_LOG_LEVEL_DEBUG, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
274#define NYX_LOG_TRACE(fmt, ...) \
275 do { nyx_log(NYX_LOG_LEVEL_TRACE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
296 __NYX_ZEROABLE__
size_t size,
297 __NYX_NULLABLE__
BUFF_t buff,
312 uint8_t result_mac[6],
329 __NYX_NULLABLE__
size_t *result_len,
330 __NYX_ZEROABLE__
size_t size,
331 __NYX_NULLABLE__
BUFF_t buff
345 __NYX_NULLABLE__
size_t *result_size,
346 __NYX_ZEROABLE__
size_t len,
347 __NYX_NULLABLE__
STR_t str
361 __NYX_NULLABLE__
size_t *result_size,
362 __NYX_ZEROABLE__
size_t size,
363 __NYX_NULLABLE__
BUFF_t buff
377 __NYX_NOTNULL__
size_t *result_size,
378 __NYX_ZEROABLE__
size_t size,
379 __NYX_NULLABLE__
BUFF_t buff
393 __NYX_NULLABLE__
size_t *result_len,
394 __NYX_ZEROABLE__
size_t size,
395 __NYX_NULLABLE__
BUFF_t buff
409 __NYX_NOTNULL__
size_t *result_size,
410 __NYX_ZEROABLE__
size_t len,
411 __NYX_NULLABLE__
STR_t str
424#define NYX_OBJECT_MAGIC UINT32_C(0x65656500)
428#define NYX_FLAGS_DISABLED UINT64_C(0x0000000000000001)
431#define NYX_FLAGS_BLOB_MASK UINT64_C(0x00000001FFFFFFFC)
434#define NYX_FLAGS_STREAM_MASK UINT64_C(0xFFFFFFFE00000000)
469typedef struct nyx_object_s
479 __NYX_NULLABLE__
struct nyx_node_s *node;
481 __NYX_NULLABLE__
struct nyx_object_s *parent;
487 __NYX_NULLABLE__
void *_ptr;
489 __NYX_NULLABLE__ bool (* _int)(
490 struct nyx_dict_s *vector,
491 struct nyx_dict_s *prop,
496 __NYX_NULLABLE__ bool (* _uint)(
497 struct nyx_dict_s *vector,
498 struct nyx_dict_s *prop,
499 unsigned int new_value,
500 unsigned int old_value
503 __NYX_NULLABLE__ bool (* _long)(
504 struct nyx_dict_s *vector,
505 struct nyx_dict_s *prop,
510 __NYX_NULLABLE__ bool (* _ulong)(
511 struct nyx_dict_s *vector,
512 struct nyx_dict_s *prop,
513 unsigned long new_value,
514 unsigned long old_value
517 __NYX_NULLABLE__ bool (* _double)(
518 struct nyx_dict_s *vector,
519 struct nyx_dict_s *prop,
524 __NYX_NULLABLE__ bool (* _str)(
525 struct nyx_dict_s *vector,
526 struct nyx_dict_s *prop,
531 __NYX_NULLABLE__ bool (* _buffer)(
532 struct nyx_dict_s *vector,
533 struct nyx_dict_s *prop,
538 __NYX_NULLABLE__ void (* _vector)(
539 struct nyx_dict_s *vector,
547 __NYX_NULLABLE__
void *ctx;
564 __NYX_ZEROABLE__
size_t size,
565 __NYX_NULLABLE__
BUFF_t buff
578 __NYX_NULLABLE__
STR_t string
591 __NYX_NULLABLE__
void *
object
604 __NYX_NULLABLE__
void *
object
764double nyx_number_get(
794str_t nyx_number_to_string(
887str_t nyx_boolean_to_string(
971 __NYX_NULLABLE__
size_t *result_size,
972 __NYX_NULLABLE__
buff_t *result_buff
1107typedef struct nyx_dict_s
1111 struct nyx_dict_node_s *head;
1112 struct nyx_dict_node_s *tail;
1137#define NYX_DICT_ITER(dict) \
1138 ((nyx_dict_iter_t) {0, ((nyx_dict_t *) (dict))->head})
1197bool nyx_dict_iterate(
1244size_t nyx_dict_size(
1258str_t nyx_dict_to_string(
1438typedef struct nyx_list_s
1442 struct nyx_list_node_s *head;
1443 struct nyx_list_node_s *tail;
1468#define NYX_LIST_ITER(list) \
1469 ((nyx_list_iter_t) {0, ((nyx_list_t *) (list))->head})
1528bool nyx_list_iterate(
1573 return nyx_list_set(
object, (
size_t) -1, value);
1585size_t nyx_list_size(
1599str_t nyx_list_to_string(
1766#if !defined(ARDUINO)
1784 NYX_XML_COMMENT = 302,
1785 NYX_XML_CDATA = 303,
1797typedef struct nyx_xmldoc_s
1803 struct nyx_xmldoc_s *next;
1804 struct nyx_xmldoc_s *parent;
1806 struct nyx_xmldoc_s *children;
1807 struct nyx_xmldoc_s *attributes;
1824 __NYX_ZEROABLE__
size_t size,
1825 __NYX_NULLABLE__
BUFF_t buff
1838 __NYX_NULLABLE__
STR_t string
1872#if !defined(ARDUINO)
1915#define NYX_INDI_VERSION "1.7"
1938STR_t nyx_state_to_str(
1972STR_t nyx_perm_to_str(
2006STR_t nyx_rule_to_str(
2039STR_t nyx_onoff_to_str(
2093 __NYX_NULLABLE__
STR_t label,
2117 __NYX_NULLABLE__
STR_t label,
2141 __NYX_NULLABLE__
STR_t label,
2165 __NYX_NULLABLE__
STR_t label,
2189 __NYX_NULLABLE__
STR_t label,
2379 __NYX_NULLABLE__
STR_t label,
2380 __NYX_NULLABLE__
STR_t value,
2396 __NYX_NULLABLE__
STR_t value,
2464 __NYX_NULLABLE__
STR_t label,
2543 __NYX_NULLABLE__
STR_t label,
2630 __NYX_NULLABLE__
STR_t label,
2631 __NYX_NULLABLE__
STR_t format,
2632 __NYX_ZEROABLE__
size_t size,
2633 __NYX_NULLABLE__
BUFF_t buff,
2650 __NYX_ZEROABLE__
size_t size,
2651 __NYX_NULLABLE__
BUFF_t buff,
2667 __NYX_NULLABLE__
size_t *size,
2668 __NYX_NULLABLE__
buff_t *buff
2723 __NYX_NULLABLE__
STR_t label
2760 __NYX_ZEROABLE__
size_t n_fields,
2761 const size_t field_sizes[],
2762 const buff_t field_buffs[]
2794 __NYX_NULLABLE__
STR_t message
2810 __NYX_NULLABLE__
STR_t name,
2811 __NYX_NULLABLE__
STR_t message
2840 NYX_NODE_EVENT_OPEN = 1100,
2841 NYX_NODE_EVENT_MSG = 1101,
2864 size_t message_size,
2890 __NYX_NULLABLE__
STR_t indi_url,
2891 __NYX_NULLABLE__
STR_t mqtt_url,
2892 __NYX_NULLABLE__
STR_t nss_url,
2894 __NYX_NULLABLE__
STR_t mqtt_username,
2895 __NYX_NULLABLE__
STR_t mqtt_password,
2931 uint32_t interval_ms,
2932 void(* callback)(
void *),
2965 __NYX_NULLABLE__
STR_t name,
2966 __NYX_NULLABLE__
STR_t message
2983 __NYX_NULLABLE__
STR_t name,
2984 __NYX_NULLABLE__
STR_t message
3001 __NYX_NULLABLE__
STR_t message
3019 __NYX_NULLABLE__
STR_t name,
3020 __NYX_NULLABLE__
STR_t message
3056 __NYX_ZEROABLE__
size_t message_size,
3057 __NYX_NULLABLE__
BUFF_t message_buff,
3082 __NYX_ZEROABLE__
size_t n_fields,
3083 const uint32_t field_hashes[],
3084 const size_t field_sizes[],
3085 const buff_t field_buffs[]
3092#if defined(__clang__) && !defined(ARDUINO)
3093# pragma clang diagnostic pop
bool value
Boolean payload.
nyx_object_t base
Common object header for JSON objects.
__NYX_INLINE__ nyx_boolean_t * nyx_boolean_from(bool value)
Returns a JSON boolean object holding the value of the provided argument.
nyx_boolean_t * nyx_boolean_new(void)
Allocates a new JSON boolean object.
bool nyx_boolean_set(nyx_boolean_t *object, bool value)
Sets the value of the provided JSON boolean object.
Struct describing a JSON boolean object.
size_t idx
Current zero-based iteration index.
struct nyx_dict_node_s * head
Next JSON object to visit.
__NYX_INLINE__ bool nyx_dict_set_number(const nyx_dict_t *dict, STR_t key, double value)
Sets a number value of an existing key holding a number.
__NYX_INLINE__ bool nyx_dict_set_buff(const nyx_dict_t *dict, STR_t key, size_t size, BUFF_t buff, bool managed)
Sets the content of an existing key holding a string from a byte buffer.
__NYX_INLINE__ bool nyx_dict_set_string(const nyx_dict_t *dict, STR_t key, STR_t value, bool managed)
Sets a text value of an existing key holding a string.
__NYX_INLINE__ double nyx_dict_get_number(const nyx_dict_t *dict, STR_t key)
Gets a number value of the provided key.
__NYX_INLINE__ STR_t nyx_dict_get_string(const nyx_dict_t *dict, STR_t key)
Gets a text value of the provided key.
__NYX_INLINE__ bool nyx_dict_set_boolean(const nyx_dict_t *dict, STR_t key, bool value)
Sets a boolean value of an existing key holding a boolean.
nyx_object_t * nyx_dict_get(const nyx_dict_t *object, STR_t key)
Gets the JSON object of the provided key.
__NYX_INLINE__ bool nyx_dict_get_boolean(const nyx_dict_t *object, STR_t key)
Gets a boolean value of the provided key.
__NYX_INLINE__ void nyx_dict_get_buff(const nyx_dict_t *dict, STR_t key, __NYX_NULLABLE__ size_t *result_size, __NYX_NULLABLE__ buff_t *result_buff)
Gets the content of the provided key as a byte buffer.
Struct describing a JSON dict iterator.
Struct describing a JSON dict object.
struct nyx_list_node_s * head
Next JSON object to visit.
size_t idx
Current zero-based iteration index.
__NYX_INLINE__ void nyx_list_get_buff(const nyx_list_t *list, size_t idx, __NYX_NULLABLE__ size_t *result_size, __NYX_NULLABLE__ buff_t *result_buff)
Gets the content of the provided index as a byte buffer.
__NYX_INLINE__ double nyx_list_get_number(const nyx_list_t *list, size_t idx)
Gets a number value at the provided index.
__NYX_INLINE__ bool nyx_list_push(nyx_list_t *object, void *value)
Pushes a JSON object in the provided JSON list object.
__NYX_INLINE__ STR_t nyx_list_get_string(const nyx_list_t *list, size_t idx)
Gets a text value at the provided index.
__NYX_INLINE__ bool nyx_list_get_boolean(const nyx_list_t *object, size_t idx)
Gets a boolean value at the provided index.
__NYX_INLINE__ bool nyx_list_set_string(const nyx_list_t *list, size_t idx, STR_t value, bool managed)
Sets a text value of an existing index holding a string.
__NYX_INLINE__ bool nyx_list_set_number(const nyx_list_t *list, size_t idx, double value)
Sets a number value of an existing index holding a number.
nyx_object_t * nyx_list_get(const nyx_list_t *object, size_t idx)
Gets the JSON object at the provided index.
__NYX_INLINE__ bool nyx_list_set_boolean(const nyx_list_t *list, size_t idx, bool value)
Sets a boolean value of an existing index holding a boolean.
__NYX_INLINE__ bool nyx_list_set_buff(const nyx_list_t *list, size_t idx, size_t size, BUFF_t buff, bool managed)
Sets the content of an existing index holding a string from a byte buffer.
Struct describing a JSON list iterator.
Struct describing a JSON list object.
nyx_log_level_e
Nyx log levels.
void nyx_set_log_level(nyx_log_level_t level)
Sets the log level threshold.
enum nyx_log_level_e nyx_log_level_t
Nyx log levels.
@ NYX_LOG_LEVEL_NONE
Logging disabled.
@ NYX_LOG_LEVEL_ERROR
Error level.
@ NYX_LOG_LEVEL_DEBUG
Debug level.
@ NYX_LOG_LEVEL_TRACE
Trace level.
@ NYX_LOG_LEVEL_INFO
Log level.
@ NYX_LOG_LEVEL_WARN
Warning level.
@ NYX_LOG_LEVEL_FATAL
Fatal level.
#define STR_t
Alias for const char *.
__NYX_NULLABLE__ buff_t nyx_memory_alloc(__NYX_ZEROABLE__ size_t size)
Similar to libc malloc except that a memory overflow causes the node to stop.
__NYX_ZEROABLE__ size_t nyx_memory_free(__NYX_NULLABLE__ buff_t buff)
Similar to libc free except that it returns the amount of memory freed.
#define buff_t
Alias for void *.
#define BUFF_t
Alias for const void *.
void nyx_memory_initialize(void)
Initializes the memory subsystem.
bool nyx_memory_finalize(void)
Finalizes the memory subsystem.
__NYX_NULLABLE__ buff_t nyx_buffer_ndup(__NYX_NULLABLE__ BUFF_t b, __NYX_ZEROABLE__ size_t n)
Similar to libc memdup.
__NYX_NULLABLE__ str_t nyx_string_dup(__NYX_NULLABLE__ STR_t s)
Similar to libc strdup.
__NYX_NULLABLE__ str_t nyx_string_ndup(__NYX_NULLABLE__ STR_t s, __NYX_ZEROABLE__ size_t n)
Similar to libc strndup.
__NYX_NULLABLE__ buff_t nyx_memory_realloc(__NYX_NULLABLE__ buff_t buff, __NYX_ZEROABLE__ size_t size)
Similar to libc realloc except that a memory overflow causes the node to stop.
#define str_t
Alias for char *.
void nyx_node_add_timer(const nyx_node_t *node, uint32_t interval_ms, void(*callback)(void *), void *arg)
Adds a new timer.
nyx_event_type_t
TCP or MQTT event type.
void nyx_node_send_message(const nyx_node_t *node, STR_t device, __NYX_NULLABLE__ STR_t message)
Sends a human-oriented message to the clients.
void nyx_node_disable(const nyx_node_t *node, STR_t device, __NYX_NULLABLE__ STR_t name, __NYX_NULLABLE__ STR_t message)
Disables a device or a vector and notifies clients.
void nyx_mqtt_pub(const nyx_node_t *node, STR_t topic, __NYX_ZEROABLE__ size_t message_size, __NYX_NULLABLE__ BUFF_t message_buff, int qos)
If MQTT is enabled, publishes an MQTT message.
void nyx_nss_pub(const nyx_node_t *node, STR_t device, STR_t stream, __NYX_ZEROABLE__ size_t n_fields, const uint32_t field_hashes[], const size_t field_sizes[], const buff_t field_buffs[])
If Nyx Stream is enabled, publishes an entry to a stream.
__NYX_NULLABLE__ nyx_node_t * nyx_node_initialize(STR_t node_id, nyx_dict_t *vectors[], __NYX_NULLABLE__ STR_t indi_url, __NYX_NULLABLE__ STR_t mqtt_url, __NYX_NULLABLE__ STR_t nss_url, __NYX_NULLABLE__ STR_t mqtt_username, __NYX_NULLABLE__ STR_t mqtt_password, __NYX_NULLABLE__ nyx_mqtt_handler_t mqtt_handler, uint32_t retry_ms, bool enable_xml)
Allocates and initializes a new Nyx node.
void nyx_mqtt_sub(const nyx_node_t *node, STR_t topic, int qos)
If MQTT is enabled, subscribes to an MQTT topic.
void(* nyx_mqtt_handler_t)(nyx_node_t *node, nyx_event_type_t event_type, size_t topic_size, BUFF_t topic_buff, size_t message_size, BUFF_t message_buff)
MQTT event handler.
void nyx_node_send_del_property(const nyx_node_t *node, STR_t device, __NYX_NULLABLE__ STR_t name, __NYX_NULLABLE__ STR_t message)
Sends a del-property message to the clients.
void nyx_node_poll(const nyx_node_t *node, uint32_t timeout_ms)
Performs a single poll iteration.
void nyx_node_finalize(nyx_node_t *node, bool free_vectors)
Finalizes a Nyx node.
void nyx_node_enable(const nyx_node_t *node, STR_t device, __NYX_NULLABLE__ STR_t name, __NYX_NULLABLE__ STR_t message)
Enables a device or a vector and notifies clients.
Opaque struct describing a Nyx node.
nyx_object_t base
Common object header for JSON objects.
str_t nyx_null_to_string(const nyx_null_t *object)
Returns a string representing the provided JSON null object.
Struct describing a JSON null object.
double value
Number payload.
nyx_object_t base
Common object header for JSON objects.
__NYX_INLINE__ nyx_number_t * nyx_number_from(double value)
Returns a JSON number object holding the value of the provided argument.
nyx_number_t * nyx_number_new(void)
Allocates a new JSON number object.
bool nyx_number_set(nyx_number_t *object, double value)
Sets the value of the provided JSON number object.
Struct describing a JSON number object.
nyx_dict_t * nyx_blob_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label, __NYX_NULLABLE__ STR_t format, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff, bool managed)
Allocates a new INDI / Nyx BLOB property.
void nyx_blob_prop_get(const nyx_dict_t *prop, __NYX_NULLABLE__ size_t *size, __NYX_NULLABLE__ buff_t *buff)
Gets the payload of the provided property object.
bool nyx_blob_prop_set(const nyx_dict_t *prop, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff, bool managed)
Sets the payload of the provided property object.
nyx_dict_t * nyx_blob_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_perm_t perm, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx BLOB vector.
nyx_dict_t * nyx_light_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label, nyx_state_t value)
Allocates a new INDI / Nyx light property.
bool nyx_light_prop_set(const nyx_dict_t *prop, nyx_state_t value)
Sets the new value of the provided property object.
nyx_state_t nyx_light_prop_get(const nyx_dict_t *prop)
Gets the value of the provided property object.
nyx_dict_t * nyx_light_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx light vector.
nyx_dict_t * nyx_message_new(STR_t device, __NYX_NULLABLE__ STR_t message)
Allocates a new INDI / Nyx human-oriented message object.
nyx_dict_t * nyx_del_property_new(STR_t device, __NYX_NULLABLE__ STR_t name, __NYX_NULLABLE__ STR_t message)
Allocates a new INDI / Nyx delete-property message object.
nyx_dict_t * nyx_number_prop_new_int(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, int32_t min, int32_t max, int32_t step, int32_t value)
Allocates a new INDI / Nyx int32_t number property.
int64_t nyx_number_prop_get_long(const nyx_dict_t *prop)
Gets the value of the provided property object.
int32_t nyx_number_prop_get_int(const nyx_dict_t *prop)
Gets the value of the provided property object.
nyx_dict_t * nyx_number_prop_new_long(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, int64_t min, int64_t max, int64_t step, int64_t value)
Allocates a new INDI / Nyx int64_t number property.
nyx_dict_t * nyx_number_prop_new_double(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, double min, double max, double step, double value)
Allocates a new INDI / Nyx double number property.
nyx_dict_t * nyx_number_prop_new_ulong(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, uint64_t min, uint64_t max, uint64_t step, uint64_t value)
Allocates a new INDI / Nyx uint64_t number property.
bool nyx_number_prop_set_int(nyx_dict_t *prop, int32_t value)
Sets the new value of the provided property object.
double nyx_number_prop_get_double(const nyx_dict_t *prop)
Gets the value of the provided property object.
uint64_t nyx_number_prop_get_ulong(const nyx_dict_t *prop)
Gets the value of the provided property object.
bool nyx_number_prop_set_ulong(nyx_dict_t *prop, uint64_t value)
Sets the new value of the provided property object.
nyx_dict_t * nyx_number_prop_new_uint(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, uint32_t min, uint32_t max, uint32_t step, uint32_t value)
Allocates a new INDI / Nyx uint32_t number property.
bool nyx_number_prop_set_long(nyx_dict_t *prop, int64_t value)
Sets the new value of the provided property object.
bool nyx_number_prop_set_uint(nyx_dict_t *prop, uint32_t value)
Sets the new value of the provided property object.
nyx_dict_t * nyx_number_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_perm_t perm, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx number vector.
uint32_t nyx_number_prop_get_uint(const nyx_dict_t *prop)
Gets the value of the provided property object.
bool nyx_number_prop_set_double(nyx_dict_t *prop, double value)
Sets the new value of the provided property object.
nyx_dict_t * nyx_stream_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new Nyx Stream vector.
nyx_dict_t * nyx_stream_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label)
Allocates a new Nyx Stream property.
bool nyx_stream_pub(const nyx_dict_t *vector, __NYX_ZEROABLE__ size_t n_fields, const size_t field_sizes[], const buff_t field_buffs[])
If Nyx Stream is enabled, publishes an entry to a stream.
bool nyx_switch_prop_set(const nyx_dict_t *prop, nyx_onoff_t value)
Sets the new value of the provided property object.
nyx_dict_t * nyx_switch_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_perm_t perm, nyx_rule_t rule, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx switch vector.
nyx_dict_t * nyx_switch_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label, nyx_onoff_t value)
Allocates a new INDI / Nyx switch property.
nyx_onoff_t nyx_switch_prop_get(const nyx_dict_t *prop)
Gets the value of the provided property object.
STR_t nyx_text_prop_get(const nyx_dict_t *prop)
Gets the text value of the provided property object.
nyx_dict_t * nyx_text_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_perm_t perm, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx text vector.
nyx_dict_t * nyx_text_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label, __NYX_NULLABLE__ STR_t value, bool managed)
Allocates a new INDI / Nyx text property.
bool nyx_text_prop_set(const nyx_dict_t *prop, __NYX_NULLABLE__ STR_t value, bool managed)
Sets the text value of the provided property object.
__NYX_ZEROABLE__ double timeout
Worst-case time [sec] to apply, 0 by default, N/A for RO.
__NYX_NULLABLE__ STR_t label
GUI label, if NULL, replaced by the device name.
__NYX_NULLABLE__ STR_t hints
GUI Markdown description.
__NYX_NULLABLE__ STR_t message
Free comment.
__NYX_NULLABLE__ STR_t group
GUI group membership, if NULL, replaced by "Main".
nyx_perm_t
Vector permission hint.
nyx_state_t
Vector state hint.
nyx_rule_t
Switch vector rule hint.
@ NYX_PERM_RW
Read & write.
@ NYX_STATE_IDLE
State is idle.
@ NYX_STATE_BUSY
State is busy.
@ NYX_STATE_OK
State is ok.
@ NYX_STATE_ALERT
State is alert.
@ NYX_ONOFF_ON
Switch is ON.
@ NYX_ONOFF_OFF
Switch is OFF.
@ NYX_RULE_ONE_OF_MANY
Only one switch of many can be ON (e.g., radio buttons).
@ NYX_RULE_ANY_OF_MANY
Any number of switches can be ON (e.g., check boxes).
@ NYX_RULE_AT_MOST_ONE
At most one switch can be ON, but all switches can be OFF.
Struct describing the options for INDI / Nyx vectors.
str_t nyx_object_to_cstring(__NYX_NULLABLE__ const nyx_object_t *object)
Returns a C string, without special character escaping, representing the provided JSON object.
__NYX_NULLABLE__ nyx_object_t * nyx_object_ref(__NYX_NULLABLE__ void *object)
Increments the reference counter of the provided JSON object.
__NYX_NULLABLE__ nyx_object_t * nyx_object_unref(__NYX_NULLABLE__ void *object)
Decrements the reference counter of the provided JSON object and frees it when it reaches zero.
nyx_type_t
JSON object types.
bool nyx_object_notify(__NYX_NULLABLE__ const nyx_object_t *object)
Notifies the provided Nyx / INDI object to the clients.
__NYX_NULLABLE__ nyx_object_t * nyx_object_parse(__NYX_NULLABLE__ STR_t string)
Parses a JSON object from a C string.
bool nyx_object_equal(__NYX_NULLABLE__ const nyx_object_t *object1, __NYX_NULLABLE__ const nyx_object_t *object2)
Compares two JSON objects.
__NYX_NULLABLE__ nyx_object_t * nyx_object_parse_buff(__NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Parses a JSON object from a string buffer.
str_t nyx_object_to_string(__NYX_NULLABLE__ const nyx_object_t *object)
Returns a string, with the special character escaping, representing the provided JSON object.
#define NYX_OBJECT_MAGIC
Magic number for identifying JSON objects.
nyx_type_t nyx_object_get_type(__NYX_NULLABLE__ const nyx_object_t *object)
Gets the type of the provided JSON object.
@ NYX_TYPE_DICT
Dict object.
@ NYX_TYPE_LIST
List object.
@ NYX_TYPE_BOOLEAN
Boolean object.
@ NYX_TYPE_NUMBER
Number object.
@ NYX_TYPE_NULL
Null object.
@ NYX_TYPE_STRING
String object.
Struct describing a JSON object.
str_t value
C string payload.
nyx_object_t base
Common object header for JSON objects.
size_t length
C string length excluding NULL.
bool managed
true if the value is freed with this object.
void nyx_string_get_buff(const nyx_string_t *object, __NYX_NULLABLE__ size_t *result_size, __NYX_NULLABLE__ buff_t *result_buff)
Gets the content of the provided JSON string object as a byte buffer.
size_t nyx_string_length(const nyx_string_t *object)
Returns the number of content bytes of the provided JSON string object.
__NYX_INLINE__ nyx_string_t * nyx_string_from_buff(size_t size, BUFF_t buff, bool managed)
Returns a JSON string object holding the provided content bytes.
bool nyx_string_set(nyx_string_t *object, STR_t value, bool managed)
Sets the text value of the provided JSON string object.
str_t nyx_string_to_string(const nyx_string_t *object)
Returns a C string, with the special character escaping, representing the provided JSON string object...
str_t nyx_string_to_cstring(const nyx_string_t *object)
Returns a C string, without special character escaping, representing the provided JSON string object.
nyx_string_t * nyx_string_new(void)
Allocates a new JSON string object.
bool nyx_string_set_buff(nyx_string_t *object, size_t size, BUFF_t buff, bool managed)
Sets the content of the provided JSON string object from a byte buffer.
__NYX_INLINE__ nyx_string_t * nyx_string_from(STR_t value, bool managed)
Returns a JSON string object holding the provided text value.
Struct describing a JSON string object.
__NYX_NULLABLE__ buff_t nyx_zlib_inflate(__NYX_NOTNULL__ size_t *result_size, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Decompresses a buffer using the ZLib algorithm.
uint32_t nyx_hash(__NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff, uint32_t seed)
Hashes a buffer using the MurmurHash2 algorithm.
__NYX_NULLABLE__ buff_t nyx_zlib_base64_inflate(__NYX_NOTNULL__ size_t *result_size, __NYX_ZEROABLE__ size_t len, __NYX_NULLABLE__ STR_t str)
Decompresses a string using the ZLib+Base64 algorithm.
__NYX_NULLABLE__ buff_t nyx_zlib_deflate(__NYX_NULLABLE__ size_t *result_size, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Compresses a buffer using the ZLib algorithm.
__NYX_NULLABLE__ str_t nyx_base64_encode(__NYX_NULLABLE__ size_t *result_len, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Encodes a buffer using the Base64 algorithm.
__NYX_NULLABLE__ str_t nyx_zlib_base64_deflate(__NYX_NULLABLE__ size_t *result_len, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Compresses a buffer using the ZLib+Base64 algorithm.
__NYX_NULLABLE__ buff_t nyx_base64_decode(__NYX_NULLABLE__ size_t *result_size, __NYX_ZEROABLE__ size_t len, __NYX_NULLABLE__ STR_t str)
Decodes a string using the Base64 algorithm.
void nyx_generate_mac_addr(uint8_t result_mac[6], uint8_t mac0, uint8_t mac1, STR_t node_id)
Generates a MAC address based on a node identifier.
nyx_xml_type_t
XML node types.
str_t nyx_xmldoc_to_string(const nyx_xmldoc_t *xmldoc)
Returns a string representing the provided XML document.
void nyx_xmldoc_free(__NYX_NULLABLE__ nyx_xmldoc_t *xmldoc)
Frees memory of the provided XML document.
__NYX_NULLABLE__ nyx_xmldoc_t * nyx_xmldoc_parse(__NYX_NULLABLE__ STR_t string)
Parses an XML document from a C string.
__NYX_NULLABLE__ nyx_xmldoc_t * nyx_xmldoc_parse_buff(__NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Parses an XML document from a string buffer.
Struct describing an XML document.