Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
5a1c228
Moved NfcMode to a separate header
RebornedBrain Nov 7, 2024
95961b5
Raw logger implementation added
RebornedBrain Nov 7, 2024
d8e079e
nfc_logger_config is now responsible for setting up logger params
RebornedBrain Nov 8, 2024
1acfea3
New function for free logger thread and queue
RebornedBrain Nov 8, 2024
3c82e3b
New disabled state added in order to turn off logger when there is no…
RebornedBrain Nov 8, 2024
6359104
Files moved to another folder and also some parts were split
RebornedBrain Nov 11, 2024
28defcf
Adjusted list_alloc function to return protocols count, created durin…
RebornedBrain Nov 11, 2024
e9b6a94
Added logger history and some iso14 history flags
RebornedBrain Nov 12, 2024
61a2f06
Now iso14 logs its history
RebornedBrain Nov 12, 2024
80317ef
Add logger to nfc instance
RebornedBrain Nov 12, 2024
6d0568f
Added raw implementation of table printable to FuriString
RebornedBrain Nov 15, 2024
2f975c7
logger now saved nfc_events
RebornedBrain Nov 15, 2024
3f3eedd
Read and format functions added to transaction
RebornedBrain Nov 15, 2024
9f868a5
Hal flags added
RebornedBrain Nov 15, 2024
d4bca6f
api changes
RebornedBrain Nov 15, 2024
a78d098
Logger raw load-save-convert logic added
RebornedBrain Nov 15, 2024
40445d8
Alignment for table columns added
RebornedBrain Nov 19, 2024
1a183ae
Now table can format data to make it fit column width
RebornedBrain Nov 19, 2024
43b95bc
Table cleanup
RebornedBrain Nov 19, 2024
a8a3b95
Logger types renamed to logger flags
RebornedBrain Nov 20, 2024
021350c
History module introduced
RebornedBrain Nov 20, 2024
0b71c50
Transaction format logic introduced
RebornedBrain Nov 20, 2024
37d7966
Logger convert bin to text logic added, but still WIP
RebornedBrain Nov 20, 2024
3a301b7
Function for removing LOG files added
RebornedBrain Nov 20, 2024
a6d64a6
Removed old unused code
RebornedBrain Nov 20, 2024
9c5eed9
History save logic reworked
RebornedBrain Nov 21, 2024
5947f15
Added log_history callback to listener's base
RebornedBrain Nov 21, 2024
eb64be4
Some renamings
RebornedBrain Nov 21, 2024
2271d02
Added logic for processing listener history
RebornedBrain Nov 21, 2024
eb3fb2f
iso14 and ultralight both collect logs now
RebornedBrain Nov 21, 2024
0914399
History load and CRC format logic done
RebornedBrain Nov 22, 2024
ad3f038
Some adjustments to logger module
RebornedBrain Nov 22, 2024
4d448e3
Now transaction loads history and formats crc
RebornedBrain Nov 22, 2024
60674d7
Temporary solution for formatting pack payload with crc outline
RebornedBrain Nov 22, 2024
893620f
Some MfUltralight flags added
RebornedBrain Nov 22, 2024
eea8f19
Transaction begin/end is now placed properly in nfc_worker_listener
RebornedBrain Nov 22, 2024
bfcd008
Now protocol will be setup separately before logger start
RebornedBrain Nov 22, 2024
10763f1
Removed garbage left after bad commit
RebornedBrain Nov 22, 2024
dab64e7
Extended nfc_protocol api with new functions
RebornedBrain Nov 22, 2024
06f12fd
Now logger formats protocol list hierarchy as legend for annotation
RebornedBrain Nov 22, 2024
8e539d9
Some logger cleanups
RebornedBrain Nov 22, 2024
2f49d1d
Added nfc flag and annotation formatting
RebornedBrain Nov 28, 2024
cd16623
Annotation column width increased
RebornedBrain Nov 28, 2024
5560af1
History and transaction filters added
RebornedBrain Nov 28, 2024
762971a
New callback definition for log history function
RebornedBrain Dec 1, 2024
160faed
Added callback for mfu and iso14 pollers
RebornedBrain Dec 1, 2024
0479028
Now poller uses logger
RebornedBrain Dec 1, 2024
65b4527
iso14 and mfu pollers now log their flags
RebornedBrain Dec 1, 2024
70a172e
Free function now nulls ptrs
RebornedBrain Dec 1, 2024
f9c5faf
History data formatter base type declared
RebornedBrain Dec 3, 2024
0f9fd5f
Basic logic for data formatter and iso14443_3a and mfu formatters added
RebornedBrain Dec 3, 2024
425f3aa
File structure adjusted
RebornedBrain Dec 3, 2024
8dcf566
Adjustments to logger levels due to new history logic
RebornedBrain Dec 3, 2024
71d4a9c
New history data types added to mfu and iso14_3a listeners
RebornedBrain Dec 3, 2024
dda59d5
iso14_3a and mfu listeners now store history data in a new way
RebornedBrain Dec 3, 2024
c588c00
Moved file structure data types to separate headers
RebornedBrain Dec 4, 2024
bfc94ff
Formatter is now responsible for all formatting operations within all…
RebornedBrain Dec 4, 2024
d695820
Transaction string data type and functions moved to a separate module
RebornedBrain Dec 4, 2024
3922ad7
New file structure and logic for formatters added
RebornedBrain Dec 5, 2024
8e166cb
mfu and iso14_3a pollers now collect their history
RebornedBrain Dec 5, 2024
b1946c5
Revert "Adjusted list_alloc function to return protocols count, creat…
RebornedBrain Dec 5, 2024
f710a52
Table module moved closer to formatter
RebornedBrain Dec 5, 2024
bbb1145
History files renamed and history size calculation logic moved to sep…
RebornedBrain Dec 5, 2024
22994f1
Nfc flags are now completely removed
RebornedBrain Dec 5, 2024
1f3f124
nfc_hal_formatter now parses events from nfc layer
RebornedBrain Dec 5, 2024
4307c77
Logger api adjustments
RebornedBrain Dec 5, 2024
bd2b4df
History chain data types are now in a separate header
RebornedBrain Dec 5, 2024
04236a9
Forgotten function call commit
RebornedBrain Dec 5, 2024
982affa
Now logger thread will exit only when logger queue is empty
RebornedBrain Dec 6, 2024
5c6b210
Queue size temporary increased
RebornedBrain Dec 6, 2024
e54335c
Some temp adjustements to nfc_formatter
RebornedBrain Dec 6, 2024
5137ff3
Felica logging is now supported
RebornedBrain Dec 6, 2024
b3f17de
Changed logger file structure in order to reduce public api function …
RebornedBrain Dec 6, 2024
6309c55
New header included to modules which uses logger as opaque object
RebornedBrain Dec 6, 2024
6ca58d2
New api symbols for logger
RebornedBrain Dec 6, 2024
767bbe5
Modified listener to use new log history callback in chain manner rat…
RebornedBrain Dec 9, 2024
c69476e
Listeners now use new log callback function
RebornedBrain Dec 9, 2024
dfb8a2f
Modified poller to use new log history callback in chain manner rathe…
RebornedBrain Dec 9, 2024
8dd30a3
Pollers now use new log callback function
RebornedBrain Dec 9, 2024
e3eb799
iso14443_3b now saves history
RebornedBrain Dec 9, 2024
3951fd2
iso14443_4a now saves history
RebornedBrain Dec 9, 2024
93e2dcc
iso14443_4b now saves history
RebornedBrain Dec 9, 2024
e8934a1
Iso15693_3 now saves history
RebornedBrain Dec 9, 2024
1d0a710
Desfire now saves history
RebornedBrain Dec 9, 2024
1d6523d
MfPlus now saves history
RebornedBrain Dec 9, 2024
a1feea3
Slix now saves history
RebornedBrain Dec 9, 2024
0f1a103
St25tb now saves history
RebornedBrain Dec 9, 2024
e58b8ba
Modified slix listener to save history
RebornedBrain Dec 9, 2024
07f6f78
All history data structures sizes added
RebornedBrain Dec 9, 2024
4fc9c7f
Time measurement logic based on DWT added to logger
RebornedBrain Dec 12, 2024
70983f4
Now transaction saves both start and end time
RebornedBrain Dec 12, 2024
800be88
Logger provides time for transaction through new logic
RebornedBrain Dec 12, 2024
d6c4cf0
Formatter adjustements according to new time logic
RebornedBrain Dec 12, 2024
800a472
Now logger uses stream for both save and load operations
RebornedBrain Dec 12, 2024
d472a55
Save logic now has size checks
RebornedBrain Dec 12, 2024
c652b1e
Includes cleanup
RebornedBrain Dec 12, 2024
ab55dc4
Transaction functions naming adjustments
RebornedBrain Dec 12, 2024
74fc81c
Now transaction module doesn't have access to history internals
RebornedBrain Dec 12, 2024
90ef1bc
Log folder path changed to "nfc/log"
RebornedBrain Dec 12, 2024
a64b79c
Formatter moved to plugin
RebornedBrain Dec 16, 2024
81d2cb8
All formatters moved to one directory due to compilation issues
RebornedBrain Dec 17, 2024
dfac0a2
Transaction logic moved to transaction folder
RebornedBrain Dec 17, 2024
7a58d06
Public data type files renamed
RebornedBrain Dec 17, 2024
79e5f3e
All protocols now have separate header with public history data struc…
RebornedBrain Dec 17, 2024
cb367de
Lib part adjusted to be used by plugin
RebornedBrain Dec 17, 2024
6147cf0
nfc lib script adjusted
RebornedBrain Dec 17, 2024
946eae4
Logger formatter plugin adjusted
RebornedBrain Dec 17, 2024
65089c9
Some formatter modules moved to helpers folder
RebornedBrain Dec 17, 2024
0b21f31
Log folder is now set via config function
RebornedBrain Dec 18, 2024
9d688d1
NfcLoggerState moved to internal header
RebornedBrain Dec 18, 2024
e1edb9e
Filter enums removed from library to plugin
RebornedBrain Dec 18, 2024
de62e49
Formatter plugin now gets latest log file name from library logger
RebornedBrain Dec 18, 2024
a32b272
Path to logs folder added to nfc app
RebornedBrain Dec 18, 2024
d0a246d
Logger on/off logic added to debug scene
RebornedBrain Dec 18, 2024
3b900f4
Logger function calls added to app logic
RebornedBrain Dec 18, 2024
a1d7187
Formatter config added to app and plugin
RebornedBrain Dec 18, 2024
c1ad5ec
Transaction filter now works
RebornedBrain Dec 18, 2024
db7c9e6
Format function replaced to string array
RebornedBrain Dec 18, 2024
9e1f27a
History protocol filter now works
RebornedBrain Dec 18, 2024
71cf939
NfcHistoryItemInternal is now available only within nfc_history.c file
RebornedBrain Dec 18, 2024
f6e72e0
Api adjusted
RebornedBrain Dec 18, 2024
2eb042e
Now nfc_hal formatter can parse NfcCommand values
RebornedBrain Dec 18, 2024
e7d81ad
Additional transaction creation and history append logic
RebornedBrain Dec 19, 2024
3439009
Fixed wrong rx buffer for felica
RebornedBrain Dec 19, 2024
2a39e70
iso14443_3a additional activation history save logic added
RebornedBrain Dec 19, 2024
ea8bd0a
Iso15 poller now saves payload and history
RebornedBrain Dec 19, 2024
b312adf
Iso15 poller formatter added and also some formatter adjustements
RebornedBrain Dec 19, 2024
9da9a60
Temporary disabled logging during dict attack
RebornedBrain Dec 19, 2024
49f66e2
Added check for zero data_size to append data functions
RebornedBrain Dec 20, 2024
7fb7a9e
iso15 listener formatter added and poller adjusted
RebornedBrain Dec 20, 2024
934bce3
Slix formatting added
RebornedBrain Dec 20, 2024
649ba04
st25tb poller now saves history and payload
RebornedBrain Dec 23, 2024
92be6da
st25tb formatter added
RebornedBrain Dec 23, 2024
c5b8efc
iso14443_3b poller saves activation history
RebornedBrain Dec 23, 2024
c14270f
iso14443_3b poller data formatter added
RebornedBrain Dec 23, 2024
4aeb09d
iso14443_4b poller data formatter added
RebornedBrain Dec 23, 2024
64376d4
st25tb formatter fix
RebornedBrain Dec 23, 2024
c131d2c
iso14443_4a formatter added
RebornedBrain Dec 23, 2024
00f5dd6
MfPlus formatter added
RebornedBrain Dec 23, 2024
558edaa
iso14443_4a listener data formatter added
RebornedBrain Dec 23, 2024
554ab3b
Added all new formatters to the collections
RebornedBrain Dec 23, 2024
f3f82c3
Desfire poller history saving logic adjusted
RebornedBrain Dec 24, 2024
8d64305
Desfire formatter added
RebornedBrain Dec 24, 2024
ed23a06
Moved all formatters to protocol specific folders
RebornedBrain Dec 24, 2024
39c3a41
Fixed some include mismatches
RebornedBrain Jan 13, 2025
d82cc0c
More include mistakes fixed
RebornedBrain Jan 15, 2025
b60eb0e
All files are now included excplicitly due to some constraints from b…
RebornedBrain Jan 15, 2025
b7f48b6
Simplified history filter mode added
RebornedBrain Jan 15, 2025
fbe5d7f
New history formatting logic with simplified option
RebornedBrain Jan 16, 2025
c6e3d58
Thread and queue alloc/free are now done in appropriate way to avoid …
RebornedBrain Jan 17, 2025
c0bb55c
Now trace will be freed each time when logger stops
RebornedBrain Jan 17, 2025
d4d4d15
Missing history for some MFU commands were fixed
RebornedBrain Jan 20, 2025
244b3d6
Logger is now able to save entry log_callback and its poller context …
RebornedBrain Jan 22, 2025
acbae3c
Poller provides its log callback to logger with context and doesn't t…
RebornedBrain Jan 22, 2025
8d69995
Logger triggers log_callback before transaction ends, but does this o…
RebornedBrain Jan 22, 2025
b0d78d8
Added a temporary flag which indicates that history of this protocol …
RebornedBrain Jan 22, 2025
2865513
Log saving logic of all pollers is now done with new modified flag
RebornedBrain Jan 22, 2025
a3ec7ae
State names added for SLIX poller
RebornedBrain Jan 22, 2025
2d63409
Merge branch 'reborned/nfc_logger_plugin' into nfc_logger_poller_hist…
RebornedBrain Jan 22, 2025
08bb91b
Now logger appends history only if item was modified
RebornedBrain Jan 22, 2025
269fcb1
Modified all pollers to follow new logic
RebornedBrain Jan 22, 2025
b0013b9
Listeners modified for new history append logic
RebornedBrain Jan 22, 2025
c15eb2e
Felica formatter string adjusted
RebornedBrain Jan 22, 2025
919b527
Poller formatter string adjusted
RebornedBrain Jan 22, 2025
ea5fb16
Now logger saves listener's response after it has been transmitted
RebornedBrain Jan 24, 2025
bcde6a7
Fix NULL exception
RebornedBrain Jan 24, 2025
b8e760c
Added decrypt callback and appropriate api to protocol formatters
RebornedBrain Jan 31, 2025
d891d88
Formatter plugin is now able to decrypt saved encrypted transactions …
RebornedBrain Jan 31, 2025
b43f0d2
Added formatter for mf_classic listener
RebornedBrain Jan 31, 2025
87743b6
Moved some typedefs to public namespace
RebornedBrain Jan 31, 2025
457e3ca
Added history data for mf_classic listener
RebornedBrain Jan 31, 2025
ea9f9d0
mf_classic_listener now logs its data and history
RebornedBrain Jan 31, 2025
00c89ca
Transaction incapsulation fixed with proper includes
RebornedBrain Feb 3, 2025
6d092b3
Flag added for skipping empty transactions in case of classics
RebornedBrain Feb 3, 2025
ee5c2d8
Added a function for refreshing empty transaction data
RebornedBrain Feb 3, 2025
b1716ba
Now in case of MfClassic, empty transaction will be skipped and not p…
RebornedBrain Feb 3, 2025
60f3b4c
Moved some enums to public namespace for logger
RebornedBrain Feb 6, 2025
cc07669
Poller history data struct added
RebornedBrain Feb 6, 2025
698471a
iso14443_3a poller appends payloads during custom scenarios used by m…
RebornedBrain Feb 6, 2025
04b6e03
Now mf_classic poller saves its history during card reading
RebornedBrain Feb 6, 2025
62521da
mf_classic formatter for poller added to plugin
RebornedBrain Feb 6, 2025
217c7a6
transaction allocation logic adjusted, get_size function added
RebornedBrain Feb 7, 2025
b1dcf3c
Now logger monitors free memory and waits until there will be enough …
RebornedBrain Feb 7, 2025
8483135
New file search funtion, will return first .bin which doesn't have sa…
RebornedBrain Feb 7, 2025
8dbbb44
log folder will not be cleared on each start anymore
RebornedBrain Feb 7, 2025
930d933
Chain count reduced to 2
RebornedBrain Feb 7, 2025
ceb7f8f
Logger thread stack reduced
RebornedBrain Feb 7, 2025
8551c0e
Now formatter will format all new .bin log files, not only the last one
RebornedBrain Feb 7, 2025
3864a4c
Now formatting performed at success screen
RebornedBrain Feb 7, 2025
ed3ace7
Raw poller crc check function implemented
RebornedBrain Feb 8, 2025
4d3d7a9
Now logger has trace_count which is appended to filename in order to …
RebornedBrain Feb 11, 2025
47c3a91
Some log messages added, some removed
RebornedBrain Feb 11, 2025
49f9583
Now plugin scanner will skip all except _parser.fal files in folder
RebornedBrain Feb 11, 2025
5c45c06
Added a dummy implementation of simplified formatting callback
RebornedBrain Feb 11, 2025
c4ed779
Some cleanup
RebornedBrain Feb 11, 2025
9968736
Added debug buttons related to logger
RebornedBrain Feb 11, 2025
7c16ddb
Removed unnesecary log messages from protocol formatters
RebornedBrain Feb 11, 2025
f468134
Merge branch 'dev' into reborned/nfc_logger_plugin
RebornedBrain Feb 11, 2025
6df412e
Bump API
RebornedBrain Feb 11, 2025
1d4ecab
Make PVS happy again
RebornedBrain Feb 13, 2025
42e2c19
Cleanups
RebornedBrain Feb 13, 2025
2d7da81
Fix Todo
RebornedBrain Feb 13, 2025
91035e1
Placed some asserts
RebornedBrain Feb 13, 2025
3970bbe
Merge branch 'dev' into reborned/nfc_logger_plugin
RebornedBrain Feb 13, 2025
8dde8ee
Formatting and comments
RebornedBrain Feb 25, 2025
919f16d
formatting
hedger Sep 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions applications/main/nfc/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,41 @@ App(
sources=["nfc_cli.c"],
order=30,
)

App(
appid="nfc_logger_formatter",
apptype=FlipperAppType.PLUGIN,
entry_point="formatter_plugin_ep",
targets=["f7"],
requires=["nfc"],
sources=[
"plugins/logger/formatter/nfc_formatter.c",
"plugins/logger/formatter/common/nfc_history_formatter.c",
"plugins/logger/formatter/common/nfc_transaction_formatter.c",
"plugins/logger/formatter/helpers/nfc_transaction_string.c",
"plugins/logger/formatter/helpers/table.c",
"plugins/logger/formatter/protocols/nfc_protocol_formatters.c",
"plugins/logger/formatter/protocols/felica/felica_listener_data_formatter.c",
"plugins/logger/formatter/protocols/felica/felica_poller_data_formatter.c",
"plugins/logger/formatter/protocols/iso14443_3a/iso14443_3a_listener_data_formatter.c",
"plugins/logger/formatter/protocols/iso14443_3a/iso14443_3a_poller_data_formatter.c",
"plugins/logger/formatter/protocols/iso14443_3b/iso14443_3b_poller_data_formatter.c",
"plugins/logger/formatter/protocols/iso14443_4a/iso14443_4a_listener_data_formatter.c",
"plugins/logger/formatter/protocols/iso14443_4a/iso14443_4a_poller_data_formatter.c",
"plugins/logger/formatter/protocols/iso14443_4b/iso14443_4b_poller_data_formatter.c",
"plugins/logger/formatter/protocols/iso15693_3/iso15693_3_error_formatter.c",
"plugins/logger/formatter/protocols/iso15693_3/iso15693_3_listener_data_formatter.c",
"plugins/logger/formatter/protocols/iso15693_3/iso15693_3_poller_data_formatter.c",
"plugins/logger/formatter/protocols/mf_desfire/mf_desfire_poller_data_formatter.c",
"plugins/logger/formatter/protocols/mf_plus/mf_plus_poller_data_formatter.c",
"plugins/logger/formatter/protocols/mf_ultralight/mf_ultralight_listener_data_formatter.c",
"plugins/logger/formatter/protocols/mf_ultralight/mf_ultralight_poller_data_formatter.c",
"plugins/logger/formatter/protocols/mf_classic/mf_classic_listener_data_formatter.c",
"plugins/logger/formatter/protocols/mf_classic/mf_classic_poller_data_formatter.c",
"plugins/logger/formatter/protocols/nfc_hal/nfc_hal_formatter.c",
"plugins/logger/formatter/protocols/slix/slix_error_formatter.c",
"plugins/logger/formatter/protocols/slix/slix_listener_data_formatter.c",
"plugins/logger/formatter/protocols/slix/slix_poller_data_formatter.c",
"plugins/logger/formatter/protocols/st25tb/st25tb_poller_data_formatter.c",
],
)
52 changes: 52 additions & 0 deletions applications/main/nfc/helpers/logger_formatter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "logger_formatter.h"

#include <flipper_application/flipper_application.h>
#include <flipper_application/plugins/plugin_manager.h>
#include <flipper_application/plugins/composite_resolver.h>
#include <loader/firmware_api/firmware_api.h>

#include "../plugins/logger/nfc_logger_formatter_plugin.h"

#define TAG "LogFormatPluginLoader"

void nfc_logger_format(Nfc* nfc, const NfcLoggerFormatterConfig* config) {
furi_assert(nfc);
furi_assert(config);

Storage* storage = furi_record_open(RECORD_STORAGE);

FlipperApplication* app = flipper_application_alloc(storage, firmware_api_interface);

do {
FlipperApplicationPreloadStatus preload_res =
flipper_application_preload(app, APP_DATA_PATH("plugins/nfc_logger_formatter.fal"));

if(preload_res != FlipperApplicationPreloadStatusSuccess) {
FURI_LOG_E(TAG, "Failed to preload plugin");
break;
}

if(!flipper_application_is_plugin(app)) {
FURI_LOG_E(TAG, "Plugin file is not a library");
break;
}

FlipperApplicationLoadStatus load_status = flipper_application_map_to_memory(app);
if(load_status != FlipperApplicationLoadStatusSuccess) {
FURI_LOG_E(TAG, "Failed to load plugin file");
break;
}

const FlipperAppPluginDescriptor* app_descriptor =
flipper_application_plugin_get_descriptor(app);

furi_check(app_descriptor->ep_api_version == 1);
furi_check(strcmp(app_descriptor->appid, NFC_LOGGER_FORMATTER_PLUGIN_APP_ID) == 0);

const NfcLoggerFormatterPlugin* plugin = app_descriptor->entry_point;
plugin->format(nfc, config);
} while(false);
flipper_application_free(app);

furi_record_close(RECORD_STORAGE);
}
16 changes: 16 additions & 0 deletions applications/main/nfc/helpers/logger_formatter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <core/string.h>

#include <nfc/nfc.h>
#include "plugins/logger/nfc_logger_config_data_type.h"

#ifdef __cplusplus
extern "C" {
#endif

void nfc_logger_format(Nfc* nfc, const NfcLoggerFormatterConfig* config);

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion applications/main/nfc/helpers/nfc_supported_cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static const NfcSupportedCardsPlugin* nfc_supported_cards_get_next_plugin(
&instance->file_name[suffix_start_pos],
NFC_SUPPORTED_CARDS_PLUGIN_SUFFIX,
suffix_len) != 0) //-V1051
break;
continue; //Continue scanning plugin forlder because now there can be not only '_parser.fal' plugins

// Trim suffix from file_name to save memory. The suffix will be concatenated on plugin load.
instance->file_name[suffix_start_pos] = '\0';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "nfc_protocol_support_defs.h"
#include "nfc_protocol_support_gui_common.h"

#include "helpers/logger_formatter.h"
/**
* @brief Common scene entry handler.
*
Expand Down Expand Up @@ -150,6 +150,8 @@ static void nfc_protocol_support_scene_read_on_enter(NfcApp* instance) {

view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewPopup);

nfc_logger_config(nfc_get_logger(instance->nfc), instance->logger_enabled, NFC_LOG_FOLDER);

const NfcProtocol protocol = nfc_detected_protocols_get_selected(instance->detected_protocols);
instance->poller = nfc_poller_alloc(instance->nfc, protocol);

Expand Down Expand Up @@ -321,6 +323,10 @@ static void nfc_protocol_support_scene_read_success_on_enter(NfcApp* instance) {
nfc_protocol_support[protocol]->scene_read_success.on_enter(instance);
}

if(instance->logger_enabled) {
nfc_logger_format(instance->nfc, &instance->logger_config);
}

furi_string_free(temp_str);

widget_add_button_element(
Expand Down Expand Up @@ -608,6 +614,7 @@ static void nfc_protocol_support_scene_emulate_on_enter(NfcApp* instance) {
text_box_set_focus(text_box, TextBoxFocusEnd);
furi_string_reset(instance->text_box_store);

nfc_logger_config(nfc_get_logger(instance->nfc), instance->logger_enabled, NFC_LOG_FOLDER);
// instance->listener is allocated in the respective on_enter() handler
nfc_protocol_support[protocol]->scene_emulate.on_enter(instance);

Expand Down Expand Up @@ -674,6 +681,10 @@ static void nfc_protocol_support_scene_emulate_stop_listener(NfcApp* instance) {
}
}

if(instance->logger_enabled) {
nfc_logger_format(instance->nfc, &instance->logger_config);
}

nfc_listener_free(instance->listener);
}

Expand Down
4 changes: 4 additions & 0 deletions applications/main/nfc/nfc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ NfcApp* nfc_app_alloc(void) {

instance->nfc = nfc_alloc();

instance->logger_enabled = false;
instance->logger_config.history_filter = NfcLoggerHistoryLayerFilterAll;
instance->logger_config.transaction_filter = NfcLoggerTransactionFilterAll;

instance->detected_protocols = nfc_detected_protocols_alloc();
instance->felica_auth = felica_auth_alloc();
instance->mf_ul_auth = mf_ultralight_auth_alloc();
Expand Down
5 changes: 5 additions & 0 deletions applications/main/nfc/nfc_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "helpers/felica_auth.h"
#include "helpers/slix_unlock.h"

#include "plugins/logger/nfc_logger_config_data_type.h"

#include <dialogs/dialogs.h>
#include <storage/storage.h>
#include <toolbox/path.h>
Expand Down Expand Up @@ -67,6 +69,7 @@
#define NFC_BYTE_INPUT_STORE_SIZE 10
#define NFC_LOG_SIZE_MAX (1024)
#define NFC_APP_FOLDER EXT_PATH("nfc")
#define NFC_LOG_FOLDER (NFC_APP_FOLDER "/log")
#define NFC_APP_EXTENSION ".nfc"
#define NFC_APP_SHADOW_EXTENSION ".shd"
#define NFC_APP_FILENAME_PREFIX "NFC"
Expand Down Expand Up @@ -116,6 +119,8 @@ struct NfcApp {
char text_store[NFC_TEXT_STORE_SIZE + 1];
FuriString* text_box_store;
uint8_t byte_input_store[NFC_BYTE_INPUT_STORE_SIZE];
bool logger_enabled;
NfcLoggerFormatterConfig logger_config;

NfcDetectedProtocols* detected_protocols;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#include "nfc_history_formatter.h"
#include "../protocols/nfc_hal/nfc_hal_formatter.h"
#include "../protocols/nfc_protocol_formatters.h"
#include <nfc/helpers/logger/history/nfc_history_chain_data_type.h>

#define TAG "NfcHistoryFormatter"

static bool
nfc_history_layer_filter_skip(const NfcFormatter* instance, const NfcProtocol item_protocol) {
const NfcLoggerHistoryLayerFilter filter = instance->config->history_filter;

return (
(filter == NfcLoggerHistoryLayerFilterTopProtocol ||
filter == NfcLoggerHistoryLayerFilterTopProtocolSimplified) &&
item_protocol != instance->protocol);
}

static void nfc_history_format_hal_item(const FuriHalNfcEvent nfc_event, FuriString* output) {
FuriString* layer_parsed_str = furi_string_alloc();
nfc_hal_data_format_hal_event_type(nfc_event, layer_parsed_str);
furi_string_printf(output, "L0(%s)", furi_string_get_cstr(layer_parsed_str));
furi_string_free(layer_parsed_str);
}

static NfcHistoryItemDataFormatCallback nfc_history_get_item_format_callback(
const NfcProtocol protocol,
const NfcMode mode,
const NfcLoggerHistoryLayerFilter filter) {
NfcHistoryItemDataFormatCallback callback = NULL;
do {
const NfcProtocolFormatterBase* protocol_formatter =
nfc_protocol_formatter_get(protocol, mode);
if(!protocol_formatter) break;

if(filter == NfcLoggerHistoryLayerFilterAll ||
filter == NfcLoggerHistoryLayerFilterTopProtocol) {
callback = protocol_formatter->format_history;
} else if(filter == NfcLoggerHistoryLayerFilterTopProtocolSimplified) {
callback = protocol_formatter->format_history_simplified;
if(callback == NULL) {
FURI_LOG_W(TAG, "Simplified formatting not implemented for protocol %d", protocol);
}
}
} while(false);
return callback;
}

static void nfc_history_format_item(
const NfcFormatter* instance,
const NfcPacket* request,
const NfcHistoryItem* item,
FuriString* output) {
do {
NfcHistoryItemDataFormatCallback callback = nfc_history_get_item_format_callback(
item->base.protocol, instance->mode, instance->config->history_filter);

if(callback == NULL) {
furi_string_printf(output, "Not implemented");
break;
}

callback(request, &item->data, output);
} while(false);
}

static void nfc_history_format_layer(
const size_t layer_num,
const NfcLoggerHistoryLayerFilter filter,
const FuriString* formatted_item,
FuriString* annotation) {
if(filter == NfcLoggerHistoryLayerFilterAll ||
filter == NfcLoggerHistoryLayerFilterTopProtocol) {
const char* format = (filter == NfcLoggerHistoryLayerFilterTopProtocol) ? "L%d(%s)" :
"->L%d(%s)";
furi_string_cat_printf(
annotation, format, layer_num, furi_string_get_cstr(formatted_item));
} else if(filter == NfcLoggerHistoryLayerFilterTopProtocolSimplified) {
furi_string_printf(annotation, "%s", furi_string_get_cstr(formatted_item));
}
}

void nfc_histroy_format_annotation(
const NfcFormatter* instance,
const NfcPacket* request,
const NfcHistory* history,
const FuriHalNfcEvent nfc_event,
FuriString* annotation) {
furi_assert(instance);
furi_assert(history);
furi_assert(annotation);

const NfcLoggerHistoryLayerFilter filter = instance->config->history_filter;

if(filter == NfcLoggerHistoryLayerFilterAll) {
nfc_history_format_hal_item(nfc_event, annotation);
}

FuriString* layer_parsed_str = furi_string_alloc();
for(size_t i = 0; i < history->base.chain_count; i++) {
for(size_t j = 0; j < history->chains[i].length; j++) {
furi_string_reset(layer_parsed_str);
const NfcHistoryItem* item = &(history->chains[i].items[j]);

if(nfc_history_layer_filter_skip(instance, item->base.protocol)) continue;
nfc_history_format_item(instance, request, item, layer_parsed_str);
nfc_history_format_layer(j + 1, filter, layer_parsed_str, annotation);
}
}

furi_string_free(layer_parsed_str);
}

const NfcHistoryItem* nfc_history_get_item(const NfcHistory* history, const NfcProtocol protocol) {
for(size_t i = 0; i < history->base.chain_count; i++) {
for(size_t j = 0; j < history->chains[i].length; j++) {
const NfcHistoryItem* item = &(history->chains[i].items[j]);
if(item->base.protocol != protocol) continue;
return item;
}
}

return NULL;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "../nfc_formatter_context.h"

#include <furi.h>
#include <furi_hal_nfc.h>
#include <nfc/helpers/logger/history/nfc_history.h>
#include <nfc/helpers/logger/transaction/nfc_packet_data_type.h>

#ifdef __cplusplus
extern "C" {
#endif

void nfc_histroy_format_annotation(
const NfcFormatter* instance,
const NfcPacket* request,
const NfcHistory* history,
const FuriHalNfcEvent nfc_event,
FuriString* annotation);

const NfcHistoryItem* nfc_history_get_item(const NfcHistory* history, const NfcProtocol protocol);

#ifdef __cplusplus
}
#endif
Loading