Nyx Node
Toggle main menu visibility
Loading...
Searching...
No Matches
mqtt.c
1
/* NyxNode
2
* Author: Jérôme ODIER <jerome.odier@lpsc.in2p3.fr>
3
* SPDX-License-Identifier: GPL-2.0-only (Mongoose backend) or GPL-3.0+
4
*/
5
6
/*--------------------------------------------------------------------------------------------------------------------*/
7
8
#include "nyx_node_internal.h"
9
10
/*--------------------------------------------------------------------------------------------------------------------*/
11
12
void
nyx_mqtt_sub
(
const
nyx_node_t
*node,
STR_t
topic,
int
qos)
13
{
14
if
(node->mqtt_handler == NULL)
15
{
16
NYX_LOG_ERROR
(
"MQTT handler has not been set"
);
17
}
18
else
19
{
20
nyx_str_t _topic = nyx_str_s(topic);
21
22
internal_mqtt_sub(
23
node,
24
_topic,
25
qos
26
);
27
}
28
}
29
30
/*--------------------------------------------------------------------------------------------------------------------*/
31
32
void
nyx_mqtt_pub(
const
nyx_node_t
*node,
STR_t
topic,
size_t
message_size,
BUFF_t
message_buff,
int
qos)
33
{
34
nyx_str_t _topic = nyx_str_s(topic);
35
36
nyx_str_t _message = NYX_STR_S(
37
message_buff,
38
message_size
39
);
40
41
internal_mqtt_pub(
42
node,
43
_topic,
44
_message,
45
qos
46
);
47
}
48
49
/*--------------------------------------------------------------------------------------------------------------------*/
NYX_LOG_ERROR
#define NYX_LOG_ERROR(fmt,...)
Logs an error message.
Definition
nyx_node.h:219
STR_t
#define STR_t
Alias for const char *.
Definition
nyx_node.h:71
BUFF_t
#define BUFF_t
Alias for const void *.
Definition
nyx_node.h:68
nyx_node_t::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.
Definition
mqtt.c:12
nyx_node_t
Opaque struct describing a Nyx node.
Author:
Jérôme ODIER
License:
LGPL-3.0-or-later
Copyright:
LPSC / CNRS