mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge branch 'nfc_refactors_fixes_merge' into dev
This commit is contained in:
@@ -13,6 +13,7 @@ static void nfc_scene_info_on_enter_felica(NfcApp* instance) {
|
||||
const FelicaData* data = nfc_device_get_data(device, NfcProtocolFelica);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
nfc_render_felica_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
@@ -58,8 +59,8 @@ 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, uint32_t event) {
|
||||
if(event == SubmenuIndexCommonEdit) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ static void nfc_scene_info_on_enter_iso14443_3a(NfcApp* instance) {
|
||||
const Iso14443_3aData* data = nfc_device_get_data(device, NfcProtocolIso14443_3a);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
nfc_render_iso14443_3a_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
@@ -95,8 +97,8 @@ 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, uint32_t event) {
|
||||
if(event == SubmenuIndexCommonEmulate) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -6,13 +6,17 @@ void nfc_render_iso14443_3a_format_bytes(FuriString* str, const uint8_t* const d
|
||||
}
|
||||
}
|
||||
|
||||
void nfc_render_iso14443_tech_type(const Iso14443_3aData* data, FuriString* str) {
|
||||
const char iso_type = iso14443_3a_supports_iso14443_4(data) ? '4' : '3';
|
||||
furi_string_cat_printf(str, "Tech: ISO 14443-%c (NFC-A)\n", iso_type);
|
||||
}
|
||||
|
||||
void nfc_render_iso14443_3a_info(
|
||||
const Iso14443_3aData* data,
|
||||
NfcProtocolFormatType format_type,
|
||||
FuriString* str) {
|
||||
if(format_type == NfcProtocolFormatTypeFull) {
|
||||
const char iso_type = iso14443_3a_supports_iso14443_4(data) ? '4' : '3';
|
||||
furi_string_cat_printf(str, "ISO 14443-%c (NFC-A)\n", iso_type);
|
||||
nfc_render_iso14443_tech_type(data, str);
|
||||
}
|
||||
|
||||
nfc_render_iso14443_3a_brief(data, str);
|
||||
@@ -30,5 +34,5 @@ void nfc_render_iso14443_3a_brief(const Iso14443_3aData* data, FuriString* str)
|
||||
|
||||
void nfc_render_iso14443_3a_extra(const Iso14443_3aData* data, FuriString* str) {
|
||||
furi_string_cat_printf(str, "\nATQA: %02X %02X ", data->atqa[1], data->atqa[0]);
|
||||
furi_string_cat_printf(str, "SAK: %02X", data->sak);
|
||||
furi_string_cat_printf(str, "\nSAK: %02X", data->sak);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ void nfc_render_iso14443_3a_info(
|
||||
NfcProtocolFormatType format_type,
|
||||
FuriString* str);
|
||||
|
||||
void nfc_render_iso14443_tech_type(const Iso14443_3aData* data, FuriString* str);
|
||||
|
||||
void nfc_render_iso14443_3a_format_bytes(FuriString* str, const uint8_t* const data, size_t size);
|
||||
|
||||
void nfc_render_iso14443_3a_brief(const Iso14443_3aData* data, FuriString* str);
|
||||
|
||||
@@ -13,6 +13,7 @@ static void nfc_scene_info_on_enter_iso14443_3b(NfcApp* instance) {
|
||||
const Iso14443_3bData* data = nfc_device_get_data(device, NfcProtocolIso14443_3b);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
nfc_render_iso14443_3b_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
@@ -59,8 +60,8 @@ 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, uint32_t event) {
|
||||
if(event == SubmenuIndexCommonEdit) {
|
||||
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;
|
||||
}
|
||||
@@ -68,7 +69,7 @@ bool nfc_scene_saved_menu_on_event_iso14443_3b_common(NfcApp* instance, uint32_t
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool nfc_scene_saved_menu_on_event_iso14443_3b(NfcApp* instance, uint32_t event) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
|
||||
#include "iso14443_3b.h"
|
||||
|
||||
bool nfc_scene_saved_menu_on_event_iso14443_3b_common(NfcApp* instance, uint32_t event);
|
||||
bool nfc_scene_saved_menu_on_event_iso14443_3b_common(NfcApp* instance, SceneManagerEvent event);
|
||||
|
||||
@@ -6,7 +6,7 @@ void nfc_render_iso14443_3b_info(
|
||||
FuriString* str) {
|
||||
if(format_type == NfcProtocolFormatTypeFull) {
|
||||
const char iso_type = iso14443_3b_supports_iso14443_4(data) ? '4' : '3';
|
||||
furi_string_cat_printf(str, "ISO 14443-%c (NFC-B)\n", iso_type);
|
||||
furi_string_cat_printf(str, "Tech: ISO 14443-%c (NFC-B)\n", iso_type);
|
||||
}
|
||||
|
||||
furi_string_cat_printf(str, "UID:");
|
||||
@@ -20,7 +20,7 @@ void nfc_render_iso14443_3b_info(
|
||||
|
||||
if(format_type != NfcProtocolFormatTypeFull) return;
|
||||
|
||||
furi_string_cat_printf(str, "\n\e#Protocol info\n");
|
||||
furi_string_cat_printf(str, "\n::::::::::::::::[Protocol info]:::::::::::::::\n");
|
||||
|
||||
if(iso14443_3b_supports_bit_rate(data, Iso14443_3bBitRateBoth106Kbit)) {
|
||||
furi_string_cat(str, "Bit rate PICC <-> PCD:\n 106 kBit/s supported\n");
|
||||
@@ -68,7 +68,7 @@ void nfc_render_iso14443_3b_info(
|
||||
iso14443_3b_supports_frame_option(data, Iso14443_3bFrameOptionCid) ? "" : "not ";
|
||||
furi_string_cat_printf(str, "CID: %ssupported", cid_support_str);
|
||||
|
||||
furi_string_cat_printf(str, "\n\e#Application data\nRaw:");
|
||||
furi_string_cat_printf(str, "\n::::::::::::[Application data]::::::::::::\nRaw:");
|
||||
|
||||
size_t app_data_size;
|
||||
const uint8_t* app_data = iso14443_3b_get_application_data(data, &app_data_size);
|
||||
|
||||
@@ -14,6 +14,7 @@ static void nfc_scene_info_on_enter_iso14443_4a(NfcApp* instance) {
|
||||
const Iso14443_4aData* data = nfc_device_get_data(device, NfcProtocolIso14443_4a);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
nfc_render_iso14443_4a_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
@@ -99,8 +100,8 @@ 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, uint32_t event) {
|
||||
if(event == SubmenuIndexCommonEmulate) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,12 @@ void nfc_render_iso14443_4a_info(
|
||||
}
|
||||
|
||||
void nfc_render_iso14443_4a_brief(const Iso14443_4aData* data, FuriString* str) {
|
||||
nfc_render_iso14443_tech_type(iso14443_4a_get_base_data(data), str);
|
||||
nfc_render_iso14443_3a_brief(iso14443_4a_get_base_data(data), str);
|
||||
}
|
||||
|
||||
void nfc_render_iso14443_4a_extra(const Iso14443_4aData* data, FuriString* str) {
|
||||
furi_string_cat_printf(str, "\n\e#Protocol info\n");
|
||||
furi_string_cat_printf(str, "\n::::::::::::::::[Protocol info]:::::::::::::::\n");
|
||||
|
||||
if(iso14443_4a_supports_bit_rate(data, Iso14443_4aBitRateBoth106Kbit)) {
|
||||
furi_string_cat(str, "Bit rate PICC <-> PCD:\n 106 kBit/s supported\n");
|
||||
@@ -72,7 +73,7 @@ void nfc_render_iso14443_4a_extra(const Iso14443_4aData* data, FuriString* str)
|
||||
const uint8_t* hist_bytes = iso14443_4a_get_historical_bytes(data, &hist_bytes_count);
|
||||
|
||||
if(hist_bytes_count > 0) {
|
||||
furi_string_cat_printf(str, "\n\e#Historical bytes\nRaw:");
|
||||
furi_string_cat_printf(str, "\n:::::::::::::[Historical bytes]:::::::::::::\nRaw:");
|
||||
|
||||
for(size_t i = 0; i < hist_bytes_count; ++i) {
|
||||
furi_string_cat_printf(str, " %02X", hist_bytes[i]);
|
||||
|
||||
@@ -14,6 +14,7 @@ static void nfc_scene_info_on_enter_iso14443_4b(NfcApp* instance) {
|
||||
const Iso14443_4bData* data = nfc_device_get_data(device, NfcProtocolIso14443_4b);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
nfc_render_iso14443_4b_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
@@ -64,8 +65,8 @@ 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, uint32_t event) {
|
||||
if(event == SubmenuIndexCommonEmulate) {
|
||||
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;
|
||||
}
|
||||
@@ -73,7 +74,7 @@ static bool nfc_scene_read_menu_on_event_iso14443_4b(NfcApp* instance, uint32_t
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool nfc_scene_saved_menu_on_event_iso14443_4b(NfcApp* instance, uint32_t event) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,16 +14,30 @@ static void nfc_scene_info_on_enter_iso15693_3(NfcApp* instance) {
|
||||
const Iso15693_3Data* data = nfc_device_get_data(device, NfcProtocolIso15693_3);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
nfc_render_iso15693_3_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
|
||||
widget_reset(instance->widget);
|
||||
widget_add_text_scroll_element(
|
||||
instance->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
|
||||
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static void nfc_scene_more_info_on_enter_iso15693_3(NfcApp* instance) {
|
||||
const NfcDevice* device = instance->nfc_device;
|
||||
const Iso15693_3Data* data = nfc_device_get_data(device, NfcProtocolIso15693_3);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_render_iso15693_3_system_info(data, temp_str);
|
||||
|
||||
widget_add_text_scroll_element(
|
||||
instance->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static NfcCommand nfc_scene_read_poller_callback_iso15693_3(NfcGenericEvent event, void* context) {
|
||||
furi_assert(event.protocol == NfcProtocolIso15693_3);
|
||||
|
||||
@@ -94,8 +108,8 @@ 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, uint32_t event) {
|
||||
if(event == SubmenuIndexCommonEdit) {
|
||||
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;
|
||||
}
|
||||
@@ -104,13 +118,19 @@ static bool nfc_scene_saved_menu_on_event_iso15693_3(NfcApp* instance, uint32_t
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_iso15693_3 = {
|
||||
.features = NfcProtocolFeatureEmulateFull | NfcProtocolFeatureEditUid,
|
||||
.features = NfcProtocolFeatureEmulateFull | NfcProtocolFeatureEditUid |
|
||||
NfcProtocolFeatureMoreInfo,
|
||||
|
||||
.scene_info =
|
||||
{
|
||||
.on_enter = nfc_scene_info_on_enter_iso15693_3,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_more_info =
|
||||
{
|
||||
.on_enter = nfc_scene_more_info_on_enter_iso15693_3,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_read =
|
||||
{
|
||||
.on_enter = nfc_scene_read_on_enter_iso15693_3,
|
||||
|
||||
@@ -36,32 +36,7 @@ void nfc_render_iso15693_3_brief(const Iso15693_3Data* data, FuriString* str) {
|
||||
}
|
||||
}
|
||||
|
||||
void nfc_render_iso15693_3_extra(const Iso15693_3Data* data, FuriString* str) {
|
||||
furi_string_cat(str, "\n\e#General info\n");
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_DSFID) {
|
||||
furi_string_cat_printf(str, "DSFID: %02X\n", data->system_info.ic_ref);
|
||||
}
|
||||
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_AFI) {
|
||||
furi_string_cat_printf(str, "AFI: %02X\n", data->system_info.afi);
|
||||
}
|
||||
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_IC_REF) {
|
||||
furi_string_cat_printf(str, "IC Reference: %02X\n", data->system_info.ic_ref);
|
||||
}
|
||||
|
||||
furi_string_cat(str, "\e#Lock bits\n");
|
||||
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_DSFID) {
|
||||
furi_string_cat_printf(
|
||||
str, "DSFID: %s locked\n", data->settings.lock_bits.dsfid ? "" : "not");
|
||||
}
|
||||
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_AFI) {
|
||||
furi_string_cat_printf(
|
||||
str, "AFI: %s locked\n", data->settings.lock_bits.dsfid ? "" : "not");
|
||||
}
|
||||
|
||||
void nfc_render_iso15693_3_system_info(const Iso15693_3Data* data, FuriString* str) {
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_MEMORY) {
|
||||
furi_string_cat(str, "\e#Memory data\n\e*--------------------\n");
|
||||
|
||||
@@ -88,5 +63,34 @@ void nfc_render_iso15693_3_extra(const Iso15693_3Data* data, FuriString* str) {
|
||||
"(Data is too big. Showing only the first %u bytes.)",
|
||||
display_block_count * block_size);
|
||||
}
|
||||
} else {
|
||||
furi_string_cat(str, "\e#No available data\n");
|
||||
}
|
||||
}
|
||||
|
||||
void nfc_render_iso15693_3_extra(const Iso15693_3Data* data, FuriString* str) {
|
||||
furi_string_cat(str, "\n::::::::::::::::[General info]:::::::::::::::::\n");
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_DSFID) {
|
||||
furi_string_cat_printf(str, "DSFID: %02X\n", data->system_info.ic_ref);
|
||||
}
|
||||
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_AFI) {
|
||||
furi_string_cat_printf(str, "AFI: %02X\n", data->system_info.afi);
|
||||
}
|
||||
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_IC_REF) {
|
||||
furi_string_cat_printf(str, "IC Reference: %02X\n", data->system_info.ic_ref);
|
||||
}
|
||||
|
||||
furi_string_cat(str, ":::::::::::::::::::[Lock bits]::::::::::::::::::::\n");
|
||||
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_DSFID) {
|
||||
furi_string_cat_printf(
|
||||
str, "DSFID: %s locked\n", data->settings.lock_bits.dsfid ? "" : "not");
|
||||
}
|
||||
|
||||
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_AFI) {
|
||||
furi_string_cat_printf(
|
||||
str, "AFI: %s locked\n", data->settings.lock_bits.dsfid ? "" : "not");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,3 +12,5 @@ void nfc_render_iso15693_3_info(
|
||||
void nfc_render_iso15693_3_brief(const Iso15693_3Data* data, FuriString* str);
|
||||
|
||||
void nfc_render_iso15693_3_extra(const Iso15693_3Data* data, FuriString* str);
|
||||
|
||||
void nfc_render_iso15693_3_system_info(const Iso15693_3Data* data, FuriString* str);
|
||||
|
||||
@@ -21,6 +21,7 @@ static void nfc_scene_info_on_enter_mf_classic(NfcApp* instance) {
|
||||
const MfClassicData* data = nfc_device_get_data(device, NfcProtocolMfClassic);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
furi_string_replace(temp_str, "Mifare", "MIFARE");
|
||||
@@ -99,8 +100,9 @@ static void nfc_scene_read_on_enter_mf_classic(NfcApp* instance) {
|
||||
nfc_poller_start(instance->poller, nfc_scene_read_poller_callback_mf_classic, instance);
|
||||
}
|
||||
|
||||
static bool nfc_scene_read_on_event_mf_classic(NfcApp* instance, uint32_t event) {
|
||||
if(event == NfcCustomEventPollerIncomplete) {
|
||||
static bool nfc_scene_read_on_event_mf_classic(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom &&
|
||||
event.event == NfcCustomEventPollerIncomplete) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicDictAttack);
|
||||
}
|
||||
|
||||
@@ -170,8 +172,8 @@ static void nfc_scene_emulate_on_enter_mf_classic(NfcApp* instance) {
|
||||
nfc_listener_start(instance->listener, NULL, NULL);
|
||||
}
|
||||
|
||||
static bool nfc_scene_read_menu_on_event_mf_classic(NfcApp* instance, uint32_t event) {
|
||||
if(event == SubmenuIndexDetectReader) {
|
||||
static bool nfc_scene_read_menu_on_event_mf_classic(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexDetectReader) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSaveConfirm);
|
||||
dolphin_deed(DolphinDeedNfcDetectReader);
|
||||
return true;
|
||||
@@ -180,27 +182,29 @@ static bool nfc_scene_read_menu_on_event_mf_classic(NfcApp* instance, uint32_t e
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool nfc_scene_saved_menu_on_event_mf_classic(NfcApp* instance, uint32_t event) {
|
||||
static bool nfc_scene_saved_menu_on_event_mf_classic(NfcApp* instance, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event == SubmenuIndexDetectReader) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicDetectReader);
|
||||
consumed = true;
|
||||
} else if(event == SubmenuIndexWrite) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicWriteInitial);
|
||||
consumed = true;
|
||||
} else if(event == SubmenuIndexUpdate) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicUpdateInitial);
|
||||
consumed = true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexDetectReader) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicDetectReader);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexWrite) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicWriteInitial);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexUpdate) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicUpdateInitial);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
static bool nfc_scene_save_name_on_event_mf_classic(NfcApp* instance, uint32_t event) {
|
||||
static bool nfc_scene_save_name_on_event_mf_classic(NfcApp* instance, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event == NfcCustomEventTextInputDone) {
|
||||
if(event.type == SceneManagerEventTypeCustom && event.event == NfcCustomEventTextInputDone) {
|
||||
mf_classic_key_cache_save(
|
||||
instance->mfc_key_cache,
|
||||
nfc_device_get_data(instance->nfc_device, NfcProtocolMfClassic));
|
||||
|
||||
@@ -18,13 +18,48 @@ void nfc_render_mf_classic_info(
|
||||
furi_string_cat_printf(str, "\nSectors Read: %u/%u", sectors_read, sectors_total);
|
||||
}
|
||||
|
||||
static void
|
||||
mf_classic_render_raw_data(const uint8_t* data, size_t size, bool data_read, FuriString* str) {
|
||||
furi_assert((size % 2) == 0);
|
||||
|
||||
for(size_t i = 0; i < size; i += 2) {
|
||||
if(data_read) {
|
||||
furi_string_cat_printf(str, "%02X%02X ", data[i], data[i + 1]);
|
||||
} else {
|
||||
furi_string_cat_printf(str, "???? ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mf_classic_render_block(const MfClassicData* data, uint8_t block_num, FuriString* str) {
|
||||
if(mf_classic_is_sector_trailer(block_num)) {
|
||||
uint8_t sec_num = mf_classic_get_sector_by_block(block_num);
|
||||
MfClassicSectorTrailer* sec_tr = mf_classic_get_sector_trailer_by_sector(data, sec_num);
|
||||
|
||||
// Render key A
|
||||
bool key_read = mf_classic_is_key_found(data, sec_num, MfClassicKeyTypeA);
|
||||
mf_classic_render_raw_data(sec_tr->key_a.data, sizeof(MfClassicKey), key_read, str);
|
||||
|
||||
// Render access bits
|
||||
bool access_bits_read = mf_classic_is_block_read(data, block_num);
|
||||
mf_classic_render_raw_data(
|
||||
sec_tr->access_bits.data, sizeof(MfClassicAccessBits), access_bits_read, str);
|
||||
|
||||
// Render key B
|
||||
key_read = mf_classic_is_key_found(data, sec_num, MfClassicKeyTypeB);
|
||||
mf_classic_render_raw_data(sec_tr->key_b.data, sizeof(MfClassicKey), key_read, str);
|
||||
} else {
|
||||
const uint8_t* block_data = data->block[block_num].data;
|
||||
bool block_read = mf_classic_is_block_read(data, block_num);
|
||||
mf_classic_render_raw_data(block_data, sizeof(MfClassicBlock), block_read, str);
|
||||
}
|
||||
}
|
||||
|
||||
void nfc_render_mf_classic_dump(const MfClassicData* data, FuriString* str) {
|
||||
uint16_t total_blocks = mf_classic_get_total_block_num(data->type);
|
||||
|
||||
for(size_t i = 0; i < total_blocks; i++) {
|
||||
for(size_t j = 0; j < sizeof(MfClassicBlock); j += 2) {
|
||||
furi_string_cat_printf(
|
||||
str, "%02X%02X ", data->block[i].data[j], data->block[i].data[j + 1]);
|
||||
}
|
||||
mf_classic_render_block(data, i, str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,10 @@ static void nfc_scene_info_on_enter_mf_desfire(NfcApp* instance) {
|
||||
const MfDesfireData* data = nfc_device_get_data(device, NfcProtocolMfDesfire);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
furi_string_replace(temp_str, "Mifare", "MIFARE");
|
||||
nfc_render_mf_desfire_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
|
||||
widget_add_text_scroll_element(
|
||||
@@ -56,6 +58,7 @@ static void nfc_scene_read_success_on_enter_mf_desfire(NfcApp* instance) {
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
furi_string_replace(temp_str, "Mifare", "MIFARE");
|
||||
nfc_render_mf_desfire_info(data, NfcProtocolFormatTypeShort, temp_str);
|
||||
|
||||
widget_add_text_scroll_element(
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "mf_ultralight_render.h"
|
||||
|
||||
#include <nfc/protocols/mf_ultralight/mf_ultralight_poller.h>
|
||||
#include <toolbox/pretty_format.h>
|
||||
|
||||
#include "nfc/nfc_app_i.h"
|
||||
|
||||
@@ -15,11 +16,18 @@ enum {
|
||||
SubmenuIndexWrite,
|
||||
};
|
||||
|
||||
enum {
|
||||
NfcSceneMoreInfoStateASCII,
|
||||
NfcSceneMoreInfoStateRawData,
|
||||
};
|
||||
|
||||
static void nfc_scene_info_on_enter_mf_ultralight(NfcApp* instance) {
|
||||
const NfcDevice* device = instance->nfc_device;
|
||||
const MfUltralightData* data = nfc_device_get_data(device, NfcProtocolMfUltralight);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
nfc_render_mf_ultralight_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
@@ -35,11 +43,62 @@ static void nfc_scene_more_info_on_enter_mf_ultralight(NfcApp* instance) {
|
||||
const MfUltralightData* mfu = nfc_device_get_data(device, NfcProtocolMfUltralight);
|
||||
|
||||
furi_string_reset(instance->text_box_store);
|
||||
nfc_render_mf_ultralight_dump(mfu, instance->text_box_store);
|
||||
uint32_t scene_state =
|
||||
scene_manager_get_scene_state(instance->scene_manager, NfcSceneMoreInfo);
|
||||
|
||||
text_box_set_font(instance->text_box, TextBoxFontHex);
|
||||
text_box_set_text(instance->text_box, furi_string_get_cstr(instance->text_box_store));
|
||||
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewTextBox);
|
||||
if(scene_state == NfcSceneMoreInfoStateASCII) {
|
||||
pretty_format_bytes_hex_canonical(
|
||||
instance->text_box_store,
|
||||
MF_ULTRALIGHT_PAGE_SIZE,
|
||||
PRETTY_FORMAT_FONT_MONOSPACE,
|
||||
(uint8_t*)mfu->page,
|
||||
mfu->pages_read * MF_ULTRALIGHT_PAGE_SIZE);
|
||||
|
||||
widget_add_text_scroll_element(
|
||||
instance->widget, 0, 0, 128, 48, furi_string_get_cstr(instance->text_box_store));
|
||||
widget_add_button_element(
|
||||
instance->widget,
|
||||
GuiButtonTypeRight,
|
||||
"Raw Data",
|
||||
nfc_protocol_support_common_widget_callback,
|
||||
instance);
|
||||
|
||||
widget_add_button_element(
|
||||
instance->widget,
|
||||
GuiButtonTypeLeft,
|
||||
"Info",
|
||||
nfc_protocol_support_common_widget_callback,
|
||||
instance);
|
||||
} else if(scene_state == NfcSceneMoreInfoStateRawData) {
|
||||
nfc_render_mf_ultralight_dump(mfu, instance->text_box_store);
|
||||
widget_add_text_scroll_element(
|
||||
instance->widget, 0, 0, 128, 48, furi_string_get_cstr(instance->text_box_store));
|
||||
|
||||
widget_add_button_element(
|
||||
instance->widget,
|
||||
GuiButtonTypeLeft,
|
||||
"ASCII",
|
||||
nfc_protocol_support_common_widget_callback,
|
||||
instance);
|
||||
}
|
||||
}
|
||||
|
||||
static bool nfc_scene_more_info_on_event_mf_ultralight(NfcApp* instance, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if((event.type == SceneManagerEventTypeCustom && event.event == GuiButtonTypeLeft) ||
|
||||
(event.type == SceneManagerEventTypeBack)) {
|
||||
scene_manager_set_scene_state(
|
||||
instance->scene_manager, NfcSceneMoreInfo, NfcSceneMoreInfoStateASCII);
|
||||
scene_manager_previous_scene(instance->scene_manager);
|
||||
consumed = true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom && event.event == GuiButtonTypeRight) {
|
||||
scene_manager_set_scene_state(
|
||||
instance->scene_manager, NfcSceneMoreInfo, NfcSceneMoreInfoStateRawData);
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMoreInfo);
|
||||
consumed = true;
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
static NfcCommand
|
||||
@@ -132,15 +191,17 @@ static void nfc_scene_read_on_enter_mf_ultralight(NfcApp* instance) {
|
||||
nfc_poller_start(instance->poller, nfc_scene_read_poller_callback_mf_ultralight, instance);
|
||||
}
|
||||
|
||||
bool nfc_scene_read_on_event_mf_ultralight(NfcApp* instance, uint32_t event) {
|
||||
if(event == NfcCustomEventCardDetected) {
|
||||
scene_manager_set_scene_state(
|
||||
instance->scene_manager, NfcSceneRead, NfcSceneMfUltralightReadMenuStateCardFound);
|
||||
nfc_scene_read_setup_view(instance);
|
||||
} else if((event == NfcCustomEventPollerIncomplete)) {
|
||||
notification_message(instance->notifications, &sequence_semi_success);
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneReadSuccess);
|
||||
dolphin_deed(DolphinDeedNfcReadSuccess);
|
||||
bool nfc_scene_read_on_event_mf_ultralight(NfcApp* instance, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NfcCustomEventCardDetected) {
|
||||
scene_manager_set_scene_state(
|
||||
instance->scene_manager, NfcSceneRead, NfcSceneMfUltralightReadMenuStateCardFound);
|
||||
nfc_scene_read_setup_view(instance);
|
||||
} else if((event.event == NfcCustomEventPollerIncomplete)) {
|
||||
notification_message(instance->notifications, &sequence_semi_success);
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneReadSuccess);
|
||||
dolphin_deed(DolphinDeedNfcReadSuccess);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -202,14 +263,17 @@ static void nfc_scene_emulate_on_enter_mf_ultralight(NfcApp* instance) {
|
||||
nfc_listener_start(instance->listener, NULL, NULL);
|
||||
}
|
||||
|
||||
static bool
|
||||
nfc_scene_read_and_saved_menu_on_event_mf_ultralight(NfcApp* instance, uint32_t event) {
|
||||
if(event == SubmenuIndexUnlock) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfUltralightUnlockMenu);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexWrite) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfUltralightWrite);
|
||||
return true;
|
||||
static bool nfc_scene_read_and_saved_menu_on_event_mf_ultralight(
|
||||
NfcApp* instance,
|
||||
SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexUnlock) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfUltralightUnlockMenu);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexWrite) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneMfUltralightWrite);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -225,7 +289,7 @@ const NfcProtocolSupportBase nfc_protocol_support_mf_ultralight = {
|
||||
.scene_more_info =
|
||||
{
|
||||
.on_enter = nfc_scene_more_info_on_enter_mf_ultralight,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
.on_event = nfc_scene_more_info_on_event_mf_ultralight,
|
||||
},
|
||||
.scene_read =
|
||||
{
|
||||
|
||||
@@ -36,10 +36,11 @@ void nfc_render_mf_ultralight_info(
|
||||
}
|
||||
|
||||
void nfc_render_mf_ultralight_dump(const MfUltralightData* data, FuriString* str) {
|
||||
furi_string_cat_printf(str, "\e*");
|
||||
for(size_t i = 0; i < data->pages_read; i++) {
|
||||
const uint8_t* page_data = data->page[i].data;
|
||||
for(size_t j = 0; j < MF_ULTRALIGHT_PAGE_SIZE; j += 2) {
|
||||
furi_string_cat_printf(str, "%02X%02X ", page_data[j], page_data[j + 1]);
|
||||
furi_string_cat_printf(str, " %02X%02X", page_data[j], page_data[j + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ void nfc_protocol_support_on_exit(NfcProtocolSupportScene scene, void* context)
|
||||
nfc_protocol_support_scenes[scene].on_exit(instance);
|
||||
}
|
||||
|
||||
static bool nfc_protocol_support_has_feature(NfcProtocol protocol, NfcProtocolFeature feature) {
|
||||
bool nfc_protocol_support_has_feature(NfcProtocol protocol, NfcProtocolFeature feature) {
|
||||
return nfc_protocol_support[protocol]->features & feature;
|
||||
}
|
||||
|
||||
@@ -131,16 +131,15 @@ static bool
|
||||
nfc_protocol_support_scene_more_info_on_event(NfcApp* instance, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
const NfcProtocol protocol = nfc_device_get_protocol(instance->nfc_device);
|
||||
consumed = nfc_protocol_support[protocol]->scene_more_info.on_event(instance, event.event);
|
||||
}
|
||||
const NfcProtocol protocol = nfc_device_get_protocol(instance->nfc_device);
|
||||
consumed = nfc_protocol_support[protocol]->scene_more_info.on_event(instance, event);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
static void nfc_protocol_support_scene_more_info_on_exit(NfcApp* instance) {
|
||||
text_box_reset(instance->text_box);
|
||||
widget_reset(instance->widget);
|
||||
furi_string_reset(instance->text_box_store);
|
||||
}
|
||||
|
||||
@@ -188,8 +187,7 @@ static bool nfc_protocol_support_scene_read_on_event(NfcApp* instance, SceneMana
|
||||
} else {
|
||||
const NfcProtocol protocol =
|
||||
instance->protocols_detected[instance->protocols_detected_selected_idx];
|
||||
consumed =
|
||||
nfc_protocol_support[protocol]->scene_read.on_event(instance, event.event);
|
||||
consumed = nfc_protocol_support[protocol]->scene_read.on_event(instance, event);
|
||||
}
|
||||
} else if(event.event == NfcCustomEventPollerFailure) {
|
||||
nfc_poller_stop(instance->poller);
|
||||
@@ -202,7 +200,7 @@ static bool nfc_protocol_support_scene_read_on_event(NfcApp* instance, SceneMana
|
||||
} else if(event.event == NfcCustomEventCardDetected) {
|
||||
const NfcProtocol protocol =
|
||||
instance->protocols_detected[instance->protocols_detected_selected_idx];
|
||||
consumed = nfc_protocol_support[protocol]->scene_read.on_event(instance, event.event);
|
||||
consumed = nfc_protocol_support[protocol]->scene_read.on_event(instance, event);
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
nfc_poller_stop(instance->poller);
|
||||
@@ -287,8 +285,7 @@ static bool
|
||||
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.event);
|
||||
consumed = nfc_protocol_support[protocol]->scene_read_menu.on_event(instance, event);
|
||||
}
|
||||
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
@@ -456,8 +453,7 @@ static bool
|
||||
consumed = true;
|
||||
} else {
|
||||
const NfcProtocol protocol = nfc_device_get_protocol(instance->nfc_device);
|
||||
consumed =
|
||||
nfc_protocol_support[protocol]->scene_saved_menu.on_event(instance, event.event);
|
||||
consumed = nfc_protocol_support[protocol]->scene_saved_menu.on_event(instance, event);
|
||||
}
|
||||
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
@@ -523,8 +519,8 @@ static bool
|
||||
DolphinDeedNfcSave);
|
||||
const NfcProtocol protocol =
|
||||
instance->protocols_detected[instance->protocols_detected_selected_idx];
|
||||
consumed = nfc_protocol_support[protocol]->scene_save_name.on_event(
|
||||
instance, event.event);
|
||||
consumed =
|
||||
nfc_protocol_support[protocol]->scene_save_name.on_event(instance, event);
|
||||
} else {
|
||||
consumed = scene_manager_search_and_switch_to_previous_scene(
|
||||
instance->scene_manager, NfcSceneStart);
|
||||
@@ -565,11 +561,11 @@ static void nfc_protocol_support_scene_emulate_on_enter(NfcApp* instance) {
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
const NfcProtocol protocol = nfc_device_get_protocol(instance->nfc_device);
|
||||
|
||||
widget_add_icon_element(widget, 0, 3, &I_NFC_dolphin_emulation_47x61);
|
||||
widget_add_icon_element(widget, 0, 3, &I_NFC_dolphin_emulation_51x64);
|
||||
|
||||
if(nfc_protocol_support_has_feature(protocol, NfcProtocolFeatureEmulateUid)) {
|
||||
widget_add_string_element(
|
||||
widget, 90, 13, AlignCenter, AlignTop, FontPrimary, "Emulating UID");
|
||||
widget, 90, 26, AlignCenter, AlignCenter, FontPrimary, "Emulating UID");
|
||||
|
||||
size_t uid_len;
|
||||
const uint8_t* uid = nfc_device_get_uid(instance->nfc_device, &uid_len);
|
||||
@@ -581,7 +577,8 @@ static void nfc_protocol_support_scene_emulate_on_enter(NfcApp* instance) {
|
||||
furi_string_trim(temp_str);
|
||||
|
||||
} else {
|
||||
widget_add_string_element(widget, 90, 13, AlignCenter, AlignTop, FontPrimary, "Emulating");
|
||||
widget_add_string_element(
|
||||
widget, 90, 26, AlignCenter, AlignCenter, FontPrimary, "Emulating");
|
||||
if(!furi_string_empty(instance->file_name)) {
|
||||
furi_string_printf(
|
||||
temp_str,
|
||||
@@ -593,11 +590,12 @@ static void nfc_protocol_support_scene_emulate_on_enter(NfcApp* instance) {
|
||||
temp_str,
|
||||
"Unsaved\n%s",
|
||||
nfc_device_get_name(instance->nfc_device, NfcDeviceNameTypeFull));
|
||||
furi_string_replace_str(temp_str, "Mifare", "MIFARE");
|
||||
}
|
||||
}
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 56, 28, 71, 25, AlignCenter, AlignTop, furi_string_get_cstr(temp_str), false);
|
||||
widget, 56, 33, 71, 25, AlignCenter, AlignTop, furi_string_get_cstr(temp_str), false);
|
||||
|
||||
furi_string_free(temp_str);
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
#include <lib/nfc/protocols/nfc_protocol.h>
|
||||
|
||||
#include "nfc_protocol_support_common.h"
|
||||
|
||||
@@ -111,3 +112,5 @@ bool nfc_protocol_support_on_event(
|
||||
* @param[in,out] context pointer to a user-specified context (will be passed to concrete handler).
|
||||
*/
|
||||
void nfc_protocol_support_on_exit(NfcProtocolSupportScene scene, void* context);
|
||||
|
||||
bool nfc_protocol_support_has_feature(NfcProtocol protocol, NfcProtocolFeature feature);
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <core/string.h>
|
||||
|
||||
#include "../../nfc_app.h"
|
||||
#include "../../nfc_app_i.h"
|
||||
|
||||
/**
|
||||
* @brief Scene entry handler.
|
||||
@@ -19,10 +20,10 @@ typedef void (*NfcProtocolSupportOnEnter)(NfcApp* instance);
|
||||
* @brief Scene event handler.
|
||||
*
|
||||
* @param[in,out] instance pointer to the NFC application instance.
|
||||
* @param[in] event custom event that has occurred.
|
||||
* @param[in] event scene manager event that has occurred.
|
||||
* @returns true if the event was handled, false otherwise.
|
||||
*/
|
||||
typedef bool (*NfcProtocolSupportOnEvent)(NfcApp* instance, uint32_t event);
|
||||
typedef bool (*NfcProtocolSupportOnEvent)(NfcApp* instance, SceneManagerEvent event);
|
||||
|
||||
/**
|
||||
* @brief Abstract scene interface.
|
||||
|
||||
@@ -35,8 +35,8 @@ void nfc_protocol_support_common_on_enter_empty(NfcApp* instance) {
|
||||
UNUSED(instance);
|
||||
}
|
||||
|
||||
bool nfc_protocol_support_common_on_event_empty(NfcApp* instance, uint32_t event) {
|
||||
bool nfc_protocol_support_common_on_event_empty(NfcApp* instance, SceneManagerEvent event) {
|
||||
UNUSED(instance);
|
||||
UNUSED(event);
|
||||
return true;
|
||||
return event.type != SceneManagerEventTypeBack;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <gui/modules/widget.h>
|
||||
|
||||
#include "nfc/nfc_app.h"
|
||||
#include "nfc/nfc_app_i.h"
|
||||
|
||||
/**
|
||||
* @brief Common submenu indices.
|
||||
@@ -82,4 +83,4 @@ void nfc_protocol_support_common_on_enter_empty(NfcApp* instance);
|
||||
* @param[in] event custom event type that has occurred.
|
||||
* @returns always true.
|
||||
*/
|
||||
bool nfc_protocol_support_common_on_event_empty(NfcApp* instance, uint32_t event);
|
||||
bool nfc_protocol_support_common_on_event_empty(NfcApp* instance, SceneManagerEvent event);
|
||||
|
||||
@@ -14,16 +14,30 @@ static void nfc_scene_info_on_enter_slix(NfcApp* instance) {
|
||||
const SlixData* data = nfc_device_get_data(device, NfcProtocolSlix);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
nfc_render_slix_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
|
||||
widget_reset(instance->widget);
|
||||
widget_add_text_scroll_element(
|
||||
instance->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
|
||||
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static void nfc_scene_more_info_on_enter_slix(NfcApp* instance) {
|
||||
const NfcDevice* device = instance->nfc_device;
|
||||
const SlixData* data = nfc_device_get_data(device, NfcProtocolSlix);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_render_iso15693_3_system_info(slix_get_base_data(data), temp_str);
|
||||
|
||||
widget_add_text_scroll_element(
|
||||
instance->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static NfcCommand nfc_scene_read_poller_callback_slix(NfcGenericEvent event, void* context) {
|
||||
furi_assert(event.protocol == NfcProtocolSlix);
|
||||
|
||||
@@ -91,8 +105,8 @@ 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, uint32_t event) {
|
||||
if(event == SubmenuIndexCommonEdit) {
|
||||
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;
|
||||
}
|
||||
@@ -101,13 +115,18 @@ static bool nfc_scene_saved_menu_on_event_slix(NfcApp* instance, uint32_t event)
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_slix = {
|
||||
.features = NfcProtocolFeatureEmulateFull,
|
||||
.features = NfcProtocolFeatureEmulateFull | NfcProtocolFeatureMoreInfo,
|
||||
|
||||
.scene_info =
|
||||
{
|
||||
.on_enter = nfc_scene_info_on_enter_slix,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_more_info =
|
||||
{
|
||||
.on_enter = nfc_scene_more_info_on_enter_slix,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_read =
|
||||
{
|
||||
.on_enter = nfc_scene_read_on_enter_slix,
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
#include "slix_render.h"
|
||||
|
||||
#include "../iso15693_3/iso15693_3_render.h"
|
||||
|
||||
void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_type, FuriString* str) {
|
||||
nfc_render_iso15693_3_brief(slix_get_base_data(data), str);
|
||||
|
||||
if(format_type != NfcProtocolFormatTypeFull) return;
|
||||
const SlixType slix_type = slix_get_type(data);
|
||||
|
||||
furi_string_cat(str, "\n\e#Passwords\n");
|
||||
furi_string_cat(str, "\n::::::::::::::::::[Passwords]:::::::::::::::::\n");
|
||||
|
||||
static const char* slix_password_names[] = {
|
||||
"Read",
|
||||
@@ -25,7 +23,7 @@ void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_typ
|
||||
}
|
||||
}
|
||||
|
||||
furi_string_cat(str, "\e#Lock bits\n");
|
||||
furi_string_cat(str, ":::::::::::::::::::[Lock bits]::::::::::::::::::::\n");
|
||||
|
||||
if(slix_type_has_features(slix_type, SLIX_TYPE_FEATURE_EAS)) {
|
||||
furi_string_cat_printf(
|
||||
@@ -38,7 +36,7 @@ void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_typ
|
||||
|
||||
const SlixProtection protection = data->system_info.protection;
|
||||
|
||||
furi_string_cat(str, "\e#Page protection\n");
|
||||
furi_string_cat(str, "::::::::::::[Page protection]::::::::::::\n");
|
||||
furi_string_cat_printf(str, "Pointer: H >= %02X\n", protection.pointer);
|
||||
|
||||
const char* rh = (protection.condition & SLIX_PP_CONDITION_RH) ? "" : "un";
|
||||
@@ -52,12 +50,12 @@ void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_typ
|
||||
}
|
||||
|
||||
if(slix_type_has_features(slix_type, SLIX_TYPE_FEATURE_PRIVACY)) {
|
||||
furi_string_cat(str, "\e#Privacy\n");
|
||||
furi_string_cat(str, "::::::::::::::::::::[Privacy]::::::::::::::::::::::\n");
|
||||
furi_string_cat_printf(str, "Privacy mode: %sabled\n", data->privacy ? "en" : "dis");
|
||||
}
|
||||
|
||||
if(slix_type_has_features(slix_type, SLIX_TYPE_FEATURE_SIGNATURE)) {
|
||||
furi_string_cat(str, "\e#Signature\n");
|
||||
furi_string_cat(str, ":::::::::::::::::::[Signature]::::::::::::::::::\n");
|
||||
for(uint32_t i = 0; i < 4; ++i) {
|
||||
furi_string_cat_printf(str, "%02X ", data->signature[i]);
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
#include <nfc/protocols/slix/slix.h>
|
||||
|
||||
#include "../nfc_protocol_support_render_common.h"
|
||||
#include "../iso15693_3/iso15693_3_render.h"
|
||||
|
||||
void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_type, FuriString* str);
|
||||
|
||||
@@ -13,6 +13,7 @@ static void nfc_scene_info_on_enter_st25tb(NfcApp* instance) {
|
||||
const St25tbData* data = nfc_device_get_data(device, NfcProtocolSt25tb);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
nfc_render_st25tb_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
@@ -60,8 +61,8 @@ 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, uint32_t event) {
|
||||
if(event == SubmenuIndexCommonEdit) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "nfc_app_i.h"
|
||||
#include "helpers/protocol_support/nfc_protocol_support.h"
|
||||
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
@@ -445,6 +446,15 @@ void nfc_app_reset_detected_protocols(NfcApp* instance) {
|
||||
instance->protocols_detected_num = 0;
|
||||
}
|
||||
|
||||
void nfc_append_filename_string_when_present(NfcApp* instance, FuriString* string) {
|
||||
furi_assert(instance);
|
||||
furi_assert(string);
|
||||
|
||||
if(!furi_string_empty(instance->file_name)) {
|
||||
furi_string_cat_printf(string, "Name:%s\n", furi_string_get_cstr(instance->file_name));
|
||||
}
|
||||
}
|
||||
|
||||
static bool nfc_is_hal_ready() {
|
||||
if(furi_hal_nfc_is_hal_ready() != FuriHalNfcErrorNone) {
|
||||
// No connection to the chip, show an error screen
|
||||
@@ -466,6 +476,15 @@ static bool nfc_is_hal_ready() {
|
||||
}
|
||||
}
|
||||
|
||||
static void nfc_show_initial_scene_for_device(NfcApp* nfc) {
|
||||
NfcProtocol prot = nfc_device_get_protocol(nfc->nfc_device);
|
||||
uint32_t scene = nfc_protocol_support_has_feature(
|
||||
prot, NfcProtocolFeatureEmulateFull | NfcProtocolFeatureEmulateUid) ?
|
||||
NfcSceneEmulate :
|
||||
NfcSceneSavedMenu;
|
||||
scene_manager_next_scene(nfc->scene_manager, scene);
|
||||
}
|
||||
|
||||
int32_t nfc_app(void* p) {
|
||||
if(!nfc_is_hal_ready()) return 0;
|
||||
|
||||
@@ -485,7 +504,7 @@ int32_t nfc_app(void* p) {
|
||||
|
||||
furi_string_set(nfc->file_path, args);
|
||||
if(nfc_load_file(nfc, nfc->file_path, false)) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulate);
|
||||
nfc_show_initial_scene_for_device(nfc);
|
||||
} else {
|
||||
view_dispatcher_stop(nfc->view_dispatcher);
|
||||
}
|
||||
|
||||
@@ -193,3 +193,5 @@ void nfc_make_app_folder(NfcApp* instance);
|
||||
void nfc_app_set_detected_protocols(NfcApp* instance, const NfcProtocol* types, uint32_t count);
|
||||
|
||||
void nfc_app_reset_detected_protocols(NfcApp* instance);
|
||||
|
||||
void nfc_append_filename_string_when_present(NfcApp* instance, FuriString* string);
|
||||
|
||||
@@ -29,6 +29,8 @@ void nfc_scene_select_protocol_on_enter(void* context) {
|
||||
"%s %s",
|
||||
prefix,
|
||||
nfc_device_get_protocol_name(instance->protocols_detected[i]));
|
||||
|
||||
furi_string_replace_str(temp_str, "Mifare", "MIFARE");
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
furi_string_get_cstr(temp_str),
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
BIN
assets/icons/NFC/NFC_dolphin_emulation_51x64.png
Normal file
BIN
assets/icons/NFC/NFC_dolphin_emulation_51x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Reference in New Issue
Block a user