Skip to content

Commit

Permalink
picopass: clean up UI, espeicially for SR cards (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
bettse authored Aug 27, 2023
1 parent 0c3773e commit 1700285
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
8 changes: 2 additions & 6 deletions scenes/picopass_scene_device_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ void picopass_scene_device_info_on_enter(void* context) {
FuriString* csn_str = furi_string_alloc_set("CSN:");
FuriString* credential_str = furi_string_alloc();
FuriString* wiegand_str = furi_string_alloc();
FuriString* sio_str = furi_string_alloc();

dolphin_deed(DolphinDeedNfcReadSuccess);

Expand All @@ -43,7 +42,7 @@ void picopass_scene_device_info_on_enter(void* context) {
}
furi_string_set(credential_str, "");
for(uint8_t i = RFAL_PICOPASS_BLOCK_LEN - bytesLength; i < RFAL_PICOPASS_BLOCK_LEN; i++) {
furi_string_cat_printf(credential_str, " %02X", pacs->credential[i]);
furi_string_cat_printf(credential_str, "%02X", pacs->credential[i]);
}

if(pacs->record.valid) {
Expand All @@ -54,7 +53,7 @@ void picopass_scene_device_info_on_enter(void* context) {
}

if(pacs->sio) {
furi_string_cat_printf(sio_str, "+SIO");
furi_string_cat_printf(credential_str, " +SIO");
}
}

Expand All @@ -70,13 +69,10 @@ void picopass_scene_device_info_on_enter(void* context) {
AlignCenter,
FontSecondary,
furi_string_get_cstr(credential_str));
widget_add_string_element(
widget, 64, 46, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(sio_str));

furi_string_free(csn_str);
furi_string_free(credential_str);
furi_string_free(wiegand_str);
furi_string_free(sio_str);

widget_add_button_element(
picopass->widget,
Expand Down
17 changes: 7 additions & 10 deletions scenes/picopass_scene_read_card_success.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void picopass_scene_read_card_success_on_enter(void* context) {
FuriString* csn_str = furi_string_alloc_set("CSN:");
FuriString* credential_str = furi_string_alloc();
FuriString* wiegand_str = furi_string_alloc();
FuriString* sio_str = furi_string_alloc();
FuriString* key_str = furi_string_alloc();

dolphin_deed(DolphinDeedNfcReadSuccess);

Expand Down Expand Up @@ -79,7 +79,7 @@ void picopass_scene_read_card_success_on_enter(void* context) {
size_t bytesLength = 1 + pacs->record.bitLength / 8;
furi_string_set(credential_str, "");
for(uint8_t i = RFAL_PICOPASS_BLOCK_LEN - bytesLength; i < RFAL_PICOPASS_BLOCK_LEN; i++) {
furi_string_cat_printf(credential_str, " %02X", pacs->credential[i]);
furi_string_cat_printf(credential_str, "%02X", pacs->credential[i]);
}

if(pacs->record.valid) {
Expand All @@ -90,19 +90,16 @@ void picopass_scene_read_card_success_on_enter(void* context) {
}

if(pacs->sio) {
furi_string_cat_printf(sio_str, "+SIO");
furi_string_cat_printf(credential_str, " +SIO");
}

if(pacs->key) {
if(pacs->sio) {
furi_string_cat_printf(sio_str, " ");
}
furi_string_cat_printf(sio_str, "Key: ");
furi_string_cat_printf(key_str, "Key: ");

uint8_t key[RFAL_PICOPASS_BLOCK_LEN];
memcpy(key, &pacs->key, RFAL_PICOPASS_BLOCK_LEN);
for(uint8_t i = 0; i < RFAL_PICOPASS_BLOCK_LEN; i++) {
furi_string_cat_printf(sio_str, "%02X", key[i]);
furi_string_cat_printf(key_str, "%02X", key[i]);
}
}

Expand Down Expand Up @@ -134,12 +131,12 @@ void picopass_scene_read_card_success_on_enter(void* context) {
FontSecondary,
furi_string_get_cstr(credential_str));
widget_add_string_element(
widget, 64, 46, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(sio_str));
widget, 64, 46, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(key_str));

furi_string_free(csn_str);
furi_string_free(credential_str);
furi_string_free(wiegand_str);
furi_string_free(sio_str);
furi_string_free(key_str);

view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewWidget);
}
Expand Down

0 comments on commit 1700285

Please sign in to comment.