correct json buffer size optimizations

This commit is contained in:
Florian committed 2019-03-19 21:47:29 +01:00
1 parent bbb4dd3065
commit e6191915e3
9 files changed
+9 -15

No files matched your search

+1 -2
View File
@@ -702,8 +702,7 @@ void stateMeasures(){
unsigned long now = millis();
if (now > (timer_sys_measures + TimeBetweenReadingSYS)) {//retriving value of memory ram every TimeBetweenReadingSYS
timer_sys_measures = millis();
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(4);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& SYSdata = jsonBuffer.createObject();
trc(F("Uptime (s)"));
unsigned long uptime = millis()/1000;
+1 -2
View File
@@ -82,8 +82,7 @@ boolean _2GtoMQTT(){
// Get the memory locations of unread SMS messages.
unreadSMSNum = A6l.getUnreadSMSLocs(unreadSMSLocs, 512);
trc(F("Creating SMS buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& SMSdata = jsonBuffer.createObject();
for (int i = 0; i < unreadSMSNum; i++) {
trc(F("New message at index: "));
+1 -2
View File
@@ -94,8 +94,7 @@ void IRtoMQTT(){
if (irrecv.decode(&results)){
trc(F("Creating IR buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(4);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& IRdata = jsonBuffer.createObject();
trc(F("Rcv. IR"));
+1 -2
View File
@@ -59,8 +59,7 @@ void setupLORA() {
void LORAtoMQTT(){
int packetSize = LoRa.parsePacket();
if (packetSize) {
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(5);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& LORAdata = jsonBuffer.createObject();
trc(F("Rcv. LORA"));
#ifdef ESP32
+1 -1
View File
@@ -68,7 +68,7 @@ void RF2toMQTT(){
if(rf2rd.hasNewData){
trc(F("Creating RF2 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(4);
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(5);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject& RF2data = jsonBuffer.createObject();
+1 -2
View File
@@ -143,8 +143,7 @@ boolean RFM69toMQTT(void) {
if (radio.receiveDone())
{
trc(F("Creating RFM69 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& RFM69data = jsonBuffer.createObject();
uint8_t data[RF69_MAX_DATA_LEN+1]; // For the null character
uint8_t SENDERID = radio.SENDERID;
+1 -2
View File
@@ -103,8 +103,7 @@ void _rfbDecode() {
_rfbToChar(&_uartbuf[1], buffer);
trc(F("Creating SRFB buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(4);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& SRFBdata = jsonBuffer.createObject();
SRFBdata.set("raw", (char *)buffer);
+1 -1
View File
@@ -358,7 +358,7 @@ void createDiscovery(char * sensor_type,
int off_delay,
char * payload_available, char * payload_not_avalaible, boolean child_device , char * command_topic)
{
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(14) + JSON_OBJECT_SIZE(4);
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(14) + JSON_OBJECT_SIZE(5)+ JSON_ARRAY_SIZE(1);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject &sensor = jsonBuffer.createObject();
sensor.set("stat_t", state_topic); //state_topic
+1 -1
View File
@@ -92,7 +92,7 @@ void MeasureLightIntensityTSL2561()
timetsl2561 = millis();
trc(F("Creating TSL2561 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(4);
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject& TSL2561data = jsonBuffer.createObject();