diff --git a/src/plugins/mqtt/src/mqttSystem.c b/src/plugins/mqtt/src/mqttSystem.c index 030d950a79975f72c772088245d3fc520cb396b8..33d83228a75226ae924eb32e0a4f92133ef20e2f 100644 --- a/src/plugins/mqtt/src/mqttSystem.c +++ b/src/plugins/mqtt/src/mqttSystem.c @@ -38,6 +38,12 @@ char* topicPath; int isStop = 1; int32_t mqttInitSystem() { int rc = 0; + + return rc; +} + +int32_t mqttStartSystem() { + int rc = 0; uint8_t sendbuf[2048]; uint8_t recvbuf[1024]; recnt_status.sendbuf = sendbuf; @@ -54,7 +60,7 @@ int32_t mqttInitSystem() { recnt_status.hostname = strbetween(url, "//", ":"); } else { - recnt_status.hostname = strbetween(url, "//", "/"); + recnt_status.hostname = strbetween(url, "//", "/"); } char* _begin_hostname = strstr(url, recnt_status.hostname); @@ -65,22 +71,16 @@ int32_t mqttInitSystem() { } topicPath = strbetween(strstr(url, strstr(_begin_hostname, ":") != NULL ? recnt_status.port : recnt_status.hostname), - "/", "/"); + "/", "/"); char* _topic = "+/+/+/"; int _tpsize = strlen(topicPath) + strlen(_topic) + 1; recnt_status.topic = calloc(1, _tpsize); sprintf(recnt_status.topic, "/%s/%s", topicPath, _topic); - recnt_status.client_id = strlen(tsMqttBrokerClientId)<3? tsMqttBrokerClientId:"taos_mqtt"; - + recnt_status.client_id = strlen(tsMqttBrokerClientId) < 3 ? tsMqttBrokerClientId : "taos_mqtt"; taos_init(); mqttPrint("mqttInitSystem mqtt://%s:%s@%s:%s/%s/", recnt_status.user_name, recnt_status.password, recnt_status.hostname, recnt_status.port, topicPath); - return rc; -} - -int32_t mqttStartSystem() { - int rc = 0; mqtt_conn = NULL; mqtt_init_reconnect(&client, mqttReconnectClient, &recnt_status, mqtt_PublishCallback); if (pthread_create(&client_daemon, NULL, mqttClientRefresher, &client)) {