Skip to content

Commit

Permalink
no gen4 ? :(
Browse files Browse the repository at this point in the history
actually, gen4 changes will be finished and merged here soon, app is reverted to ofw current version only for testing purposes, please be patient and wait for next updates on gen4 improvements
  • Loading branch information
xMasterX committed Apr 5, 2024
1 parent 19b0f83 commit f746977
Show file tree
Hide file tree
Showing 56 changed files with 3,472 additions and 1,242 deletions.
7 changes: 1 addition & 6 deletions base_pack/nfc_magic/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ App(
],
stack_size=4 * 1024,
fap_description="Application for writing to NFC tags with modifiable sector 0",
fap_version="1.6",
fap_version="1.7",
fap_icon="assets/Nfc_10px.png",
fap_category="NFC",
fap_private_libs=[
Lib(
name="magic",
),
],
fap_icon_assets="assets",
)
Binary file added base_pack/nfc_magic/assets/DolphinSuccess_91x55.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 0 additions & 97 deletions base_pack/nfc_magic/lib/magic/protocols/gen4/gen4.c

This file was deleted.

101 changes: 0 additions & 101 deletions base_pack/nfc_magic/lib/magic/protocols/gen4/gen4.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "nfc_magic_scanner.h"

#include "core/check.h"
#include "protocols/gen1a/gen1a_poller.h"
#include "protocols/gen4/gen4.h"
#include "protocols/gen2/gen2_poller.h"
#include "protocols/gen4/gen4_poller.h"
#include <nfc/nfc_poller.h>

Expand All @@ -19,8 +18,7 @@ struct NfcMagicScanner {
NfcMagicScannerSessionState session_state;
NfcMagicProtocol current_protocol;

Gen4Password gen4_password;
Gen4* gen4_data;
uint32_t gen4_password;
bool magic_protocol_detected;

NfcMagicScannerCallback callback;
Expand All @@ -45,19 +43,17 @@ NfcMagicScanner* nfc_magic_scanner_alloc(Nfc* nfc) {

NfcMagicScanner* instance = malloc(sizeof(NfcMagicScanner));
instance->nfc = nfc;
instance->gen4_data = gen4_alloc();

return instance;
}

void nfc_magic_scanner_free(NfcMagicScanner* instance) {
furi_assert(instance);

gen4_free(instance->gen4_data);
free(instance);
}

void nfc_magic_scanner_set_gen4_password(NfcMagicScanner* instance, Gen4Password password) {
void nfc_magic_scanner_set_gen4_password(NfcMagicScanner* instance, uint32_t password) {
furi_assert(instance);

instance->gen4_password = password;
Expand All @@ -70,24 +66,33 @@ static int32_t nfc_magic_scanner_worker(void* context) {
furi_assert(instance->session_state == NfcMagicScannerSessionStateActive);

while(instance->session_state == NfcMagicScannerSessionStateActive) {
if(instance->current_protocol == NfcMagicProtocolGen1) {
instance->magic_protocol_detected = gen1a_poller_detect(instance->nfc);
} else if(instance->current_protocol == NfcMagicProtocolGen4) {
gen4_reset(instance->gen4_data);
Gen4 gen4_data;
Gen4PollerError error =
gen4_poller_detect(instance->nfc, instance->gen4_password, &gen4_data);
if(error == Gen4PollerErrorProtocol) {
NfcMagicScannerEvent event = {
.type = NfcMagicScannerEventTypeDetectedNotMagic,
};
instance->callback(event, instance->context);
break;
} else {
do {
if(instance->current_protocol == NfcMagicProtocolGen1) {
instance->magic_protocol_detected = gen1a_poller_detect(instance->nfc);
if(instance->magic_protocol_detected) {
break;
}
} else if(instance->current_protocol == NfcMagicProtocolGen4) {
Gen4PollerError error = gen4_poller_detect(instance->nfc, instance->gen4_password);
instance->magic_protocol_detected = (error == Gen4PollerErrorNone);
gen4_copy(instance->gen4_data, &gen4_data);
if(instance->magic_protocol_detected) {
break;
}
} else if(instance->current_protocol == NfcMagicProtocolGen2) {
Gen2PollerError error = gen2_poller_detect(instance->nfc);
instance->magic_protocol_detected = (error == Gen2PollerErrorNone);
if(instance->magic_protocol_detected) {
break;
}
} else if(instance->current_protocol == NfcMagicProtocolClassic) {
NfcPoller* poller = nfc_poller_alloc(instance->nfc, NfcProtocolMfClassic);
instance->magic_protocol_detected = nfc_poller_detect(poller);
nfc_poller_free(poller);
if(instance->magic_protocol_detected) {
break;
}
}
}
} while(false);

if(instance->magic_protocol_detected) {
NfcMagicScannerEvent event = {
Expand Down Expand Up @@ -157,9 +162,3 @@ void nfc_magic_scanner_stop(NfcMagicScanner* instance) {
instance->callback = NULL;
instance->context = NULL;
}

Gen4* nfc_magic_scanner_get_gen4_data(NfcMagicScanner* instance) {
furi_assert(instance);

return instance->gen4_data;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "protocols/gen4/gen4.h"
#include <nfc/nfc.h>
#include "protocols/nfc_magic_protocols.h"

Expand Down Expand Up @@ -31,7 +30,7 @@ NfcMagicScanner* nfc_magic_scanner_alloc(Nfc* nfc);

void nfc_magic_scanner_free(NfcMagicScanner* instance);

void nfc_magic_scanner_set_gen4_password(NfcMagicScanner* instance, Gen4Password password);
void nfc_magic_scanner_set_gen4_password(NfcMagicScanner* instance, uint32_t password);

void nfc_magic_scanner_start(
NfcMagicScanner* instance,
Expand All @@ -40,8 +39,6 @@ void nfc_magic_scanner_start(

void nfc_magic_scanner_stop(NfcMagicScanner* instance);

Gen4* nfc_magic_scanner_get_gen4_data(NfcMagicScanner* instance);

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit f746977

Please sign in to comment.