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
190void __attribute__((format(printf, 5, 6))) nyx_log(
208#define NYX_LOG_FATAL(fmt, ...) \
209 do { nyx_log(NYX_LOG_LEVEL_FATAL, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(1)
219#define NYX_LOG_ERROR(fmt, ...) \
220 do { nyx_log(NYX_LOG_LEVEL_ERROR, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
230#define NYX_LOG_WARN(fmt, ...) \
231 do { nyx_log(NYX_LOG_LEVEL_WARN, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
241#define NYX_LOG_INFO(fmt, ...) \
242 do { nyx_log(NYX_LOG_LEVEL_INFO, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
252#define NYX_LOG_DEBUG(fmt, ...) \
253 do { nyx_log(NYX_LOG_LEVEL_DEBUG, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
263#define NYX_LOG_TRACE(fmt, ...) \
264 do { nyx_log(NYX_LOG_LEVEL_TRACE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
285 __NYX_ZEROABLE__
size_t size,
286 __NYX_NULLABLE__
BUFF_t buff,
301 uint8_t result_mac[6],
318 __NYX_NULLABLE__
size_t *result_len,
319 __NYX_ZEROABLE__
size_t size,
320 __NYX_NULLABLE__
BUFF_t buff
334 __NYX_NULLABLE__
size_t *result_size,
335 __NYX_ZEROABLE__
size_t len,
336 __NYX_NULLABLE__
STR_t str
350 __NYX_NULLABLE__
size_t *result_size,
351 __NYX_ZEROABLE__
size_t size,
352 __NYX_NULLABLE__
BUFF_t buff
366 __NYX_NOTNULL__
size_t *result_size,
367 __NYX_ZEROABLE__
size_t size,
368 __NYX_NULLABLE__
BUFF_t buff
382 __NYX_NULLABLE__
size_t *result_len,
383 __NYX_ZEROABLE__
size_t size,
384 __NYX_NULLABLE__
BUFF_t buff
398 __NYX_NOTNULL__
size_t *result_size,
399 __NYX_ZEROABLE__
size_t len,
400 __NYX_NULLABLE__
STR_t str
413#define NYX_OBJECT_MAGIC UINT32_C(0x65656500)
417#define NYX_FLAGS_DISABLED UINT64_C(0x0000000000000001)
420#define NYX_FLAGS_BLOB_MASK UINT64_C(0x00000001FFFFFFFC)
423#define NYX_FLAGS_STREAM_MASK UINT64_C(0xFFFFFFFE00000000)
458typedef struct nyx_object_s
468 __NYX_NULLABLE__
struct nyx_node_s *node;
470 __NYX_NULLABLE__
struct nyx_object_s *parent;
476 __NYX_NULLABLE__
void *_ptr;
478 __NYX_NULLABLE__ bool (* _int)(
479 struct nyx_dict_s *vector,
480 struct nyx_dict_s *prop,
485 __NYX_NULLABLE__ bool (* _uint)(
486 struct nyx_dict_s *vector,
487 struct nyx_dict_s *prop,
488 unsigned int new_value,
489 unsigned int old_value
492 __NYX_NULLABLE__ bool (* _long)(
493 struct nyx_dict_s *vector,
494 struct nyx_dict_s *prop,
499 __NYX_NULLABLE__ bool (* _ulong)(
500 struct nyx_dict_s *vector,
501 struct nyx_dict_s *prop,
502 unsigned long new_value,
503 unsigned long old_value
506 __NYX_NULLABLE__ bool (* _double)(
507 struct nyx_dict_s *vector,
508 struct nyx_dict_s *prop,
513 __NYX_NULLABLE__ bool (* _str)(
514 struct nyx_dict_s *vector,
515 struct nyx_dict_s *prop,
520 __NYX_NULLABLE__ bool (* _buffer)(
521 struct nyx_dict_s *vector,
522 struct nyx_dict_s *prop,
527 __NYX_NULLABLE__ void (* _vector)(
528 struct nyx_dict_s *vector,
536 __NYX_NULLABLE__
void *ctx;
553 __NYX_ZEROABLE__
size_t size,
554 __NYX_NULLABLE__
BUFF_t buff
567 __NYX_NULLABLE__
STR_t string
580 __NYX_NULLABLE__
void *
object
593 __NYX_NULLABLE__
void *
object
753double nyx_number_get(
783str_t nyx_number_to_string(
876str_t nyx_boolean_to_string(
960 __NYX_NULLABLE__
size_t *result_size,
961 __NYX_NULLABLE__
buff_t *result_buff
1096typedef struct nyx_dict_s
1100 struct nyx_dict_node_s *head;
1101 struct nyx_dict_node_s *tail;
1126#define NYX_DICT_ITER(dict) \
1127 ((nyx_dict_iter_t) {0, ((nyx_dict_t *) (dict))->head})
1186bool nyx_dict_iterate(
1233size_t nyx_dict_size(
1247str_t nyx_dict_to_string(
1427typedef struct nyx_list_s
1431 struct nyx_list_node_s *head;
1432 struct nyx_list_node_s *tail;
1457#define NYX_LIST_ITER(list) \
1458 ((nyx_list_iter_t) {0, ((nyx_list_t *) (list))->head})
1517bool nyx_list_iterate(
1562 return nyx_list_set(
object, (
size_t) -1, value);
1574size_t nyx_list_size(
1588str_t nyx_list_to_string(
1755#if !defined(ARDUINO)
1773 NYX_XML_COMMENT = 302,
1774 NYX_XML_CDATA = 303,
1786typedef struct nyx_xmldoc_s
1792 struct nyx_xmldoc_s *next;
1793 struct nyx_xmldoc_s *parent;
1795 struct nyx_xmldoc_s *children;
1796 struct nyx_xmldoc_s *attributes;
1813 __NYX_ZEROABLE__
size_t size,
1814 __NYX_NULLABLE__
BUFF_t buff
1827 __NYX_NULLABLE__
STR_t string
1861#if !defined(ARDUINO)
1904#define NYX_INDI_VERSION "1.7"
1927STR_t nyx_state_to_str(
1961STR_t nyx_perm_to_str(
1995STR_t nyx_rule_to_str(
2028STR_t nyx_onoff_to_str(
2082 __NYX_NULLABLE__
STR_t label,
2106 __NYX_NULLABLE__
STR_t label,
2130 __NYX_NULLABLE__
STR_t label,
2154 __NYX_NULLABLE__
STR_t label,
2178 __NYX_NULLABLE__
STR_t label,
2368 __NYX_NULLABLE__
STR_t label,
2369 __NYX_NULLABLE__
STR_t value,
2385 __NYX_NULLABLE__
STR_t value,
2453 __NYX_NULLABLE__
STR_t label,
2532 __NYX_NULLABLE__
STR_t label,
2619 __NYX_NULLABLE__
STR_t label,
2620 __NYX_NULLABLE__
STR_t format,
2621 __NYX_ZEROABLE__
size_t size,
2622 __NYX_NULLABLE__
BUFF_t buff,
2639 __NYX_ZEROABLE__
size_t size,
2640 __NYX_NULLABLE__
BUFF_t buff,
2656 __NYX_NULLABLE__
size_t *size,
2657 __NYX_NULLABLE__
buff_t *buff
2712 __NYX_NULLABLE__
STR_t label
2749 __NYX_ZEROABLE__
size_t n_fields,
2750 const size_t field_sizes[],
2751 const buff_t field_buffs[]
2783 __NYX_NULLABLE__
STR_t message
2799 __NYX_NULLABLE__
STR_t name,
2800 __NYX_NULLABLE__
STR_t message
2829 NYX_NODE_EVENT_OPEN = 1100,
2830 NYX_NODE_EVENT_MSG = 1101,
2853 size_t message_size,
2879 __NYX_NULLABLE__
STR_t indi_url,
2880 __NYX_NULLABLE__
STR_t mqtt_url,
2881 __NYX_NULLABLE__
STR_t nss_url,
2883 __NYX_NULLABLE__
STR_t mqtt_username,
2884 __NYX_NULLABLE__
STR_t mqtt_password,
2920 uint32_t interval_ms,
2921 void(* callback)(
void *),
2954 __NYX_NULLABLE__
STR_t name,
2955 __NYX_NULLABLE__
STR_t message
2972 __NYX_NULLABLE__
STR_t name,
2973 __NYX_NULLABLE__
STR_t message
2990 __NYX_NULLABLE__
STR_t message
3008 __NYX_NULLABLE__
STR_t name,
3009 __NYX_NULLABLE__
STR_t message
3045 __NYX_ZEROABLE__
size_t message_size,
3046 __NYX_NULLABLE__
BUFF_t message_buff,
3071 __NYX_ZEROABLE__
size_t n_fields,
3072 const uint32_t field_hashes[],
3073 const size_t field_sizes[],
3074 const buff_t field_buffs[]
3081#if defined(__clang__) && !defined(ARDUINO)
3082# 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__ 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.