Skip to content

Commit

Permalink
#8 - Add decimal values to id & facility.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamisonderek committed Jun 11, 2023
1 parent bd1b14b commit 885c465
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gpio/wiegand/application.fam
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
App(
appid="Wiegand_Reader",
appid="wiegand_reader",
name="Wiegand Reader",
apptype=FlipperAppType.EXTERNAL,
entry_point="wiegand_app",
Expand Down
15 changes: 15 additions & 0 deletions gpio/wiegand/scenes/wiegand_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,27 @@ void wiegand_add_info_26bit(FuriString* buffer) {
furi_string_cat_printf(buffer, "\nFacility: 0x");
int code = 0;
int count = 0;
uint32_t dec = 0;
for(int i = 1; i < 25; i++) {
code = code << 1;
dec = dec << 1;
code |= data[i] ? 1 : 0;
dec |= data[i] ? 1 : 0;
if(++count % 4 == 0) {
furi_string_cat_printf(buffer, "%X", code);
code = 0;
}

if(i == 8) {
furi_string_cat_printf(buffer, " (%ld)", dec);
dec = 0;
}
// Parity, then 8 bit facility code, then id.
if(i == 9) {
furi_string_cat_printf(buffer, "\nId: 0x");
}
}
furi_string_cat_printf(buffer, " (%ld)", dec);

if(data[13]) {
parity = 1;
Expand All @@ -91,18 +100,24 @@ void wiegand_add_info_24bit(FuriString* buffer) {
furi_string_cat_printf(buffer, "\nFacility: 0x");
int code = 0;
int count = 0;
uint32_t dec = 0;
for(int i = 0; i < 24; i++) {
code = code << 1;
dec = dec << 1;
code |= data[i] ? 1 : 0;
dec |= data[i] ? 1 : 0;
if(++count % 4 == 0) {
furi_string_cat_printf(buffer, "%X", code);
code = 0;
}
// The first 8 bits are facility code, then comes id.
if(i == 8) {
furi_string_cat_printf(buffer, " (%ld)", dec);
dec = 0;
furi_string_cat_printf(buffer, "\nId: 0x");
}
}
furi_string_cat_printf(buffer, " (%ld)", dec);
}

void wiegand_add_info(FuriString* buffer) {
Expand Down

0 comments on commit 885c465

Please sign in to comment.