Skip to content

Commit 352812c

Browse files
authored
Merge pull request #185 from tobiasschuerg/feat/is_connected
feat: adding isConnected to test connection persistence state
2 parents e52504d + 8b514ce commit 352812c

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
## Unreleased
3+
### Features
4+
- [185](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/185) - Added diagnostic connection state getter `bool InfluxDBClient::isConnected()`
5+
26
## 3.11.0 [2022-02-18]
37
### Features
48
- [174](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/174),[181](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/181) - All API methods with a string param allow specifying string by all basic types:

src/HTTPService.h

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ friend class Test;
129129
uint32_t getLastRequestTime() const { return _lastRequestTime; }
130130
// Returns response of last failed call.
131131
String getLastErrorMessage() const { return _pConnInfo->lastError; }
132+
// Returns true if HTTP connection is kept open
133+
bool isConnected() const { return _httpClient && _httpClient->connected(); }
132134
};
133135

134136
#endif //_HTTP_SERVICE_H_

src/InfluxDbClient.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ class InfluxDBClient {
164164
// Enables/disables streaming write. This allows sending large batches without allocating buffer.
165165
// It is about 50% slower than writing by allocated buffer (default);
166166
void setStreamWrite(bool enable = true);
167-
//
167+
// Returns true if HTTP connection is kept open (connection reuse must be set to true)
168+
bool isConnected() const { return _service && _service->isConnected(); }
168169
protected:
169170
// Checks params and sets up security, if needed.
170171
// Returns true in case of success, otherwise false

0 commit comments

Comments
 (0)