[RF] handle 64 bits values (except for UNO) (#698)
* handle 64 bits values, except for UNO Arduino UNO is not enough powerfull to handle properly uint64_t in terms of memory so differenciate the variable type depending on the board type With this configuration ATMega will not be able to receive with simpleReceiving 64 bits values. Of course Json will work with 64 bits values for this board. * Simplify jsondata.success() condition * Renamings and optimize deduplication functions * replace 2 dimensions array by a structure so as to handle the time with an uint32_t when using an ESP (instead of a uint64_t) * change storeValue and isAduplicate function names * point to the rcswitch revision with the new 40 bits protocol Co-authored-by: Leon Kiefer <leon.k97@gmx.de>
This commit is contained in:
1 parent
b66d72ac99
commit
6e9b170c00
10 files changed
+115
-73
No files matched your search
@@ -54,7 +54,7 @@ void setupWeatherStation() {
|
||||
|
||||
void sendWindSpeedData(byte id, float wind_speed, byte battery_status) {
|
||||
unsigned long MQTTvalue = 10000 + round(wind_speed);
|
||||
if (!isAduplicate(MQTTvalue)) { // conditions to avoid duplications of RF -->MQTT
|
||||
if (!isAduplicateSignal(MQTTvalue)) { // conditions to avoid duplications of RF -->MQTT
|
||||
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3);
|
||||
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
|
||||
JsonObject& RFdata = jsonBuffer.createObject();
|
||||
@@ -63,13 +63,13 @@ void sendWindSpeedData(byte id, float wind_speed, byte battery_status) {
|
||||
RFdata.set("battery", bitRead(battery_status, 0) == 0 ? "OK" : "Low");
|
||||
pub(subjectRFtoMQTT, RFdata);
|
||||
Log.trace(F("Store wind speed val: %lu" CR), MQTTvalue);
|
||||
storeValue(MQTTvalue);
|
||||
storeSignalValue(MQTTvalue);
|
||||
}
|
||||
}
|
||||
|
||||
void sendRainData(byte id, float rain_volume, byte battery_status) {
|
||||
unsigned long MQTTvalue = 11000 + round(rain_volume * 10.0);
|
||||
if (!isAduplicate(MQTTvalue)) { // conditions to avoid duplications of RF -->MQTT
|
||||
if (!isAduplicateSignal(MQTTvalue)) { // conditions to avoid duplications of RF -->MQTT
|
||||
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3);
|
||||
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
|
||||
JsonObject& RFdata = jsonBuffer.createObject();
|
||||
@@ -78,13 +78,13 @@ void sendRainData(byte id, float rain_volume, byte battery_status) {
|
||||
RFdata.set("battery", bitRead(battery_status, 1) == 0 ? "OK" : "Low");
|
||||
pub(subjectRFtoMQTT, RFdata);
|
||||
Log.trace(F("Store rain_volume: %lu" CR), MQTTvalue);
|
||||
storeValue(MQTTvalue);
|
||||
storeSignalValue(MQTTvalue);
|
||||
}
|
||||
}
|
||||
|
||||
void sendWindData(byte id, int wind_direction, float wind_gust, byte battery_status) {
|
||||
unsigned long MQTTvalue = 20000 + round(wind_gust * 10.0) + wind_direction;
|
||||
if (!isAduplicate(MQTTvalue)) { // conditions to avoid duplications of RF -->MQTT
|
||||
if (!isAduplicateSignal(MQTTvalue)) { // conditions to avoid duplications of RF -->MQTT
|
||||
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(4);
|
||||
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
|
||||
JsonObject& RFdata = jsonBuffer.createObject();
|
||||
@@ -94,13 +94,13 @@ void sendWindData(byte id, int wind_direction, float wind_gust, byte battery_sta
|
||||
RFdata.set("battery", bitRead(battery_status, 0) == 0 ? "OK" : "Low");
|
||||
pub(subjectRFtoMQTT, RFdata);
|
||||
Log.trace(F("Store wind data val: %lu" CR), MQTTvalue);
|
||||
storeValue(MQTTvalue);
|
||||
storeSignalValue(MQTTvalue);
|
||||
}
|
||||
}
|
||||
|
||||
void sendTemperatureData(byte id, float temperature, int humidity, byte battery_status) {
|
||||
unsigned long MQTTvalue = 40000 + abs(round(temperature * 100.0)) + humidity;
|
||||
if (!isAduplicate(MQTTvalue)) { // conditions to avoid duplications of RF -->MQTT
|
||||
if (!isAduplicateSignal(MQTTvalue)) { // conditions to avoid duplications of RF -->MQTT
|
||||
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(4);
|
||||
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
|
||||
JsonObject& RFdata = jsonBuffer.createObject();
|
||||
@@ -110,7 +110,7 @@ void sendTemperatureData(byte id, float temperature, int humidity, byte battery_
|
||||
RFdata.set("battery", bitRead(battery_status, 0) == 0 ? "OK" : "Low");
|
||||
pub(subjectRFtoMQTT, RFdata);
|
||||
Log.trace(F("Store temp val: %lu" CR), MQTTvalue);
|
||||
storeValue(MQTTvalue);
|
||||
storeSignalValue(MQTTvalue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user