Add support for W48 (H2004064)

This commit is contained in:
Derek Jamison 2023-09-06 12:02:26 -05:00
parent 7d18e75287
commit 356f49365b
4 changed files with 36 additions and 2 deletions

View File

@ -47,6 +47,10 @@ This is a 26-bit format used by many readers. The first bit is an even parity bi
This is similar to W26, but without the leading and trailing parity bits. The first 8 bits are the facility code. The next 16 bits are the card number. The application will display the facility code and card number.
## W48: 48-bit Wiegand
This is HID 48 bit Corporate 1000 - H2004064 format. The first bit is odd parity 2 (based on bits 2-48). The next bit is even parity (based on 4-5,7-8,10-11,...,46-47). Then 22 bit company code. Then 23 bit card id. Then odd parity 1 (based on 3-4,6-7,9-10,...,45-46).
## W32/W34/W37/W40: 32/34/37/40-bit Wiegand
These formats are not very standardized, so the application will not try to interpret the data. You can modify the wiegand_data.c file to add your own interpretation.

View File

@ -120,6 +120,33 @@ void wiegand_add_info_24bit(FuriString* buffer) {
furi_string_cat_printf(buffer, " (%ld)", dec);
}
void wiegand_add_info_48bit(FuriString* buffer) {
// We assume this is HID 48 bit Corporate 1000 - H2004064 format.
// The first bit is odd parity 2 (based on bits 2-48).
// The next bit is even parity (based on 4-5,7-8,10-11,...,46-47).
// Then 22 bit company code.
// Then 23 bit card id.
/// Then odd parity 1 (based on 3-4,6-7,9-10,...,45-46).
// 22 bits company code (bits 3-24; data[2..23])
uint32_t code = 0;
for(int i = 2; i <= 23; i++) {
code = code << 1;
code |= data[i] ? 1 : 0;
}
furi_string_cat_printf(buffer, "\nCompany: %lX (%ld)", code, code);
// 23 bit card id (bits 25-47; data[24..46]).
code = 0;
for(int i = 24; i <= 46; i++) {
code = code << 1;
code |= data[i] ? 1 : 0;
}
furi_string_cat_printf(buffer, "\nCard: %lX (%ld)", code, code);
// TODO: Add the 3 parity checks.
}
void wiegand_add_info(FuriString* buffer) {
furi_string_push_back(buffer, '\n');
if(bit_count == 4 || bit_count == 8) {
@ -128,6 +155,8 @@ void wiegand_add_info(FuriString* buffer) {
wiegand_add_info_26bit(buffer);
} else if(bit_count == 24) {
wiegand_add_info_24bit(buffer);
} else if(bit_count == 48) {
wiegand_add_info_48bit(buffer);
}
furi_string_push_back(buffer, '\n');
}

View File

@ -68,7 +68,8 @@ void wiegand_timer_callback(void* context) {
FURI_CRITICAL_ENTER();
if(duration > 25 * one_millisecond) {
if(bit_count == 4 || bit_count == 8 || bit_count == 24 || bit_count == 26 ||
bit_count == 32 || bit_count == 34 || bit_count == 37 || bit_count == 40) {
bit_count == 32 || bit_count == 34 || bit_count == 37 || bit_count == 40 ||
bit_count == 48) {
wiegand_stop_read(app);
scene_manager_next_scene(app->scene_manager, WiegandDataScene);
} else {

View File

@ -18,7 +18,7 @@ extern const GpioPin* const pinD0mosfet;
extern const GpioPin* const pinD1;
extern const GpioPin* const pinD1mosfet;
extern volatile int bit_count;
#define MAX_BITS 42
#define MAX_BITS 48
extern volatile bool data[];
extern volatile uint32_t data_fall[];
extern volatile uint32_t data_rise[];