Luu hai 1 ano
pai
achega
4ec674bf01
Modificáronse 2 ficheiros con 13 adicións e 19 borrados
  1. 6 9
      scenes/metroflip_scene_navigo.c
  2. 7 10
      scenes/metroflip_scene_ravkav.c

+ 6 - 9
scenes/metroflip_scene_navigo.c

@@ -104,9 +104,7 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
                     char bits[9];
                     uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
                     byte_to_binary(byte, bits);
-                    for(int j = 0; j < 8; j++) {
-                        bit_representation[i * 8 + j] = bits[j];
-                    }
+                    strlcat(bit_representation, bits, sizeof(bit_representation));
                 }
                 bit_representation[response_length * 8] = '\0';
                 int start = 55, end = 70;
@@ -185,9 +183,10 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
                     char bits[9];
                     uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
                     byte_to_binary(byte, bits);
-                    for(int j = 0; j < 8; j++) {
-                        environment_bit_representation[i * 8 + j] = bits[j];
-                    }
+                    strlcat(
+                        environment_bit_representation,
+                        bits,
+                        sizeof(environment_bit_representation));
                 }
                 start = 45;
                 end = 58;
@@ -265,9 +264,7 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
                         char bits[9];
                         uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
                         byte_to_binary(byte, bits);
-                        for(int j = 0; j < 8; j++) {
-                            event_bit_representation[i * 8 + j] = bits[j];
-                        }
+                        strlcat(event_bit_representation, bits, sizeof(event_bit_representation));
                     }
                     furi_string_cat_printf(parsed_data, "\nEvent 0%d:\n", i);
                     int start = 53, end = 60;

+ 7 - 10
scenes/metroflip_scene_ravkav.c

@@ -110,7 +110,8 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
 
                 float result = value / 100.0f;
                 FURI_LOG_I(TAG, "Value: %.2f ILS", (double)result);
-                furi_string_printf(parsed_data, "\e#Rav-Kav:\n");
+                furi_string_printf(parsed_data, "\e#Rav-Kav:\n\n");
+                furi_string_cat_printf(parsed_data, "\e#Contract:\n");
                 if(result != 0.0f) {
                     furi_string_cat_printf(parsed_data, "Balance: %.2f ILS\n", (double)result);
                 } else {
@@ -176,9 +177,7 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
                     char bits[9];
                     uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
                     byte_to_binary(byte, bits);
-                    for(int j = 0; j < 8; j++) {
-                        bit_representation[i * 8 + j] = bits[j];
-                    }
+                    strlcat(bit_representation, bits, sizeof(bit_representation));
                 }
                 int start = 54, end = 83;
                 char bit_slice[end - start + 1];
@@ -219,9 +218,9 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
                         app->view_dispatcher, MetroflipCustomEventPollerFileNotFound);
                     break;
                 }
-
+                furi_string_cat_printf(parsed_data, "\e#Latest Events:\n");
                 // Now send the read command
-                for(size_t i = 1; i < 7; i++) {
+                for(size_t i = 1, j = 6; i < 7 && j > 0; i++, j--) {
                     read_file[2] = i;
                     bit_buffer_reset(tx_buffer);
                     bit_buffer_append_bytes(tx_buffer, read_file, sizeof(read_file));
@@ -256,9 +255,7 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
                         char bits[9];
                         uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
                         byte_to_binary(byte, bits);
-                        for(int j = 0; j < 8; j++) {
-                            bit_representation[i * 8 + j] = bits[j];
-                        }
+                        strlcat(bit_representation, bits, sizeof(bit_representation));
                     }
                     int start = 23, end = 52;
                     char bit_slice[end - start + 2];
@@ -268,7 +265,7 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
                     uint64_t result_timestamp = decimal_value + epoch + (3600 * 3);
                     DateTime dt = {0};
                     datetime_timestamp_to_datetime(result_timestamp, &dt);
-                    furi_string_cat_printf(parsed_data, "\nEvent 0%d:\n", i);
+                    furi_string_cat_printf(parsed_data, "\nEvent 0%d:\n", j);
                     locale_format_datetime_cat(parsed_data, &dt, true);
                     furi_string_cat_printf(parsed_data, "\n\n");
                 }