Skip to content

Commit 90bcb58

Browse files
authored
Merge pull request #108 from bonitoo-io/fix/double_precision
fix: allowing custom decimal places also for double
2 parents 4fda495 + 58d5622 commit 90bcb58

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
### Documentation
77

88
### Fixes
9+
- [#108](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/108) - Added optional param for specifying decimal places of double.: `void Point::addField(String name, double value, int decimalPlaces = 2)`
910

1011
## 3.4.0 [2020-10-02]
1112
### Features

src/Point.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Point {
4141
void addTag(String name, String value);
4242
// Add field with various types
4343
void addField(String name, float value, int decimalPlaces = 2) { if(!isnan(value)) putField(name, String(value, decimalPlaces)); }
44-
void addField(String name, double value) { if(!isnan(value)) putField(name, String(value)); }
44+
void addField(String name, double value, int decimalPlaces = 2) { if(!isnan(value)) putField(name, String(value, decimalPlaces)); }
4545
void addField(String name, char value) { addField(name, String(value).c_str()); }
4646
void addField(String name, unsigned char value) { putField(name, String(value)+"i"); }
4747
void addField(String name, int value) { putField(name, String(value)+"i"); }

test/server/server.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var lastUserAgent = '';
99
var chunked = false;
1010
var delay = 0;
1111
var permanentError = 0;
12+
const prefix = '';
1213

1314
app.use (function(req, res, next) {
1415
var data='';
@@ -22,32 +23,32 @@ app.use (function(req, res, next) {
2223
next();
2324
});
2425
});
25-
app.get('/test/user-agent', (req,res) => {
26+
app.get(prefix + '/test/user-agent', (req,res) => {
2627
res.status(200).send(lastUserAgent);
2728
})
28-
app.get('/ready', (req,res) => {
29+
app.get(prefix + '/ready', (req,res) => {
2930
lastUserAgent = req.get('User-Agent');
3031
res.status(200).send("<html><body><h1>OK</h1></body></html>");
3132
})
32-
app.get('/health', (req,res) => {
33+
app.get(prefix + '/health', (req,res) => {
3334
lastUserAgent = req.get('User-Agent');
3435
res.status(200).send("<html><body><h1>OK</h1></body></html>");
3536
})
3637

37-
app.get('/ping', (req,res) => {
38+
app.get(prefix + '/ping', (req,res) => {
3839
lastUserAgent = req.get('User-Agent');
3940
if(req.query['verbose'] == 'true') {
4041
res.status(200).send("<html><body><h1>OK</h1></body></html>");
4142
} else {
4243
res.status(204).end();
4344
}
4445
})
45-
app.post('/log', (req,res) => {
46+
app.post(prefix + '/log', (req,res) => {
4647
console.log(req.body);
4748
res.status(204).end();
4849
})
4950

50-
app.post('/api/v2/write', (req,res) => {
51+
app.post(prefix + '/api/v2/write', (req,res) => {
5152
chunked = false;
5253
if(checkWriteParams(req, res) && handleAuthentication(req, res)) {
5354
//console.log('Write');
@@ -132,7 +133,7 @@ app.post('/api/v2/write', (req,res) => {
132133
}
133134
})
134135

135-
app.post('/write', (req,res) => {
136+
app.post(prefix + '/write', (req,res) => {
136137
if(checkWriteParamsV1(req, res) ) {
137138
var points = parsePoints(req.body);
138139
if(Array.isArray(points) && points.length > 0) {
@@ -170,7 +171,7 @@ app.post('/write', (req,res) => {
170171
}
171172
})
172173

173-
app.post('/api/v2/delete', (req,res) => {
174+
app.post(prefix + '/api/v2/delete', (req,res) => {
174175
console.log('Deleteting points');
175176
pointsdb = [];
176177
res.status(204).end();
@@ -259,7 +260,7 @@ function sleep(milliseconds) {
259260
} while (currentDate - date < milliseconds);
260261
}
261262

262-
app.post('/api/v2/query', (req,res) => {
263+
app.post(prefix+'/api/v2/query', (req,res) => {
263264
//console.log("Query with: " + req.body);
264265
if(checkQueryParams(req, res) && handleAuthentication(req, res)) {
265266
var queryObj = JSON.parse(req.body);

test/test.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
#define INFLUXDB_CLIENT_TESTING
88
#include <InfluxDbClient.h>
99
#include <InfluxDbCloud.h>
10+
1011
#if defined(ESP32)
12+
#include <WiFi.h>
1113
String chipId = String((unsigned long)ESP.getEfuseMac());
1214
String deviceName = "ESP32";
1315
#elif defined(ESP8266)
16+
#include <ESP8266WiFi.h>
1417
String chipId = String(ESP.getChipId());
1518
String deviceName = "ESP8266";
1619
#endif

0 commit comments

Comments
 (0)