Some memory optimization for Arduino UNO following this thread:

https://community.openmqttgateway.com/t/arduino-uno-ethernet-shield-reboots-on-receiving-rf-signal-on-v-0-9/346/22
Rework led management to avoid use of global variables
and specify special JSON_MSG_BUFFER for arduino UNO
led can now be used for all the boards

generalize use of F macro
for memory optimization
change jsonbuffer calculation method
reduce pubsubclient max packet size for uno and nano
This commit is contained in:
Florian committed 2019-03-09 17:28:54 +01:00
1 parent a34d476f04
commit da859cc6ae
22 files changed
+166 -131

No files matched your search

+4 -2
View File
@@ -358,7 +358,8 @@ void createDiscovery(char * sensor_type,
bool optimistic, bool retain, int off_delay,
char * payload_available, char * payload_not_avalaible, boolean child_device , char * command_topic)
{
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(14) + JSON_OBJECT_SIZE(4);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject &sensor = jsonBuffer.createObject();
sensor.set("stat_t", state_topic); //state_topic
sensor.set("name", s_name); //name
@@ -385,7 +386,8 @@ void createDiscovery(char * sensor_type,
if (child_device){
StaticJsonBuffer<JSON_MSG_BUFFER> jsonDeviceBuffer;
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(4) + JSON_ARRAY_SIZE(1);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonDeviceBuffer;
JsonObject &device = jsonDeviceBuffer.createObject();
device.set("name", Gateway_Name);
device.set("manufacturer", DEVICEMANUFACTURER);