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

Data Structures

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

Typedefs

typedef struct nyx_node_s nyx_node_t
 
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. More...
 

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)
 Add a new timer.
 
void nyx_node_t::nyx_node_poll (const nyx_node_t *node, uint32_t timeout_ms)
 Performs a single poll iteration.
 
bool nyx_node_t::nyx_node_notify (__NYX_NULLABLE__ nyx_object_t *object)
 Notifies the provided Nyx / INDI object to the clients.
 
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.

Typedef Documentation

◆ nyx_node_t

typedef struct nyx_node_s nyx_node_t

Definition at line 2822 of file nyx_node.h.

◆ 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_sizeMQTT topic length.
topic_buffMQTT topic buffer.
message_sizeMQTT message length.
message_buffMQTT message buffer.

Definition at line 2851 of file nyx_node.h.

Enumeration Type Documentation

◆ nyx_event_type_t

TCP or MQTT event type.

Definition at line 2831 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 ǸULL 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.
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 1031 of file node.c.

◆ nyx_node_add_timer()

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

Add a new timer.

Parameters
nodeNyx node.
interval_msInterval [milliseconds].
callbackCallback to be invoked.
argCallback argument.
Note
All added timers are polled when nyx_node_poll is called, and called if expired.

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

Definition at line 397 of file mongoose.c.

◆ nyx_node_notify()

bool nyx_node_notify ( __NYX_NULLABLE__ nyx_object_t object)

Notifies the provided Nyx / INDI object to the clients.

Parameters
objectThe provided Nyx / INDI object.

◆ 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 ≡ 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 ≡ 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 ≡ 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_sizeMQTT message length.
message_buffMQTT message buffer.
qosMQTT Quality Of Service.

◆ 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 field triplets (hash, size, buffer).
field_hashesArray of field hashes.
field_sizesArray of field sizes.
field_buffsArray of field buffers.
Warning
Field hashes must be computed with nyx_hash.
Unless performance is critical, prefer using nyx_stream_pub.