feat(mqtt): use QoS setting for message delivery

This commit is contained in:
eeff
2023-03-20 12:27:52 +08:00
parent e61bff75cc
commit 41225edd75
2 changed files with 9 additions and 7 deletions
+3 -3
View File
@@ -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;
+6 -4
View File
@@ -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;