From 9eaf8f0525c1268a0603b233e25c08d8feba47a4 Mon Sep 17 00:00:00 2001 From: fengzero Date: Thu, 12 Jun 2025 03:05:36 +0000 Subject: [PATCH] mqtt: rm / in topic --- plugins/mqtt/mqtt.json | 8 ++++---- plugins/mqtt/mqtt_plugin_intf.c | 4 ++-- tests/ft/app/test_mqtt.py | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/mqtt/mqtt.json b/plugins/mqtt/mqtt.json index 0c751d203..9d1829d2f 100644 --- a/plugins/mqtt/mqtt.json +++ b/plugins/mqtt/mqtt.json @@ -126,7 +126,7 @@ "description_zh": "接收点位写入请求的 MQTT 主题。", "attribute": "required", "type": "string", - "default": "/neuron/${random_str}/write/req", + "default": "neuron/${random_str}/write/req", "valid": { "length": 255 } @@ -138,7 +138,7 @@ "description_zh": "发送点位写入响应的 MQTT 主题。", "attribute": "required", "type": "string", - "default": "/neuron/${random_str}/write/resp", + "default": "neuron/${random_str}/write/resp", "valid": { "length": 255 } @@ -149,7 +149,7 @@ "description": "MQTT topic prefix for driver function.", "attribute": "required", "type": "string", - "default": "/neuron/${random_str}", + "default": "neuron/${random_str}", "valid": { "length": 128 } @@ -173,7 +173,7 @@ "field": "upload_drv_state", "value": true }, - "default": "/neuron/${random_str}/state/update", + "default": "neuron/${random_str}/state/update", "valid": { "length": 255 } diff --git a/plugins/mqtt/mqtt_plugin_intf.c b/plugins/mqtt/mqtt_plugin_intf.c index b39398cfd..970c8c2d4 100644 --- a/plugins/mqtt/mqtt_plugin_intf.c +++ b/plugins/mqtt/mqtt_plugin_intf.c @@ -265,13 +265,13 @@ static int create_topic(neu_plugin_t *plugin) return 0; } - neu_asprintf(&plugin->read_req_topic, "/neuron/%s/read/req", + neu_asprintf(&plugin->read_req_topic, "neuron/%s/read/req", plugin->common.name); if (NULL == plugin->read_req_topic) { return -1; } - neu_asprintf(&plugin->read_resp_topic, "/neuron/%s/read/resp", + neu_asprintf(&plugin->read_resp_topic, "neuron/%s/read/resp", plugin->common.name); if (NULL == plugin->read_resp_topic) { free(plugin->read_req_topic); diff --git a/tests/ft/app/test_mqtt.py b/tests/ft/app/test_mqtt.py index 842eba8ee..a1edd97a0 100644 --- a/tests/ft/app/test_mqtt.py +++ b/tests/ft/app/test_mqtt.py @@ -62,12 +62,12 @@ ] FORMAT_VALUES = 0 FORMAT_TAGS = 1 -UPLOAD_TOPIC = f"/neuron/{NODE}/upload" -WRITE_REQ_TOPIC = f"/neuron/{NODE}/write/req" -WRITE_RESP_TOPIC = f"/neuron/{NODE}/write/resp" -READ_REQ_TOPIC = f"/neuron/{NODE}/read/req" -READ_RESP_TOPIC = f"/neuron/{NODE}/read/resp" -UPLOAD_DRV_STATE_TOPIC = f"/neuron/{NODE}/state/update" +UPLOAD_TOPIC = f"neuron/{NODE}/upload" +WRITE_REQ_TOPIC = f"neuron/{NODE}/write/req" +WRITE_RESP_TOPIC = f"neuron/{NODE}/write/resp" +READ_REQ_TOPIC = f"neuron/{NODE}/read/req" +READ_RESP_TOPIC = f"neuron/{NODE}/read/resp" +UPLOAD_DRV_STATE_TOPIC = f"neuron/{NODE}/state/update" @pytest.fixture(autouse=True, scope="class") @@ -204,7 +204,7 @@ def conf_upload_driver_state(conf_base): return { **conf_base, "upload_drv_state": True, - "upload_drv_state_topic": f"/neuron/{NODE}/state/update", + "upload_drv_state_topic": f"neuron/{NODE}/state/update", "upload_drv_state_interval": 1, }