From c4169765afb28f7cb00a66a4c40859ebbbae1c30 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Wed, 4 Jun 2025 12:40:47 +0200 Subject: [PATCH] fix(mosq): Make mosquitto component c++ compatible Closes https://github.com/espressif/esp-protocols/issues/817 Closes https://github.com/espressif/esp-protocols/issues/816 --- components/mosquitto/port/include/mosq_broker.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/mosquitto/port/include/mosq_broker.h b/components/mosquitto/port/include/mosq_broker.h index d9b858b8c..62e7c2829 100644 --- a/components/mosquitto/port/include/mosq_broker.h +++ b/components/mosquitto/port/include/mosq_broker.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,10 @@ #include "mosquitto.h" #include "esp_tls.h" +#ifdef __cplusplus +extern "C" { +#endif + struct mosquitto__config; typedef void (*mosq_message_cb_t)(char *client, char *topic, char *data, int len, int qos, int retain); @@ -17,7 +21,7 @@ typedef void (*mosq_message_cb_t)(char *client, char *topic, char *data, int len * structure. */ struct mosq_broker_config { - char *host; /*!< Address on which the broker is listening for connections */ + const char *host; /*!< Address on which the broker is listening for connections */ int port; /*!< Port number of the broker to listen to */ esp_tls_cfg_server_t *tls_cfg; /*!< ESP-TLS configuration (if TLS transport used) * Please refer to the ESP-TLS official documentation @@ -48,3 +52,7 @@ int mosq_broker_run(struct mosq_broker_config *config); * @note After calling this API, function mosq_broker_run() unblocks and returns. */ void mosq_broker_stop(void); + +#ifdef __cplusplus +} +#endif