Skip to content

Commit bca7894

Browse files
authored
Merge pull request #4 from luu176/dev
formating
2 parents d4ed0a3 + a6b9551 commit bca7894

8 files changed

+339
-214
lines changed

metroflip.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void locale_format_datetime_cat(FuriString* out, const DateTime* dt, bool time)
154154
const char* separator = (date_format == LocaleDateFormatDMY) ? "." : "/";
155155
locale_format_date(s, dt, date_format, separator);
156156
furi_string_cat(out, s);
157-
if (time) {
157+
if(time) {
158158
locale_format_time(s, dt, locale_get_time_format(), false);
159159
furi_string_cat_printf(out, " ");
160160
furi_string_cat(out, s);

metroflip_i.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22

33
#include <furi.h>
4+
#include <furi_hal.h>
5+
#include <stdlib.h>
46
#include <gui/gui.h>
57
#include <gui/view.h>
68
#include <gui/modules/validators.h>
@@ -34,7 +36,8 @@ extern const Icon I_RFIDDolphinReceive_97x61;
3436
#include <datetime.h>
3537
#include <dolphin/dolphin.h>
3638
#include <locale/locale.h>
37-
39+
#include <stdio.h>
40+
#include <string.h>
3841
#include <flipper_application/flipper_application.h>
3942
#include <loader/firmware_api/firmware_api.h>
4043

@@ -135,4 +138,4 @@ void byte_to_binary(uint8_t byte, char* bits);
135138

136139
int binary_to_decimal(const char binary[]);
137140

138-
int bit_slice_to_dec(const char* bit_representation, int start, int end);
141+
int bit_slice_to_dec(const char* bit_representation, int start, int end);

scenes/metroflip_scene_bip.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,4 +409,4 @@ void metroflip_scene_bip_on_exit(void* context) {
409409
popup_reset(app->popup);
410410

411411
metroflip_app_blink_stop(app);
412-
}
412+
}

scenes/metroflip_scene_charliecard.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1320,4 +1320,4 @@ void metroflip_scene_charliecard_on_exit(void* context) {
13201320
popup_reset(app->popup);
13211321

13221322
metroflip_app_blink_stop(app);
1323-
}
1323+
}

scenes/metroflip_scene_metromoney.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,4 @@ void metroflip_scene_metromoney_on_exit(void* context) {
197197
popup_reset(app->popup);
198198

199199
metroflip_app_blink_stop(app);
200-
}
200+
}

scenes/metroflip_scene_navigo.c

+35-34
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88

99
#define TAG "Metroflip:Scene:Navigo"
1010

11-
void metroflip_navigo_widget_callback(
12-
GuiButtonType result,
13-
InputType type,
14-
void* context) {
11+
void metroflip_navigo_widget_callback(GuiButtonType result, InputType type, void* context) {
1512
Metroflip* app = context;
1613
UNUSED(result);
1714

@@ -46,7 +43,6 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
4643
size_t response_length = 0;
4744

4845
do {
49-
5046
// Select app for contracts
5147
select_app[6] = 32;
5248
bit_buffer_reset(tx_buffer);
@@ -75,7 +71,6 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
7571
break;
7672
}
7773

78-
7974
// read file 1
8075
read_file[2] = 1;
8176
bit_buffer_reset(tx_buffer);
@@ -103,14 +98,13 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
10398
app->view_dispatcher, MetroflipCustomEventPollerFileNotFound);
10499
break;
105100
}
106-
char bit_representation
107-
[response_length * 8 + 1];
108-
bit_representation[0] = '\0';
101+
char bit_representation[response_length * 8 + 1];
102+
bit_representation[0] = '\0';
109103
for(size_t i = 0; i < response_length; i++) {
110-
char bits[9];
104+
char bits[9];
111105
uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
112106
byte_to_binary(byte, bits);
113-
strcat(bit_representation, bits);
107+
strcat(bit_representation, bits);
114108
}
115109
int start = 55, end = 70;
116110
float decimal_value = bit_slice_to_dec(bit_representation, start, end);
@@ -155,7 +149,6 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
155149
break;
156150
}
157151

158-
159152
// read file 1
160153
read_file[2] = 1;
161154
bit_buffer_reset(tx_buffer);
@@ -183,18 +176,19 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
183176
app->view_dispatcher, MetroflipCustomEventPollerFileNotFound);
184177
break;
185178
}
186-
char environment_bit_representation[response_length * 8 + 1];
187-
environment_bit_representation[0] = '\0';
179+
char environment_bit_representation[response_length * 8 + 1];
180+
environment_bit_representation[0] = '\0';
188181
for(size_t i = 0; i < response_length; i++) {
189-
char bits[9];
182+
char bits[9];
190183
uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
191184
byte_to_binary(byte, bits);
192-
strcat(environment_bit_representation, bits);
185+
strcat(environment_bit_representation, bits);
193186
}
194187
start = 45;
195188
end = 58;
196189
decimal_value = bit_slice_to_dec(environment_bit_representation, start, end);
197-
uint64_t end_validity_timestamp = (decimal_value * 24 * 3600) + (float)epoch + 3600;
190+
uint64_t end_validity_timestamp =
191+
(decimal_value * 24 * 3600) + (float)epoch + 3600;
198192
DateTime end_dt = {0};
199193
datetime_timestamp_to_datetime(end_validity_timestamp, &end_dt);
200194
furi_string_cat_printf(parsed_data, "\nEnd Validity:\n");
@@ -260,29 +254,37 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
260254
app->view_dispatcher, MetroflipCustomEventPollerFileNotFound);
261255
break;
262256
}
263-
char event_bit_representation
264-
[response_length * 8 + 1];
265-
event_bit_representation[0] = '\0';
257+
char event_bit_representation[response_length * 8 + 1];
258+
event_bit_representation[0] = '\0';
266259
for(size_t i = 0; i < response_length; i++) {
267-
char bits[9];
260+
char bits[9];
268261
uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
269262
byte_to_binary(byte, bits);
270-
strcat(event_bit_representation, bits);
263+
strcat(event_bit_representation, bits);
271264
}
272265
furi_string_cat_printf(parsed_data, "\nEvent 0%d:\n", i);
273266
int start = 53, end = 60;
274267
int decimal_value = bit_slice_to_dec(event_bit_representation, start, end);
275268
int transport_type = decimal_value >> 4;
276269
int transition = decimal_value & 15;
277-
furi_string_cat_printf(parsed_data, "%s - %s\n", TRANSPORT_LIST[transport_type], TRANSITION_LIST[transition]);
270+
furi_string_cat_printf(
271+
parsed_data,
272+
"%s - %s\n",
273+
TRANSPORT_LIST[transport_type],
274+
TRANSITION_LIST[transition]);
278275
start = 69, end = 84;
279276
decimal_value = bit_slice_to_dec(event_bit_representation, start, end);
280277
int line_id = (decimal_value >> 9) - 1;
281278
int station_id = ((decimal_value >> 4) & 31) - 1;
282-
furi_string_cat_printf(parsed_data, "Line: %s\nStation: %s\n", METRO_LIST[line_id].name, METRO_LIST[line_id].stations[station_id]);
279+
furi_string_cat_printf(
280+
parsed_data,
281+
"Line: %s\nStation: %s\n",
282+
METRO_LIST[line_id].name,
283+
METRO_LIST[line_id].stations[station_id]);
283284
start = 61, end = 68;
284285
decimal_value = bit_slice_to_dec(event_bit_representation, start, end);
285-
furi_string_cat_printf(parsed_data, "Provider: %s\n", SERVICE_PROVIDERS[decimal_value]);
286+
furi_string_cat_printf(
287+
parsed_data, "Provider: %s\n", SERVICE_PROVIDERS[decimal_value]);
286288
start = 0, end = 13;
287289
decimal_value = bit_slice_to_dec(event_bit_representation, start, end);
288290
uint64_t date_timestamp = (decimal_value * 24 * 3600) + epoch + 3600;
@@ -292,27 +294,26 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
292294
locale_format_datetime_cat(parsed_data, &dt, false);
293295
start = 14, end = 24;
294296
decimal_value = bit_slice_to_dec(event_bit_representation, start, end);
295-
furi_string_cat_printf(parsed_data, " %02d:%02d:%02d\n\n", ((decimal_value*60) / 3600), (((decimal_value*60) % 3600)/60), (((decimal_value*60) % 3600)%60));
297+
furi_string_cat_printf(
298+
parsed_data,
299+
" %02d:%02d:%02d\n\n",
300+
((decimal_value * 60) / 3600),
301+
(((decimal_value * 60) % 3600) / 60),
302+
(((decimal_value * 60) % 3600) % 60));
296303
}
297304

298305
widget_add_text_scroll_element(
299306
widget, 0, 0, 128, 64, furi_string_get_cstr(parsed_data));
300307

301308
widget_add_button_element(
302-
widget,
303-
GuiButtonTypeRight,
304-
"Exit",
305-
metroflip_navigo_widget_callback,
306-
app);
309+
widget, GuiButtonTypeRight, "Exit", metroflip_navigo_widget_callback, app);
307310

308311
furi_string_free(parsed_data);
309312
view_dispatcher_switch_to_view(app->view_dispatcher, MetroflipViewWidget);
310313
metroflip_app_blink_stop(app);
311314
stage = MetroflipPollerEventTypeSuccess;
312315
next_command = NfcCommandStop;
313-
} while(false);
314-
315-
316+
} while(false);
316317

317318
if(stage != MetroflipPollerEventTypeSuccess) {
318319
next_command = NfcCommandStop;

scenes/metroflip_scene_ravkav.c

+11-18
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
#define TAG "Metroflip:Scene:RavKav"
66

7-
void metroflip_ravkav_widget_callback(
8-
GuiButtonType result,
9-
InputType type,
10-
void* context) {
7+
void metroflip_ravkav_widget_callback(GuiButtonType result, InputType type, void* context) {
118
Metroflip* app = context;
129
UNUSED(result);
1310

@@ -70,6 +67,7 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
7067
}
7168

7269
// Now send the read command
70+
read_file[2] = 1;
7371
bit_buffer_reset(tx_buffer);
7472
bit_buffer_append_bytes(tx_buffer, read_file, sizeof(read_file));
7573
error = iso14443_4b_poller_send_block(iso14443_4b_poller, tx_buffer, rx_buffer);
@@ -146,7 +144,7 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
146144
app->view_dispatcher, MetroflipCustomEventPollerFileNotFound);
147145
break;
148146
}
149-
147+
read_file[2] = 1;
150148
bit_buffer_reset(tx_buffer);
151149
bit_buffer_append_bytes(tx_buffer, read_file, sizeof(read_file));
152150
error = iso14443_4b_poller_send_block(iso14443_4b_poller, tx_buffer, rx_buffer);
@@ -172,14 +170,13 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
172170
app->view_dispatcher, MetroflipCustomEventPollerFileNotFound);
173171
break;
174172
}
175-
char bit_representation
176-
[response_length * 8 + 1]; // Total bits in the response (each byte = 8 bits)
177-
bit_representation[0] = '\0'; // Initialize the string to empty
173+
char bit_representation[response_length * 8 + 1];
174+
bit_representation[0] = '\0';
178175
for(size_t i = 0; i < response_length; i++) {
179-
char bits[9]; // Temporary string for each byte (8 bits + null terminator)
176+
char bits[9];
180177
uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
181178
byte_to_binary(byte, bits);
182-
strcat(bit_representation, bits); // Append binary string to the result
179+
strcat(bit_representation, bits);
183180
}
184181
int start = 54, end = 83;
185182
char bit_slice[end - start + 1];
@@ -253,12 +250,12 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
253250
}
254251
char bit_representation
255252
[response_length * 8 + 1]; // Total bits in the response (each byte = 8 bits)
256-
bit_representation[0] = '\0'; // Initialize the string to empty
253+
bit_representation[0] = '\0';
257254
for(size_t i = 0; i < response_length; i++) {
258-
char bits[9]; // Temporary string for each byte (8 bits + null terminator)
255+
char bits[9];
259256
uint8_t byte = bit_buffer_get_byte(rx_buffer, i);
260257
byte_to_binary(byte, bits);
261-
strcat(bit_representation, bits); // Append binary string to the result
258+
strcat(bit_representation, bits);
262259
}
263260
int start = 23, end = 52;
264261
char bit_slice[end - start + 2];
@@ -277,11 +274,7 @@ static NfcCommand metroflip_scene_ravkav_poller_callback(NfcGenericEvent event,
277274
widget, 0, 0, 128, 64, furi_string_get_cstr(parsed_data));
278275

279276
widget_add_button_element(
280-
widget,
281-
GuiButtonTypeRight,
282-
"Exit",
283-
metroflip_ravkav_widget_callback,
284-
app);
277+
widget, GuiButtonTypeRight, "Exit", metroflip_ravkav_widget_callback, app);
285278

286279
furi_string_free(parsed_data);
287280
view_dispatcher_switch_to_view(app->view_dispatcher, MetroflipViewWidget);

0 commit comments

Comments
 (0)