Skip to content

Commit 9bc5739

Browse files
committed
fix: debug compilation (#70)
1 parent 66ed5d0 commit 9bc5739

File tree

7 files changed

+41
-44
lines changed

7 files changed

+41
-44
lines changed

src/InfluxDbClient.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
* SOFTWARE.
2626
*/
27-
#include <core_version.h>
2827
#include "InfluxDbClient.h"
28+
#include <core_version.h>
2929

3030
#define STRHELPER(x) #x
3131
#define STR(x) STRHELPER(x) // stringifier
@@ -41,8 +41,7 @@
4141
static const char UserAgent[] PROGMEM = "influxdb-client-arduino/" INFLUXDB_CLIENT_VERSION " (" INFLUXDB_CLIENT_PLATFORM " " INFLUXDB_CLIENT_PLATFORM_VERSION ")";
4242

4343
// Uncomment bellow in case of a problem and rebuild sketch
44-
//#define INFLUXDB_CLIENT_DEBUG
45-
44+
//#define INFLUXDB_CLIENT_DEBUG_ENABLE
4645
#include "util/debug.h"
4746

4847
static const char UnitialisedMessage[] PROGMEM = "Unconfigured instance";
@@ -196,12 +195,12 @@ void InfluxDBClient::setConnectionParamsV1(const char *serverUrl, const char *db
196195
}
197196

198197
bool InfluxDBClient::init() {
199-
INFLUXDB_CLIENT_DEBUG(F("Init\n"));
200-
INFLUXDB_CLIENT_DEBUG(F(" Server url: %s\n"), _serverUrl.c_str());
201-
INFLUXDB_CLIENT_DEBUG(F(" Org: %s\n"), _org.c_str());
202-
INFLUXDB_CLIENT_DEBUG(F(" Bucket: %s\n"), _bucket.c_str());
203-
INFLUXDB_CLIENT_DEBUG(F(" Token: %s\n"), _authToken.c_str());
204-
INFLUXDB_CLIENT_DEBUG(F(" DB version: %d\n"), _dbVersion);
198+
INFLUXDB_CLIENT_DEBUG("Init\n");
199+
INFLUXDB_CLIENT_DEBUG(" Server url: %s\n", _serverUrl.c_str());
200+
INFLUXDB_CLIENT_DEBUG(" Org: %s\n", _org.c_str());
201+
INFLUXDB_CLIENT_DEBUG(" Bucket: %s\n", _bucket.c_str());
202+
INFLUXDB_CLIENT_DEBUG(" Token: %s\n", _authToken.c_str());
203+
INFLUXDB_CLIENT_DEBUG(" DB version: %d\n", _dbVersion);
205204
if(_serverUrl.length() == 0 || (_dbVersion == 2 && (_org.length() == 0 || _bucket.length() == 0 || _authToken.length() == 0))) {
206205
INFLUXDB_CLIENT_DEBUG("[E] Invalid parameters\n");
207206
return false;
@@ -222,8 +221,9 @@ bool InfluxDBClient::init() {
222221
wifiClientSec->setFingerprint(_certInfo);
223222
}
224223
}
225-
if (_insecure)
224+
if (_insecure) {
226225
wifiClientSec->setInsecure();
226+
}
227227
#elif defined(ESP32)
228228
WiFiClientSecure *wifiClientSec = new WiFiClientSecure;
229229
if(_certInfo && strlen_P(_certInfo) > 0) {
@@ -271,18 +271,18 @@ void InfluxDBClient::clean() {
271271
}
272272

273273
void InfluxDBClient::setUrls() {
274-
INFLUXDB_CLIENT_DEBUG(F("setUrls\n"));
274+
INFLUXDB_CLIENT_DEBUG("setUrls\n");
275275
if(_dbVersion == 2) {
276276
_writeUrl = _serverUrl;
277277
_writeUrl += "/api/v2/write?org=";
278278
_writeUrl += _org ;
279279
_writeUrl += "&bucket=";
280280
_writeUrl += _bucket;
281-
INFLUXDB_CLIENT_DEBUG(F(" writeUrl: %s\n"), _writeUrl.c_str());
281+
INFLUXDB_CLIENT_DEBUG(" writeUrl: %s\n", _writeUrl.c_str());
282282
_queryUrl = _serverUrl;
283283
_queryUrl += "/api/v2/query?org=";
284284
_queryUrl += _org;
285-
INFLUXDB_CLIENT_DEBUG(F(" queryUrl: %s\n"), _queryUrl.c_str());
285+
INFLUXDB_CLIENT_DEBUG(" queryUrl: %s\n", _queryUrl.c_str());
286286
} else {
287287
_writeUrl = _serverUrl;
288288
_writeUrl += "/write?db=";
@@ -297,13 +297,13 @@ void InfluxDBClient::setUrls() {
297297
_writeUrl += auth;
298298
_queryUrl += auth;
299299
}
300-
INFLUXDB_CLIENT_DEBUG(F(" writeUrl: %s\n"), _writeUrl.c_str());
301-
INFLUXDB_CLIENT_DEBUG(F(" queryUrl: %s\n"), _queryUrl.c_str());
300+
INFLUXDB_CLIENT_DEBUG(" writeUrl: %s\n", _writeUrl.c_str());
301+
INFLUXDB_CLIENT_DEBUG(" queryUrl: %s\n", _queryUrl.c_str());
302302
}
303303
if(_writePrecision != WritePrecision::NoTime) {
304304
_writeUrl += "&precision=";
305305
_writeUrl += precisionToString(_writePrecision, _dbVersion);
306-
INFLUXDB_CLIENT_DEBUG(F(" writeUrl: %s\n"), _writeUrl.c_str());
306+
INFLUXDB_CLIENT_DEBUG(" writeUrl: %s\n", _writeUrl.c_str());
307307
}
308308

309309
}

src/InfluxDbClient.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
#define INFLUXDB_CLIENT_VERSION "3.2.0"
3131

3232
#include <Arduino.h>
33-
#include "query/FluxParser.h"
34-
#include "util/helpers.h"
35-
3633
#if defined(ESP8266)
3734
# include <WiFiClientSecureBearSSL.h>
3835
# include <ESP8266HTTPClient.h>
@@ -42,6 +39,10 @@
4239
# error "This library currently supports only ESP8266 and ESP32."
4340
#endif
4441

42+
#include "query/FluxParser.h"
43+
#include "util/helpers.h"
44+
45+
4546
#ifdef USING_AXTLS
4647
#error AxTLS does not work
4748
#endif

src/query/CsvReader.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
* SOFTWARE.
2626
*/
2727
#include "CsvReader.h"
28-
// Uncomment bellow in case of a problem and rebuild sketch
29-
#define INFLUXDB_CLIENT_DEBUG
30-
#include "util/debug.h"
3128

3229
CsvReader::CsvReader(HttpStreamScanner *scanner) {
3330
_scanner = scanner;
@@ -108,4 +105,4 @@ bool CsvReader::next() {
108105
}
109106
_row = fields;
110107
return true;
111-
}
108+
}

src/query/FluxParser.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "FluxParser.h"
2929
// Uncomment bellow in case of a problem and rebuild sketch
30-
//#define INFLUXDB_CLIENT_DEBUG
30+
//#define INFLUXDB_CLIENT_DEBUG_ENABLE
3131
#include "util/debug.h"
3232

3333
FluxQueryResult::FluxQueryResult(CsvReader *reader) {
@@ -123,12 +123,12 @@ bool FluxQueryResult::next() {
123123
if(!stat) {
124124
if(_data->_reader->getError()< 0) {
125125
_data->_error = HTTPClient::errorToString(_data->_reader->getError());
126-
INFLUXDB_CLIENT_DEBUG(F("Error '%s'\n"), _data->_error.c_str());
126+
INFLUXDB_CLIENT_DEBUG("Error '%s'\n", _data->_error.c_str());
127127
}
128128
return false;
129129
}
130130
std::vector<String> vals = _data->_reader->getRow();
131-
INFLUXDB_CLIENT_DEBUG(F("[D] FluxQueryResult: vals.size %d\n"), vals.size());
131+
INFLUXDB_CLIENT_DEBUG("[D] FluxQueryResult: vals.size %d\n", vals.size());
132132
if(vals.size() < 2) {
133133
goto readRow;
134134
}
@@ -145,15 +145,15 @@ bool FluxQueryResult::next() {
145145
reference = "," + vals[2];
146146
}
147147
_data->_error = message + reference;
148-
INFLUXDB_CLIENT_DEBUG(F("Error '%s'\n"), _data->_error.c_str());
148+
INFLUXDB_CLIENT_DEBUG("Error '%s'\n", _data->_error.c_str());
149149
return false;
150150
} else if (parsingState == ParsingStateNameRow) {
151151
if (vals[1] == "error") {
152152
parsingState = ParsingStateError;
153153
} else {
154154
if (vals.size()-1 != _data->_columnDatatypes.size()) {
155155
_data->_error = String(F("Parsing error, header has different number of columns than table: ")) + String(vals.size()-1) + " vs " + String(_data->_columnDatatypes.size());
156-
INFLUXDB_CLIENT_DEBUG(F("Error '%s'\n"), _data->_error.c_str());
156+
INFLUXDB_CLIENT_DEBUG("Error '%s'\n", _data->_error.c_str());
157157
return false;
158158
} else {
159159
for(int i=1;i < vals.size(); i++) {
@@ -166,12 +166,12 @@ bool FluxQueryResult::next() {
166166
}
167167
if(_data->_columnDatatypes.size() == 0) {
168168
_data->_error = F("Parsing error, datatype annotation not found");
169-
INFLUXDB_CLIENT_DEBUG(F("Error '%s'\n"), _data->_error.c_str());
169+
INFLUXDB_CLIENT_DEBUG("Error '%s'\n", _data->_error.c_str());
170170
return false;
171171
}
172172
if (vals.size()-1 != _data->_columnNames.size()) {
173173
_data->_error = String(F("Parsing error, row has different number of columns than table: ")) + String(vals.size()-1) + " vs " + String(_data->_columnNames.size());
174-
INFLUXDB_CLIENT_DEBUG(F("Error '%s'\n"), _data->_error.c_str());
174+
INFLUXDB_CLIENT_DEBUG("Error '%s'\n", _data->_error.c_str());
175175
return false;
176176
}
177177
for(int i=1;i < vals.size(); i++) {
@@ -180,7 +180,7 @@ bool FluxQueryResult::next() {
180180
v = convertValue(vals[i], _data->_columnDatatypes[i-1]);
181181
if(!v) {
182182
_data->_error = String(F("Unsupported datatype: ")) + _data->_columnDatatypes[i-1];
183-
INFLUXDB_CLIENT_DEBUG(F("Error '%s'\n"), _data->_error.c_str());
183+
INFLUXDB_CLIENT_DEBUG("Error '%s'\n", _data->_error.c_str());
184184
return false;
185185
}
186186
}

src/query/HttpStreamScanner.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "HttpStreamScanner.h"
2828

2929
// Uncomment bellow in case of a problem and rebuild sketch
30-
//#define INFLUXDB_CLIENT_DEBUG
30+
//#define INFLUXDB_CLIENT_DEBUG_ENABLE
3131
#include "util/debug.h"
3232

3333
HttpStreamScanner::HttpStreamScanner(HTTPClient *client, bool chunked)
@@ -37,13 +37,13 @@ HttpStreamScanner::HttpStreamScanner(HTTPClient *client, bool chunked)
3737
_chunked = chunked;
3838
_chunkHeader = chunked;
3939
_len = client->getSize();
40-
INFLUXDB_CLIENT_DEBUG(F("[D] HttpStreamScanner: chunked: %s, size: %d\n"), _chunked?"true":"false", _len);
40+
INFLUXDB_CLIENT_DEBUG("[D] HttpStreamScanner: chunked: %s, size: %d\n", _chunked?"true":"false", _len);
4141
}
4242

4343
bool HttpStreamScanner::next() {
4444
while(_client->connected() && (_len > 0 || _len == -1)) {
4545
_line = _stream->readStringUntil('\n');
46-
INFLUXDB_CLIENT_DEBUG(F("[D] HttpStreamScanner: line: %s\n"), _line.c_str());
46+
INFLUXDB_CLIENT_DEBUG("[D] HttpStreamScanner: line: %s\n", _line.c_str());
4747
++_linesNum;
4848
int lineLen = _line.length();
4949
if(lineLen == 0) {
@@ -68,7 +68,7 @@ bool HttpStreamScanner::next() {
6868
}
6969
if(_chunkHeader){
7070
_chunkLen = (int) strtol((const char *) _line.c_str(), NULL, 16);
71-
INFLUXDB_CLIENT_DEBUG(F("[D] HttpStreamScanner chunk len: %d\n"), _chunkLen);
71+
INFLUXDB_CLIENT_DEBUG("[D] HttpStreamScanner chunk len: %d\n", _chunkLen);
7272
_chunkHeader = false;
7373
_read = 0;
7474
if(_chunkLen == 0) { //last chunk
@@ -86,13 +86,13 @@ bool HttpStreamScanner::next() {
8686

8787
if(_len > 0) {
8888
_len -= r;
89-
INFLUXDB_CLIENT_DEBUG(F("[D] HttpStreamScanner new len: %d\n"), _len);
89+
INFLUXDB_CLIENT_DEBUG("[D] HttpStreamScanner new len: %d\n", _len);
9090
}
9191
return true;
9292
}
9393
if(!_client->connected() && ( (_chunked && _chunkLen > 0) || (!_chunked && _len > 0))) { //report error only if we didn't went to
9494
_error = HTTPC_ERROR_CONNECTION_LOST;
95-
INFLUXDB_CLIENT_DEBUG(F("HttpStreamScanner connection lost\n"));
95+
INFLUXDB_CLIENT_DEBUG("HttpStreamScanner connection lost\n");
9696
}
9797
return false;
9898
}

src/util/debug.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
#ifndef _INFLUXDB_CLIENT_DEBUG_H
2828
#define _INFLUXDB_CLIENT_DEBUG_H
2929

30-
// captilised the A of Arduino - kdriver
3130
#include <Arduino.h>
3231

33-
#ifdef INFLUXDB_CLIENT_DEBUG
32+
#ifdef INFLUXDB_CLIENT_DEBUG_ENABLE
3433
# define INFLUXDB_CLIENT_DEBUG(fmt, ...) Serial.printf_P( (PGM_P)PSTR(fmt), ## __VA_ARGS__ )
3534
#else
3635
# define INFLUXDB_CLIENT_DEBUG(fmt, ...)

test/test.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ void loop() {
6868
testUserAgent();
6969
testFailedWrites();
7070
testTimestamp();
71-
// testRetryOnFailedConnection();
72-
// testBufferOverwriteBatchsize1();
73-
// testBufferOverwriteBatchsize5();
74-
// testServerTempDownBatchsize5();
75-
// testRetriesOnServerOverload();
71+
testRetryOnFailedConnection();
72+
testBufferOverwriteBatchsize1();
73+
testBufferOverwriteBatchsize5();
74+
testServerTempDownBatchsize5();
75+
testRetriesOnServerOverload();
7676

7777
Serial.printf("Test %s\n", failures ? "FAILED" : "SUCCEEDED");
7878
while(1) delay(1000);

0 commit comments

Comments
 (0)