Zigbee Protocol Controller 1.6.0
mqtt_wrapper.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#ifndef MQTT_WRAPPER_H
14#define MQTT_WRAPPER_H
15
16// Standard library
17#include <stdbool.h>
18
19// Unify components
20#include "sl_status.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
27 int mid;
28 const char *topic;
29 void *payload;
31 int qos;
32 bool retain;
33};
34
43
52void *mqtt_wrapper_new(const char *id, bool clean_session, void *obj);
53
60
66void mqtt_wrapper_destroy(void *instance);
67
74int mqtt_wrapper_socket(void *instance);
89 const char *cafile,
90 const char *certfile,
91 const char *keyfile);
108 const char *psk,
109 const char *id,
110 const char *ciphers);
123 const char *host,
124 int port,
125 int keepalive);
126
136
151sl_status_t mqtt_wrapper_loop(void *instance, int timeout);
152
166
180
190
201 const char *mqtt_client_id,
202 int qos);
203
225 int *mid,
226 const char *topic,
227 int payloadlen,
228 const void *payload,
229 int qos,
230 bool retain);
231
247 mqtt_wrapper_subscribe(void *instance, int *mid, const char *sub, int qos);
248
262sl_status_t mqtt_wrapper_unsubscribe(void *instance, int *mid, const char *sub);
263
275 const char *topic,
276 bool *result);
277
294 void *instance, void (*on_connect)(void *inst, void *obj, int result_code));
295
309 void *instance, void (*on_disconnect)(void *inst, void *obj, int rc));
310
320 void *instance,
321 void (*on_message)(void *inst, void *obj, const struct mqtt_message *msg));
322
323#ifdef __cplusplus
324}
325#endif
326
327#endif
uint32_t sl_status_t
Definition: sl_status.h:139
void mqtt_wrapper_message_callback_set(void *instance, void(*on_message)(void *inst, void *obj, const struct mqtt_message *msg))
Set the message callback.
sl_status_t mqtt_wrapper_publish(void *instance, int *mid, const char *topic, int payloadlen, const void *payload, int qos, bool retain)
Publish a message to a topic.
sl_status_t mqtt_wrapper_loop_write(void *instance)
Carry out write-opeartions on the network-socket connected to the MQTT-broker.
void * mqtt_wrapper_new(const char *id, bool clean_session, void *obj)
Initialize a new instance of the underlying client implementation.
int mqtt_wrapper_socket(void *instance)
Fetch the file-descriptor for the underlying network-socket.
sl_status_t mqtt_wrapper_set_will_message(void *instance, const char *mqtt_client_id, int qos)
Configures the MQTT Will message using the Client ID.
sl_status_t mqtt_wrapper_topic_matches_sub(const char *sub, const char *topic, bool *result)
Check whether a given topic matches a subscription-pattern.
sl_status_t mqtt_wrapper_tls_psk_set(void *instance, const char *psk, const char *id, const char *ciphers)
Configure the client for pre-shared-key based TLS support.
void mqtt_wrapper_connect_callback_set(void *instance, void(*on_connect)(void *inst, void *obj, int result_code))
Set the connect callback.
sl_status_t mqtt_wrapper_lib_cleanup()
Do a cleanup of the underlying client-library.
void mqtt_wrapper_disconnect_callback_set(void *instance, void(*on_disconnect)(void *inst, void *obj, int rc))
Set the disconnect callback.
sl_status_t mqtt_wrapper_lib_init()
Initialize the underlying MQTT-client library.
sl_status_t mqtt_wrapper_loop_misc(void *instance)
Carry out miscellaneous operations required as part of the nwtwork-loop (e.g. PINGs).
sl_status_t mqtt_wrapper_disconnect(void *instance)
Close the MQTT-broker connection.
void mqtt_wrapper_destroy(void *instance)
Destroy (free) a client-instance.
sl_status_t mqtt_wrapper_connect(void *instance, const char *host, int port, int keepalive)
Connect to an MQTT-broker.
sl_status_t mqtt_wrapper_loop(void *instance, int timeout)
Run an iteration of the network-loop of the underlying client-library.
sl_status_t mqtt_wrapper_subscribe(void *instance, int *mid, const char *sub, int qos)
Subscribe to a topic.
sl_status_t mqtt_wrapper_tls_set(void *instance, const char *cafile, const char *certfile, const char *keyfile)
Configure the client for Certficate based TLS support.
sl_status_t mqtt_wrapper_loop_read(void *instance)
Carry out read-operations on the network-socket connected to the MQTT-broker.
sl_status_t mqtt_wrapper_unsubscribe(void *instance, int *mid, const char *sub)
Unsubscribe from a topic.
SL Status Codes.
Definition: mqtt_wrapper.h:26
const char * topic
MQTT-topic where message originated from.
Definition: mqtt_wrapper.h:28
int mid
Message-ID.
Definition: mqtt_wrapper.h:27
void * payload
Pointer to the payload.
Definition: mqtt_wrapper.h:29
int payloadlen
Size of the payload in bytes.
Definition: mqtt_wrapper.h:30
int qos
QoS value when message was published.
Definition: mqtt_wrapper.h:31
bool retain
True if this was a retained message.
Definition: mqtt_wrapper.h:32