diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a5a972..888a4e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/InfluxDbClient.cpp b/src/InfluxDbClient.cpp index 8a3353d..7736b66 100644 --- a/src/InfluxDbClient.cpp +++ b/src/InfluxDbClient.cpp @@ -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()); @@ -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;iavailable() == 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(); } @@ -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; @@ -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";