Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages

MQTT log backend API . More...

Functions

int log_backend_mqtt_client_set (struct mqtt_client *client)
 Set the MQTT client instance to be able to publish application's log messages to broker.
 
int log_backend_mqtt_topic_set (const char *topic)
 Set the MQTT topic to which log messages will be published.
 

Detailed Description

MQTT log backend API .

Function Documentation

◆ log_backend_mqtt_client_set()

int log_backend_mqtt_client_set ( struct mqtt_client * client)

#include <zephyr/logging/log_backend_mqtt.h>

Set the MQTT client instance to be able to publish application's log messages to broker.

This function allows the application to provide its own initialized MQTT client to the log backend. The backend will use this client exclusively for publishing log messages via mqtt_publish().

Parameters
clientPointer to an initialized and connected MQTT client. The client must remain valid for the lifetime of the log backend usage. Pass NULL to disable MQTT logging.
Returns
0 on success, negative error code on failure.
Note
The MQTT client must be connected before calling this function.
The backend will not manage the client connection - this is the responsibility of the application.
The backend will only use mqtt_publish() and will not perform any other operations on the client.

◆ log_backend_mqtt_topic_set()

int log_backend_mqtt_topic_set ( const char * topic)

#include <zephyr/logging/log_backend_mqtt.h>

Set the MQTT topic to which log messages will be published.

Allows the application to specify the MQTT topic that the log backend will use for publishing log messages to.

Parameters
topicPointer to a null-terminated string containing the MQTT topic. The topic must remain valid for the lifetime of the log backend usage.
Returns
0 on success, negative error code on failure.
Note
The topic must be a valid UTF-8 string, null-terminated and should not exceed the maximum length supported by the MQTT broker.