From db9351850681352c70766bc780ef01d7c240f547 Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Fri, 29 Sep 2023 16:16:52 +0200 Subject: [PATCH] http order fix, time var fix --- src/app.cpp | 4 ++-- src/plugins/zeroExport/zeroExport.h | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index 4ecfe57e..e81bc7e5 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -622,8 +622,8 @@ void app::zeroexport() { serializeJsonPretty(object, data); DPRINTLN(DBG_INFO, data); mApi.ctrlRequest(object); - } - mConfig->plugin.zexport.lastTime = millis(); // set last timestamp + mConfig->plugin.zexport.lastTime = millis(); // set last timestamp + } } #endif \ No newline at end of file diff --git a/src/plugins/zeroExport/zeroExport.h b/src/plugins/zeroExport/zeroExport.h index 3e9bdf50..4974b5ba 100644 --- a/src/plugins/zeroExport/zeroExport.h +++ b/src/plugins/zeroExport/zeroExport.h @@ -50,12 +50,6 @@ class ZeroExport { // TODO: Need to improve here. 2048 for a JSON Obj is to big!? bool zero() { - if (!httpClient.begin(mCfg->monitor_url)) { - DPRINTLN(DBG_INFO, "httpClient.begin failed"); - httpClient.end(); - return false; - } - httpClient.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); httpClient.setUserAgent("Ahoy-Agent"); httpClient.setConnectTimeout(1000); @@ -63,6 +57,12 @@ class ZeroExport { httpClient.addHeader("Content-Type", "application/json"); httpClient.addHeader("Accept", "application/json"); + if (!httpClient.begin(mCfg->monitor_url)) { + DPRINTLN(DBG_INFO, "httpClient.begin failed"); + httpClient.end(); + return false; + } + int httpCode = httpClient.GET(); if (httpCode == HTTP_CODE_OK) { @@ -95,6 +95,7 @@ class ZeroExport { DPRINTLN(DBG_INFO, F("ZeroExport(): Error ") + String(httpCode)); return false; } + httpClient.end(); return true; }