diff --git a/lib/nfc/parsers/plantain_4k_parser.c b/lib/nfc/parsers/plantain_4k_parser.c index c970d74e..eddebac2 100644 --- a/lib/nfc/parsers/plantain_4k_parser.c +++ b/lib/nfc/parsers/plantain_4k_parser.c @@ -1,5 +1,4 @@ #include "nfc_supported_card.h" -#include "plantain_parser.h" // For luhn and string_push_uint64 #include #include @@ -121,26 +120,15 @@ bool plantain_4k_parser_parse(NfcDeviceData* dev_data) { FuriString* card_number_str; card_number_str = furi_string_alloc(); // Should look like "361301047292848684" - // %llu doesn't work for some reason in sprintf, so we use string_push_uint64 instead - string_push_uint64(card_number, card_number_str); + furi_string_printf(card_number_str, "%llu", card_number); // Add suffix with luhn checksum (1 digit) to the card number string FuriString* card_number_suffix; card_number_suffix = furi_string_alloc(); - // The number to calculate the checksum on doesn't fit into uint64_t, idk - //uint8_t luhn_checksum = plantain_calculate_luhn(card_number); - - // // Convert luhn checksum to string - // FuriString* luhn_checksum_str; - // luhn_checksum_str = furi_string_alloc(); - // string_push_uint64(luhn_checksum, luhn_checksum_str); - furi_string_cat_printf(card_number_suffix, "-"); - // FURI_LOG_D("plant4k", "Card checksum: %d", luhn_checksum); furi_string_cat_printf(card_number_str, furi_string_get_cstr(card_number_suffix)); // Free all not needed strings furi_string_free(card_number_suffix); - // furi_string_free(luhn_checksum_str); furi_string_printf( dev_data->parsed_data, diff --git a/lib/nfc/parsers/plantain_parser.c b/lib/nfc/parsers/plantain_parser.c index 8ef8ee14..ac7a90b2 100644 --- a/lib/nfc/parsers/plantain_parser.c +++ b/lib/nfc/parsers/plantain_parser.c @@ -55,29 +55,6 @@ bool plantain_parser_read(NfcWorker* nfc_worker, FuriHalNfcTxRxContext* tx_rx) { return mf_classic_read_card(tx_rx, &reader, &nfc_worker->dev_data->mf_classic_data) == 16; } -void string_push_uint64(uint64_t input, FuriString* output) { - const uint8_t base = 10; - - do { - char c = input % base; - input /= base; - - if(c < 10) - c += '0'; - else - c += 'A' - 10; - furi_string_push_back(output, c); - } while(input); - - // reverse string - for(uint8_t i = 0; i < furi_string_size(output) / 2; i++) { - char c = furi_string_get_char(output, i); - furi_string_set_char( - output, i, furi_string_get_char(output, furi_string_size(output) - i - 1)); - furi_string_set_char(output, furi_string_size(output) - i - 1, c); - } -} - uint8_t plantain_calculate_luhn(uint64_t number) { // No. UNUSED(number); @@ -116,26 +93,15 @@ bool plantain_parser_parse(NfcDeviceData* dev_data) { FuriString* card_number_str; card_number_str = furi_string_alloc(); // Should look like "361301047292848684" - // %llu doesn't work for some reason in sprintf, so we use string_push_uint64 instead - string_push_uint64(card_number, card_number_str); + furi_string_printf(card_number_str, "%llu", card_number); // Add suffix with luhn checksum (1 digit) to the card number string FuriString* card_number_suffix; card_number_suffix = furi_string_alloc(); - // The number to calculate the checksum on doesn't fit into uint64_t, idk - //uint8_t luhn_checksum = plantain_calculate_luhn(card_number); - - // // Convert luhn checksum to string - // FuriString* luhn_checksum_str; - // luhn_checksum_str = furi_string_alloc(); - // string_push_uint64(luhn_checksum, luhn_checksum_str); - furi_string_cat_printf(card_number_suffix, "-"); - // FURI_LOG_D("plant4k", "Card checksum: %d", luhn_checksum); furi_string_cat_printf(card_number_str, furi_string_get_cstr(card_number_suffix)); // Free all not needed strings furi_string_free(card_number_suffix); - // furi_string_free(luhn_checksum_str); furi_string_printf( dev_data->parsed_data, diff --git a/lib/nfc/parsers/plantain_parser.h b/lib/nfc/parsers/plantain_parser.h index 65f396f1..1af8c506 100644 --- a/lib/nfc/parsers/plantain_parser.h +++ b/lib/nfc/parsers/plantain_parser.h @@ -8,6 +8,4 @@ bool plantain_parser_read(NfcWorker* nfc_worker, FuriHalNfcTxRxContext* tx_rx); bool plantain_parser_parse(NfcDeviceData* dev_data); -void string_push_uint64(uint64_t input, FuriString* output); - uint8_t plantain_calculate_luhn(uint64_t number); diff --git a/lib/nfc/parsers/two_cities.c b/lib/nfc/parsers/two_cities.c index 3dc97586..f5e31d51 100644 --- a/lib/nfc/parsers/two_cities.c +++ b/lib/nfc/parsers/two_cities.c @@ -121,26 +121,15 @@ bool two_cities_parser_parse(NfcDeviceData* dev_data) { FuriString* card_number_str; card_number_str = furi_string_alloc(); // Should look like "361301047292848684" - // %llu doesn't work for some reason in sprintf, so we use string_push_uint64 instead - string_push_uint64(card_number, card_number_str); + furi_string_printf(card_number_str, "%llu", card_number); // Add suffix with luhn checksum (1 digit) to the card number string FuriString* card_number_suffix; card_number_suffix = furi_string_alloc(); - // The number to calculate the checksum on doesn't fit into uint64_t, idk - //uint8_t luhn_checksum = two_cities_calculate_luhn(card_number); - - // // Convert luhn checksum to string - // FuriString* luhn_checksum_str; - // luhn_checksum_str = furi_string_alloc(); - // string_push_uint64(luhn_checksum, luhn_checksum_str); - furi_string_cat_printf(card_number_suffix, "-"); - // FURI_LOG_D("plant4k", "Card checksum: %d", luhn_checksum); furi_string_cat_printf(card_number_str, furi_string_get_cstr(card_number_suffix)); // Free all not needed strings furi_string_free(card_number_suffix); - // furi_string_free(luhn_checksum_str); // ===== // --PLANTAIN--