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-2605] NFC new design #1364

Merged
merged 53 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
022d62c
nfc: add new read scene
gornekich Jun 29, 2022
11cff4f
lib: refactore nfc library
gornekich Jun 30, 2022
c40f9c3
mifare desfire: add read card fuction
gornekich Jul 1, 2022
a9e5173
lib nfc: add auto read worker
gornekich Jun 30, 2022
1206266
nfc: add supported cards
gornekich Jul 4, 2022
fb21fed
nfc: add mifare classic read success scene
gornekich Jul 4, 2022
10d9ccd
nfc: add troyka support
gornekich Jul 4, 2022
8a0f476
submodule: update protobuf
gornekich Jul 4, 2022
2685cdf
nfc: mifare classic keys cache
gornekich Jul 8, 2022
dc5f3b8
nfc: rework mifare classic key cache
gornekich Jul 12, 2022
6d1b974
Correct spelling
Astrrra Jul 12, 2022
27a7f85
nfc: add user dictionary
gornekich Jul 13, 2022
fb17b14
nfc: introduce block read map in fff
gornekich Jul 14, 2022
b5afd7a
nfc: rework dict attack
gornekich Jul 18, 2022
f424a8a
nfc: improve dict attack
gornekich Jul 19, 2022
8016dbf
nfc: rework mifare classic format
gornekich Jul 19, 2022
ab96033
nfc: rework MFC read with Reader
gornekich Jul 20, 2022
5557022
nfc: add gui for MFC read success scene
gornekich Jul 20, 2022
ffdc8d6
nfc: fix dict attack view gui
gornekich Jul 20, 2022
26dd54d
nfc: add retry and exit confirm scenes
gornekich Jul 20, 2022
312cb92
nfc: add retry and exit scenes navigation
gornekich Jul 20, 2022
86f8894
nfc: check user dictionary
gornekich Jul 20, 2022
1b4a812
nfc: remove unused scenes
gornekich Jul 21, 2022
a67317f
nfc: rename functions in nfc worker
gornekich Jul 21, 2022
a3d4b27
nfc: rename mf_classic_dict_attack -> dict_attack
gornekich Jul 21, 2022
8131af4
nfc: change scenes names
gornekich Jul 21, 2022
d4581e4
nfc: remove scene tick events
gornekich Jul 21, 2022
8bf93a6
Merge branch 'dev' into gornek/2605_nfc_new_design
gornekich Jul 22, 2022
559ff96
nfc: format sources
gornekich Jul 22, 2022
63d81e0
Merge branch 'dev' into gornek/2605_nfc_new_design
gornekich Jul 24, 2022
0087a88
nfc: rework dict calls with buffer streams
gornekich Jul 24, 2022
51d98d0
nfc: fix notifications
gornekich Jul 25, 2022
37403c4
nfc: fix mf desfire navigation
gornekich Jul 25, 2022
d465f93
nfc: remove notification from mf classic read success
gornekich Jul 25, 2022
98546d1
nfc: fix read sectors calculation
gornekich Jul 25, 2022
10301cf
nfc: add fallback for unknown card
gornekich Jul 25, 2022
3c48c43
nfc: show file name while emulating
gornekich Jul 25, 2022
5442fb8
Merge branch 'dev' into gornek/2605_nfc_new_design
gornekich Jul 25, 2022
f7375ef
Merge branch 'dev' into gornek/2605_nfc_new_design
gornekich Jul 25, 2022
a8812c1
nfc: fix build
gornekich Jul 25, 2022
8ae0e6a
nfc: fix memory leak
gornekich Jul 25, 2022
e7cadab
nfc: fix desfire read
gornekich Jul 25, 2022
0f30a6d
nfc: add no dict found navigation
gornekich Jul 25, 2022
6ba679a
nfc: add read views
gornekich Jul 25, 2022
45cffe5
nfc: update card fix
gornekich Jul 26, 2022
d937c1f
Merge branch 'dev' into gornek/2605_nfc_new_design
gornekich Jul 26, 2022
20cc454
nfc: fix access bytes save
gornekich Jul 26, 2022
698a556
nfc: add exit and retry confirm to mf ultralight read success
gornekich Jul 26, 2022
5a1b49c
nfc: introduce detect reader
gornekich Jul 26, 2022
9be933e
merge branch 'dev' into gornek/2605_nfc_new_design
gornekich Jul 26, 2022
dd38d9a
nfc: change record open arg to macros
gornekich Jul 26, 2022
f8180c9
Merge branch 'dev' into gornek/2605_nfc_new_design
skotopes Jul 26, 2022
bea8ac5
nfc: fix start from archive
gornekich Jul 26, 2022
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: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
/lib/microtar/ @skotopes @DrZlo13 @hedger
/lib/mlib/ @skotopes @DrZlo13 @hedger
/lib/nanopb/ @skotopes @DrZlo13 @hedger
/lib/nfc_protocols/ @skotopes @DrZlo13 @hedger @gornekich
/lib/nfc/ @skotopes @DrZlo13 @hedger @gornekich
/lib/one_wire/ @skotopes @DrZlo13 @hedger
/lib/qrcode/ @skotopes @DrZlo13 @hedger
/lib/subghz/ @skotopes @DrZlo13 @hedger @Skorpionm
Expand Down
1 change: 1 addition & 0 deletions applications/nfc/helpers/nfc_custom_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ enum NfcCustomEvent {
NfcCustomEventByteInputDone,
NfcCustomEventTextInputDone,
NfcCustomEventDictAttackDone,
NfcCustomEventDictAttackSkip,
NfcCustomEventRpcLoad,
};
26 changes: 13 additions & 13 deletions applications/nfc/helpers/nfc_generators.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,67 +267,67 @@ static void nfc_generate_ntag_i2c_plus_2k(NfcDeviceData* data) {
static const NfcGenerator mf_ul_generator = {
.name = "Mifare Ultralight",
.generator_func = nfc_generate_mf_ul_orig,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator mf_ul_11_generator = {
.name = "Mifare Ultralight EV1 11",
.generator_func = nfc_generate_mf_ul_11,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator mf_ul_h11_generator = {
.name = "Mifare Ultralight EV1 H11",
.generator_func = nfc_generate_mf_ul_h11,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator mf_ul_21_generator = {
.name = "Mifare Ultralight EV1 21",
.generator_func = nfc_generate_mf_ul_21,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator mf_ul_h21_generator = {
.name = "Mifare Ultralight EV1 H21",
.generator_func = nfc_generate_mf_ul_h21,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator ntag203_generator = {
.name = "NTAG203",
.generator_func = nfc_generate_mf_ul_ntag203,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator ntag213_generator = {
.name = "NTAG213",
.generator_func = nfc_generate_ntag213,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator ntag215_generator = {
.name = "NTAG215",
.generator_func = nfc_generate_ntag215,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator ntag216_generator = {
.name = "NTAG216",
.generator_func = nfc_generate_ntag216,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator ntag_i2c_1k_generator = {
.name = "NTAG I2C 1k",
.generator_func = nfc_generate_ntag_i2c_1k,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator ntag_i2c_2k_generator = {
.name = "NTAG I2C 2k",
.generator_func = nfc_generate_ntag_i2c_2k,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator ntag_i2c_plus_1k_generator = {
.name = "NTAG I2C Plus 1k",
.generator_func = nfc_generate_ntag_i2c_plus_1k,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

static const NfcGenerator ntag_i2c_plus_2k_generator = {
.name = "NTAG I2C Plus 2k",
.generator_func = nfc_generate_ntag_i2c_plus_2k,
.next_scene = NfcSceneMifareUlMenu};
.next_scene = NfcSceneMfUltralightMenu};

const NfcGenerator* const nfc_generators[] = {
&mf_ul_generator,
Expand Down
53 changes: 0 additions & 53 deletions applications/nfc/helpers/nfc_mf_classic_dict.c

This file was deleted.

15 changes: 0 additions & 15 deletions applications/nfc/helpers/nfc_mf_classic_dict.h

This file was deleted.

24 changes: 9 additions & 15 deletions applications/nfc/nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ bool nfc_back_event_callback(void* context) {
return scene_manager_handle_back_event(nfc->scene_manager);
}

void nfc_tick_event_callback(void* context) {
furi_assert(context);
Nfc* nfc = context;
scene_manager_handle_tick_event(nfc->scene_manager);
}

void nfc_rpc_exit_callback(Nfc* nfc) {
if(nfc->rpc_state == NfcRpcStateEmulating) {
// Stop worker
Expand All @@ -36,11 +30,12 @@ void nfc_rpc_exit_callback(Nfc* nfc) {
}
}

static void nfc_rpc_emulate_callback(NfcWorkerEvent event, void* context) {
static bool nfc_rpc_emulate_callback(NfcWorkerEvent event, void* context) {
UNUSED(event);
Nfc* nfc = context;

nfc->rpc_state = NfcRpcStateEmulated;
return true;
}

static bool nfc_rpc_command_callback(RpcAppSystemEvent event, const char* arg, void* context) {
Expand All @@ -67,20 +62,20 @@ static bool nfc_rpc_command_callback(RpcAppSystemEvent event, const char* arg, v
if(nfc->dev->format == NfcDeviceSaveFormatMifareUl) {
nfc_worker_start(
nfc->worker,
NfcWorkerStateEmulateMifareUltralight,
NfcWorkerStateMfUltralightEmulate,
&nfc->dev->dev_data,
nfc_rpc_emulate_callback,
nfc);
} else if(nfc->dev->format == NfcDeviceSaveFormatMifareClassic) {
nfc_worker_start(
nfc->worker,
NfcWorkerStateEmulateMifareClassic,
NfcWorkerStateMfClassicEmulate,
&nfc->dev->dev_data,
nfc_rpc_emulate_callback,
nfc);
} else {
nfc_worker_start(
nfc->worker, NfcWorkerStateEmulate, &nfc->dev->dev_data, NULL, nfc);
nfc->worker, NfcWorkerStateUidEmulate, &nfc->dev->dev_data, NULL, nfc);
}
nfc->rpc_state = NfcRpcStateEmulating;
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventRpcLoad);
Expand All @@ -102,7 +97,6 @@ Nfc* nfc_alloc() {
view_dispatcher_set_event_callback_context(nfc->view_dispatcher, nfc);
view_dispatcher_set_custom_event_callback(nfc->view_dispatcher, nfc_custom_event_callback);
view_dispatcher_set_navigation_event_callback(nfc->view_dispatcher, nfc_back_event_callback);
view_dispatcher_set_tick_event_callback(nfc->view_dispatcher, nfc_tick_event_callback, 100);

// Nfc device
nfc->dev = nfc_device_alloc();
Expand Down Expand Up @@ -155,7 +149,7 @@ Nfc* nfc_alloc() {
view_dispatcher_add_view(
nfc->view_dispatcher, NfcViewBankCard, bank_card_get_view(nfc->bank_card));

// Dict Attack
// Mifare Classic Dict Attack
nfc->dict_attack = dict_attack_alloc();
view_dispatcher_add_view(
nfc->view_dispatcher, NfcViewDictAttack, dict_attack_get_view(nfc->dict_attack));
Expand Down Expand Up @@ -209,7 +203,7 @@ void nfc_free(Nfc* nfc) {
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewBankCard);
bank_card_free(nfc->bank_card);

// Dict Attack
// Mifare Classic Dict Attack
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewDictAttack);
dict_attack_free(nfc->dict_attack);

Expand Down Expand Up @@ -301,9 +295,9 @@ int32_t nfc_app(void* p) {
nfc->view_dispatcher, nfc->gui, ViewDispatcherTypeFullscreen);
if(nfc_device_load(nfc->dev, p, true)) {
if(nfc->dev->format == NfcDeviceSaveFormatMifareUl) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateMifareUl);
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightEmulate);
} else if(nfc->dev->format == NfcDeviceSaveFormatMifareClassic) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateMifareClassic);
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicEmulate);
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
}
Expand Down
5 changes: 3 additions & 2 deletions applications/nfc/nfc_cli.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <furi.h>
#include <furi_hal.h>
#include <cli/cli.h>
#include <toolbox/args.h>
#include <lib/toolbox/args.h>

#include "nfc_types.h"
#include <lib/nfc/nfc_types.h>
#include <lib/nfc/nfc_device.h>

static void nfc_cli_print_usage() {
printf("Usage:\r\n");
Expand Down
11 changes: 6 additions & 5 deletions applications/nfc/nfc_i.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#pragma once

#include "nfc.h"
#include "nfc_types.h"
#include "nfc_worker.h"
#include "nfc_device.h"

#include <furi.h>
#include <furi_hal.h>
Expand All @@ -24,6 +21,11 @@
#include <gui/modules/text_box.h>
#include <gui/modules/widget.h>

#include <lib/nfc/nfc_types.h>
#include <lib/nfc/nfc_worker.h>
#include <lib/nfc/nfc_device.h>
#include <lib/nfc/helpers/mf_classic_dict.h>

#include "views/bank_card.h"
#include "views/dict_attack.h"

Expand All @@ -32,8 +34,6 @@

#include "rpc/rpc_app.h"

#define NFC_SEND_NOTIFICATION_FALSE (0UL)
#define NFC_SEND_NOTIFICATION_TRUE (1UL)
#define NFC_TEXT_STORE_SIZE 128

typedef enum {
Expand All @@ -56,6 +56,7 @@ struct Nfc {

char text_store[NFC_TEXT_STORE_SIZE + 1];
string_t text_box_store;
uint8_t byte_input_store[6];

void* rpc_ctx;
NfcRpcState rpc_state;
Expand Down
Loading