Quick fix for displaying valid 26-bit tags

Quick fix for displaying valid 26-bit tags (#14834)
34-bit tags is a challenge as we currently do not support 64-bit variables. To be continued.
This commit is contained in:
Theo Arends 2022-02-14 18:29:26 +01:00
parent 5d9da0f971
commit 3e914a7ad1
1 changed files with 59 additions and 49 deletions

View File

@ -390,10 +390,9 @@ void Wiegand::ScanForTag() {
AddLog(LOG_LEVEL_INFO, PSTR("WIE: ScanForTag(). bitTime: %0lu lastFoundTime: %0lu RFIDS in buffer: %lu"), bitTime, lastFoundTime, currentFoundRFIDcount); AddLog(LOG_LEVEL_INFO, PSTR("WIE: ScanForTag(). bitTime: %0lu lastFoundTime: %0lu RFIDS in buffer: %lu"), bitTime, lastFoundTime, currentFoundRFIDcount);
#endif #endif
// format MQTT output // format MQTT output
setOutputFormat(); // setOutputFormat();
char sFormat[50]; // char sFormat[50];
snprintf( sFormat, 50, PSTR(",\"Wiegand\":{\"UID\":%%0ll%s,\"" D_JSON_SIZE "\":%%%s}}"), outFormat, outFormat); // snprintf( sFormat, 50, PSTR(",\"Wiegand\":{\"UID\":%%0ll%s,\"" D_JSON_SIZE "\":%%%s}}"), outFormat, outFormat);
for (int i= 0; i < WIEGAND_RFID_ARRAY_SIZE; i++) for (int i= 0; i < WIEGAND_RFID_ARRAY_SIZE; i++)
{ {
if (rfid_found[i].RFID != 0 || (rfid_found[i].RFID == 0 && i == 0)) { if (rfid_found[i].RFID != 0 || (rfid_found[i].RFID == 0 && i == 0)) {
@ -408,7 +407,13 @@ void Wiegand::ScanForTag() {
if (oldTag == rfid) { if (oldTag == rfid) {
AddLog(LOG_LEVEL_DEBUG, PSTR("WIE: Old tag")); AddLog(LOG_LEVEL_DEBUG, PSTR("WIE: Old tag"));
} }
ResponseTime_P(sFormat, rfid, tagSize); // ResponseTime_P(sFormat, rfid, tagSize);
// Tasmota does not support 64-bit decimal output specifier (%llu) saving 60k code
if (GetOption(WIEGAND_OPTION_HEX) == 0) {
ResponseTime_P(PSTR(",\"Wiegand\":{\"UID\":%lu,\"" D_JSON_SIZE "\":%d}}"), (uint32_t)rfid, tagSize);
} else {
ResponseTime_P(PSTR(",\"Wiegand\":{\"UID\":\"%2_X" WIEGAND_OPTION_HEX_POSTFIX "\",\"" D_JSON_SIZE "\":\"%X" WIEGAND_OPTION_HEX_POSTFIX "\"}}"), &rfid, tagSize);
}
MqttPublishTeleSensor(); MqttPublishTeleSensor();
} }
} }
@ -429,12 +434,17 @@ void Wiegand::ScanForTag() {
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
void Wiegand::Show(void) { void Wiegand::Show(void) {
setOutputFormat(); // setOutputFormat();
char sFormat [30]; // char sFormat [30];
snprintf( sFormat, 30,PSTR("{s}Wiegand UID{m}%%ll%s {e}"), outFormat); // snprintf( sFormat, 30,PSTR("{s}Wiegand UID{m}%%ll%s {e}"), outFormat);
if (tagSize>0) { WSContentSend_PD(sFormat, rfid); } // if (tagSize>0) { WSContentSend_PD(sFormat, rfid); }
else { WSContentSend_PD(sFormat, webRFIDKeypadBuffer); } // else { WSContentSend_PD(sFormat, webRFIDKeypadBuffer); }
// Tasmota does not support 64-bit decimal output specifier (%llu) saving 60k code
if (GetOption(WIEGAND_OPTION_HEX) == 0) {
WSContentSend_P(PSTR("{s}Wiegand UID{m}%lu{e}"), (tagSize>0) ? (uint32_t)rfid : (uint32_t)webRFIDKeypadBuffer);
} else {
WSContentSend_P(PSTR("{s}Wiegand UID{m}%2_X" WIEGAND_OPTION_HEX_POSTFIX "{e}"), (tagSize>0) ? &rfid : &webRFIDKeypadBuffer);
}
#if (DEV_WIEGAND_TEST_MODE)>0 #if (DEV_WIEGAND_TEST_MODE)>0
AddLog(LOG_LEVEL_INFO, PSTR("WIE: Tag %llu, Bits %u"), rfid, bitCount); AddLog(LOG_LEVEL_INFO, PSTR("WIE: Tag %llu, Bits %u"), rfid, bitCount);
#endif // DEV_WIEGAND_TEST_MODE>0 #endif // DEV_WIEGAND_TEST_MODE>0