diff --git a/.github/workflows/mosq__build.yml b/.github/workflows/mosq__build.yml
index 3d2fa5dca..0182a9f33 100644
--- a/.github/workflows/mosq__build.yml
+++ b/.github/workflows/mosq__build.yml
@@ -13,7 +13,7 @@ jobs:
name: Mosquitto build
strategy:
matrix:
- idf_ver: ["latest", "release-v5.3"]
+ idf_ver: ["latest", "release-v5.5", "release-v5.4", "release-v5.3", "release-v5.2", "release-v5.1"]
runs-on: ubuntu-22.04
container: espressif/idf:${{ matrix.idf_ver }}
env:
diff --git a/components/mosquitto/.cz.yaml b/components/mosquitto/.cz.yaml
index 97a05a678..683a6eb79 100644
--- a/components/mosquitto/.cz.yaml
+++ b/components/mosquitto/.cz.yaml
@@ -3,6 +3,6 @@ commitizen:
bump_message: 'bump(mosq): $current_version -> $new_version'
pre_bump_hooks: python ../../ci/changelog.py mosquitto
tag_format: mosq-v$version
- version: 2.0.20~2
+ version: 2.0.20~3
version_files:
- idf_component.yml
diff --git a/components/mosquitto/CHANGELOG.md b/components/mosquitto/CHANGELOG.md
index ba62d2182..a04fd7e05 100644
--- a/components/mosquitto/CHANGELOG.md
+++ b/components/mosquitto/CHANGELOG.md
@@ -1,5 +1,15 @@
# Changelog
+## [2.0.20~3](https://github.com/espressif/esp-protocols/commits/mosq-v2.0.20_3)
+
+
+### Bug Fixes
+
+- Support build on older IDF branches ([13b90ad1](https://github.com/espressif/esp-protocols/commit/13b90ad1))
+- Fix misleading error when accepting connection ([fd410061](https://github.com/espressif/esp-protocols/commit/fd410061), [#807](https://github.com/espressif/esp-protocols/issues/807))
+- Make mosquitto component c++ compatible ([c4169765](https://github.com/espressif/esp-protocols/commit/c4169765), [#817](https://github.com/espressif/esp-protocols/issues/817))
+- include config.h before any system header ([1b1ede43](https://github.com/espressif/esp-protocols/commit/1b1ede43))
+
## [2.0.20~2](https://github.com/espressif/esp-protocols/commits/mosq-v2.0.20_2)
### Features
diff --git a/components/mosquitto/Kconfig b/components/mosquitto/Kconfig
index 00d5e0a01..207fa1e7a 100644
--- a/components/mosquitto/Kconfig
+++ b/components/mosquitto/Kconfig
@@ -1,5 +1,13 @@
menu "Mosquitto"
+ config MOSQ_IS_ENABLED
+ # Invisible option that is enabled if MOSQ is added to the IDF components.
+ # This is used to "select" CONFIG_ESP_TLS_SERVER option (needed for TLS connection)
+ # (these are optionally used in mosq)
+ bool
+ default "y"
+ select ESP_TLS_SERVER
+
config MOSQ_ENABLE_SYS
bool "Enable $SYS topics"
default n
diff --git a/components/mosquitto/api.md b/components/mosquitto/api.md
index aea93fdfe..1e1219559 100644
--- a/components/mosquitto/api.md
+++ b/components/mosquitto/api.md
@@ -37,7 +37,7 @@ Variables:
- void(\* handle_message_cb
On message callback. If configured, user function is called whenever mosquitto processes a message.
-- 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
diff --git a/components/mosquitto/examples/serverless_mqtt/main/wifi_connect.c b/components/mosquitto/examples/serverless_mqtt/main/wifi_connect.c
index aeb3af759..9c8ec1dd3 100644
--- a/components/mosquitto/examples/serverless_mqtt/main/wifi_connect.c
+++ b/components/mosquitto/examples/serverless_mqtt/main/wifi_connect.c
@@ -3,6 +3,8 @@
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
+#include "freertos/FreeRTOS.h"
+#include "freertos/event_groups.h"
#include "nvs_flash.h"
#include "esp_event.h"
#include "esp_netif.h"
diff --git a/components/mosquitto/idf_component.yml b/components/mosquitto/idf_component.yml
index 82a37351b..d58f5b215 100644
--- a/components/mosquitto/idf_component.yml
+++ b/components/mosquitto/idf_component.yml
@@ -1,4 +1,4 @@
-version: "2.0.20~2"
+version: "2.0.20~3"
url: https://github.com/espressif/esp-protocols/tree/master/components/mosquitto
description: The component provides a simple ESP32 port of mosquitto broker
dependencies:
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
diff --git a/components/mosquitto/port/net__esp_tls.c b/components/mosquitto/port/net__esp_tls.c
index 078a47f9d..cbe771581 100644
--- a/components/mosquitto/port/net__esp_tls.c
+++ b/components/mosquitto/port/net__esp_tls.c
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*
- * SPDX-FileContributor: 2024 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileContributor: 2024-2025 Espressif Systems (Shanghai) CO LTD
*/
/*
@@ -106,6 +106,9 @@ struct mosquitto *net__socket_accept(struct mosquitto__listener_sock *listensock
new_sock = accept(listensock->sock, NULL, 0);
if (new_sock == INVALID_SOCKET) {
+ if (errno == EAGAIN) { // mosquitto tries to accept() in a loop until EAGAIN is returned
+ return NULL;
+ }
log__printf(NULL, MOSQ_LOG_ERR,
"Unable to accept new connection, system socket count has been exceeded. Try increasing \"ulimit -n\" or equivalent.");
return NULL;
diff --git a/components/mosquitto/port/priv_include/config.h b/components/mosquitto/port/priv_include/config.h
index deed531fc..9a743a68d 100644
--- a/components/mosquitto/port/priv_include/config.h
+++ b/components/mosquitto/port/priv_include/config.h
@@ -20,4 +20,4 @@
#undef isspace
#define isspace(__c) (__ctype_lookup((int)__c)&_S)
-#define VERSION "v2.0.20~2"
+#define VERSION "v2.0.20~3"