#8 - Add decimal values to id & facility.

This commit is contained in:
Derek Jamison 2023-06-11 15:50:30 -05:00
parent bd1b14bb01
commit 885c465b44
2 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,5 @@
App( App(
appid="Wiegand_Reader", appid="wiegand_reader",
name="Wiegand Reader", name="Wiegand Reader",
apptype=FlipperAppType.EXTERNAL, apptype=FlipperAppType.EXTERNAL,
entry_point="wiegand_app", entry_point="wiegand_app",

View File

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