From 41225edd7583f10aa25481bf8cea376167291a12 Mon Sep 17 00:00:00 2001 From: eeff <33566201+eeff@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:27:52 +0800 Subject: [PATCH] feat(mqtt): use QoS setting for message delivery --- plugins/mqtt/mqtt_handle.c | 6 +++--- plugins/mqtt/mqtt_plugin.c | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/mqtt/mqtt_handle.c b/plugins/mqtt/mqtt_handle.c index 3a451860..1f18022f 100644 --- a/plugins/mqtt/mqtt_handle.c +++ b/plugins/mqtt/mqtt_handle.c @@ -373,7 +373,7 @@ int handle_write_response(neu_plugin_t *plugin, neu_json_mqtt_t *mqtt_json, } char * topic = plugin->write_resp_topic; - neu_mqtt_qos_e qos = NEU_MQTT_QOS0; + neu_mqtt_qos_e qos = plugin->config.qos; rv = publish(plugin, qos, topic, json_str, strlen(json_str)); json_str = NULL; @@ -455,7 +455,7 @@ int handle_read_response(neu_plugin_t *plugin, neu_json_mqtt_t *mqtt_json, } char * topic = plugin->read_resp_topic; - neu_mqtt_qos_e qos = NEU_MQTT_QOS0; + neu_mqtt_qos_e qos = plugin->config.qos; rv = publish(plugin, qos, topic, json_str, strlen(json_str)); json_str = NULL; @@ -496,7 +496,7 @@ int handle_trans_data(neu_plugin_t * plugin, } char * topic = route->topic; - neu_mqtt_qos_e qos = NEU_MQTT_QOS0; + neu_mqtt_qos_e qos = plugin->config.qos; rv = publish(plugin, qos, topic, json_str, strlen(json_str)); json_str = NULL; diff --git a/plugins/mqtt/mqtt_plugin.c b/plugins/mqtt/mqtt_plugin.c index f9e3a601..09b96fd6 100644 --- a/plugins/mqtt/mqtt_plugin.c +++ b/plugins/mqtt/mqtt_plugin.c @@ -286,16 +286,18 @@ static int mqtt_plugin_start(neu_plugin_t *plugin) } if (0 != - neu_mqtt_client_subscribe(plugin->client, 0, plugin->read_req_topic, - plugin, handle_read_req)) { + neu_mqtt_client_subscribe(plugin->client, plugin->config.qos, + plugin->read_req_topic, plugin, + handle_read_req)) { plog_error(plugin, "subscribe [%s] fail", plugin->read_req_topic); rv = NEU_ERR_MQTT_SUBSCRIBE_FAILURE; goto end; } if (0 != - neu_mqtt_client_subscribe(plugin->client, 0, plugin->write_req_topic, - plugin, handle_write_req)) { + neu_mqtt_client_subscribe(plugin->client, plugin->config.qos, + plugin->write_req_topic, plugin, + handle_write_req)) { plog_error(plugin, "subscribe [%s] fail", plugin->write_req_topic); rv = NEU_ERR_MQTT_SUBSCRIBE_FAILURE; goto end;