From 4c488bd9704cb6af32bc9bcb523c3104c0a4a6a0 Mon Sep 17 00:00:00 2001 From: Anton Chistyakov Date: Wed, 5 Apr 2023 07:16:20 +0300 Subject: [PATCH] Fixing parsing troika number (#2536) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- lib/nfc/parsers/troika_4k_parser.c | 5 +++-- lib/nfc/parsers/troika_parser.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/nfc/parsers/troika_4k_parser.c b/lib/nfc/parsers/troika_4k_parser.c index 1f1b85a5c..d248feb17 100644 --- a/lib/nfc/parsers/troika_4k_parser.c +++ b/lib/nfc/parsers/troika_4k_parser.c @@ -90,13 +90,14 @@ bool troika_4k_parser_parse(NfcDeviceData* dev_data) { uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5]; uint16_t balance = ((temp_ptr[0] << 8) | temp_ptr[1]) / 25; - temp_ptr = &data->block[8 * 4].value[3]; + temp_ptr = &data->block[8 * 4].value[2]; uint32_t number = 0; - for(size_t i = 0; i < 4; i++) { + for(size_t i = 1; i < 5; i++) { number <<= 8; number |= temp_ptr[i]; } number >>= 4; + number |= (temp_ptr[0] & 0xf) << 28; furi_string_printf( dev_data->parsed_data, "\e#Troika\nNum: %lu\nBalance: %u rur.", number, balance); diff --git a/lib/nfc/parsers/troika_parser.c b/lib/nfc/parsers/troika_parser.c index bfd22364b..6d8ae98f3 100644 --- a/lib/nfc/parsers/troika_parser.c +++ b/lib/nfc/parsers/troika_parser.c @@ -70,13 +70,14 @@ bool troika_parser_parse(NfcDeviceData* dev_data) { // Parse data uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5]; uint16_t balance = ((temp_ptr[0] << 8) | temp_ptr[1]) / 25; - temp_ptr = &data->block[8 * 4].value[3]; + temp_ptr = &data->block[8 * 4].value[2]; uint32_t number = 0; - for(size_t i = 0; i < 4; i++) { + for(size_t i = 1; i < 5; i++) { number <<= 8; number |= temp_ptr[i]; } number >>= 4; + number |= (temp_ptr[0] & 0xf) << 28; furi_string_printf( dev_data->parsed_data, "\e#Troika\nNum: %lu\nBalance: %u rur.", number, balance);