diff --git a/components/mosquitto/.cz.yaml b/components/mosquitto/.cz.yaml index b74ae209d..97a05a678 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~1 + version: 2.0.20~2 version_files: - idf_component.yml diff --git a/components/mosquitto/CHANGELOG.md b/components/mosquitto/CHANGELOG.md index 954ccc8ee..ba62d2182 100644 --- a/components/mosquitto/CHANGELOG.md +++ b/components/mosquitto/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [2.0.20~2](https://github.com/espressif/esp-protocols/commits/mosq-v2.0.20_2) + +### Features + +- Allow user to enable SYS topic ([905b84fb](https://github.com/espressif/esp-protocols/commit/905b84fb)) + +### Bug Fixes + +- Remove temp modification of IDF files ([9162de11](https://github.com/espressif/esp-protocols/commit/9162de11)) +- Add a note about stack size ([dbd164dd](https://github.com/espressif/esp-protocols/commit/dbd164dd)) + ## [2.0.20~1](https://github.com/espressif/esp-protocols/commits/mosq-v2.0.20_1) ### Bug Fixes diff --git a/components/mosquitto/CMakeLists.txt b/components/mosquitto/CMakeLists.txt index a7e337009..3608021e2 100644 --- a/components/mosquitto/CMakeLists.txt +++ b/components/mosquitto/CMakeLists.txt @@ -21,7 +21,6 @@ set(m_srcs ${m_lib_dir}/handle_pubrec.c ${m_lib_dir}/handle_pubrel.c ${m_lib_dir}/handle_ping.c - ${m_lib_dir}/time_mosq.c ${m_lib_dir}/utf8_mosq.c ${m_src_dir}/bridge.c @@ -75,6 +74,7 @@ idf_component_register(SRCS ${m_srcs} port/config.c port/signals.c port/broker.c + port/mosq_time.c port/files.c port/net__esp_tls.c port/sysconf.c @@ -82,9 +82,12 @@ idf_component_register(SRCS ${m_srcs} ${m_incl_dir} ${m_lib_dir} ${m_deps_dir} INCLUDE_DIRS ${m_incl_dir} port/include REQUIRES esp-tls - PRIV_REQUIRES newlib sock_utils) + PRIV_REQUIRES newlib sock_utils esp_timer) target_compile_definitions(${COMPONENT_LIB} PRIVATE "WITH_BROKER") +if (CONFIG_MOSQ_ENABLE_SYS) + target_compile_definitions(${COMPONENT_LIB} PRIVATE "WITH_SYS_TREE") +endif() target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") # Some mosquitto source unconditionally define `_GNU_SOURCE` which collides with IDF build system diff --git a/components/mosquitto/Kconfig b/components/mosquitto/Kconfig new file mode 100644 index 000000000..00d5e0a01 --- /dev/null +++ b/components/mosquitto/Kconfig @@ -0,0 +1,15 @@ +menu "Mosquitto" + + config MOSQ_ENABLE_SYS + bool "Enable $SYS topics" + default n + help + Enable the $SYS topics for the broker + + config MOSQ_SYS_UPDATE_INTERVAL + int "Update interval for the SYS topic" + default 10 + depends on MOSQ_ENABLE_SYS + help + Time in seconds for the update of the $SYS topics for the broker +endmenu diff --git a/components/mosquitto/idf_component.yml b/components/mosquitto/idf_component.yml index 6dda14b8f..82a37351b 100644 --- a/components/mosquitto/idf_component.yml +++ b/components/mosquitto/idf_component.yml @@ -1,4 +1,4 @@ -version: "2.0.20~1" +version: "2.0.20~2" 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/config.c b/components/mosquitto/port/config.c index 04ab00b97..29f927ee2 100644 --- a/components/mosquitto/port/config.c +++ b/components/mosquitto/port/config.c @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: EPL-2.0 * - * SPDX-FileContributor: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2024-2025 Espressif Systems (Shanghai) CO LTD */ #include "mosquitto_internal.h" #include "mosquitto_broker.h" @@ -14,6 +14,7 @@ #include "utlist.h" #include "lib_load.h" #include "syslog.h" +#include "sdkconfig.h" void config__init(struct mosquitto__config *config) @@ -66,7 +67,7 @@ void config__init(struct mosquitto__config *config) config->log_file = NULL; config->log_facility = LOG_DAEMON; - config->log_dest = MQTT3_LOG_STDERR | MQTT3_LOG_DLT; + config->log_dest = MQTT3_LOG_STDERR | MQTT3_LOG_TOPIC; if (db.verbose) { config->log_type = UINT_MAX; } else { @@ -91,7 +92,9 @@ void config__init(struct mosquitto__config *config) config->queue_qos0_messages = false; config->retain_available = true; config->set_tcp_nodelay = false; - config->sys_interval = 10; +#if defined(WITH_SYS_TREE) + config->sys_interval = CONFIG_MOSQ_SYS_UPDATE_INTERVAL; +#endif config->upgrade_outgoing_qos = false; config->daemon = false; @@ -236,7 +239,7 @@ char *misc__trimblanks(char *str) // Dummy definition of fork() to work around IDF warning: " warning: _fork is not implemented and will always fail" // fork() is used in mosquitto.c to deamonize the broker, which we do not call. -pid_t fork (void) +pid_t fork(void) { abort(); return 0; diff --git a/components/mosquitto/port/mosq_time.c b/components/mosquitto/port/mosq_time.c new file mode 100644 index 000000000..56158ac36 --- /dev/null +++ b/components/mosquitto/port/mosq_time.c @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2024 Roger Light + * + * SPDX-License-Identifier: EPL-2.0 + * + * SPDX-FileContributor: 2025 Espressif Systems (Shanghai) CO LTD + */ + +#include +#include "time_mosq.h" + +#include "esp_timer.h" + +void mosquitto_time_init(void) +{ +} + +time_t mosquitto_time(void) +{ + return esp_timer_get_time() / 1000000; // Convert microseconds to seconds +} diff --git a/components/mosquitto/port/priv_include/config.h b/components/mosquitto/port/priv_include/config.h index bf7cb619b..5be59e100 100644 --- a/components/mosquitto/port/priv_include/config.h +++ b/components/mosquitto/port/priv_include/config.h @@ -12,4 +12,4 @@ #include_next "config.h" -#define VERSION "v2.0.20~1" +#define VERSION "v2.0.20~2"