8
8
9
9
#define TAG "Metroflip:Scene:Navigo"
10
10
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 ) {
15
12
Metroflip * app = context ;
16
13
UNUSED (result );
17
14
@@ -46,7 +43,6 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
46
43
size_t response_length = 0 ;
47
44
48
45
do {
49
-
50
46
// Select app for contracts
51
47
select_app [6 ] = 32 ;
52
48
bit_buffer_reset (tx_buffer );
@@ -75,7 +71,6 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
75
71
break ;
76
72
}
77
73
78
-
79
74
// read file 1
80
75
read_file [2 ] = 1 ;
81
76
bit_buffer_reset (tx_buffer );
@@ -103,14 +98,13 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
103
98
app -> view_dispatcher , MetroflipCustomEventPollerFileNotFound );
104
99
break ;
105
100
}
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' ;
109
103
for (size_t i = 0 ; i < response_length ; i ++ ) {
110
- char bits [9 ];
104
+ char bits [9 ];
111
105
uint8_t byte = bit_buffer_get_byte (rx_buffer , i );
112
106
byte_to_binary (byte , bits );
113
- strcat (bit_representation , bits );
107
+ strcat (bit_representation , bits );
114
108
}
115
109
int start = 55 , end = 70 ;
116
110
float decimal_value = bit_slice_to_dec (bit_representation , start , end );
@@ -155,7 +149,6 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
155
149
break ;
156
150
}
157
151
158
-
159
152
// read file 1
160
153
read_file [2 ] = 1 ;
161
154
bit_buffer_reset (tx_buffer );
@@ -183,18 +176,19 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
183
176
app -> view_dispatcher , MetroflipCustomEventPollerFileNotFound );
184
177
break ;
185
178
}
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' ;
188
181
for (size_t i = 0 ; i < response_length ; i ++ ) {
189
- char bits [9 ];
182
+ char bits [9 ];
190
183
uint8_t byte = bit_buffer_get_byte (rx_buffer , i );
191
184
byte_to_binary (byte , bits );
192
- strcat (environment_bit_representation , bits );
185
+ strcat (environment_bit_representation , bits );
193
186
}
194
187
start = 45 ;
195
188
end = 58 ;
196
189
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 ;
198
192
DateTime end_dt = {0 };
199
193
datetime_timestamp_to_datetime (end_validity_timestamp , & end_dt );
200
194
furi_string_cat_printf (parsed_data , "\nEnd Validity:\n" );
@@ -260,29 +254,37 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
260
254
app -> view_dispatcher , MetroflipCustomEventPollerFileNotFound );
261
255
break ;
262
256
}
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' ;
266
259
for (size_t i = 0 ; i < response_length ; i ++ ) {
267
- char bits [9 ];
260
+ char bits [9 ];
268
261
uint8_t byte = bit_buffer_get_byte (rx_buffer , i );
269
262
byte_to_binary (byte , bits );
270
- strcat (event_bit_representation , bits );
263
+ strcat (event_bit_representation , bits );
271
264
}
272
265
furi_string_cat_printf (parsed_data , "\nEvent 0%d:\n" , i );
273
266
int start = 53 , end = 60 ;
274
267
int decimal_value = bit_slice_to_dec (event_bit_representation , start , end );
275
268
int transport_type = decimal_value >> 4 ;
276
269
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 ]);
278
275
start = 69 , end = 84 ;
279
276
decimal_value = bit_slice_to_dec (event_bit_representation , start , end );
280
277
int line_id = (decimal_value >> 9 ) - 1 ;
281
278
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 ]);
283
284
start = 61 , end = 68 ;
284
285
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 ]);
286
288
start = 0 , end = 13 ;
287
289
decimal_value = bit_slice_to_dec (event_bit_representation , start , end );
288
290
uint64_t date_timestamp = (decimal_value * 24 * 3600 ) + epoch + 3600 ;
@@ -292,27 +294,26 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
292
294
locale_format_datetime_cat (parsed_data , & dt , false);
293
295
start = 14 , end = 24 ;
294
296
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 ));
296
303
}
297
304
298
305
widget_add_text_scroll_element (
299
306
widget , 0 , 0 , 128 , 64 , furi_string_get_cstr (parsed_data ));
300
307
301
308
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 );
307
310
308
311
furi_string_free (parsed_data );
309
312
view_dispatcher_switch_to_view (app -> view_dispatcher , MetroflipViewWidget );
310
313
metroflip_app_blink_stop (app );
311
314
stage = MetroflipPollerEventTypeSuccess ;
312
315
next_command = NfcCommandStop ;
313
- } while (false);
314
-
315
-
316
+ } while (false);
316
317
317
318
if (stage != MetroflipPollerEventTypeSuccess ) {
318
319
next_command = NfcCommandStop ;
0 commit comments