diff --git a/datatransfer/data_trans.cpp b/datatransfer/data_trans.cpp index c79b8a3..4cd1cf4 100644 --- a/datatransfer/data_trans.cpp +++ b/datatransfer/data_trans.cpp @@ -301,7 +301,6 @@ int DataTrans::Gets(const std::string &strUrl, std::string &strResponse, const c } int DataTrans::upload_file(const std::string &strUrl, const std::string &filename, std::string &response) { - CURLcode res; CURL *curl; CURLM *multi_handle; int still_running; @@ -341,10 +340,10 @@ int DataTrans::upload_file(const std::string &strUrl, const std::string &filenam curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); curl_multi_add_handle(multi_handle, curl); - res = curl_multi_perform(multi_handle, &still_running); - if (res != CURLE_OK) { - zlog_error(zct, "[upload_file] curl_multi_perform() failed: %s", curl_easy_strerror(res)); - return res; + CURLMcode ret1 = curl_multi_perform(multi_handle, &still_running); + if (ret1 != CURLM_OK) { + zlog_error(zct, "[upload_file] curl_multi_perform() failed: %d", ret1); + return ret1; } do { diff --git a/mqttclient/mqtt_client.cpp b/mqttclient/mqtt_client.cpp index 36a49d4..e67ea6c 100644 --- a/mqttclient/mqtt_client.cpp +++ b/mqttclient/mqtt_client.cpp @@ -77,7 +77,7 @@ int data_publish_wave(WAVE_CONTAIN *str, const char *topic) { str->waveData[(str->number - 2)]); ret = mosquitto_publish(mosq, &mid_sent, topic, sizeof(WAVE_CONTAIN), str, ud.topic_qos, false); if (ret != MOSQ_ERR_SUCCESS) { - zlog_error(zct, "fail to send mqtt msg, ret: [%s], topic: %s, str: %s", mosquitto_strerror(ret), topic, str); + zlog_error(zct, "fail to send mqtt msg, ret: [%s], topic: %s", mosquitto_strerror(ret), topic); } } return ret; @@ -103,16 +103,11 @@ int disconnect() { return mosquitto_disconnect(mosq); } int reconnect() { return mosquitto_reconnect(mosq); } int start_client(const char *boardname, const char *gwid, const char *gwip, const char *gwver, const char *gwcode, std::string &salt) { - char *id = NULL; - char *id_prefix = NULL; char *host; int port = 51613; char *bind_address = NULL; int keepalive = 60; - bool clean_session = true; int rc = 0; - char hostname[256]; - int len; char will_payload[100]; long will_payloadlen = 0; int will_qos = 0; @@ -189,12 +184,8 @@ int start_client(const char *boardname, const char *gwid, const char *gwip, cons ud.resp_topic = res_topic; sprintf(will_payload, "{\"cmd\":\"15\",\"gwID\":\"%s\"}", mqttsdata.gwid); will_payloadlen = strlen(will_payload); - zlog_info(zct, "will_payload:%s,will_payloadlen:%ld", will_payload, will_payloadlen); - - hostname[0] = '\0'; - gethostname(hostname, 256); - hostname[255] = '\0'; - len = strlen("mosqsub/-") + 6 + strlen(hostname); + zlog_info(zct, "will_payload:%s,will_payloadlen:%ld", will_payload, will_payloadlen); + mosquitto_lib_init(); mosq = mosquitto_new(NULL, true, &ud); if (!mosq) { diff --git a/threadfunc/thread_func.cpp b/threadfunc/thread_func.cpp index 001de67..33eca14 100644 --- a/threadfunc/thread_func.cpp +++ b/threadfunc/thread_func.cpp @@ -417,9 +417,6 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos) { int i; - struct userdata *ud; - assert(obj); - ud = (struct userdata *)obj; zlog_info(zct, "Subscribed (mid: %d): %d", mid, granted_qos[0]); for (i = 1; i < qos_count; i++) { zlog_info(zct, ", %d", granted_qos[i]); diff --git a/utility/udp_scan.cpp b/utility/udp_scan.cpp index db507fc..dfd7a8f 100644 --- a/utility/udp_scan.cpp +++ b/utility/udp_scan.cpp @@ -52,7 +52,7 @@ void UdpSys::recvUdpData() { udpSock.async_receive_from(boost::asio::buffer(m_bu void UdpSys::HandleRead(const boost::system::error_code& pEc, std::size_t pBytesTransferred) { std::string ip = senderEndPoint.address().to_string(); if (pEc) { - zlog_error(zct, "pEc value:%d, category name:%s, message:%s", pEc.value(), pEc.category().name(), pEc.message()); + zlog_error(zct, "pEc value:%d, category name:%s, message:%s", pEc.value(), pEc.category().name(), pEc.message().c_str()); } else if (pBytesTransferred == 0) { zlog_info(zct, "rev has rec!"); if (pBytesTransferred == 0) {