Publish refactoring (#298)
* factoring of the publishing function * integration of json publishing to MQTT * receiving and transcode json messages from mqtt * replace the TRACE runtime condition by a buildtime one so as to decrease program size * remove retainFlag parameter not necessary for the moment * Increase the scope of tests for arduino mega and esp32 * Update arduinojson library to 5.13.3 * add macros to choose between simple or json publishing or both * differentiate build test for ATmega2560 * correct wrong sprintf definition * change IDE version for continuous integration * let default warning level in arduino ide * correct pins for ESP32 * reorganize user_config
This commit is contained in:
1 parent
f77df7347f
commit
d8dba15a81
182 files changed
+2701
-20768
No files matched your search
+6
-6
@@ -48,20 +48,20 @@ void MeasureTempAndHum(){
|
||||
if (isnan(h) || isnan(t)) {
|
||||
trc(F("Failed to read from DHT sensor!"));
|
||||
}else{
|
||||
trc(F("Creating DHT buffer"));
|
||||
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject& DHTdata = jsonBuffer.createObject();
|
||||
if(h != persistedh || dht_always){
|
||||
trc(F("Sending Hum to MQTT"));
|
||||
trc(h);
|
||||
client.publish(HUM1,String(h).c_str());
|
||||
DHTdata.set("hum", (float)h);
|
||||
}else{
|
||||
trc(F("Same hum don't send it"));
|
||||
}
|
||||
if(t != persistedt || dht_always){
|
||||
trc(F("Sending Temp to MQTT"));
|
||||
trc(t);
|
||||
client.publish(TEMP1, String(t).c_str());
|
||||
DHTdata.set("temp", (float)t);
|
||||
}else{
|
||||
trc(F("Same temp don't send it"));
|
||||
}
|
||||
if(DHTdata.size()>0) pub(DHTTOPIC,DHTdata);
|
||||
}
|
||||
persistedh = h;
|
||||
persistedt = t;
|
||||
|
||||
Reference in new issue
Block a user