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 *
101 __NYX_NULLABLE__
buff_t buff
111 __NYX_ZEROABLE__
size_t size
121 __NYX_NULLABLE__
buff_t buff,
122 __NYX_ZEROABLE__
size_t size
132 __NYX_NULLABLE__
STR_t s
142 __NYX_NULLABLE__
STR_t s,
143 __NYX_ZEROABLE__
size_t n
162 NYX_LOG_LEVEL_NONE = 100,
163 NYX_LOG_LEVEL_FATAL = 101,
164 NYX_LOG_LEVEL_ERROR = 102,
165 NYX_LOG_LEVEL_WARN = 103,
166 NYX_LOG_LEVEL_INFO = 104,
167 NYX_LOG_LEVEL_DEBUG = 105,
168 NYX_LOG_LEVEL_TRACE = 106,
189void __attribute__((format(printf, 5, 6))) nyx_log(
207#define NYX_LOG_FATAL(fmt, ...) \
208 do { nyx_log(NYX_LOG_LEVEL_FATAL, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(1)
218#define NYX_LOG_ERROR(fmt, ...) \
219 do { nyx_log(NYX_LOG_LEVEL_ERROR, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
229#define NYX_LOG_INFO(fmt, ...) \
230 do { nyx_log(NYX_LOG_LEVEL_INFO, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
240#define NYX_LOG_DEBUG(fmt, ...) \
241 do { nyx_log(NYX_LOG_LEVEL_DEBUG, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
251#define NYX_LOG_VERBOSE(fmt, ...) \
252 do { nyx_log(NYX_LOG_LEVEL_VERBOSE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
273 __NYX_ZEROABLE__
size_t size,
274 __NYX_NULLABLE__
BUFF_t buff,
289 uint8_t result_mac[6],
306 __NYX_NULLABLE__
size_t *result_len,
307 __NYX_ZEROABLE__
size_t size,
308 __NYX_NULLABLE__
BUFF_t buff
322 __NYX_NULLABLE__
size_t *result_size,
323 __NYX_ZEROABLE__
size_t len,
324 __NYX_NULLABLE__
STR_t str
338 __NYX_NULLABLE__
size_t *result_size,
339 __NYX_ZEROABLE__
size_t size,
340 __NYX_NULLABLE__
BUFF_t buff
354 __NYX_NOTNULL__
size_t *result_size,
355 __NYX_ZEROABLE__
size_t size,
356 __NYX_NULLABLE__
BUFF_t buff
370 __NYX_NULLABLE__
size_t *result_len,
371 __NYX_ZEROABLE__
size_t size,
372 __NYX_NULLABLE__
BUFF_t buff
386 __NYX_NOTNULL__
size_t *result_size,
387 __NYX_ZEROABLE__
size_t len,
388 __NYX_NULLABLE__
STR_t str
401#define NYX_OBJECT_MAGIC UINT32_C(0x65656565)
405#define NYX_FLAGS_DISABLED UINT64_C(0x0000000000000001)
408#define NYX_FLAGS_BLOB_MASK UINT64_C(0x00000001FFFFFFFC)
411#define NYX_FLAGS_STREAM_MASK UINT64_C(0xFFFFFFFE00000000)
446typedef struct nyx_object_s
457 __NYX_NULLABLE__
struct nyx_node_s *node;
459 __NYX_NULLABLE__
struct nyx_object_s *parent;
465 __NYX_NULLABLE__
void *_ptr;
467 __NYX_NULLABLE__ bool (* _int)(
468 struct nyx_dict_s *vector,
469 struct nyx_dict_s *prop,
474 __NYX_NULLABLE__ bool (* _uint)(
475 struct nyx_dict_s *vector,
476 struct nyx_dict_s *prop,
477 unsigned int new_value,
478 unsigned int old_value
481 __NYX_NULLABLE__ bool (* _long)(
482 struct nyx_dict_s *vector,
483 struct nyx_dict_s *prop,
488 __NYX_NULLABLE__ bool (* _ulong)(
489 struct nyx_dict_s *vector,
490 struct nyx_dict_s *prop,
491 unsigned long new_value,
492 unsigned long old_value
495 __NYX_NULLABLE__ bool (* _double)(
496 struct nyx_dict_s *vector,
497 struct nyx_dict_s *prop,
502 __NYX_NULLABLE__ bool (* _str)(
503 struct nyx_dict_s *vector,
504 struct nyx_dict_s *prop,
509 __NYX_NULLABLE__ bool (* _buffer)(
510 struct nyx_dict_s *vector,
511 struct nyx_dict_s *prop,
516 __NYX_NULLABLE__ void (* _vector)(
517 struct nyx_dict_s *vector,
525 __NYX_NULLABLE__
void *ctx;
542 __NYX_ZEROABLE__
size_t size,
543 __NYX_NULLABLE__
BUFF_t buff
556 __NYX_NULLABLE__
STR_t string
727double nyx_number_get(
757str_t nyx_number_to_string(
774 nyx_number_set(result, value);
820void nyx_boolean_free(
862str_t nyx_boolean_to_string(
879 nyx_boolean_set(result, value);
950void nyx_string_get_buff(
952 __NYX_NULLABLE__
size_t *result_size,
953 __NYX_NULLABLE__
buff_t *result_buff
985bool nyx_string_set_buff(
1001size_t nyx_string_length(
1015str_t nyx_string_to_string(
1066 nyx_string_set(result, value,
true);
1085 nyx_string_set(result, value,
false);
1105 nyx_string_set_buff(result, size, buff,
true);
1125 nyx_string_set_buff(result, size, buff,
false);
1146typedef struct nyx_dict_s
1150 struct nyx_dict_node_s *head;
1151 struct nyx_dict_node_s *tail;
1176#define NYX_DICT_ITER(dict) \
1177 ((nyx_dict_iter_t) {.idx = 0, .head = ((nyx_dict_t *) (dict))->head})
1248bool nyx_dict_iterate(
1295size_t nyx_dict_size(
1309str_t nyx_dict_to_string(
1386typedef struct nyx_list_s
1390 struct nyx_list_node_s *head;
1391 struct nyx_list_node_s *tail;
1416#define NYX_LIST_ITER(list) \
1417 ((nyx_list_iter_t) {.idx = 0, .head = ((nyx_list_t *) (list))->head})
1488bool nyx_list_iterate(
1533 return nyx_list_set(
object, (
size_t) -1, value);
1545size_t nyx_list_size(
1559str_t nyx_list_to_string(
1623#if !defined(ARDUINO)
1641 NYX_XML_COMMENT = 302,
1642 NYX_XML_CDATA = 303,
1654typedef struct nyx_xmldoc_s
1657 nyx_xml_type_t type;
1660 struct nyx_xmldoc_s *next;
1661 struct nyx_xmldoc_s *parent;
1663 struct nyx_xmldoc_s *children;
1664 struct nyx_xmldoc_s *attributes;
1681 __NYX_ZEROABLE__
size_t size,
1682 __NYX_NULLABLE__
BUFF_t buff
1695 __NYX_NULLABLE__
STR_t string
1720str_t nyx_xmldoc_to_string(
1729#if !defined(ARDUINO)
1772#define NYX_INDI_VERSION "1.7"
1795STR_t nyx_state_to_str(
1829STR_t nyx_perm_to_str(
1863STR_t nyx_rule_to_str(
1896STR_t nyx_onoff_to_str(
1938 NYX_VARIANT_TYPE_INT = 1000,
1939 NYX_VARIANT_TYPE_UINT = 1001,
1940 NYX_VARIANT_TYPE_LONG = 1002,
1941 NYX_VARIANT_TYPE_ULONG = 1003,
1942 NYX_VARIANT_TYPE_DOUBLE = 1004,
1968__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_INT(int32_t value)
1971 return (nyx_variant_t) {NYX_VARIANT_TYPE_INT, {._int = value}};
1973 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_INT, {._int = value}};
1983__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_UINT(uint32_t value)
1986 return (nyx_variant_t) {NYX_VARIANT_TYPE_UINT, {._uint = value}};
1988 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_UINT, {._uint = value}};
1998__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_LONG(int64_t value)
2001 return (nyx_variant_t) {NYX_VARIANT_TYPE_LONG, {._long = value}};
2003 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_LONG, {._long = value}};
2013__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_ULONG(uint64_t value)
2016 return (nyx_variant_t) {NYX_VARIANT_TYPE_ULONG, {._ulong = value}};
2018 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_ULONG, {._ulong = value}};
2028__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_DOUBLE(
double value)
2031 return (nyx_variant_t) {NYX_VARIANT_TYPE_DOUBLE, {._double = value}};
2033 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_DOUBLE, {._double = value}};
2052 __NYX_NULLABLE__
STR_t label,
2076 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_INT(min), NYX_VARIANT_FROM_INT(max), NYX_VARIANT_FROM_INT(step), NYX_VARIANT_FROM_INT(value));
2095 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_UINT(min), NYX_VARIANT_FROM_UINT(max), NYX_VARIANT_FROM_UINT(step), NYX_VARIANT_FROM_UINT(value));
2114 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_LONG(min), NYX_VARIANT_FROM_LONG(max), NYX_VARIANT_FROM_LONG(step), NYX_VARIANT_FROM_LONG(value));
2133 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_ULONG(min), NYX_VARIANT_FROM_ULONG(max), NYX_VARIANT_FROM_ULONG(step), NYX_VARIANT_FROM_ULONG(value));
2152 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_DOUBLE(min), NYX_VARIANT_FROM_DOUBLE(max), NYX_VARIANT_FROM_DOUBLE(step), NYX_VARIANT_FROM_DOUBLE(value));
2160bool nyx_number_prop_set(
2170nyx_variant_t nyx_number_prop_get(
2185 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_INT(value));
2198 return nyx_number_prop_get(prop).value._int;
2212 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_UINT(value));
2225 return nyx_number_prop_get(prop).value._uint;
2239 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_LONG(value));
2252 return nyx_number_prop_get(prop).value._long;
2266 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_ULONG(value));
2279 return nyx_number_prop_get(prop).value._ulong;
2293 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_DOUBLE(value));
2306 return nyx_number_prop_get(prop).value._double;
2361 __NYX_NULLABLE__
STR_t label,
2362 __NYX_NULLABLE__
STR_t value
2377 __NYX_NULLABLE__
STR_t value
2443 __NYX_NULLABLE__
STR_t label,
2522 __NYX_NULLABLE__
STR_t label,
2609 __NYX_NULLABLE__
STR_t label,
2610 __NYX_NULLABLE__
STR_t format,
2611 __NYX_ZEROABLE__
size_t size,
2612 __NYX_NULLABLE__
BUFF_t buff,
2629 __NYX_ZEROABLE__
size_t size,
2630 __NYX_NULLABLE__
BUFF_t buff
2646 __NYX_ZEROABLE__
size_t size,
2647 __NYX_NULLABLE__
BUFF_t buff
2661 __NYX_NULLABLE__
size_t *size,
2662 __NYX_NULLABLE__
buff_t *buff
2717 __NYX_NULLABLE__
STR_t label
2753 __NYX_ZEROABLE__
size_t n_fields,
2754 const size_t field_sizes[],
2755 const buff_t field_buffs[]
2787 __NYX_NULLABLE__
STR_t message
2803 __NYX_NULLABLE__
STR_t name,
2804 __NYX_NULLABLE__
STR_t message
2833 NYX_NODE_EVENT_OPEN = 1100,
2834 NYX_NODE_EVENT_MSG = 1101,
2851typedef void (* nyx_mqtt_handler_t)(
2856 size_t message_size,
2882 __NYX_NULLABLE__
STR_t indi_url,
2883 __NYX_NULLABLE__
STR_t mqtt_url,
2884 __NYX_NULLABLE__
STR_t nss_url,
2886 __NYX_NULLABLE__
STR_t mqtt_username,
2887 __NYX_NULLABLE__
STR_t mqtt_password,
2889 __NYX_NULLABLE__ nyx_mqtt_handler_t mqtt_handler,
2904void nyx_node_finalize(
2921void nyx_node_add_timer(
2923 uint32_t interval_ms,
2924 void(* callback)(
void *),
2968 __NYX_NULLABLE__
STR_t name,
2969 __NYX_NULLABLE__
STR_t message
2986 __NYX_NULLABLE__
STR_t name,
2987 __NYX_NULLABLE__
STR_t message
3004 __NYX_NULLABLE__
STR_t message
3022 __NYX_NULLABLE__
STR_t name,
3023 __NYX_NULLABLE__
STR_t message
3058 __NYX_ZEROABLE__
size_t message_size,
3059 __NYX_NULLABLE__
BUFF_t message_buff,
3083 __NYX_ZEROABLE__
size_t n_fields,
3084 const uint32_t field_hashes[],
3085 const size_t field_sizes[],
3086 const buff_t field_buffs[]
3094# pragma clang diagnostic pop
__NYX_INLINE__ nyx_boolean_t * nyx_boolean_from(bool value)
Returns a JSON boolean object holding the value of the provided argument.
__NYX_INLINE__ double nyx_dict_get_number(const nyx_dict_t *object, STR_t key)
Gets a number value 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__ STR_t nyx_dict_get_string(const nyx_dict_t *object, STR_t key)
Gets a C string value of the provided key.
__NYX_INLINE__ bool nyx_list_push(nyx_list_t *object, void *value)
Pushes a JSON object in the provided JSON list object.
__NYX_INLINE__ double nyx_list_get_number(const nyx_list_t *object, size_t idx)
Gets a number value at the provided index.
__NYX_INLINE__ STR_t nyx_list_get_string(const nyx_list_t *object, size_t idx)
Gets a C string 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_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.
#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)
Initialize the memory subsystem.
bool nyx_memory_finalize(void)
Finalize the memory subsystem.
__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 *.
bool nyx_node_notify(__NYX_NULLABLE__ nyx_object_t *object)
Notifies the provided Nyx / INDI object to the clients.
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_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_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.
str_t nyx_null_to_string(const nyx_null_t *object)
Returns a string representing the provided JSON null object.
__NYX_INLINE__ nyx_number_t * nyx_number_from(double value)
Returns a JSON number object holding the value of the provided argument.
bool nyx_blob_prop_set_unmanaged(nyx_dict_t *prop, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Sets the new value of the provided property 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 current value 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.
bool nyx_blob_prop_set_managed(nyx_dict_t *prop, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Sets the new value of the provided property object.
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(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 current 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_INLINE__ uint32_t nyx_number_prop_get_uint(const nyx_dict_t *prop)
Gets the current value of the provided property object.
__NYX_INLINE__ bool nyx_number_prop_set_double(nyx_dict_t *prop, double value)
Sets the new value of the provided property object.
__NYX_INLINE__ double nyx_number_prop_get_double(const nyx_dict_t *prop)
Gets the current value of the provided property object.
__NYX_INLINE__ int64_t nyx_number_prop_get_long(const nyx_dict_t *prop)
Gets the current value of the provided property object.
__NYX_INLINE__ int32_t nyx_number_prop_get_int(const nyx_dict_t *prop)
Gets the current value of the provided property object.
__NYX_INLINE__ 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.
__NYX_INLINE__ bool nyx_number_prop_set_uint(nyx_dict_t *prop, uint32_t value)
Sets the new value of the provided property object.
__NYX_INLINE__ uint64_t nyx_number_prop_get_ulong(const nyx_dict_t *prop)
Gets the current value of the provided property object.
__NYX_INLINE__ bool nyx_number_prop_set_long(nyx_dict_t *prop, int64_t value)
Sets the new value of the provided property object.
__NYX_INLINE__ 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_INLINE__ 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.
__NYX_INLINE__ bool nyx_number_prop_set_ulong(nyx_dict_t *prop, uint64_t value)
Sets the new value of the provided property object.
__NYX_INLINE__ 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.
__NYX_INLINE__ 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_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.
__NYX_INLINE__ bool nyx_number_prop_set_int(nyx_dict_t *prop, int32_t 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.
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(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 current value of the provided property object.
nyx_dict_t * nyx_text_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label, __NYX_NULLABLE__ STR_t value)
Allocates a new INDI / Nyx text property.
STR_t nyx_text_prop_get(const nyx_dict_t *prop)
Gets the current 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.
bool nyx_text_prop_set(nyx_dict_t *prop, __NYX_NULLABLE__ STR_t value)
Sets the new value of the provided property object.
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.
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_type_t
JSON object types.
void nyx_object_free(__NYX_NULLABLE__ nyx_object_t *object)
Frees memory of the provided JSON object.
__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 special character escaping, representing 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.
__NYX_INLINE__ nyx_string_t * nyx_string_from_buff_unmanaged(size_t size, BUFF_t buff)
Returns a JSON string object holding the value of the provided buffer (unmanaged reference).
__NYX_INLINE__ nyx_string_t * nyx_string_from_managed(STR_t value)
Returns a JSON string object holding the value of the provided string (managed reference).
__NYX_INLINE__ nyx_string_t * nyx_string_from_buff_managed(size_t size, BUFF_t buff)
Returns a JSON string object holding the value of the provided buffer (managed reference).
__NYX_INLINE__ nyx_string_t * nyx_string_from_unmanaged(STR_t value)
Returns a JSON string object holding the value of the provided string (unmanaged reference).
__NYX_INLINE__ nyx_string_t * nyx_string_from_dup(STR_t value)
Returns a JSON string object holding the value of the provided string (managed duplication).
__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.
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.
str_t nyx_string_to_cstring(const nyx_string_t *object)
Struct describing a JSON boolean object.
bool value
Boolean payload.
nyx_object_t base
Common object header for JSON objects.
Struct describing a JSON dict iterator.
size_t idx
Current zero-based iteration index.
struct nyx_dict_node_s * head
Next JSON object to visit.
Struct describing a JSON dict object.
Struct describing a JSON list iterator.
struct nyx_list_node_s * head
Next JSON object to visit.
size_t idx
Current zero-based iteration index.
Struct describing a JSON list object.
Opaque struct describing a Nyx node.
Struct describing a JSON null object.
nyx_object_t base
Common object header for JSON objects.
Struct describing a JSON number object.
double value
Number payload.
nyx_object_t base
Common object header for JSON objects.
Struct describing a JSON object.
Struct describing the options for INDI / Nyx vectors.
__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".
Struct describing a JSON string 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.
Struct describing an XML document.