correct deduplication issue with SRFB and improve OMG performance
by reducing the receivingMQTT call numbers https://community.openmqttgateway.com/t/seeing-duplicated-messages/398/7
This commit is contained in:
1 parent
54d95158c7
commit
4dafcd3779
2 files changed
+20
-19
No files matched your search
+6
-8
@@ -203,8 +203,8 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
||||
memcpy(p,payload,length);
|
||||
// Conversion to a printable string
|
||||
p[length] = '\0';
|
||||
//launch the function to treat received data
|
||||
receivingMQTT(topic,(char *) p);
|
||||
//launch the function to treat received data if this data concern OpenMQTTGateway
|
||||
if ((strstr(topic, subjectMultiGTWKey) != NULL) || (strstr(topic, subjectGTWSendKey) != NULL)) receivingMQTT(topic,(char *) p);
|
||||
// Free the memory
|
||||
free(p);
|
||||
}
|
||||
@@ -802,14 +802,15 @@ return false;
|
||||
}
|
||||
|
||||
void receivingMQTT(char * topicOri, char * datacallback) {
|
||||
|
||||
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject& jsondata = jsonBuffer.parseObject(datacallback);
|
||||
|
||||
if (strstr(topicOri, subjectMultiGTWKey) != NULL) // storing received value so as to avoid publishing this value if it has been already sent by this or another OpenMQTTGateway
|
||||
{
|
||||
trc(F("Store signal"));
|
||||
unsigned long data = 0;
|
||||
#ifdef jsonPublishing
|
||||
trc(F("Json buf."));
|
||||
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject& jsondata = jsonBuffer.parseObject(datacallback);
|
||||
if (jsondata.success()) data = jsondata["value"];
|
||||
#endif
|
||||
|
||||
@@ -823,9 +824,6 @@ void receivingMQTT(char * topicOri, char * datacallback) {
|
||||
}
|
||||
}
|
||||
|
||||
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject& jsondata = jsonBuffer.parseObject(datacallback);
|
||||
|
||||
if (jsondata.success()) { // json object ok -> json decoding
|
||||
#ifdef ZgatewayPilight // ZgatewayPilight is only defined with json publishing
|
||||
MQTTtoPilight(topicOri, jsondata);
|
||||
|
||||
+14
-11
@@ -109,21 +109,24 @@ void _rfbDecode() {
|
||||
|
||||
char val[8]= {0};
|
||||
extract_char(buffer, val, 12 ,8, false,true);
|
||||
SRFBdata.set("value", (char *)val);
|
||||
unsigned long MQTTvalue = (unsigned long)strtoul(val, NULL, 10);
|
||||
SRFBdata.set("value", (unsigned long)MQTTvalue);
|
||||
|
||||
char val_Tsyn[4]= {0};
|
||||
extract_char(buffer, val_Tsyn , 0 ,4, false, true);
|
||||
SRFBdata.set("delay", (char *)val_Tsyn);
|
||||
char Tsyn[4]= {0};
|
||||
extract_char(buffer, Tsyn , 0 ,4, false, true);
|
||||
int val_Tsyn = (int)strtol(Tsyn, NULL, 10);
|
||||
SRFBdata.set("delay", (int)val_Tsyn);
|
||||
|
||||
char val_Thigh[4]= {0};
|
||||
extract_char(buffer, val_Thigh , 4 ,4, false, true);
|
||||
SRFBdata.set("val_Thigh", (char *)val_Thigh);
|
||||
char Thigh[4]= {0};
|
||||
extract_char(buffer, Thigh , 4 ,4, false, true);
|
||||
int val_Thigh = (int)strtol(Thigh, NULL, 10);
|
||||
SRFBdata.set("val_Thigh", (int)val_Thigh);
|
||||
|
||||
char val_Tlow[4]= {0};
|
||||
extract_char(buffer,val_Tlow , 8 ,4, false, true);
|
||||
SRFBdata.set("val_Tlow", (char *)val_Tlow);
|
||||
char Tlow[4]= {0};
|
||||
extract_char(buffer,Tlow , 8 ,4, false, true);
|
||||
int val_Tlow = (int)strtol(Tlow, NULL, 10);
|
||||
SRFBdata.set("val_Tlow", (int)val_Tlow);
|
||||
|
||||
unsigned long MQTTvalue = SRFBdata.get<unsigned long>("value");
|
||||
if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT
|
||||
trc(F("Adv data SRFBtoMQTT"));
|
||||
pub(subjectSRFBtoMQTT,SRFBdata);
|
||||
|
||||
Reference in new issue
Block a user