replace the use of calculate buffer by a constant buffer size for json size

This commit is contained in:
Florian committed 2019-06-29 14:46:24 +02:00
1 parent 618f8d6087
commit 2ee18320be
5 files changed
+5 -10

No files matched your search

+1 -2
View File
@@ -55,8 +55,7 @@ void MeasureLightIntensity()
{ {
if (millis() > (timebh1750 + TimeBetweenReadingBH1750)) {//retriving value of Lux, FtCd and Wattsm2 from BH1750 if (millis() > (timebh1750 + TimeBetweenReadingBH1750)) {//retriving value of Lux, FtCd and Wattsm2 from BH1750
trc(F("Creating BH1750 buffer")); trc(F("Creating BH1750 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3); StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject& BH1750data = jsonBuffer.createObject(); JsonObject& BH1750data = jsonBuffer.createObject();
timebh1750 = millis(); timebh1750 = millis();
+1 -2
View File
@@ -129,8 +129,7 @@ void MeasureTempHumAndPressure()
trc(F("Failed to read from Weather Sensor BME280!")); trc(F("Failed to read from Weather Sensor BME280!"));
}else{ }else{
trc(F("Creating BME280 buffer")); trc(F("Creating BME280 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(6); StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject& BME280data = jsonBuffer.createObject(); JsonObject& BME280data = jsonBuffer.createObject();
// Generate Temperature in degrees C // Generate Temperature in degrees C
if(BmeTempC != persisted_bme_tempc || bme280_always){ if(BmeTempC != persisted_bme_tempc || bme280_always){
+1 -2
View File
@@ -49,8 +49,7 @@ void MeasureTempAndHum(){
trc(F("Failed to read from DHT sensor!")); trc(F("Failed to read from DHT sensor!"));
}else{ }else{
trc(F("Creating DHT buffer")); trc(F("Creating DHT buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(2); StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject& DHTdata = jsonBuffer.createObject(); JsonObject& DHTdata = jsonBuffer.createObject();
if(h != persistedh || dht_always){ if(h != persistedh || dht_always){
DHTdata.set("hum", (float)h); DHTdata.set("hum", (float)h);
+1 -2
View File
@@ -52,8 +52,7 @@ void MeasureINA226(){
if (millis() > (timeINA226 + TimeBetweenReadingINA226)) {//retriving value of temperature and humidity of the box from DHT every xUL if (millis() > (timeINA226 + TimeBetweenReadingINA226)) {//retriving value of temperature and humidity of the box from DHT every xUL
timeINA226 = millis(); timeINA226 = millis();
trc(F("Creating INA226 buffer")); trc(F("Creating INA226 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3); StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject& INA226data = jsonBuffer.createObject(); JsonObject& INA226data = jsonBuffer.createObject();
// Topic on which we will send data // Topic on which we will send data
trc(F("Retrieving electrical data")); trc(F("Retrieving electrical data"));
+1 -2
View File
@@ -92,8 +92,7 @@ void MeasureLightIntensityTSL2561()
timetsl2561 = millis(); timetsl2561 = millis();
trc(F("Creating TSL2561 buffer")); trc(F("Creating TSL2561 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3); StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject& TSL2561data = jsonBuffer.createObject(); JsonObject& TSL2561data = jsonBuffer.createObject();
sensors_event_t event; sensors_event_t event;