[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
+7
-7
@@ -38,7 +38,7 @@
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
|
||||
# ifdef ZmqttDiscovery
|
||||
void RFtoMQTTdiscovery(unsigned long MQTTvalue) { //on the fly switch creation from received RF values
|
||||
void RFtoMQTTdiscovery(SIGNAL_SIZE_UL_ULL MQTTvalue) { //on the fly switch creation from received RF values
|
||||
char val[11];
|
||||
sprintf(val, "%lu", MQTTvalue);
|
||||
Log.trace(F("switchRFDiscovery" CR));
|
||||
@@ -78,20 +78,20 @@ void RFtoMQTT() {
|
||||
# ifdef ESP32
|
||||
Log.trace(F("RF Task running on core :%d" CR), xPortGetCoreID());
|
||||
# endif
|
||||
RFdata.set("value", (unsigned long)mySwitch.getReceivedValue());
|
||||
SIGNAL_SIZE_UL_ULL MQTTvalue = mySwitch.getReceivedValue();
|
||||
RFdata.set("value", (SIGNAL_SIZE_UL_ULL)MQTTvalue);
|
||||
RFdata.set("protocol", (int)mySwitch.getReceivedProtocol());
|
||||
RFdata.set("length", (int)mySwitch.getReceivedBitlength());
|
||||
RFdata.set("delay", (int)mySwitch.getReceivedDelay());
|
||||
mySwitch.resetAvailable();
|
||||
|
||||
unsigned long MQTTvalue = RFdata.get<unsigned long>("value");
|
||||
if (!isAduplicate(MQTTvalue) && MQTTvalue != 0) { // conditions to avoid duplications of RF -->MQTT
|
||||
if (!isAduplicateSignal(MQTTvalue) && MQTTvalue != 0) { // conditions to avoid duplications of RF -->MQTT
|
||||
# ifdef ZmqttDiscovery //component creation for HA
|
||||
RFtoMQTTdiscovery(MQTTvalue);
|
||||
# endif
|
||||
pub(subjectRFtoMQTT, RFdata);
|
||||
Log.trace(F("Store val: %lu" CR), MQTTvalue);
|
||||
storeValue(MQTTvalue);
|
||||
storeSignalValue(MQTTvalue);
|
||||
if (repeatRFwMQTT) {
|
||||
Log.trace(F("Pub RF for rpt" CR));
|
||||
pub(subjectMQTTtoRF, RFdata);
|
||||
@@ -107,7 +107,7 @@ void MQTTtoRF(char* topicOri, char* datacallback) {
|
||||
mySwitch.disableReceive();
|
||||
mySwitch.enableTransmit(RF_EMITTER_GPIO);
|
||||
# endif
|
||||
unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
|
||||
SIGNAL_SIZE_UL_ULL data = STRTO_UL_ULL(datacallback, NULL, 10); // we will not be able to pass values > 4294967295 on Arduino boards
|
||||
|
||||
// RF DATA ANALYSIS
|
||||
//We look into the subject to see if a special RF protocol is defined
|
||||
@@ -171,7 +171,7 @@ void MQTTtoRF(char* topicOri, JsonObject& RFdata) { // json object decoding
|
||||
# endif
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoRF)) {
|
||||
Log.trace(F("MQTTtoRF json" CR));
|
||||
unsigned long data = RFdata["value"];
|
||||
SIGNAL_SIZE_UL_ULL data = RFdata["value"];
|
||||
if (data != 0) {
|
||||
int valuePRT = RFdata["protocol"] | 1;
|
||||
int valuePLSL = RFdata["delay"] | 350;
|
||||
|
||||
Reference in new issue
Block a user