diff --git a/plugins/mqtt/aws-iot.json b/plugins/mqtt/aws-iot.json index 8ad79c18..237e8065 100644 --- a/plugins/mqtt/aws-iot.json +++ b/plugins/mqtt/aws-iot.json @@ -1,23 +1,4 @@ { - "version": { - "name": "MQTT Version", - "name_zh": "MQTT 版本", - "type": "map", - "attribute": "optional", - "default": 5, - "valid": { - "map": [ - { - "key": "3.1.1", - "value": 4 - }, - { - "key": "5.0", - "value": 5 - } - ] - } - }, "client-id": { "name": "Client ID", "name_zh": "客户端 ID", diff --git a/plugins/mqtt/azure-iot.json b/plugins/mqtt/azure-iot.json index aca21359..14fd6ecd 100644 --- a/plugins/mqtt/azure-iot.json +++ b/plugins/mqtt/azure-iot.json @@ -1,23 +1,4 @@ { - "version": { - "name": "MQTT Version", - "name_zh": "MQTT 版本", - "type": "map", - "attribute": "optional", - "default": 5, - "valid": { - "map": [ - { - "key": "3.1.1", - "value": 4 - }, - { - "key": "5.0", - "value": 5 - } - ] - } - }, "device-id": { "name": "Device ID", "name_zh": "设备 ID", diff --git a/plugins/mqtt/azure_iot_plugin.c b/plugins/mqtt/azure_iot_plugin.c index 3aa17b66..7c997997 100644 --- a/plugins/mqtt/azure_iot_plugin.c +++ b/plugins/mqtt/azure_iot_plugin.c @@ -73,12 +73,6 @@ static int azure_parse_config(neu_plugin_t *plugin, const char *setting, char * write_resp_topic = NULL; char * username = NULL; - neu_json_elem_t version = { - .name = "version", - .t = NEU_JSON_INT, - .v.val_int = NEU_MQTT_VERSION_V5, // default to V5 - .attribute = NEU_JSON_ATTRIBUTE_OPTIONAL, // for backward compatibility - }; neu_json_elem_t client_id = { .name = "device-id", .t = NEU_JSON_STR }; neu_json_elem_t qos = { .name = "qos", .t = NEU_JSON_INT }; neu_json_elem_t format = { .name = "format", .t = NEU_JSON_INT }; @@ -101,14 +95,6 @@ static int azure_parse_config(neu_plugin_t *plugin, const char *setting, goto error; } - ret = neu_parse_param(setting, &err_param, 1, &version); - if (0 != ret) { - plog_error( - plugin, - "parsing mqtt version fail, key: `%s`. Set default version: mqttv5", - err_param); - } - // client-id, required if (0 == strlen(client_id.v.val_str)) { plog_error(plugin, "setting empty client-id"); @@ -179,7 +165,7 @@ static int azure_parse_config(neu_plugin_t *plugin, const char *setting, goto error; } - config->version = version.v.val_int; + config->version = NEU_MQTT_VERSION_V311; config->client_id = client_id.v.val_str; config->qos = qos.v.val_int; config->format = format.v.val_int; diff --git a/plugins/mqtt/mqtt.json b/plugins/mqtt/mqtt.json index 7862d523..05abf4f5 100644 --- a/plugins/mqtt/mqtt.json +++ b/plugins/mqtt/mqtt.json @@ -4,7 +4,7 @@ "name_zh": "MQTT 版本", "type": "map", "attribute": "optional", - "default": 5, + "default": 4, "valid": { "map": [ { diff --git a/plugins/mqtt/mqtt_config.c b/plugins/mqtt/mqtt_config.c index 6a9ced31..834ec2aa 100644 --- a/plugins/mqtt/mqtt_config.c +++ b/plugins/mqtt/mqtt_config.c @@ -221,7 +221,7 @@ int mqtt_config_parse(neu_plugin_t *plugin, const char *setting, neu_json_elem_t version = { .name = "version", .t = NEU_JSON_INT, - .v.val_int = NEU_MQTT_VERSION_V5, // default to V5 + .v.val_int = NEU_MQTT_VERSION_V311, // default to V311 .attribute = NEU_JSON_ATTRIBUTE_OPTIONAL, // for backward compatibility }; neu_json_elem_t client_id = { .name = "client-id", .t = NEU_JSON_STR }; @@ -276,10 +276,8 @@ int mqtt_config_parse(neu_plugin_t *plugin, const char *setting, ret = neu_parse_param(setting, &err_param, 1, &version); if (0 != ret) { - plog_error( - plugin, - "parsing mqtt version fail, key: `%s`. Set default version: mqttv5", - err_param); + plog_error(plugin, "parsing mqtt version fail, key: `%s`.", err_param); + goto error; } // client-id, required