Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FL-3595] Nfc fixes #3111

Merged
merged 17 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions applications/main/nfc/helpers/mf_classic_key_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ bool mf_classic_key_cache_load(MfClassicKeyCache* instance, const uint8_t* uid,
furi_assert(instance);
furi_assert(uid);

mf_classic_key_cache_reset(instance);

FuriString* file_path = furi_string_alloc();
nfc_get_key_cache_file_path(uid, uid_len, file_path);

Expand Down
18 changes: 7 additions & 11 deletions applications/main/nfc/helpers/protocol_support/felica/felica.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static NfcCommand nfc_scene_read_poller_callback_felica(NfcGenericEvent event, v
furi_assert(event.protocol == NfcProtocolFelica);

NfcApp* instance = context;
const FelicaPollerEvent* felica_event = event.data;
const FelicaPollerEvent* felica_event = event.event_data;

if(felica_event->type == FelicaPollerEventTypeReady) {
nfc_device_set_data(
Expand Down Expand Up @@ -57,15 +57,6 @@ static void nfc_scene_read_success_on_enter_felica(NfcApp* instance) {
furi_string_free(temp_str);
}

static bool nfc_scene_info_on_event_felica(NfcApp* instance, uint32_t event) {
if(event == GuiButtonTypeRight) {
scene_manager_next_scene(instance->scene_manager, NfcSceneNotImplemented);
return true;
}

return false;
}

static bool nfc_scene_saved_menu_on_event_felica(NfcApp* instance, uint32_t event) {
if(event == SubmenuIndexCommonEdit) {
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
Expand All @@ -81,7 +72,7 @@ const NfcProtocolSupportBase nfc_protocol_support_felica = {
.scene_info =
{
.on_enter = nfc_scene_info_on_enter_felica,
.on_event = nfc_scene_info_on_event_felica,
.on_event = NULL,
},
.scene_read =
{
Expand All @@ -103,6 +94,11 @@ const NfcProtocolSupportBase nfc_protocol_support_felica = {
.on_enter = nfc_protocol_support_common_on_enter_empty,
.on_event = nfc_scene_saved_menu_on_event_felica,
},
.scene_save_name =
{
.on_enter = NULL,
.on_event = NULL,
},
.scene_emulate =
{
.on_enter = NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static NfcCommand
furi_assert(event.protocol == NfcProtocolIso14443_3a);

NfcApp* instance = context;
const Iso14443_3aPollerEvent* iso14443_3a_event = event.data;
const Iso14443_3aPollerEvent* iso14443_3a_event = event.event_data;

if(iso14443_3a_event->type == Iso14443_3aPollerEventTypeReady) {
nfc_device_set_data(
Expand Down Expand Up @@ -62,10 +62,10 @@ static NfcCommand
nfc_scene_emulate_listener_callback_iso14443_3a(NfcGenericEvent event, void* context) {
furi_assert(context);
furi_assert(event.protocol == NfcProtocolIso14443_3a);
furi_assert(event.data);
furi_assert(event.event_data);

NfcApp* nfc = context;
Iso14443_3aListenerEvent* iso14443_3a_event = event.data;
Iso14443_3aListenerEvent* iso14443_3a_event = event.event_data;

if(iso14443_3a_event->type == Iso14443_3aListenerEventTypeReceivedStandardFrame) {
furi_string_cat_printf(nfc->text_box_store, "R:");
Expand All @@ -91,15 +91,6 @@ static void nfc_scene_emulate_on_enter_iso14443_3a(NfcApp* instance) {
instance->listener, nfc_scene_emulate_listener_callback_iso14443_3a, instance);
}

static bool nfc_scene_info_on_event_iso14443_3a(NfcApp* instance, uint32_t event) {
if(event == GuiButtonTypeRight) {
scene_manager_next_scene(instance->scene_manager, NfcSceneNotImplemented);
return true;
}

return false;
}

static bool nfc_scene_read_menu_on_event_iso14443_3a(NfcApp* instance, uint32_t event) {
if(event == SubmenuIndexCommonEmulate) {
scene_manager_next_scene(instance->scene_manager, NfcSceneEmulate);
Expand All @@ -115,7 +106,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_3a = {
.scene_info =
{
.on_enter = nfc_scene_info_on_enter_iso14443_3a,
.on_event = nfc_scene_info_on_event_iso14443_3a,
.on_event = NULL,
},
.scene_read =
{
Expand All @@ -137,6 +128,11 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_3a = {
.on_enter = nfc_protocol_support_common_on_enter_empty,
.on_event = NULL,
},
.scene_save_name =
{
.on_enter = NULL,
.on_event = NULL,
},
.scene_emulate =
{
.on_enter = nfc_scene_emulate_on_enter_iso14443_3a,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static NfcCommand
furi_assert(event.protocol == NfcProtocolIso14443_3b);

NfcApp* instance = context;
const Iso14443_3bPollerEvent* iso14443_3b_event = event.data;
const Iso14443_3bPollerEvent* iso14443_3b_event = event.event_data;

if(iso14443_3b_event->type == Iso14443_3bPollerEventTypeReady) {
nfc_device_set_data(
Expand Down Expand Up @@ -58,15 +58,6 @@ static void nfc_scene_read_success_on_enter_iso14443_3b(NfcApp* instance) {
furi_string_free(temp_str);
}

static bool nfc_scene_info_on_event_iso14443_3b(NfcApp* instance, uint32_t event) {
if(event == GuiButtonTypeRight) {
scene_manager_next_scene(instance->scene_manager, NfcSceneNotImplemented);
return true;
}

return false;
}

bool nfc_scene_saved_menu_on_event_iso14443_3b_common(NfcApp* instance, uint32_t event) {
if(event == SubmenuIndexCommonEdit) {
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
Expand All @@ -86,7 +77,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_3b = {
.scene_info =
{
.on_enter = nfc_scene_info_on_enter_iso14443_3b,
.on_event = nfc_scene_info_on_event_iso14443_3b,
.on_event = NULL,
},
.scene_read =
{
Expand All @@ -108,6 +99,11 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_3b = {
.on_enter = nfc_protocol_support_common_on_enter_empty,
.on_event = nfc_scene_saved_menu_on_event_iso14443_3b,
},
.scene_save_name =
{
.on_enter = NULL,
.on_event = NULL,
},
.scene_emulate =
{
.on_enter = NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static NfcCommand
furi_assert(event.protocol == NfcProtocolIso14443_4a);

NfcApp* instance = context;
const Iso14443_4aPollerEvent* iso14443_4a_event = event.data;
const Iso14443_4aPollerEvent* iso14443_4a_event = event.event_data;

if(iso14443_4a_event->type == Iso14443_4aPollerEventTypeReady) {
nfc_device_set_data(
Expand Down Expand Up @@ -66,10 +66,10 @@ static void nfc_scene_saved_menu_on_enter_iso14443_4a(NfcApp* instance) {
NfcCommand nfc_scene_emulate_listener_callback_iso14443_4a(NfcGenericEvent event, void* context) {
furi_assert(context);
furi_assert(event.protocol == NfcProtocolIso14443_4a);
furi_assert(event.data);
furi_assert(event.event_data);

NfcApp* nfc = context;
Iso14443_4aListenerEvent* iso14443_4a_event = event.data;
Iso14443_4aListenerEvent* iso14443_4a_event = event.event_data;

if(iso14443_4a_event->type == Iso14443_4aListenerEventTypeReceivedData) {
furi_string_cat_printf(nfc->text_box_store, "R:");
Expand All @@ -95,15 +95,6 @@ static void nfc_scene_emulate_on_enter_iso14443_4a(NfcApp* instance) {
instance->listener, nfc_scene_emulate_listener_callback_iso14443_4a, instance);
}

static bool nfc_scene_info_on_event_iso14443_4a(NfcApp* instance, uint32_t event) {
if(event == GuiButtonTypeRight) {
scene_manager_next_scene(instance->scene_manager, NfcSceneNotImplemented);
return true;
}

return false;
}

static bool nfc_scene_read_menu_on_event_iso14443_4a(NfcApp* instance, uint32_t event) {
if(event == SubmenuIndexCommonEmulate) {
scene_manager_next_scene(instance->scene_manager, NfcSceneEmulate);
Expand All @@ -119,7 +110,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_4a = {
.scene_info =
{
.on_enter = nfc_scene_info_on_enter_iso14443_4a,
.on_event = nfc_scene_info_on_event_iso14443_4a,
.on_event = NULL,
},
.scene_read =
{
Expand All @@ -141,6 +132,11 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_4a = {
.on_enter = nfc_scene_saved_menu_on_enter_iso14443_4a,
.on_event = NULL,
},
.scene_save_name =
{
.on_enter = NULL,
.on_event = NULL,
},
.scene_emulate =
{
.on_enter = nfc_scene_emulate_on_enter_iso14443_4a,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static NfcCommand
furi_assert(event.protocol == NfcProtocolIso14443_4b);

NfcApp* instance = context;
const Iso14443_4bPollerEvent* iso14443_4b_event = event.data;
const Iso14443_4bPollerEvent* iso14443_4b_event = event.event_data;

if(iso14443_4b_event->type == Iso14443_4bPollerEventTypeReady) {
nfc_device_set_data(
Expand Down Expand Up @@ -63,15 +63,6 @@ static void nfc_scene_saved_menu_on_enter_iso14443_4b(NfcApp* instance) {
UNUSED(instance);
}

static bool nfc_scene_info_on_event_iso14443_4b(NfcApp* instance, uint32_t event) {
if(event == GuiButtonTypeRight) {
scene_manager_next_scene(instance->scene_manager, NfcSceneNotImplemented);
return true;
}

return false;
}

static bool nfc_scene_read_menu_on_event_iso14443_4b(NfcApp* instance, uint32_t event) {
if(event == SubmenuIndexCommonEmulate) {
scene_manager_next_scene(instance->scene_manager, NfcSceneEmulate);
Expand All @@ -91,7 +82,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_4b = {
.scene_info =
{
.on_enter = nfc_scene_info_on_enter_iso14443_4b,
.on_event = nfc_scene_info_on_event_iso14443_4b,
.on_event = NULL,
},
.scene_read =
{
Expand All @@ -113,6 +104,11 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_4b = {
.on_enter = nfc_scene_saved_menu_on_enter_iso14443_4b,
.on_event = nfc_scene_saved_menu_on_event_iso14443_4b,
},
.scene_save_name =
{
.on_enter = NULL,
.on_event = NULL,
},
.scene_emulate =
{
.on_enter = NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static NfcCommand nfc_scene_read_poller_callback_iso15693_3(NfcGenericEvent even
furi_assert(event.protocol == NfcProtocolIso15693_3);

NfcApp* instance = context;
const Iso15693_3PollerEvent* iso15693_3_event = event.data;
const Iso15693_3PollerEvent* iso15693_3_event = event.event_data;

if(iso15693_3_event->type == Iso15693_3PollerEventTypeReady) {
nfc_device_set_data(
Expand Down Expand Up @@ -63,10 +63,10 @@ static NfcCommand
nfc_scene_emulate_listener_callback_iso15693_3(NfcGenericEvent event, void* context) {
furi_assert(context);
furi_assert(event.protocol == NfcProtocolIso15693_3);
furi_assert(event.data);
furi_assert(event.event_data);

NfcApp* nfc = context;
Iso15693_3ListenerEvent* iso15693_3_event = event.data;
Iso15693_3ListenerEvent* iso15693_3_event = event.event_data;

if(iso15693_3_event->type == Iso15693_3ListenerEventTypeCustomCommand) {
furi_string_cat_printf(nfc->text_box_store, "R:");
Expand All @@ -91,15 +91,6 @@ static void nfc_scene_emulate_on_enter_iso15693_3(NfcApp* instance) {
instance->listener, nfc_scene_emulate_listener_callback_iso15693_3, instance);
}

static bool nfc_scene_info_on_event_iso15693_3(NfcApp* instance, uint32_t event) {
if(event == GuiButtonTypeRight) {
scene_manager_next_scene(instance->scene_manager, NfcSceneNotImplemented);
return true;
}

return false;
}

static bool nfc_scene_saved_menu_on_event_iso15693_3(NfcApp* instance, uint32_t event) {
if(event == SubmenuIndexCommonEdit) {
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
Expand All @@ -115,7 +106,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso15693_3 = {
.scene_info =
{
.on_enter = nfc_scene_info_on_enter_iso15693_3,
.on_event = nfc_scene_info_on_event_iso15693_3,
.on_event = NULL,
},
.scene_read =
{
Expand All @@ -137,6 +128,11 @@ const NfcProtocolSupportBase nfc_protocol_support_iso15693_3 = {
.on_enter = nfc_protocol_support_common_on_enter_empty,
.on_event = nfc_scene_saved_menu_on_event_iso15693_3,
},
.scene_save_name =
{
.on_enter = NULL,
.on_event = NULL,
},
.scene_emulate =
{
.on_enter = nfc_scene_emulate_on_enter_iso15693_3,
Expand Down
Loading