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

Classes

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

Typedefs

typedef void(* nyx_node_t::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.

Enumerations

enum  nyx_node_t::nyx_event_type_t
 TCP or MQTT event type.

Functions

__NYX_NULLABLE__ nyx_node_tnyx_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_t::nyx_node_finalize (nyx_node_t *node, bool free_vectors)
 Finalizes a Nyx node.
void nyx_node_t::nyx_node_add_timer (const nyx_node_t *node, uint32_t interval_ms, void(*callback)(void *), void *arg)
 Adds a new timer.
void nyx_node_t::nyx_node_poll (const nyx_node_t *node, uint32_t timeout_ms)
 Performs a single poll iteration.
void nyx_node_t::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.
void nyx_node_t::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_node_t::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_t::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_t::nyx_mqtt_sub (const nyx_node_t *node, STR_t topic, int qos)
 If MQTT is enabled, subscribes to an MQTT topic.
void nyx_node_t::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_node_t::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.

Detailed Description

Nyx node.


Class Documentation

◆ nyx_node_t

struct nyx_node_t

Opaque struct describing a Nyx node.

Public Types

enum  nyx_event_type_t
 TCP or MQTT event type.
typedef 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.

Public Member Functions

__NYX_NULLABLE__ nyx_node_tnyx_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_finalize (nyx_node_t *node, bool free_vectors)
 Finalizes a Nyx node.
void nyx_node_add_timer (const nyx_node_t *node, uint32_t interval_ms, void(*callback)(void *), void *arg)
 Adds a new timer.
void nyx_node_poll (const nyx_node_t *node, uint32_t timeout_ms)
 Performs a single poll iteration.
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.
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_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_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_mqtt_sub (const nyx_node_t *node, STR_t topic, int qos)
 If MQTT is enabled, subscribes to an MQTT topic.
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.

Typedef Documentation

◆ nyx_mqtt_handler_t

typedef 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.

Parameters
nodeNyx node.
event_typeEvent type.
topic_sizeNumber of MQTT topic bytes.
topic_buffMQTT topic buffer.
message_sizeNumber of message payload bytes.
message_buffMessage payload buffer.
Note
The message payload may contain arbitrary binary data.

Definition at line 2848 of file nyx_node.h.

Function Documentation

◆ nyx_node_initialize()

__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.

Parameters
node_idUnique node identifier.
vectorsArray of vectors with NULL sentinel.
indi_urlOptional INDI URL (e.g., tcp://0.0.0.0:7625).
mqtt_urlOptional MQTT URL (e.g., mqtt://localhost:1883).
nss_urlOptional Nyx Stream URL (e.g., tcp://localhost:6379).
mqtt_usernameOptional MQTT username.
mqtt_passwordOptional MQTT password.
mqtt_handlerOptional MQTT handler.
retry_msConnect retry time [milliseconds].
enable_xmlEnables the XML messages for INDI compatibility.
Returns
The new Nyx node.

◆ nyx_node_finalize()

void nyx_node_finalize ( nyx_node_t * node,
bool free_vectors )

Finalizes a Nyx node.

Parameters
nodeNyx node.
free_vectorsIf true, the previously registered vectors are freed.

Definition at line 1030 of file node.c.

◆ nyx_node_add_timer()

void nyx_node_add_timer ( const nyx_node_t * node,
uint32_t interval_ms,
void(* callback )(void *),
void * arg )

Adds a new timer.

Parameters
nodeNyx node.
interval_msInterval [milliseconds].
callbackCallback to be invoked.
argCallback argument.
Note
Timers are triggered by the nyx_node_poll method.

Definition at line 390 of file mongoose.c.

◆ nyx_node_poll()

void nyx_node_poll ( const nyx_node_t * node,
uint32_t timeout_ms )

Performs a single poll iteration.

Parameters
nodeNyx node.
timeout_msTimeout [milliseconds].
Note
timeout_ms determines the minimum timer resolution.

Definition at line 397 of file mongoose.c.

◆ nyx_node_enable()

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.

Parameters
nodeNyx node.
deviceDevice name.
nameOptional vector name (NULL means the whole device).
messageOptional human-oriented message.

◆ nyx_node_disable()

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.

Parameters
nodeNyx node.
deviceDevice name.
nameOptional vector name (NULL means the whole device).
messageOptional human-oriented message.

◆ nyx_node_send_message()

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.

Parameters
nodeNyx node.
deviceDevice name.
messageHuman-oriented message.

◆ nyx_node_send_del_property()

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.

Parameters
nodeNyx node.
deviceDevice name.
nameOptional vector name (NULL means the whole device).
messageOptional human-oriented message.

◆ nyx_mqtt_sub()

void nyx_mqtt_sub ( const nyx_node_t * node,
STR_t topic,
int qos )

If MQTT is enabled, subscribes to an MQTT topic.

Parameters
nodeNyx node.
topicMQTT topic.
qosMQTT Quality Of Service.
Note
mqtt_handler has to be defined in nyx_node_initialize.

Definition at line 12 of file mqtt.c.

◆ nyx_mqtt_pub()

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.

Parameters
nodeNyx node.
topicMQTT topic.
message_sizeNumber of message payload bytes.
message_buffMessage payload buffer.
qosMQTT Quality Of Service.
Note
The message payload may contain arbitrary binary data.

◆ nyx_nss_pub()

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.

Parameters
nodeNyx node.
deviceDevice name.
streamStream name.
n_fieldsNumber of fields.
field_hashesArray of field name hashes, one per field.
field_sizesArray of payload byte counts, one per field.
field_buffsArray of payload buffers, one per field.
Warning
Field hashes must be computed with nyx_hash.
Unless performance is critical, prefer using nyx_stream_pub.
Note
Field payloads may contain arbitrary binary data.