Skip to content

Commit 2e28774

Browse files
Merge pull request #775 from euripedesrocha/feature/mosquitto_plugin
Add config to enable SYS on mosquito and bump version
2 parents 6f00c36 + e14e21a commit 2e28774

File tree

8 files changed

+62
-9
lines changed

8 files changed

+62
-9
lines changed

components/mosquitto/.cz.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ commitizen:
33
bump_message: 'bump(mosq): $current_version -> $new_version'
44
pre_bump_hooks: python ../../ci/changelog.py mosquitto
55
tag_format: mosq-v$version
6-
version: 2.0.20~1
6+
version: 2.0.20~2
77
version_files:
88
- idf_component.yml

components/mosquitto/CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## [2.0.20~2](https://github.com/espressif/esp-protocols/commits/mosq-v2.0.20_2)
4+
5+
### Features
6+
7+
- Allow user to enable SYS topic ([905b84fb](https://github.com/espressif/esp-protocols/commit/905b84fb))
8+
9+
### Bug Fixes
10+
11+
- Remove temp modification of IDF files ([9162de11](https://github.com/espressif/esp-protocols/commit/9162de11))
12+
- Add a note about stack size ([dbd164dd](https://github.com/espressif/esp-protocols/commit/dbd164dd))
13+
314
## [2.0.20~1](https://github.com/espressif/esp-protocols/commits/mosq-v2.0.20_1)
415

516
### Bug Fixes

components/mosquitto/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ set(m_srcs
2121
${m_lib_dir}/handle_pubrec.c
2222
${m_lib_dir}/handle_pubrel.c
2323
${m_lib_dir}/handle_ping.c
24-
${m_lib_dir}/time_mosq.c
2524
${m_lib_dir}/utf8_mosq.c
2625

2726
${m_src_dir}/bridge.c
@@ -75,16 +74,20 @@ idf_component_register(SRCS ${m_srcs}
7574
port/config.c
7675
port/signals.c
7776
port/broker.c
77+
port/mosq_time.c
7878
port/files.c
7979
port/net__esp_tls.c
8080
port/sysconf.c
8181
PRIV_INCLUDE_DIRS port/priv_include port/priv_include/sys ${m_dir} ${m_src_dir}
8282
${m_incl_dir} ${m_lib_dir} ${m_deps_dir}
8383
INCLUDE_DIRS ${m_incl_dir} port/include
8484
REQUIRES esp-tls
85-
PRIV_REQUIRES newlib sock_utils)
85+
PRIV_REQUIRES newlib sock_utils esp_timer)
8686

8787
target_compile_definitions(${COMPONENT_LIB} PRIVATE "WITH_BROKER")
88+
if (CONFIG_MOSQ_ENABLE_SYS)
89+
target_compile_definitions(${COMPONENT_LIB} PRIVATE "WITH_SYS_TREE")
90+
endif()
8891
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
8992

9093
# Some mosquitto source unconditionally define `_GNU_SOURCE` which collides with IDF build system

components/mosquitto/Kconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
menu "Mosquitto"
2+
3+
config MOSQ_ENABLE_SYS
4+
bool "Enable $SYS topics"
5+
default n
6+
help
7+
Enable the $SYS topics for the broker
8+
9+
config MOSQ_SYS_UPDATE_INTERVAL
10+
int "Update interval for the SYS topic"
11+
default 10
12+
depends on MOSQ_ENABLE_SYS
13+
help
14+
Time in seconds for the update of the $SYS topics for the broker
15+
endmenu

components/mosquitto/idf_component.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.0.20~1"
1+
version: "2.0.20~2"
22
url: https://github.com/espressif/esp-protocols/tree/master/components/mosquitto
33
description: The component provides a simple ESP32 port of mosquitto broker
44
dependencies:

components/mosquitto/port/config.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* SPDX-License-Identifier: EPL-2.0
55
*
6-
* SPDX-FileContributor: 2024 Espressif Systems (Shanghai) CO LTD
6+
* SPDX-FileContributor: 2024-2025 Espressif Systems (Shanghai) CO LTD
77
*/
88
#include "mosquitto_internal.h"
99
#include "mosquitto_broker.h"
@@ -14,6 +14,7 @@
1414
#include "utlist.h"
1515
#include "lib_load.h"
1616
#include "syslog.h"
17+
#include "sdkconfig.h"
1718

1819

1920
void config__init(struct mosquitto__config *config)
@@ -66,7 +67,7 @@ void config__init(struct mosquitto__config *config)
6667
config->log_file = NULL;
6768

6869
config->log_facility = LOG_DAEMON;
69-
config->log_dest = MQTT3_LOG_STDERR | MQTT3_LOG_DLT;
70+
config->log_dest = MQTT3_LOG_STDERR | MQTT3_LOG_TOPIC;
7071
if (db.verbose) {
7172
config->log_type = UINT_MAX;
7273
} else {
@@ -91,7 +92,9 @@ void config__init(struct mosquitto__config *config)
9192
config->queue_qos0_messages = false;
9293
config->retain_available = true;
9394
config->set_tcp_nodelay = false;
94-
config->sys_interval = 10;
95+
#if defined(WITH_SYS_TREE)
96+
config->sys_interval = CONFIG_MOSQ_SYS_UPDATE_INTERVAL;
97+
#endif
9598
config->upgrade_outgoing_qos = false;
9699

97100
config->daemon = false;
@@ -236,7 +239,7 @@ char *misc__trimblanks(char *str)
236239

237240
// Dummy definition of fork() to work around IDF warning: " warning: _fork is not implemented and will always fail"
238241
// fork() is used in mosquitto.c to deamonize the broker, which we do not call.
239-
pid_t fork (void)
242+
pid_t fork(void)
240243
{
241244
abort();
242245
return 0;

components/mosquitto/port/mosq_time.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Roger Light <[email protected]>
3+
*
4+
* SPDX-License-Identifier: EPL-2.0
5+
*
6+
* SPDX-FileContributor: 2025 Espressif Systems (Shanghai) CO LTD
7+
*/
8+
9+
#include <time.h>
10+
#include "time_mosq.h"
11+
12+
#include "esp_timer.h"
13+
14+
void mosquitto_time_init(void)
15+
{
16+
}
17+
18+
time_t mosquitto_time(void)
19+
{
20+
return esp_timer_get_time() / 1000000; // Convert microseconds to seconds
21+
}

components/mosquitto/port/priv_include/config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
#include_next "config.h"
1414

15-
#define VERSION "v2.0.20~1"
15+
#define VERSION "v2.0.20~2"

0 commit comments

Comments
 (0)