|
59 | 59 | * INCLUDES
|
60 | 60 | *****************************************************************************/
|
61 | 61 |
|
| 62 | +#include <stdbool.h> |
| 63 | + |
62 | 64 | #include "buzzer.h"
|
63 | 65 | #include "card_fetch_data.h"
|
64 | 66 | #include "card_fetch_wallet_list.h"
|
|
88 | 90 | /*****************************************************************************
|
89 | 91 | * STATIC VARIABLES
|
90 | 92 | *****************************************************************************/
|
91 |
| -card_error_type_e card_get_wallet_list( |
92 |
| - card_operation_data_t card_data, |
93 |
| - const card_fetch_wallet_list_config_t *configuration, |
94 |
| - card_fetch_wallet_list_response_t *response) { |
95 |
| - if (NULL == configuration || NULL == response || |
96 |
| - NULL == response->wallet_list) { |
97 |
| - return CARD_OPERATION_DEFAULT_INVALID; |
98 |
| - } |
99 |
| - if (CARD_OPERATION_SUCCESS == card_data.error_type) { |
100 |
| - card_data.nfc_data.status = nfc_list_all_wallet(response->wallet_list); |
101 | 93 |
|
102 |
| - if (card_data.nfc_data.status == SW_NO_ERROR || |
103 |
| - card_data.nfc_data.status == SW_RECORD_NOT_FOUND) { |
104 |
| - if (card_data.nfc_data.status == SW_RECORD_NOT_FOUND || |
105 |
| - configuration->operation.buzzer_on_success) { |
106 |
| - buzzer_start(BUZZER_DURATION); |
107 |
| - } |
108 |
| - if (!configuration->operation.skip_card_removal) { |
109 |
| - wait_for_card_removal(); |
110 |
| - } |
111 |
| - // break; |
112 |
| - } else { |
113 |
| - card_handle_errors(&card_data); |
114 |
| - } |
115 |
| - } |
116 |
| - |
117 |
| - response->card_info.pairing_error = card_data.nfc_data.pairing_error; |
118 |
| - response->card_info.tapped_card = card_data.nfc_data.tapped_card; |
119 |
| - response->card_info.recovery_mode = card_data.nfc_data.recovery_mode; |
120 |
| - response->card_info.status = card_data.nfc_data.status; |
121 |
| - return card_data.error_type; |
122 |
| -} |
123 | 94 | /*****************************************************************************
|
124 | 95 | * GLOBAL VARIABLES
|
125 | 96 | *****************************************************************************/
|
@@ -156,48 +127,7 @@ card_error_type_e card_fetch_encrypt_data(const uint8_t *wallet_id,
|
156 | 127 | #if USE_SIMULATOR == 0
|
157 | 128 | memcpy(card_data.nfc_data.family_id, get_family_id(), FAMILY_ID_SIZE);
|
158 | 129 | result = card_initialize_applet(&card_data);
|
159 |
| -#endif |
160 |
| - // Fetch wallet list from card |
161 |
| - wallet_list_t wallets_in_card = {0}; |
162 |
| - card_fetch_wallet_list_config_t configuration = { |
163 |
| - .operation = {.acceptable_cards = ACCEPTABLE_CARDS_ALL, |
164 |
| - .skip_card_removal = true, |
165 |
| - .expected_family_id = card_data.nfc_data.family_id, |
166 |
| - .buzzer_on_success = false}, |
167 |
| - .frontend = {.heading = ui_text_tap_1_2_cards, |
168 |
| - .msg = ui_text_place_card_below}}; |
169 |
| - |
170 |
| - card_fetch_wallet_list_response_t response = { |
171 |
| - .wallet_list = &wallets_in_card, .card_info = {0}}; |
172 |
| -#if USE_SIMULATOR == 0 |
173 |
| - card_error_type_e status = |
174 |
| - card_get_wallet_list(card_data, &configuration, &response); |
175 |
| - // If the tapped card is not paired, it is a terminal case in the flow |
176 |
| - if (true == response.card_info.pairing_error) { |
177 |
| - return CARD_OPERATION_DEFAULT_INVALID; |
178 |
| - } |
179 |
| - |
180 |
| - // At this stage, either there is no core error message set, or it is set |
181 |
| - // but we want to overwrite the error message using user facing messages in |
182 |
| - // this flow |
183 |
| - uint32_t card_fault_status = 0; |
184 |
| - if (1 == response.card_info.recovery_mode) { |
185 |
| - card_fault_status = NFC_NULL_PTR_ERROR; |
186 |
| - } else if (CARD_OPERATION_SUCCESS != status) { |
187 |
| - card_fault_status = response.card_info.status; |
188 |
| - } |
189 |
| - |
190 |
| - for (uint8_t i = 0; i < wallets_in_card.count; i++) { |
191 |
| - if (memcmp(wallet_id, wallets_in_card.wallet[i].id, WALLET_ID_SIZE) == |
192 |
| - 0) { |
193 |
| - memcpy(wallet_name, |
194 |
| - (const char *)wallets_in_card.wallet[i].name, |
195 |
| - NAME_SIZE); |
196 |
| - break; |
197 |
| - } |
198 |
| - } |
199 |
| - if (0 == strlen(wallet_name)) { |
200 |
| - delay_scr_init(ui_text_wallet_doesnt_exists_on_this_card, DELAY_TIME); |
| 130 | + if (!card_fetch_wallet_name(card_data, wallet_id, wallet_name)) { |
201 | 131 | return CARD_OPERATION_DEFAULT_INVALID;
|
202 | 132 | }
|
203 | 133 | #endif
|
|
0 commit comments