Skip to content

Commit b7c4db2

Browse files
author
Jeppe Odgaard
committed
shell: mqtt: use topic levels
Change topic from <device_id>_rx (and tx) to <device_id>/sh/rx. This allows use of wildcards. E.g. subscribe to all devices "+/sh/tx". Level "sh" is added to the topic to make it less generic and prevent potential clashes with other topics. Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
1 parent 93d479d commit b7c4db2

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

doc/releases/migration-guide-4.3.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ Networking
4141
Other subsystems
4242
****************
4343

44+
Shell
45+
=====
46+
47+
* The MQTT topics related to :kconfig:option:`SHELL_BACKEND_MQTT` have been renamed. Renamed
48+
``<device_id>_rx`` to ``<device_id>/sh/rx`` and ``<device_id>_tx`` to ``<device_id>/sh/rx``.
49+
(:github:`92677`).
50+
4451
Modules
4552
*******
4653

include/zephyr/shell/shell_mqtt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525
#define SH_MQTT_BUFFER_SIZE 64
2626
#define DEVICE_ID_BIN_MAX_SIZE 3
2727
#define DEVICE_ID_HEX_MAX_SIZE ((DEVICE_ID_BIN_MAX_SIZE * 2) + 1)
28-
#define SH_MQTT_TOPIC_MAX_SIZE DEVICE_ID_HEX_MAX_SIZE + 3
28+
#define SH_MQTT_TOPIC_MAX_SIZE DEVICE_ID_HEX_MAX_SIZE + 6 /* /sh/rx */
2929

3030
extern const struct shell_transport_api shell_mqtt_transport_api;
3131

subsys/shell/backends/shell_mqtt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ static int init(const struct shell_transport *transport, const void *config,
657657

658658
LOG_DBG("Client ID is %s", sh->device_id);
659659

660-
(void)snprintf(sh->pub_topic, SH_MQTT_TOPIC_MAX_SIZE, "%s_tx", sh->device_id);
661-
(void)snprintf(sh->sub_topic, SH_MQTT_TOPIC_MAX_SIZE, "%s_rx", sh->device_id);
660+
(void)snprintf(sh->pub_topic, SH_MQTT_TOPIC_MAX_SIZE, "%s/sh/tx", sh->device_id);
661+
(void)snprintf(sh->sub_topic, SH_MQTT_TOPIC_MAX_SIZE, "%s/sh/rx", sh->device_id);
662662

663663
ring_buf_init(&sh->rx_rb, RX_RB_SIZE, sh->rx_rb_buf);
664664

0 commit comments

Comments
 (0)