初始化放到启动部分
This commit is contained in:
parent
c89b2493a3
commit
3671647cd5
|
@ -38,6 +38,12 @@ char* topicPath;
|
||||||
int isStop = 1;
|
int isStop = 1;
|
||||||
int32_t mqttInitSystem() {
|
int32_t mqttInitSystem() {
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mqttStartSystem() {
|
||||||
|
int rc = 0;
|
||||||
uint8_t sendbuf[2048];
|
uint8_t sendbuf[2048];
|
||||||
uint8_t recvbuf[1024];
|
uint8_t recvbuf[1024];
|
||||||
recnt_status.sendbuf = sendbuf;
|
recnt_status.sendbuf = sendbuf;
|
||||||
|
@ -70,17 +76,11 @@ int32_t mqttInitSystem() {
|
||||||
int _tpsize = strlen(topicPath) + strlen(_topic) + 1;
|
int _tpsize = strlen(topicPath) + strlen(_topic) + 1;
|
||||||
recnt_status.topic = calloc(1, _tpsize);
|
recnt_status.topic = calloc(1, _tpsize);
|
||||||
sprintf(recnt_status.topic, "/%s/%s", topicPath, _topic);
|
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();
|
taos_init();
|
||||||
mqttPrint("mqttInitSystem mqtt://%s:%s@%s:%s/%s/", recnt_status.user_name, recnt_status.password,
|
mqttPrint("mqttInitSystem mqtt://%s:%s@%s:%s/%s/", recnt_status.user_name, recnt_status.password,
|
||||||
recnt_status.hostname, recnt_status.port, topicPath);
|
recnt_status.hostname, recnt_status.port, topicPath);
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mqttStartSystem() {
|
|
||||||
int rc = 0;
|
|
||||||
mqtt_conn = NULL;
|
mqtt_conn = NULL;
|
||||||
mqtt_init_reconnect(&client, mqttReconnectClient, &recnt_status, mqtt_PublishCallback);
|
mqtt_init_reconnect(&client, mqttReconnectClient, &recnt_status, mqtt_PublishCallback);
|
||||||
if (pthread_create(&client_daemon, NULL, mqttClientRefresher, &client)) {
|
if (pthread_create(&client_daemon, NULL, mqttClientRefresher, &client)) {
|
||||||
|
|
Loading…
Reference in New Issue