Created
June 15, 2016 15:45
-
-
Save xaqq/49277193c48d889a26c2fc76c72477c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/auth/WiegandCard.cpp b/src/core/auth/WiegandCard.cpp | |
index d71f304..e074a10 100644 | |
--- a/src/core/auth/WiegandCard.cpp | |
+++ b/src/core/auth/WiegandCard.cpp | |
@@ -81,6 +81,8 @@ uint64_t WiegandCard::to_int() const | |
{ | |
case 26: | |
return to_wiegand_26(); | |
+ case 34: | |
+ return to_wiegand_34(); | |
default: | |
INFO("Not using format to convert WiegandCard to integer because no format " | |
"match."); | |
@@ -100,3 +102,16 @@ uint64_t WiegandCard::to_wiegand_26() const | |
tmp &= 0xFFFF; | |
return tmp; | |
} | |
+ | |
+uint64_t WiegandCard::to_wiegand_34() const | |
+{ | |
+ assert(nb_bits_ == 34); | |
+ assert(card_id_.size() == 2 * 5 + 4); | |
+ | |
+ uint64_t tmp = to_raw_int(); | |
+ // Drop the last bit (parity) from the raw frame. | |
+ tmp >>= 1; | |
+ // keep 24 bits | |
+ tmp &= 0xFFFFFF; | |
+ return tmp; | |
+} | |
diff --git a/src/core/auth/WiegandCard.hpp b/src/core/auth/WiegandCard.hpp | |
index 390a000..de60e3b 100644 | |
--- a/src/core/auth/WiegandCard.hpp | |
+++ b/src/core/auth/WiegandCard.hpp | |
@@ -82,6 +82,11 @@ namespace Leosac | |
uint64_t to_wiegand_26() const; | |
/** | |
+ * Extract the card ID, assuming the format to be Wiegand26. | |
+ */ | |
+ uint64_t to_wiegand_34() const; | |
+ | |
+ /** | |
* Card id | |
*/ | |
std::string card_id_; | |
╭ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment