2018-01-17 01:21:58 +01:00
|
|
|
/** Node type: mqtt
|
|
|
|
*
|
|
|
|
* @file
|
2022-12-14 17:41:58 +01:00
|
|
|
* @author Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
|
2022-07-04 18:20:03 +02:00
|
|
|
* @license Apache 2.0
|
2018-01-17 01:21:58 +01:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/pool.hpp>
|
2021-05-10 00:12:30 +02:00
|
|
|
#include <villas/format.hpp>
|
2018-02-06 21:26:12 +01:00
|
|
|
#include <villas/queue_signalled.h>
|
2021-08-17 11:27:11 +02:00
|
|
|
#include <villas/super_node.hpp>
|
2018-01-17 01:21:58 +01:00
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
struct mosquitto;
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
class NodeCompat;
|
|
|
|
|
2018-01-17 01:21:58 +01:00
|
|
|
struct mqtt {
|
|
|
|
struct mosquitto *client;
|
2021-08-10 10:12:48 -04:00
|
|
|
struct CQueueSignalled queue;
|
|
|
|
struct Pool pool;
|
2018-01-17 01:21:58 +01:00
|
|
|
|
|
|
|
int keepalive; /**< Keep-alive interval in seconds. Zero for no keepalive. */
|
|
|
|
int port; /**< Hostname / IP address of the broker. */
|
|
|
|
int qos; /**< Integer value 0, 1 or 2 indicating the Quality of Service to be used for publishing messages. */
|
|
|
|
int retain; /**< Mark published messages as retained. */
|
|
|
|
char *host; /**< Hostname / IP address of the broker. */
|
|
|
|
char *username; /**< Username for authentication to the broker. */
|
|
|
|
char *password; /**< Password for authentication to the broker. */
|
|
|
|
char *publish; /**< Publish topic. */
|
|
|
|
char *subscribe; /**< Subscribe topic. */
|
|
|
|
|
|
|
|
struct {
|
2021-11-09 17:11:51 +01:00
|
|
|
int enabled; /**< Enable SSL encrypted connection to broker. */
|
|
|
|
int insecure; /**< Allow insecure SSL connections. */
|
|
|
|
char *cafile; /**< SSL CA file. */
|
|
|
|
char *capath; /**< SSL CA path. */
|
|
|
|
char *certfile; /**< SSL certificate. */
|
|
|
|
char *keyfile; /**< SSL private key. */
|
|
|
|
int cert_reqs; /**< SSL_VERIFY_NONE(0) or SSL_VERIFY_PEER(1) */
|
|
|
|
char *tls_version; /**< SSL tls verion */
|
|
|
|
char *ciphers; /**< SSL chipher list. */
|
2018-01-17 01:21:58 +01:00
|
|
|
} ssl;
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
Format *formatter;
|
2018-01-17 01:21:58 +01:00
|
|
|
};
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int mqtt_reverse(NodeCompat *n);
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
char * mqtt_print(NodeCompat *n);
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int mqtt_prepare(NodeCompat *n);
|
2021-01-08 15:22:28 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int mqtt_parse(NodeCompat *n, json_t *json);
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int mqtt_check(NodeCompat *n);
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int mqtt_start(NodeCompat *n);
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int mqtt_init(NodeCompat *n);
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int mqtt_destroy(NodeCompat *n);
|
|
|
|
|
|
|
|
int mqtt_stop(NodeCompat *n);
|
|
|
|
|
|
|
|
int mqtt_type_start(SuperNode *sn);
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2018-07-16 08:08:17 +02:00
|
|
|
int mqtt_type_stop();
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int mqtt_poll_fds(NodeCompat *n, int fds[]);
|
|
|
|
|
|
|
|
int mqtt_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int mqtt_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2018-01-17 01:21:58 +01:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|