Nyx Node
Loading...
Searching...
No Matches
Nyx node

Classes

struct  nyx_node_t
 Opaque struct describing a Nyx node. More...
 

Typedefs

typedef struct nyx_node_s nyx_node_t
 
typedef void(* nyx_mqtt_handler_t) (nyx_node_t *node, nyx_event_t event, size_t topic_size, BUFF_t topic_buff, size_t message_size, BUFF_t message_buff)
 MQTT event handler.
 

Enumerations

enum  nyx_event_t {
  NYX_EVENT_OPEN = 0 ,
  NYX_EVENT_MSG = 1
}
 Nyx TCP or MQTT event type. More...
 

Functions

nyx_node_tnyx_node_t::nyx_node_initialize (STR_t node_id, nyx_dict_t *def_vectors[], __NULLABLE__ STR_t indi_url, __NULLABLE__ STR_t mqtt_url, __NULLABLE__ STR_t mqtt_username, __NULLABLE__ STR_t mqtt_password, __NULLABLE__ nyx_mqtt_handler_t mqtt_handler, __NULLABLE__ STR_t redis_url, __NULLABLE__ STR_t redis_username, __NULLABLE__ STR_t redis_password, int retry_ms, bool enable_xml, bool validate_xml)
 Initializes the Nyx node.
 
void nyx_node_t::nyx_node_finalize (nyx_node_t *node, bool free_vectors)
 Finalizes the Nyx node.
 
void nyx_node_t::nyx_node_poll (nyx_node_t *node, int timeout_ms)
 Performs a single poll iteration.
 
void nyx_node_t::nyx_node_enable (nyx_node_t *node, STR_t device, __NULLABLE__ STR_t name, __NULLABLE__ STR_t message)
 Enables a whole device or a definition vector.
 
void nyx_node_t::nyx_node_disable (nyx_node_t *node, STR_t device, __NULLABLE__ STR_t name, __NULLABLE__ STR_t message)
 Disables a whole device or a definition vector.
 
void nyx_node_t::nyx_node_send_message (nyx_node_t *node, STR_t device, STR_t message)
 Sends a message to the clients.
 
void nyx_node_t::nyx_mqtt_sub (nyx_node_t *node, STR_t topic)
 If MQTT is enabled, subscribes to a topic.
 
void nyx_node_t::nyx_mqtt_pub (nyx_node_t *node, STR_t topic, __ZEROABLE__ size_t message_size, __NULLABLE__ BUFF_t message_buff)
 If MQTT is enabled, publishes a message to a topic.
 
bool nyx_node_t::nyx_stream_pub (nyx_node_t *node, STR_t device, STR_t stream, bool check, size_t max_len, __ZEROABLE__ size_t n_fields, const str_t field_names[], const size_t field_sizes[], const buff_t field_buffs[])
 If Redis is enabled, publishes an entry to a stream, see https://redis.io/commands/xadd/.
 

Detailed Description

Nyx node.

Typedef Documentation

◆ nyx_mqtt_handler_t

typedef void(* nyx_mqtt_handler_t) (nyx_node_t *node, nyx_event_t event, size_t topic_size, BUFF_t topic_buff, size_t message_size, BUFF_t message_buff)

MQTT event handler.

Parameters
nodeThe Nyx node.
eventThe event type.
topic_sizeThe MQTT topic length.
topic_buffThe MQTT topic buffer.
message_sizeThe MQTT message length.
message_buffThe MQTT message buffer.

Enumeration Type Documentation

◆ nyx_event_t

Nyx TCP or MQTT event type.

Enumerator
NYX_EVENT_OPEN 

A connection is opened.

NYX_EVENT_MSG 

A message is received.

Function Documentation

◆ nyx_node_initialize()

nyx_node_t * nyx_node_initialize ( STR_t node_id,
nyx_dict_t * def_vectors[],
__NULLABLE__ STR_t indi_url,
__NULLABLE__ STR_t mqtt_url,
__NULLABLE__ STR_t mqtt_username,
__NULLABLE__ STR_t mqtt_password,
__NULLABLE__ nyx_mqtt_handler_t mqtt_handler,
__NULLABLE__ STR_t redis_url,
__NULLABLE__ STR_t redis_username,
__NULLABLE__ STR_t redis_password,
int retry_ms,
bool enable_xml,
bool validate_xml )

Initializes the Nyx node.

Parameters
node_idUnique node identifier.
def_vectorsArray of definition vectors.
indi_urlOptional INDI URL (e.g. tcp://0.0.0.0:7625).
mqtt_urlOptional MQTT URL (e.g. mqtt://localhost:1883).
mqtt_usernameOptional MQTT username.
mqtt_passwordOptional MQTT password.
mqtt_handlerOptional MQTT handler.
redis_urlOptional Redis URL (e.g. tcp://localhost:6379).
redis_usernameOptional Redis username.
redis_passwordOptional Redis password.
retry_msConnect retry time [milliseconds].
enable_xmlEnables the XML compatibility layer.
validate_xmlEnables the XML message validation.
Returns

◆ nyx_node_finalize()

void nyx_node_finalize ( nyx_node_t * node,
bool free_vectors )

Finalizes the Nyx node.

Parameters
nodeThe Nyx node.
free_vectorsIf true, the definition vectors are released.

◆ nyx_node_poll()

void nyx_node_poll ( nyx_node_t * node,
int timeout_ms )

Performs a single poll iteration.

Parameters
nodeThe Nyx node.
timeout_msTimeout [milliseconds].

◆ nyx_node_enable()

void nyx_node_enable ( nyx_node_t * node,
STR_t device,
__NULLABLE__ STR_t name,
__NULLABLE__ STR_t message )

Enables a whole device or a definition vector.

Parameters
nodeThe Nyx node.
deviceThe Nyx device name.
nameOptional Nyx vector name.
messageOptional message content.

◆ nyx_node_disable()

void nyx_node_disable ( nyx_node_t * node,
STR_t device,
__NULLABLE__ STR_t name,
__NULLABLE__ STR_t message )

Disables a whole device or a definition vector.

Parameters
nodeThe Nyx node.
deviceThe Nyx device name.
nameOptional Nyx vector name.
messageOptional message content.

◆ nyx_node_send_message()

void nyx_node_send_message ( nyx_node_t * node,
STR_t device,
STR_t message )

Sends a message to the clients.

Parameters
nodeThe Nyx node.
deviceThe Nyx device name.
messageThe message content.

◆ nyx_mqtt_sub()

void nyx_mqtt_sub ( nyx_node_t * node,
STR_t topic )

If MQTT is enabled, subscribes to a topic.

Parameters
nodeThe Nyx node.
topicThe MQTT topic.

◆ nyx_mqtt_pub()

void nyx_mqtt_pub ( nyx_node_t * node,
STR_t topic,
__ZEROABLE__ size_t message_size,
__NULLABLE__ BUFF_t message_buff )

If MQTT is enabled, publishes a message to a topic.

Parameters
nodeThe Nyx node.
topicThe MQTT topic.
message_sizeThe MQTT message length.
message_buffThe MQTT message buffer.

◆ nyx_stream_pub()

bool nyx_stream_pub ( nyx_node_t * node,
STR_t device,
STR_t stream,
bool check,
size_t max_len,
__ZEROABLE__ size_t n_fields,
const str_t field_names[],
const size_t field_sizes[],
const buff_t field_buffs[] )

If Redis is enabled, publishes an entry to a stream, see https://redis.io/commands/xadd/.

Parameters
nodeThe Nyx node.
deviceThe device name.
streamThe stream name.
checkIf true, the stream is published only if it has been enabled.
max_lenMaximum number of entries to keep in the Redis stream.
n_fieldsNumber of field triplets (name, length, buffer).
field_namesArray of field names.
field_sizesArray of field lengths.
field_buffsArray of field buffers.
Warning
If check is true, the stream has to be declared via nyx_stream_def_vector_new and registered via nyx_node_initialize.
Note
If a field name starts with #, its buffer is automatically base64-encoded.