Fixing parsing troika number (#2536)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Anton Chistyakov 2023-04-05 07:16:20 +03:00 committed by GitHub
parent 494002505e
commit 4c488bd970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -90,13 +90,14 @@ bool troika_4k_parser_parse(NfcDeviceData* dev_data) {
uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5]; uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5];
uint16_t balance = ((temp_ptr[0] << 8) | temp_ptr[1]) / 25; 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; uint32_t number = 0;
for(size_t i = 0; i < 4; i++) { for(size_t i = 1; i < 5; i++) {
number <<= 8; number <<= 8;
number |= temp_ptr[i]; number |= temp_ptr[i];
} }
number >>= 4; number >>= 4;
number |= (temp_ptr[0] & 0xf) << 28;
furi_string_printf( furi_string_printf(
dev_data->parsed_data, "\e#Troika\nNum: %lu\nBalance: %u rur.", number, balance); dev_data->parsed_data, "\e#Troika\nNum: %lu\nBalance: %u rur.", number, balance);

View File

@ -70,13 +70,14 @@ bool troika_parser_parse(NfcDeviceData* dev_data) {
// Parse data // Parse data
uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5]; uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5];
uint16_t balance = ((temp_ptr[0] << 8) | temp_ptr[1]) / 25; 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; uint32_t number = 0;
for(size_t i = 0; i < 4; i++) { for(size_t i = 1; i < 5; i++) {
number <<= 8; number <<= 8;
number |= temp_ptr[i]; number |= temp_ptr[i];
} }
number >>= 4; number >>= 4;
number |= (temp_ptr[0] & 0xf) << 28;
furi_string_printf( furi_string_printf(
dev_data->parsed_data, "\e#Troika\nNum: %lu\nBalance: %u rur.", number, balance); dev_data->parsed_data, "\e#Troika\nNum: %lu\nBalance: %u rur.", number, balance);