mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-17 04:34:44 -07:00
NFC: Fix duplicated ProtocolSupport handling, fix some inconsistent naming
This commit is contained in:
@@ -133,15 +133,6 @@ static void nfc_scene_read_success_on_enter_felica(NfcApp* instance) {
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static bool nfc_scene_saved_menu_on_event_felica(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexCommonEdit) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void nfc_scene_emulate_on_enter_felica(NfcApp* instance) {
|
||||
const FelicaData* data = nfc_device_get_data(instance->nfc_device, NfcProtocolFelica);
|
||||
instance->listener = nfc_listener_alloc(instance->nfc, NfcProtocolFelica, data);
|
||||
@@ -201,7 +192,7 @@ const NfcProtocolSupportBase nfc_protocol_support_felica = {
|
||||
.scene_saved_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_scene_saved_menu_on_event_felica,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_save_name =
|
||||
{
|
||||
|
||||
@@ -67,21 +67,22 @@ static NfcCommand
|
||||
furi_assert(event.protocol == NfcProtocolIso14443_3a);
|
||||
furi_assert(event.event_data);
|
||||
|
||||
NfcApp* nfc = context;
|
||||
NfcApp* instance = context;
|
||||
Iso14443_3aListenerEvent* iso14443_3a_event = event.event_data;
|
||||
|
||||
if(iso14443_3a_event->type == Iso14443_3aListenerEventTypeReceivedStandardFrame) {
|
||||
if(furi_string_size(nfc->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(nfc->text_box_store, "R:");
|
||||
if(furi_string_size(instance->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(instance->text_box_store, "R:");
|
||||
for(size_t i = 0; i < bit_buffer_get_size_bytes(iso14443_3a_event->data->buffer);
|
||||
i++) {
|
||||
furi_string_cat_printf(
|
||||
nfc->text_box_store,
|
||||
instance->text_box_store,
|
||||
" %02X",
|
||||
bit_buffer_get_byte(iso14443_3a_event->data->buffer, i));
|
||||
}
|
||||
furi_string_push_back(nfc->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
furi_string_push_back(instance->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(
|
||||
instance->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,15 +98,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_read_menu_on_event_iso14443_3a(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexCommonEmulate) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneEmulate);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_iso14443_3a = {
|
||||
.features = NfcProtocolFeatureEmulateUid | NfcProtocolFeatureEditUid,
|
||||
|
||||
@@ -122,7 +114,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_3a = {
|
||||
.scene_read_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_scene_read_menu_on_event_iso14443_3a,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_read_success =
|
||||
{
|
||||
|
||||
@@ -60,19 +60,6 @@ static void nfc_scene_read_success_on_enter_iso14443_3b(NfcApp* instance) {
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
bool nfc_scene_saved_menu_on_event_iso14443_3b_common(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexCommonEdit) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool nfc_scene_saved_menu_on_event_iso14443_3b(NfcApp* instance, SceneManagerEvent event) {
|
||||
return nfc_scene_saved_menu_on_event_iso14443_3b_common(instance, event);
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_iso14443_3b = {
|
||||
.features = NfcProtocolFeatureNone,
|
||||
|
||||
@@ -99,7 +86,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_3b = {
|
||||
.scene_saved_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_scene_saved_menu_on_event_iso14443_3b,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_save_name =
|
||||
{
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <nfc/protocols/iso14443_3b/iso14443_3b.h>
|
||||
|
||||
#include "iso14443_3b.h"
|
||||
|
||||
bool nfc_scene_saved_menu_on_event_iso14443_3b_common(NfcApp* instance, SceneManagerEvent event);
|
||||
@@ -70,21 +70,22 @@ NfcCommand nfc_scene_emulate_listener_callback_iso14443_4a(NfcGenericEvent event
|
||||
furi_assert(event.protocol == NfcProtocolIso14443_4a);
|
||||
furi_assert(event.event_data);
|
||||
|
||||
NfcApp* nfc = context;
|
||||
NfcApp* instance = context;
|
||||
Iso14443_4aListenerEvent* iso14443_4a_event = event.event_data;
|
||||
|
||||
if(iso14443_4a_event->type == Iso14443_4aListenerEventTypeReceivedData) {
|
||||
if(furi_string_size(nfc->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(nfc->text_box_store, "R:");
|
||||
if(furi_string_size(instance->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(instance->text_box_store, "R:");
|
||||
for(size_t i = 0; i < bit_buffer_get_size_bytes(iso14443_4a_event->data->buffer);
|
||||
i++) {
|
||||
furi_string_cat_printf(
|
||||
nfc->text_box_store,
|
||||
instance->text_box_store,
|
||||
" %02X",
|
||||
bit_buffer_get_byte(iso14443_4a_event->data->buffer, i));
|
||||
}
|
||||
furi_string_push_back(nfc->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
furi_string_push_back(instance->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(
|
||||
instance->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,15 +101,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_read_menu_on_event_iso14443_4a(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexCommonEmulate) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneEmulate);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_iso14443_4a = {
|
||||
.features = NfcProtocolFeatureEmulateUid | NfcProtocolFeatureEditUid,
|
||||
|
||||
@@ -125,7 +117,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_4a = {
|
||||
.scene_read_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_scene_read_menu_on_event_iso14443_4a,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_read_success =
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "../nfc_protocol_support_common.h"
|
||||
#include "../nfc_protocol_support_gui_common.h"
|
||||
#include "../iso14443_3b/iso14443_3b_i.h"
|
||||
|
||||
static void nfc_scene_info_on_enter_iso14443_4b(NfcApp* instance) {
|
||||
const NfcDevice* device = instance->nfc_device;
|
||||
@@ -61,23 +60,6 @@ static void nfc_scene_read_success_on_enter_iso14443_4b(NfcApp* instance) {
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static void nfc_scene_saved_menu_on_enter_iso14443_4b(NfcApp* instance) {
|
||||
UNUSED(instance);
|
||||
}
|
||||
|
||||
static bool nfc_scene_read_menu_on_event_iso14443_4b(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexCommonEmulate) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneEmulate);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool nfc_scene_saved_menu_on_event_iso14443_4b(NfcApp* instance, SceneManagerEvent event) {
|
||||
return nfc_scene_saved_menu_on_event_iso14443_3b_common(instance, event);
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_iso14443_4b = {
|
||||
.features = NfcProtocolFeatureNone,
|
||||
|
||||
@@ -94,7 +76,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_4b = {
|
||||
.scene_read_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_scene_read_menu_on_event_iso14443_4b,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_read_success =
|
||||
{
|
||||
@@ -103,8 +85,8 @@ const NfcProtocolSupportBase nfc_protocol_support_iso14443_4b = {
|
||||
},
|
||||
.scene_saved_menu =
|
||||
{
|
||||
.on_enter = nfc_scene_saved_menu_on_enter_iso14443_4b,
|
||||
.on_event = nfc_scene_saved_menu_on_event_iso14443_4b,
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_save_name =
|
||||
{
|
||||
|
||||
@@ -80,20 +80,21 @@ static NfcCommand
|
||||
furi_assert(event.protocol == NfcProtocolIso15693_3);
|
||||
furi_assert(event.event_data);
|
||||
|
||||
NfcApp* nfc = context;
|
||||
NfcApp* instance = context;
|
||||
Iso15693_3ListenerEvent* iso15693_3_event = event.event_data;
|
||||
|
||||
if(iso15693_3_event->type == Iso15693_3ListenerEventTypeCustomCommand) {
|
||||
if(furi_string_size(nfc->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(nfc->text_box_store, "R:");
|
||||
if(furi_string_size(instance->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(instance->text_box_store, "R:");
|
||||
for(size_t i = 0; i < bit_buffer_get_size_bytes(iso15693_3_event->data->buffer); i++) {
|
||||
furi_string_cat_printf(
|
||||
nfc->text_box_store,
|
||||
instance->text_box_store,
|
||||
" %02X",
|
||||
bit_buffer_get_byte(iso15693_3_event->data->buffer, i));
|
||||
}
|
||||
furi_string_push_back(nfc->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
furi_string_push_back(instance->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(
|
||||
instance->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,15 +109,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_saved_menu_on_event_iso15693_3(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexCommonEdit) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_iso15693_3 = {
|
||||
.features = NfcProtocolFeatureEmulateFull | NfcProtocolFeatureEditUid |
|
||||
NfcProtocolFeatureMoreInfo,
|
||||
@@ -149,7 +141,7 @@ const NfcProtocolSupportBase nfc_protocol_support_iso15693_3 = {
|
||||
.scene_saved_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_scene_saved_menu_on_event_iso15693_3,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_save_name =
|
||||
{
|
||||
|
||||
@@ -200,9 +200,6 @@ static bool nfc_scene_read_menu_on_event_mf_classic(NfcApp* instance, SceneManag
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicDictAttack);
|
||||
}
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexCommonEdit) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -249,9 +249,6 @@ static bool nfc_scene_read_and_saved_menu_on_event_mf_ultralight(
|
||||
NfcSceneMfUltralightUnlockMenu;
|
||||
scene_manager_next_scene(instance->scene_manager, next_scene);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexCommonEdit) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
|
||||
@@ -304,6 +304,9 @@ static bool
|
||||
dolphin_deed(DolphinDeedNfcEmulate);
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneWrite);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexCommonEdit) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
|
||||
consumed = true;
|
||||
} else {
|
||||
const NfcProtocol protocol = nfc_device_get_protocol(instance->nfc_device);
|
||||
consumed = nfc_protocol_support[protocol]->scene_read_menu.on_event(instance, event);
|
||||
|
||||
@@ -26,9 +26,9 @@ void nfc_protocol_support_common_byte_input_done_callback(void* context) {
|
||||
}
|
||||
|
||||
void nfc_protocol_support_common_text_input_done_callback(void* context) {
|
||||
NfcApp* nfc = context;
|
||||
NfcApp* instance = context;
|
||||
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventTextInputDone);
|
||||
view_dispatcher_send_custom_event(instance->view_dispatcher, NfcCustomEventTextInputDone);
|
||||
}
|
||||
|
||||
void nfc_protocol_support_common_on_enter_empty(NfcApp* instance) {
|
||||
|
||||
@@ -78,20 +78,21 @@ static NfcCommand nfc_scene_emulate_listener_callback_slix(NfcGenericEvent event
|
||||
furi_assert(event.protocol == NfcProtocolSlix);
|
||||
furi_assert(event.event_data);
|
||||
|
||||
NfcApp* nfc = context;
|
||||
NfcApp* instance = context;
|
||||
SlixListenerEvent* slix_event = event.event_data;
|
||||
|
||||
if(slix_event->type == SlixListenerEventTypeCustomCommand) {
|
||||
if(furi_string_size(nfc->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(nfc->text_box_store, "R:");
|
||||
if(furi_string_size(instance->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(instance->text_box_store, "R:");
|
||||
for(size_t i = 0; i < bit_buffer_get_size_bytes(slix_event->data->buffer); i++) {
|
||||
furi_string_cat_printf(
|
||||
nfc->text_box_store,
|
||||
instance->text_box_store,
|
||||
" %02X",
|
||||
bit_buffer_get_byte(slix_event->data->buffer, i));
|
||||
}
|
||||
furi_string_push_back(nfc->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
furi_string_push_back(instance->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(
|
||||
instance->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,15 +106,6 @@ static void nfc_scene_emulate_on_enter_slix(NfcApp* instance) {
|
||||
nfc_listener_start(instance->listener, nfc_scene_emulate_listener_callback_slix, instance);
|
||||
}
|
||||
|
||||
static bool nfc_scene_saved_menu_on_event_slix(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexCommonEdit) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_slix = {
|
||||
.features = NfcProtocolFeatureEmulateFull | NfcProtocolFeatureMoreInfo,
|
||||
|
||||
@@ -145,7 +137,7 @@ const NfcProtocolSupportBase nfc_protocol_support_slix = {
|
||||
.scene_saved_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_scene_saved_menu_on_event_slix,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_save_name =
|
||||
{
|
||||
|
||||
@@ -61,15 +61,6 @@ static void nfc_scene_read_success_on_enter_st25tb(NfcApp* instance) {
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static bool nfc_scene_saved_menu_on_event_st25tb(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexCommonEdit) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSetUid);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_st25tb = {
|
||||
.features = NfcProtocolFeatureNone,
|
||||
|
||||
@@ -96,7 +87,7 @@ const NfcProtocolSupportBase nfc_protocol_support_st25tb = {
|
||||
.scene_saved_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_scene_saved_menu_on_event_st25tb,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_save_name =
|
||||
{
|
||||
|
||||
@@ -139,24 +139,23 @@ static void nfc_scene_read_success_on_enter_type_4_tag(NfcApp* instance) {
|
||||
|
||||
static NfcCommand
|
||||
nfc_scene_emulate_listener_callback_type_4_tag(NfcGenericEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
furi_assert(event.protocol == NfcProtocolType4Tag);
|
||||
furi_assert(event.event_data);
|
||||
|
||||
NfcApp* nfc = context;
|
||||
NfcApp* instance = context;
|
||||
Type4TagListenerEvent* type_4_tag_event = event.event_data;
|
||||
|
||||
if(type_4_tag_event->type == Type4TagListenerEventTypeCustomCommand) {
|
||||
if(furi_string_size(nfc->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(nfc->text_box_store, "R:");
|
||||
if(furi_string_size(instance->text_box_store) < NFC_LOG_SIZE_MAX) {
|
||||
furi_string_cat_printf(instance->text_box_store, "R:");
|
||||
for(size_t i = 0; i < bit_buffer_get_size_bytes(type_4_tag_event->data->buffer); i++) {
|
||||
furi_string_cat_printf(
|
||||
nfc->text_box_store,
|
||||
instance->text_box_store,
|
||||
" %02X",
|
||||
bit_buffer_get_byte(type_4_tag_event->data->buffer, i));
|
||||
}
|
||||
furi_string_push_back(nfc->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
furi_string_push_back(instance->text_box_store, '\n');
|
||||
view_dispatcher_send_custom_event(
|
||||
instance->view_dispatcher, NfcCustomEventListenerUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user