Zigbee Protocol Controller 1.6.0
uic_mqtt.h
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13
36#ifndef UIC_MQTT_H
37#define UIC_MQTT_H
38
39#define MQTT_TOPIC_MAX_LENGTH 512
40#define MQTT_MESSAGE_MAX_LENGTH 512
41
42#include <stdbool.h>
43#include <stddef.h>
44#include "sl_status.h"
45
46// Helper defines for applications to "unretain_by_regex"
47// clang-format off
48#define REGEX_NOT_STATE_OR_MQTT_CLIENT_TOPICS "^(?!((ucl\\/by-unid\\/.*\\/State$)|(ucl\\/by-mqtt-client\\/.*))).*"
49#define REGEX_NOT_STATE_TOPIC "^(?!ucl\\/by-unid\\/.*\\/State$).*"
50#define REGEX_ALL_TOPICS "^.+"
51// clang-format on
52
60typedef void (*mqtt_message_callback_t)(const char *topic,
61 const char *message,
62 const size_t message_length);
63
64typedef void (*mqtt_message_callback_ex_t)(const char *topic,
65 const char *message,
66 const size_t message_length,
67 void *user);
68
74
75#ifdef __cplusplus
76extern "C" {
77#endif
78
87
94
105void uic_mqtt_publish(const char *topic,
106 const char *message,
107 const size_t message_length,
108 bool retain);
109
125void uic_mqtt_unretain(const char *prefix_pattern);
126
135int uic_mqtt_count_topics(const char *prefix_pattern);
136
144void uic_mqtt_unretain_by_regex(const char *regex);
145
154void uic_mqtt_subscribe(const char *topic, mqtt_message_callback_t callback);
155
165void uic_mqtt_subscribe_ex(const char *topic,
167 void *user);
168
176void uic_mqtt_unsubscribe(const char *topic, mqtt_message_callback_t callback);
177
186void uic_mqtt_unsubscribe_ex(const char *topic,
188 void *user);
189
198
205
211const char *uic_mqtt_get_client_id();
212
219
220#ifdef __cplusplus
221}
222#endif
223
224#endif // UIC_MQTT
void uic_mqtt_unsubscribe(const char *topic, mqtt_message_callback_t callback)
Unsubscribe from a topic.
Definition: uic_mqtt.c:190
void uic_mqtt_unsubscribe_ex(const char *topic, mqtt_message_callback_ex_t callback, void *user)
Unsubscribe from a topic.
Definition: uic_mqtt.c:195
void uic_mqtt_subscribe_ex(const char *topic, mqtt_message_callback_ex_t callback, void *user)
Subscribe to a topic.
Definition: uic_mqtt.c:153
int uic_mqtt_teardown()
Definition: uic_mqtt.c:140
const char * uic_mqtt_get_client_id()
Gets the MQTT Client ID in used by the MQTT Client.
Definition: uic_mqtt.c:215
void uic_mqtt_unretain(const char *prefix_pattern)
Un-retain a previously retained message.
Definition: uic_mqtt.c:173
void uic_mqtt_publish(const char *topic, const char *message, const size_t message_length, bool retain)
Add the message and topic to publisher queue system.
Definition: uic_mqtt.c:160
sl_status_t uic_mqtt_setup()
Definition: uic_mqtt.c:101
void uic_mqtt_unretain_by_regex(const char *regex)
Un-retain a previously retained message.
Definition: uic_mqtt.c:181
void uic_mqtt_subscribe(const char *topic, mqtt_message_callback_t callback)
Subscribe to a topic.
Definition: uic_mqtt.c:148
void(* mqtt_message_callback_ex_t)(const char *topic, const char *message, const size_t message_length, void *user)
Definition: uic_mqtt.h:64
void uic_mqtt_set_after_connect_callback(mqtt_connection_callbacks_t callback)
Set a callback which will be executed after having connected.
Definition: uic_mqtt.c:209
void(* mqtt_message_callback_t)(const char *topic, const char *message, const size_t message_length)
A callback type for pushing incoming messages.
Definition: uic_mqtt.h:60
void(* mqtt_connection_callbacks_t)()
A callback type for a before disconnect and after connect.
Definition: uic_mqtt.h:73
void uic_mqtt_set_before_disconnect_callback(mqtt_connection_callbacks_t callback)
Set a callback which will be executed before calling a disconnect.
Definition: uic_mqtt.c:202
bool uic_mqtt_is_connected_to_broker()
Checks if we are currently connected to an MQTT Broker.
Definition: uic_mqtt.c:220
int uic_mqtt_count_topics(const char *prefix_pattern)
Count the number of topics published.
Definition: uic_mqtt.c:168
uint32_t sl_status_t
Definition: sl_status.h:139
SL Status Codes.