@@ -32,7 +32,7 @@ typedef struct {
3232 ViewDispatcher * view_dispatcher ;
3333 Submenu * menu ;
3434 Popup * popup ;
35- NfcPlaylistWorker * nfc_worker ;
35+ int emulate_timeout ;
3636} NfcPlaylist ;
3737
3838/** all custom events */
@@ -43,8 +43,6 @@ typedef enum { NfcPlaylistEvent_ShowPopupOne } NfcPlaylistEvent;
4343/** indices for menu items */
4444typedef enum { NfcPlaylistMenuSelection_One } NfcPlaylistMenuSelection ;
4545
46- int emulate_timeout = 2000 ;
47-
4846/** main menu callback - sends a custom event to the scene manager based on the menu selection */
4947void nfc_playlist_menu_callback_main_menu (void * context , uint32_t index ) {
5048 FURI_LOG_T (TAG , "nfc_playlist_menu_callback_main_menu" );
@@ -61,6 +59,7 @@ void nfc_playlist_scene_on_enter_main_menu(void* context) {
6159 FURI_LOG_T (TAG , "nfc_playlist_scene_on_enter_main_menu" );
6260 NfcPlaylist * app = context ;
6361 submenu_reset (app -> menu );
62+ submenu_set_header (app -> menu , "NFC Playlist" );
6463 submenu_add_item (
6564 app -> menu ,
6665 "Start" ,
@@ -108,7 +107,6 @@ void nfc_playlist_scene_on_enter_popup_emulating(void* context) {
108107 Stream * stream = file_stream_alloc (storage );
109108 FuriString * line = furi_string_alloc ();
110109 NfcPlaylistWorker * nfc_worker = nfc_playlist_worker_alloc ();
111- app -> nfc_worker = nfc_worker ;
112110 // Read file
113111 if (file_stream_open (stream , APP_DATA_PATH ("playlist.txt" ), FSAM_READ , FSOM_OPEN_EXISTING )) {
114112 popup_reset (app -> popup );
@@ -122,10 +120,10 @@ void nfc_playlist_scene_on_enter_popup_emulating(void* context) {
122120 popup_set_text (app -> popup , str , 64 , 30 , AlignCenter , AlignTop );
123121 view_dispatcher_switch_to_view (app -> view_dispatcher , NfcPlaylistView_Popup );
124122
125- nfc_playlist_worker_set_nfc_data (nfc_worker , ( char * ) furi_string_get_cstr ( line ) );
123+ nfc_playlist_worker_set_nfc_data (nfc_worker , str );
126124 nfc_playlist_worker_start (nfc_worker );
127125
128- furi_delay_ms (emulate_timeout );
126+ furi_delay_ms (app -> emulate_timeout );
129127
130128 nfc_playlist_worker_stop (nfc_worker );
131129 furi_string_reset (line );
@@ -138,6 +136,7 @@ void nfc_playlist_scene_on_enter_popup_emulating(void* context) {
138136 furi_string_free (line );
139137 file_stream_close (stream );
140138 stream_free (stream );
139+ nfc_playlist_worker_free (nfc_worker );
141140 // Close storage
142141 furi_record_close (RECORD_STORAGE );
143142
@@ -277,6 +276,8 @@ int32_t nfc_playlist_main(void* p) {
277276 FURI_LOG_D (TAG , "Starting dispatcher..." );
278277 view_dispatcher_run (app -> view_dispatcher );
279278
279+ app -> emulate_timeout = 2000 ;
280+
280281 // free all memory
281282 FURI_LOG_I (TAG , "Test app finishing..." );
282283 furi_record_close (RECORD_GUI );
0 commit comments