Fix CLI with NTAG4xx and Type 4 Tag support

by WillyJL
This commit is contained in:
MX
2026-04-24 01:03:47 +03:00
parent 1ed18e469c
commit c4ef54c71a
8 changed files with 96 additions and 11 deletions
+3 -1
View File
@@ -631,13 +631,15 @@ App(
"cli/commands/dump/protocols/iso14443_4a/nfc_cli_dump_iso14443_4a.c",
"cli/commands/dump/protocols/iso14443_4b/nfc_cli_dump_iso14443_4b.c",
"cli/commands/dump/protocols/iso15693_3/nfc_cli_dump_iso15693_3.c",
"cli/commands/dump/protocols/felica/nfc_cli_dump_felica.c",
"cli/commands/dump/protocols/mf_ultralight/nfc_cli_dump_mf_ultralight.c",
"cli/commands/dump/protocols/mf_classic/nfc_cli_dump_mf_classic.c",
"cli/commands/dump/protocols/mf_plus/nfc_cli_dump_mf_plus.c",
"cli/commands/dump/protocols/mf_desfire/nfc_cli_dump_mf_desfire.c",
"cli/commands/dump/protocols/slix/nfc_cli_dump_slix.c",
"cli/commands/dump/protocols/st25tb/nfc_cli_dump_st25tb.c",
"cli/commands/dump/protocols/felica/nfc_cli_dump_felica.c",
"cli/commands/dump/protocols/ntag4xx/nfc_cli_dump_ntag4xx.c",
"cli/commands/dump/protocols/type_4_tag/nfc_cli_dump_type_4_tag.c",
"cli/commands/mfu/nfc_cli_command_mfu.c",
"cli/commands/mfu/nfc_cli_action_info.c",
"cli/commands/mfu/nfc_cli_action_rdbl.c",
@@ -9,13 +9,15 @@
#include "protocols/iso14443_4a/nfc_cli_dump_iso14443_4a.h"
#include "protocols/iso14443_4b/nfc_cli_dump_iso14443_4b.h"
#include "protocols/iso15693_3/nfc_cli_dump_iso15693_3.h"
#include "protocols/mf_classic/nfc_cli_dump_mf_classic.h"
#include "protocols/mf_desfire/nfc_cli_dump_mf_desfire.h"
#include "protocols/mf_plus/nfc_cli_dump_mf_plus.h"
#include "protocols/felica/nfc_cli_dump_felica.h"
#include "protocols/mf_ultralight/nfc_cli_dump_mf_ultralight.h"
#include "protocols/mf_classic/nfc_cli_dump_mf_classic.h"
#include "protocols/mf_plus/nfc_cli_dump_mf_plus.h"
#include "protocols/mf_desfire/nfc_cli_dump_mf_desfire.h"
#include "protocols/slix/nfc_cli_dump_slix.h"
#include "protocols/st25tb/nfc_cli_dump_st25tb.h"
#include "protocols/felica/nfc_cli_dump_felica.h"
#include "protocols/ntag4xx/nfc_cli_dump_ntag4xx.h"
#include "protocols/type_4_tag/nfc_cli_dump_type_4_tag.h"
#include <datetime.h>
#include <furi_hal_rtc.h>
@@ -81,18 +83,20 @@ static bool nfc_cli_dump_parse_filename_key(FuriString* value, void* output) {
}
NfcGenericCallback protocol_poller_callbacks[NfcProtocolNum] = {
[NfcProtocolMfUltralight] = nfc_cli_dump_poller_callback_mf_ultralight,
[NfcProtocolMfClassic] = nfc_cli_dump_poller_callback_mf_classic,
[NfcProtocolFelica] = nfc_cli_dump_poller_callback_felica,
[NfcProtocolIso14443_3a] = nfc_cli_dump_poller_callback_iso14443_3a,
[NfcProtocolIso14443_3b] = nfc_cli_dump_poller_callback_iso14443_3b,
[NfcProtocolIso14443_4a] = nfc_cli_dump_poller_callback_iso14443_4a,
[NfcProtocolIso14443_4b] = nfc_cli_dump_poller_callback_iso14443_4b,
[NfcProtocolIso15693_3] = nfc_cli_dump_poller_callback_iso15693_3,
[NfcProtocolSlix] = nfc_cli_dump_poller_callback_slix,
[NfcProtocolMfDesfire] = nfc_cli_dump_poller_callback_mf_desfire,
[NfcProtocolFelica] = nfc_cli_dump_poller_callback_felica,
[NfcProtocolMfUltralight] = nfc_cli_dump_poller_callback_mf_ultralight,
[NfcProtocolMfClassic] = nfc_cli_dump_poller_callback_mf_classic,
[NfcProtocolMfPlus] = nfc_cli_dump_poller_callback_mf_plus,
[NfcProtocolMfDesfire] = nfc_cli_dump_poller_callback_mf_desfire,
[NfcProtocolSlix] = nfc_cli_dump_poller_callback_slix,
[NfcProtocolSt25tb] = nfc_cli_dump_poller_callback_st25tb,
[NfcProtocolNtag4xx] = nfc_cli_dump_poller_callback_ntag4xx,
[NfcProtocolType4Tag] = nfc_cli_dump_poller_callback_type_4_tag,
};
static void nfc_cli_dump_generate_filename(FuriString* file_path) {
@@ -219,6 +223,8 @@ static const NfcProtocolNameValuePair supported_protocols[] = {
{.name = "des", .value = NfcProtocolMfDesfire},
{.name = "slix", .value = NfcProtocolSlix},
{.name = "st25", .value = NfcProtocolSt25tb},
{.name = "ntag4", .value = NfcProtocolNtag4xx},
{.name = "t4t", .value = NfcProtocolType4Tag},
};
static bool nfc_cli_dump_parse_protocol(FuriString* value, void* output) {
@@ -0,0 +1,31 @@
#include "nfc_cli_dump_ntag4xx.h"
#include <nfc/protocols/ntag4xx/ntag4xx_poller.h>
#define TAG "NTAG4XX"
NfcCommand nfc_cli_dump_poller_callback_ntag4xx(NfcGenericEvent event, void* context) {
furi_assert(context);
furi_assert(event.protocol == NfcProtocolNtag4xx);
furi_assert(event.event_data);
NfcCliDumpContext* instance = context;
const Ntag4xxPollerEvent* ntag4xx_event = event.event_data;
NfcCommand command = NfcCommandContinue;
if(ntag4xx_event->type == Ntag4xxPollerEventTypeReadSuccess) {
nfc_device_set_data(
instance->nfc_device, NfcProtocolNtag4xx, nfc_poller_get_data(instance->poller));
instance->result = NfcCliDumpErrorNone;
command = NfcCommandStop;
} else if(ntag4xx_event->type == Ntag4xxPollerEventTypeReadFailed) {
instance->result = NfcCliDumpErrorFailedToRead;
command = NfcCommandReset;
}
if(command == NfcCommandStop) {
furi_semaphore_release(instance->sem_done);
}
return command;
}
@@ -0,0 +1,5 @@
#pragma once
#include "../nfc_cli_dump_common_types.h"
NfcCommand nfc_cli_dump_poller_callback_ntag4xx(NfcGenericEvent event, void* context);
@@ -0,0 +1,31 @@
#include "nfc_cli_dump_type_4_tag.h"
#include <nfc/protocols/type_4_tag/type_4_tag_poller.h>
#define TAG "TYPE4TAG"
NfcCommand nfc_cli_dump_poller_callback_type_4_tag(NfcGenericEvent event, void* context) {
furi_assert(context);
furi_assert(event.protocol == NfcProtocolType4Tag);
furi_assert(event.event_data);
NfcCliDumpContext* instance = context;
const Type4TagPollerEvent* type_4_tag_event = event.event_data;
NfcCommand command = NfcCommandContinue;
if(type_4_tag_event->type == Type4TagPollerEventTypeReadSuccess) {
nfc_device_set_data(
instance->nfc_device, NfcProtocolType4Tag, nfc_poller_get_data(instance->poller));
instance->result = NfcCliDumpErrorNone;
command = NfcCommandStop;
} else if(type_4_tag_event->type == Type4TagPollerEventTypeReadFailed) {
instance->result = NfcCliDumpErrorFailedToRead;
command = NfcCommandReset;
}
if(command == NfcCommandStop) {
furi_semaphore_release(instance->sem_done);
}
return command;
}
@@ -0,0 +1,5 @@
#pragma once
#include "../nfc_cli_dump_common_types.h"
NfcCommand nfc_cli_dump_poller_callback_type_4_tag(NfcGenericEvent event, void* context);
@@ -9,10 +9,12 @@ static const char* protocol_names[NfcProtocolNum] = {
[NfcProtocolFelica] = "FeliCa",
[NfcProtocolMfUltralight] = "Mifare Ultralight",
[NfcProtocolMfClassic] = "Mifare Classic",
[NfcProtocolMfDesfire] = "Mifare DESFire",
[NfcProtocolMfPlus] = "Mifare Plus",
[NfcProtocolMfDesfire] = "Mifare DESFire",
[NfcProtocolSlix] = "Slix",
[NfcProtocolSt25tb] = "St25tb",
[NfcProtocolNtag4xx] = "Ntag4xx",
[NfcProtocolType4Tag] = "Type 4 Tag",
};
const char* nfc_cli_get_protocol_name(NfcProtocol protocol) {
@@ -117,9 +117,12 @@ const NfcCliRawProtocolSpecificHandler nfc_cli_raw_protocol_handlers[] = {
[NfcProtocolFelica] = nfc_cli_raw_felica_handler,
[NfcProtocolMfUltralight] = NULL,
[NfcProtocolMfClassic] = NULL,
[NfcProtocolMfPlus] = NULL,
[NfcProtocolMfDesfire] = NULL,
[NfcProtocolSlix] = NULL,
[NfcProtocolSt25tb] = NULL,
[NfcProtocolNtag4xx] = NULL,
[NfcProtocolType4Tag] = NULL,
};
static NfcCommand nfc_cli_raw_poller_callback(NfcGenericEventEx event, void* context) {