From 67eff89a092e70781994d9f32c9b599feed99ba7 Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Tue, 11 Oct 2022 22:12:46 +0200 Subject: [PATCH] Show set dates in MRTD auth menu --- .../nfc/scenes/nfc_scene_passport_bac.c | 19 ++++++++++++++++--- .../nfc/scenes/nfc_scene_passport_date.c | 18 +++++++++--------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/applications/nfc/scenes/nfc_scene_passport_bac.c b/applications/nfc/scenes/nfc_scene_passport_bac.c index 0998d0445..379fea4f5 100644 --- a/applications/nfc/scenes/nfc_scene_passport_bac.c +++ b/applications/nfc/scenes/nfc_scene_passport_bac.c @@ -37,10 +37,23 @@ void nfc_scene_passport_bac_on_enter(void* context) { VariableItem* item; uint8_t value_index; - variable_item_list_add(variable_item_list, "Birth Date", 1, NULL, NULL); - //TODO: show dates in menu? + const size_t temp_str_size = 10; + char temp_str[temp_str_size]; + snprintf(temp_str, temp_str_size, "%02u%02u%02u", + nfc->dev->dev_data.mrtd_data.auth.bac.birth_date.year, + nfc->dev->dev_data.mrtd_data.auth.bac.birth_date.month, + nfc->dev->dev_data.mrtd_data.auth.bac.birth_date.day); - variable_item_list_add(variable_item_list, "Expiry Date", 1, NULL, NULL); + item = variable_item_list_add(variable_item_list, "Birth Date", 1, NULL, NULL); + variable_item_set_current_value_text(item, temp_str); + + snprintf(temp_str, temp_str_size, "%02u%02u%02u", + nfc->dev->dev_data.mrtd_data.auth.bac.expiry_date.year, + nfc->dev->dev_data.mrtd_data.auth.bac.expiry_date.month, + nfc->dev->dev_data.mrtd_data.auth.bac.expiry_date.day); + + item = variable_item_list_add(variable_item_list, "Expiry Date", 1, NULL, NULL); + variable_item_set_current_value_text(item, temp_str); variable_item_list_add(variable_item_list, "Document Nr.", 1, NULL, NULL); //TODO: add scene to enter docnr, based on nfc_scene_passport_date.c diff --git a/applications/nfc/scenes/nfc_scene_passport_date.c b/applications/nfc/scenes/nfc_scene_passport_date.c index 2b553cc89..45ef86486 100644 --- a/applications/nfc/scenes/nfc_scene_passport_date.c +++ b/applications/nfc/scenes/nfc_scene_passport_date.c @@ -43,13 +43,17 @@ void nfc_scene_passport_date_on_enter(void* context) { nfc_text_store_set(nfc, "YYMMDD"); date_empty = true; } else { + char temp_str[10]; snprintf( - nfc->text_store, - DATE_LENGTH + 1, + temp_str, + 10, "%02u%02u%02u", - date_value.year % 100, - date_value.month % 112, - date_value.day % 31); // incl. '\x00' + date_value.year, + date_value.month, + date_value.day); + + memcpy(nfc->text_store, temp_str, DATE_LENGTH); + nfc->text_store[DATE_LENGTH] = '\x00'; } text_input_set_result_callback( @@ -66,8 +70,6 @@ void nfc_scene_passport_date_on_enter(void* context) { } bool nfc_scene_passport_date_save(Nfc* nfc) { - FURI_LOG_D(TAG, "Value2: %s", nfc->text_store); - int year; int month; int day; @@ -104,8 +106,6 @@ bool nfc_scene_passport_date_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == NfcCustomEventTextInputDone) { - FURI_LOG_D(TAG, "Value: %s", nfc->text_store); - nfc_scene_passport_date_save(nfc); //TODO: handle invalid date (returned false)