Skip to content

Commit bbacd33

Browse files
committed
Removed support for querying
1 parent fe50ce0 commit bbacd33

File tree

6 files changed

+130
-364
lines changed

6 files changed

+130
-364
lines changed

examples/Query/Query.ino

Lines changed: 0 additions & 232 deletions
This file was deleted.

src/InfluxDbClient.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,11 @@ void InfluxDBClient::clean() {
242242
void InfluxDBClient::setUrls() {
243243
if(_dbVersion == 2) {
244244
_writeUrl = _serverUrl + "/api/v2/write?org=" + _org + "&bucket=" + _bucket;
245-
_queryUrl = _serverUrl + "/api/v2/query?org=" + _org;
246245
} else {
247246
_writeUrl = _serverUrl + "/write?db=" + _bucket;
248-
_queryUrl = _serverUrl + "/api/v2/query?db=" + _bucket;
249247
if(_user.length() > 0 && _password.length() > 0) {
250248
String auth = "&u=" + _user + "&p=" + _password;
251249
_writeUrl += auth;
252-
_queryUrl += auth;
253250
}
254251
}
255252
if(_writePrecision != WritePrecision::NoTime) {
@@ -512,42 +509,6 @@ int InfluxDBClient::postData(const char *data) {
512509
return _lastStatusCode;
513510
}
514511

515-
String InfluxDBClient::query(String &fluxQuery) {
516-
if(_lastRetryAfter > 0 && (millis()-_lastRequestTime)/1000 < _lastRetryAfter) {
517-
// retry after period didn't run out yet
518-
return "";
519-
}
520-
if(!_wifiClient && !init()) {
521-
_lastStatusCode = 0;
522-
_lastErrorResponse = FPSTR(UnitialisedMessage);
523-
return "";
524-
}
525-
INFLUXDB_CLIENT_DEBUG("[D] Query to %s\n", _queryUrl.c_str());
526-
if(!_httpClient.begin(*_wifiClient, _queryUrl)) {
527-
INFLUXDB_CLIENT_DEBUG("[E] begin failed\n");
528-
return "";
529-
}
530-
_httpClient.addHeader(F("Content-Type"), F("application/vnd.flux"));
531-
532-
INFLUXDB_CLIENT_DEBUG("[D] JSON query:\n%s\n", fluxQuery.c_str());
533-
534-
preRequest();
535-
536-
_lastStatusCode = _httpClient.POST(fluxQuery);
537-
538-
postRequest(200);
539-
String queryResult;
540-
if(_lastStatusCode == 200) {
541-
queryResult = _httpClient.getString();
542-
queryResult.trim();
543-
INFLUXDB_CLIENT_DEBUG("[D] Response:\n%s\n", queryResult.c_str());
544-
}
545-
546-
_httpClient.end();
547-
548-
return queryResult;
549-
}
550-
551512
void InfluxDBClient::postRequest(int expectedStatusCode) {
552513
_lastRequestTime = millis();
553514
INFLUXDB_CLIENT_DEBUG("[D] HTTP status code - %d\n", _lastStatusCode);

src/InfluxDbClient.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ class InfluxDBClient {
164164
// Writes record represented by Point to buffer
165165
// Returns true if successful, false in case of any error
166166
bool writePoint(Point& point);
167-
// Sends Flux query and returns raw JSON formatted response
168-
// Return raw query response in the form of CSV table. Empty string can mean that query hasn't found anything or an error. Check getLastStatusCode() for 200
169-
String query(String &fluxQuery);
170167
// Writes all points in buffer, with respect to the batch size, and in case of success clears the buffer.
171168
// Returns true if successful, false in case of any error
172169
bool flushBuffer();
@@ -185,8 +182,6 @@ class InfluxDBClient {
185182
String getLastErrorMessage() const { return _lastErrorResponse; }
186183
// Returns server url
187184
String getServerUrl() const { return _serverUrl; }
188-
// Returns true if last query request has succeeded. Handy for distingushing empty result and error
189-
bool wasLastQuerySuccessful() { return _lastStatusCode == 200; }
190185
protected:
191186
// Checks params and sets up security, if needed.
192187
// Returns true in case of success, otherwise false
@@ -209,8 +204,6 @@ class InfluxDBClient {
209204
String _password;
210205
// Cached full write url
211206
String _writeUrl;
212-
// Cached full query url
213-
String _queryUrl;
214207
// Points timestamp precision.
215208
WritePrecision _writePrecision = WritePrecision::NoTime;
216209
// Number of points that will be written to the databases at once.

0 commit comments

Comments
 (0)