Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
## unreleased
### Fixes
- [200](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/200) - Backward compatible compilation. Solves _marked 'override', but does not override_ errors.

## 3.12.2 [2022-09-30]
### Fixes
- [198](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/198) - Effective passing Point by value
Expand Down
20 changes: 14 additions & 6 deletions src/InfluxDbClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ int InfluxDBClient::postData(Batch *batch) {

BatchStreamer *bs = new BatchStreamer(batch);
INFLUXDB_CLIENT_DEBUG("[D] Writing to %s\n", _writeUrl.c_str());
INFLUXDB_CLIENT_DEBUG("[D] Sending:\n");
INFLUXDB_CLIENT_DEBUG("[D] Sending %d:\n", bs->available());

if(!_service->doPOST(_writeUrl.c_str(), bs, PSTR("text/plain"), 204, nullptr)) {
INFLUXDB_CLIENT_DEBUG("[D] error %d: %s\n", _service->getLastStatusCode(), _service->getLastErrorMessage().c_str());
Expand Down Expand Up @@ -724,15 +724,23 @@ int InfluxDBClient::BatchStreamer::availableForWrite() {
return 0;
}

#if defined(ESP8266)
void InfluxDBClient::BatchStreamer::reset() {
_read = 0;
_pointer = 0;
_linePointer = 0;
}

int InfluxDBClient::BatchStreamer::read(uint8_t* buffer, size_t len) {
INFLUXDB_CLIENT_DEBUG("BatchStream::read %d\n", len);
INFLUXDB_CLIENT_DEBUG("BatchStream::read\n");
return readBytes((char *)buffer, len);
}
#endif
size_t InfluxDBClient::BatchStreamer::readBytes(char* buffer, size_t len) {

INFLUXDB_CLIENT_DEBUG("BatchStream::readBytes %d\n", len);
size_t InfluxDBClient::BatchStreamer::readBytes(char* buffer, size_t len) {
#if defined(ESP8266)
INFLUXDB_CLIENT_DEBUG("BatchStream::readBytes %d, free_heap %d, max_alloc_heap %d, heap_fragmentation %d\n", len, ESP.getFreeHeap(), ESP.getMaxFreeBlockSize(), ESP.getHeapFragmentation());
#elif defined(ESP32)
INFLUXDB_CLIENT_DEBUG("BatchStream::readBytes %d, free_heap %d, max_alloc_heap %d\n", len, ESP.getFreeHeap(), ESP.getMaxAllocHeap());
#endif
unsigned int r=0;
for(unsigned int i=0;i<len;i++) {
if(available()) {
Expand Down
10 changes: 5 additions & 5 deletions src/InfluxDbClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,17 @@ class InfluxDBClient {
public:
BatchStreamer(Batch *batch) ;
virtual ~BatchStreamer() {};
// Clears pointers to start reading from beginning
void reset();

// Stream overrides
virtual int available() override;

virtual int availableForWrite() override;
virtual int availableForWrite();

virtual int read() override;
#if defined(ESP8266)
virtual int read(uint8_t* buffer, size_t len) override;
#endif
virtual size_t readBytes(char* buffer, size_t len) override;
virtual int read(uint8_t* buffer, size_t len);
virtual size_t readBytes(char* buffer, size_t len);

virtual void flush() override {};
virtual int peek() override;
Expand Down
18 changes: 15 additions & 3 deletions test/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ void Test::run() {
testFluxTypes();
testFluxTypesSerialization();
testTimestampAdjustment();

testFluxParserEmpty();
testFluxParserSingleTable();
testFluxParserNilValue();
Expand All @@ -74,7 +73,6 @@ void Test::run() {
testLargeBatch();
testFailedWrites();
testTimestamp();

testRetryOnFailedConnection();
testRetryOnFailedConnectionWithFlush();
testNonRetry();
Expand Down Expand Up @@ -430,6 +428,18 @@ void Test::testBatch() {
TEST_ASSERT(buff[i++] == line[j]);
}
TEST_ASSERT(buff[i++] == '\n');
buff[0] = 0;
str.reset();
//Test Stream API
Stream *s = &str;
TEST_ASSERT(s->available() == len*2+2);
TEST_ASSERT(s->readBytes(buff, len+1) == len+1);
TEST_ASSERT(s->available() == len+1);
TEST_ASSERT(s->readBytes(buff+len+1, len) == len);
TEST_ASSERT(s->available() == 1);
TEST_ASSERT(s->readBytes(buff+2*len+1, 1) == 1);
TEST_ASSERT(s->available() == 0);

delete [] buff;
TEST_END();
}
Expand Down Expand Up @@ -2459,7 +2469,8 @@ void Test::testLargeBatch() {
#if defined(ESP8266)
int batchSize = 330;
#elif defined(ESP32)
int batchSize = 2047;
// 2.0.4. introduces a memory hog which causes original 2048 lines cannot be sent
int batchSize = 1950;
#endif
int len =strlen(line);
int points = free/len;
Expand All @@ -2477,6 +2488,7 @@ void Test::testLargeBatch() {
WS_DEBUG_RAM("Full batch");
}
TEST_ASSERTM(client.writeRecord(line),client.getLastErrorMessage());
yield();
}
WS_DEBUG_RAM("Data sent");
String query = "select";
Expand Down