diff --git a/CHANGELOG.md b/CHANGELOG.md index c3d974890..f5c2badd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. - GPIO OptionE1 selection regression (#14821) - BL0939, BL0940 and BL0942 energy monitoring buffer miscompares resulting in wrong daily energy values regression from v9.5.0.8 (#14829) - Orno WE517 power meter phase 2 current reactive (#14841) +- Wiegand 34-bit rfid reading and presentation (#14834) ## [Released] diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 45636d317..a4187f10d 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -123,6 +123,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - SSPM energy yesterday when zero - GPIO OptionE1 selection regression [#14821](https://github.com/arendst/Tasmota/issues/14821) - BL0939, BL0940 and BL0942 energy monitoring buffer miscompares resulting in wrong daily energy values regression from v9.5.0.8 [#14829](https://github.com/arendst/Tasmota/issues/14829) +- Wiegand 34-bit rfid reading and presentation [#14834](https://github.com/arendst/Tasmota/issues/14834) - Orno WE517 power meter phase 2 current reactive [#14841](https://github.com/arendst/Tasmota/issues/14841) ### Removed diff --git a/tasmota/xsns_82_wiegand.ino b/tasmota/xsns_82_wiegand.ino index beaf49153..5aaa22d4f 100644 --- a/tasmota/xsns_82_wiegand.ino +++ b/tasmota/xsns_82_wiegand.ino @@ -37,7 +37,11 @@ * Rule: * on wiegand#uid=4302741608 do publish cmnd/ailight/power 2 endon * - * contains: + * 20220215 + * - fix 34-bit size parity chk + * - fix 64-bit representation after removal of %llu support (Tasmota does not support 64-bit decimal output specifier (%llu) saving 60k code) + * --- + * 20201101 * - fix for #11047 Wiegand 26/34 missed some key press if they are press at normal speed * - removed testing code for tests without attached hardware * - added SetOption123 0-Wiegand UID decimal (default) 1-Wiegand UID hexadecimal @@ -264,8 +268,8 @@ uint64_t Wiegand::CheckAndConvertRfid(uint64_t rfidIn, uint16_t bitCount) { break; case 34: - evenParityBit = (rfidIn & 0x400000000) ? 0x80 : 0; - rfidIn = (rfidIn & 0x3FFFFFFFE) >>1; + evenParityBit = (rfidIn & 0x200000000) ? 0x80 : 0; + rfidIn = (rfidIn & 0x1FFFFFFFE) >>1; break; default: @@ -274,7 +278,7 @@ uint64_t Wiegand::CheckAndConvertRfid(uint64_t rfidIn, uint16_t bitCount) { calcParity = CalculateParities(rfidIn, bitCount); // Check result on http://www.ccdesignworks.com/wiegand_calc.htm with raw tag as input if (calcParity != (evenParityBit | oddParityBit)) { // Parity bit is wrong rfidIn=0; - AddLog(LOG_LEVEL_DEBUG, PSTR("WIE: %llu parity error"), rfidIn); + AddLog(LOG_LEVEL_DEBUG, PSTR("WIE: %_X parity error"), &rfidIn); } #if (DEV_WIEGAND_TEST_MODE)>0 AddLog(LOG_LEVEL_INFO, PSTR("WIE: even (left) parity: %u "), (evenParityBit>>7)); @@ -412,7 +416,7 @@ void Wiegand::ScanForTag() { 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); + ResponseTime_P(PSTR(",\"Wiegand\":{\"UID\":\"%1_X" WIEGAND_OPTION_HEX_POSTFIX "\",\"" D_JSON_SIZE "\":%d}}"), &rfid, tagSize); } MqttPublishTeleSensor(); } @@ -443,7 +447,7 @@ void Wiegand::Show(void) { 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); + WSContentSend_P(PSTR("{s}Wiegand UID{m}%1_X" WIEGAND_OPTION_HEX_POSTFIX "{e}"), (tagSize>0) ? &rfid : &webRFIDKeypadBuffer); } #if (DEV_WIEGAND_TEST_MODE)>0 AddLog(LOG_LEVEL_INFO, PSTR("WIE: Tag %llu, Bits %u"), rfid, bitCount);