mirror of https://github.com/arendst/Tasmota.git
only in case of valid key do action. Issue#10585 and block very slow incoming signals
This commit is contained in:
parent
f52f26f566
commit
ba12d8911e
|
@ -274,8 +274,15 @@ bool Wiegand::WiegandConversion ()
|
|||
{
|
||||
bool bRet = false;
|
||||
unsigned long nowTick = millis();
|
||||
if ((nowTick - lastFoundTime) > WIEGAND_BIT_TIMEOUT) //last bit found is WIEGAND_BIT_TIMEOUT ms ago
|
||||
{
|
||||
//add a maximum wait time for new bits
|
||||
unsigned long diffTicks = nowTick - lastFoundTime;
|
||||
if ((diffTicks > WIEGAND_BIT_TIMEOUT) && (diffTicks >= 5000 )) { //max. 5 secs between 2 bits comming in
|
||||
bitCount=0;
|
||||
rfidBuffer=0;
|
||||
lastFoundTime=nowTick;
|
||||
return bRet;
|
||||
}
|
||||
if (diffTicks > WIEGAND_BIT_TIMEOUT) { //last bit found is WIEGAND_BIT_TIMEOUT ms ago
|
||||
#if (DEV_WIEGAND_TEST_MODE)>0
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: raw tag: %llu "), rfidBuffer);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: bit count: %u "), bitCount);
|
||||
|
@ -363,19 +370,19 @@ void Wiegand::ScanForTag() {
|
|||
#endif
|
||||
if (bitCount > 0) {
|
||||
uint64_t oldTag = rfid;
|
||||
bool newKey = WiegandConversion();
|
||||
bool validKey = WiegandConversion();
|
||||
#if (DEV_WIEGAND_TEST_MODE)>0
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: previous tag: %llu"), oldTag);
|
||||
#endif
|
||||
if(newKey && (oldTag != rfid)) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: new= %llu"), rfid);
|
||||
}
|
||||
else
|
||||
{ AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: prev= %llu"), rfid);}
|
||||
// only in case of valid key do action. Issue#10585
|
||||
if(validKey) {
|
||||
if (oldTag != rfid) { AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: new= %llu"), rfid); }
|
||||
else { AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: prev= %llu"), rfid); }
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: bits= %u"), tagSize);
|
||||
ResponseTime_P(PSTR(",\"Wiegand\":{\"UID\":\"%0llu\"}}"), rfid);
|
||||
MqttPublishTeleSensor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
|
|
Loading…
Reference in New Issue