From 6a34f2b55166cd395e21916283a299897b29806c Mon Sep 17 00:00:00 2001 From: acegoal07 Date: Tue, 12 Dec 2023 16:19:06 +0000 Subject: [PATCH] Name changes --- application.fam | 2 +- nfc_playlist.c | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/application.fam b/application.fam index 43ac1b7f7b7..6b9f8926d24 100644 --- a/application.fam +++ b/application.fam @@ -1,6 +1,6 @@ App( appid="nfc_playlist", - name="nfc playlist", + name="NFC Playlist", apptype=FlipperAppType.EXTERNAL, entry_point="nfc_playlist_main", requires=["gui", "nfx"], diff --git a/nfc_playlist.c b/nfc_playlist.c index 90f1a5e61b4..604eb55c3c0 100644 --- a/nfc_playlist.c +++ b/nfc_playlist.c @@ -27,26 +27,29 @@ int32_t nfc_playlist_main(void* p) { Storage* storage = furi_record_open(RECORD_STORAGE); Stream* stream = file_stream_alloc(storage); FuriString* line = furi_string_alloc(); - NfcDevice* nfcDevice = nfc_device_alloc(); - Nfc* nfc = nfc_alloc(); // Read file if(file_stream_open(stream, APP_DATA_PATH("playlistTest.txt"), FSAM_READ, FSOM_OPEN_EXISTING)) { + + // Get resources + NfcDevice* nfc_device = nfc_device_alloc(); + Nfc* nfc = nfc_alloc(); + while(stream_read_line(stream, line)) { // Store file location - const char* fileLocation = strcat("/ext/nfc/",furi_string_get_cstr(line)); + const char* fileLocation = strcat("/ext/nfc/", furi_string_get_cstr(line)); // Load file - if (nfc_device_load(nfcDevice, fileLocation)) { + if (nfc_device_load(nfc_device, fileLocation)) { if (DEBUG) {FURI_LOG_I(TAG, "Loaded file");} // Get protocol - const NfcProtocol protocol = nfc_device_get_protocol(nfcDevice); + const NfcProtocol nfc_protocol = nfc_device_get_protocol(nfc_device); // Get listern - NfcListener* mfu_listener = nfc_listener_alloc(nfc, protocol, nfc_device_get_data(nfcDevice, protocol)); + NfcListener* listener = nfc_listener_alloc(nfc, nfc_protocol, nfc_device_get_data(nfc_device, nfc_protocol)); // Start listener - nfc_listener_start(mfu_listener, NULL, NULL); + nfc_listener_start(listener, NULL, NULL); // Worst timer ever int counter = 0; @@ -59,8 +62,8 @@ int32_t nfc_playlist_main(void* p) { } // Stop listener && free - nfc_listener_stop(mfu_listener); - nfc_listener_free(mfu_listener); + nfc_listener_stop(listener); + nfc_listener_free(listener); } else { if (DEBUG) {FURI_LOG_E(TAG, "Failed to load file");} @@ -68,8 +71,13 @@ int32_t nfc_playlist_main(void* p) { // output file location if (DEBUG) {FURI_LOG_I(TAG, "%s", fileLocation);} // clear instance - nfc_device_clear(nfcDevice); + nfc_device_clear(nfc_device); } + + // Free/close resources + nfc_device_free(nfc_device); + nfc_free(nfc); + } else { if (DEBUG) {FURI_LOG_E(TAG, "Failed to open file");} } @@ -78,8 +86,6 @@ int32_t nfc_playlist_main(void* p) { furi_string_free(line); file_stream_close(stream); stream_free(stream); - nfc_device_free(nfcDevice); - nfc_free(nfc); // Close storage furi_record_close(RECORD_STORAGE);