-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/DarkFlippers/unleashed-firmware
- Loading branch information
Showing
23 changed files
with
1,359 additions
and
2 deletions.
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
applications/main/nfc/helpers/protocol_support/mf_plus/mf_plus.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#include "mf_plus.h" | ||
#include "mf_plus_render.h" | ||
|
||
#include <nfc/protocols/mf_plus/mf_plus_poller.h> | ||
|
||
#include "nfc/nfc_app_i.h" | ||
|
||
#include "../nfc_protocol_support_common.h" | ||
#include "../nfc_protocol_support_gui_common.h" | ||
#include "../iso14443_4a/iso14443_4a_i.h" | ||
|
||
static void nfc_scene_info_on_enter_mf_plus(NfcApp* instance) { | ||
const NfcDevice* device = instance->nfc_device; | ||
const MfPlusData* data = nfc_device_get_data(device, NfcProtocolMfPlus); | ||
|
||
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_plus_info(data, NfcProtocolFormatTypeFull, temp_str); | ||
|
||
widget_add_text_scroll_element( | ||
instance->widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str)); | ||
|
||
furi_string_free(temp_str); | ||
} | ||
static NfcCommand nfc_scene_read_poller_callback_mf_plus(NfcGenericEvent event, void* context) { | ||
furi_assert(event.protocol == NfcProtocolMfPlus); | ||
|
||
NfcApp* instance = context; | ||
const MfPlusPollerEvent* mf_plus_event = event.event_data; | ||
|
||
if(mf_plus_event->type == MfPlusPollerEventTypeReadSuccess) { | ||
nfc_device_set_data( | ||
instance->nfc_device, NfcProtocolMfPlus, nfc_poller_get_data(instance->poller)); | ||
FURI_LOG_D( | ||
"MFP", | ||
"Read success: %s", | ||
nfc_device_get_name(instance->nfc_device, NfcDeviceNameTypeFull)); | ||
view_dispatcher_send_custom_event(instance->view_dispatcher, NfcCustomEventPollerSuccess); | ||
return NfcCommandStop; | ||
} | ||
|
||
return NfcCommandContinue; | ||
} | ||
|
||
static void nfc_scene_read_on_enter_mf_plus(NfcApp* instance) { | ||
nfc_poller_start(instance->poller, nfc_scene_read_poller_callback_mf_plus, instance); | ||
} | ||
|
||
static void nfc_scene_read_success_on_enter_mf_plus(NfcApp* instance) { | ||
const NfcDevice* device = instance->nfc_device; | ||
const MfPlusData* data = nfc_device_get_data(device, NfcProtocolMfPlus); | ||
|
||
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_plus_info(data, NfcProtocolFormatTypeShort, temp_str); | ||
|
||
widget_add_text_scroll_element( | ||
instance->widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str)); | ||
|
||
furi_string_free(temp_str); | ||
} | ||
|
||
static void nfc_scene_emulate_on_enter_mf_plus(NfcApp* instance) { | ||
const Iso14443_4aData* iso14443_4a_data = | ||
nfc_device_get_data(instance->nfc_device, NfcProtocolIso14443_4a); | ||
|
||
instance->listener = | ||
nfc_listener_alloc(instance->nfc, NfcProtocolIso14443_4a, iso14443_4a_data); | ||
nfc_listener_start( | ||
instance->listener, nfc_scene_emulate_listener_callback_iso14443_4a, instance); | ||
} | ||
|
||
const NfcProtocolSupportBase nfc_protocol_support_mf_plus = { | ||
.features = NfcProtocolFeatureMoreInfo, | ||
|
||
.scene_info = | ||
{ | ||
.on_enter = nfc_scene_info_on_enter_mf_plus, | ||
.on_event = nfc_protocol_support_common_on_event_empty, | ||
}, | ||
.scene_more_info = | ||
{ | ||
.on_enter = nfc_protocol_support_common_on_enter_empty, | ||
.on_event = nfc_protocol_support_common_on_event_empty, | ||
}, | ||
.scene_read = | ||
{ | ||
.on_enter = nfc_scene_read_on_enter_mf_plus, | ||
.on_event = nfc_protocol_support_common_on_event_empty, | ||
}, | ||
.scene_read_menu = | ||
{ | ||
.on_enter = nfc_protocol_support_common_on_enter_empty, | ||
.on_event = nfc_protocol_support_common_on_event_empty, | ||
}, | ||
.scene_read_success = | ||
{ | ||
.on_enter = nfc_scene_read_success_on_enter_mf_plus, | ||
.on_event = nfc_protocol_support_common_on_event_empty, | ||
}, | ||
.scene_saved_menu = | ||
{ | ||
.on_enter = nfc_protocol_support_common_on_enter_empty, | ||
.on_event = nfc_protocol_support_common_on_event_empty, | ||
}, | ||
.scene_save_name = | ||
{ | ||
.on_enter = nfc_protocol_support_common_on_enter_empty, | ||
.on_event = nfc_protocol_support_common_on_event_empty, | ||
}, | ||
.scene_emulate = | ||
{ | ||
.on_enter = nfc_scene_emulate_on_enter_mf_plus, | ||
.on_event = nfc_protocol_support_common_on_event_empty, | ||
}, | ||
}; |
5 changes: 5 additions & 0 deletions
5
applications/main/nfc/helpers/protocol_support/mf_plus/mf_plus.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include "../nfc_protocol_support_base.h" | ||
|
||
extern const NfcProtocolSupportBase nfc_protocol_support_mf_plus; |
67 changes: 67 additions & 0 deletions
67
applications/main/nfc/helpers/protocol_support/mf_plus/mf_plus_render.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "mf_plus_render.h" | ||
|
||
#include "../iso14443_4a/iso14443_4a_render.h" | ||
|
||
void nfc_render_mf_plus_info( | ||
const MfPlusData* data, | ||
NfcProtocolFormatType format_type, | ||
FuriString* str) { | ||
nfc_render_iso14443_4a_brief(mf_plus_get_base_data(data), str); | ||
|
||
if(format_type != NfcProtocolFormatTypeFull) return; | ||
|
||
furi_string_cat(str, "\n\e#ISO14443-4 data"); | ||
nfc_render_iso14443_4a_extra(mf_plus_get_base_data(data), str); | ||
} | ||
|
||
void nfc_render_mf_plus_data(const MfPlusData* data, FuriString* str) { | ||
nfc_render_mf_plus_version(&data->version, str); | ||
} | ||
|
||
void nfc_render_mf_plus_version(const MfPlusVersion* data, FuriString* str) { | ||
furi_string_cat_printf( | ||
str, | ||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", | ||
data->uid[0], | ||
data->uid[1], | ||
data->uid[2], | ||
data->uid[3], | ||
data->uid[4], | ||
data->uid[5], | ||
data->uid[6]); | ||
furi_string_cat_printf( | ||
str, | ||
"hw %02x type %02x sub %02x\n" | ||
" maj %02x min %02x\n" | ||
" size %02x proto %02x\n", | ||
data->hw_vendor, | ||
data->hw_type, | ||
data->hw_subtype, | ||
data->hw_major, | ||
data->hw_minor, | ||
data->hw_storage, | ||
data->hw_proto); | ||
furi_string_cat_printf( | ||
str, | ||
"sw %02x type %02x sub %02x\n" | ||
" maj %02x min %02x\n" | ||
" size %02x proto %02x\n", | ||
data->sw_vendor, | ||
data->sw_type, | ||
data->sw_subtype, | ||
data->sw_major, | ||
data->sw_minor, | ||
data->sw_storage, | ||
data->sw_proto); | ||
furi_string_cat_printf( | ||
str, | ||
"batch %02x:%02x:%02x:%02x:%02x\n" | ||
"week %d year %d\n", | ||
data->batch[0], | ||
data->batch[1], | ||
data->batch[2], | ||
data->batch[3], | ||
data->batch[4], | ||
data->prod_week, | ||
data->prod_year); | ||
} |
14 changes: 14 additions & 0 deletions
14
applications/main/nfc/helpers/protocol_support/mf_plus/mf_plus_render.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <nfc/protocols/mf_plus/mf_plus.h> | ||
|
||
#include "../nfc_protocol_support_render_common.h" | ||
|
||
void nfc_render_mf_plus_info( | ||
const MfPlusData* data, | ||
NfcProtocolFormatType format_type, | ||
FuriString* str); | ||
|
||
void nfc_render_mf_plus_data(const MfPlusData* data, FuriString* str); | ||
|
||
void nfc_render_mf_plus_version(const MfPlusVersion* data, FuriString* str); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.