mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-20 20:38:24 -07:00
nfc: Add faster auth callback patch
This commit is contained in:
@@ -3,12 +3,6 @@
|
||||
bool nfc_scene_mf_ultralight_unlock_auto_worker_callback(NfcWorkerEvent event, void* context) {
|
||||
Nfc* nfc = context;
|
||||
|
||||
if(event == NfcWorkerEventMfUltralightPwdAuth) {
|
||||
MfUltralightAuth* auth = &nfc->dev->dev_data.mf_ul_auth;
|
||||
memcpy(nfc->byte_input_store, auth->pwd.raw, sizeof(auth->pwd.raw));
|
||||
nfc->dev->dev_data.mf_ul_data.auth_method = MfUltralightAuthMethodManual;
|
||||
}
|
||||
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, event);
|
||||
return true;
|
||||
}
|
||||
@@ -38,6 +32,10 @@ bool nfc_scene_mf_ultralight_unlock_auto_on_event(void* context, SceneManagerEve
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if((event.event == NfcWorkerEventMfUltralightPwdAuth)) {
|
||||
MfUltralightAuth* auth = &nfc->dev->dev_data.mf_ul_auth;
|
||||
memcpy(nfc->byte_input_store, auth->pwd.raw, sizeof(auth->pwd.raw));
|
||||
nfc->dev->dev_data.mf_ul_data.auth_method = MfUltralightAuthMethodManual;
|
||||
nfc_worker_stop(nfc->worker);
|
||||
notification_message(nfc->notifications, &sequence_success);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightUnlockWarn);
|
||||
consumed = true;
|
||||
|
||||
+15
-8
@@ -531,10 +531,25 @@ void nfc_worker_emulate_apdu(NfcWorker* nfc_worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void nfc_worker_mf_ultralight_auth_received_callback(MfUltralightAuth auth, void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
NfcWorker* nfc_worker = context;
|
||||
nfc_worker->dev_data->mf_ul_auth = auth;
|
||||
if(nfc_worker->callback) {
|
||||
nfc_worker->callback(NfcWorkerEventMfUltralightPwdAuth, nfc_worker->context);
|
||||
}
|
||||
}
|
||||
|
||||
void nfc_worker_emulate_mf_ultralight(NfcWorker* nfc_worker) {
|
||||
FuriHalNfcDevData* nfc_data = &nfc_worker->dev_data->nfc_data;
|
||||
MfUltralightEmulator emulator = {};
|
||||
mf_ul_prepare_emulation(&emulator, &nfc_worker->dev_data->mf_ul_data);
|
||||
|
||||
// TODO rework with reader analyzer
|
||||
emulator.auth_received_callback = nfc_worker_mf_ultralight_auth_received_callback;
|
||||
emulator.context = nfc_worker;
|
||||
|
||||
while(nfc_worker->state == NfcWorkerStateMfUltralightEmulate) {
|
||||
mf_ul_reset_emulation(&emulator, true);
|
||||
furi_hal_nfc_emulate_nfca(
|
||||
@@ -545,14 +560,6 @@ void nfc_worker_emulate_mf_ultralight(NfcWorker* nfc_worker) {
|
||||
mf_ul_prepare_emulation_response,
|
||||
&emulator,
|
||||
5000);
|
||||
// Check if there was an auth attempt
|
||||
if(emulator.auth_attempted) {
|
||||
nfc_worker->dev_data->mf_ul_auth = emulator.auth_attempt; // Make copy
|
||||
if(nfc_worker->callback) {
|
||||
nfc_worker->callback(NfcWorkerEventMfUltralightPwdAuth, nfc_worker->context);
|
||||
}
|
||||
emulator.auth_attempted = false;
|
||||
}
|
||||
// Check if data was modified
|
||||
if(emulator.data_changed) {
|
||||
nfc_worker->dev_data->mf_ul_data = emulator.data;
|
||||
|
||||
@@ -1741,6 +1741,10 @@ bool mf_ul_prepare_emulation_response(
|
||||
&buff_rx[1],
|
||||
sizeof(emulator->auth_attempt.pwd.raw));
|
||||
emulator->auth_attempted = true;
|
||||
if(emulator->auth_received_callback) {
|
||||
emulator->auth_received_callback(
|
||||
emulator->auth_attempt, emulator->context);
|
||||
}
|
||||
|
||||
uint16_t scaled_authlim = mf_ultralight_calc_auth_count(&emulator->data);
|
||||
if(scaled_authlim != 0 && emulator->data.curr_authlim >= scaled_authlim) {
|
||||
|
||||
@@ -170,6 +170,9 @@ typedef struct {
|
||||
MfUltralightFeatures supported_features;
|
||||
} MfUltralightReader;
|
||||
|
||||
// TODO rework with reader analyzer
|
||||
typedef void (*MfUltralightAuthReceivedCallback)(MfUltralightAuth auth, void* context);
|
||||
|
||||
typedef struct {
|
||||
MfUltralightData data;
|
||||
MfUltralightConfigPages* config;
|
||||
@@ -188,6 +191,10 @@ typedef struct {
|
||||
bool read_counter_incremented;
|
||||
bool auth_attempted;
|
||||
MfUltralightAuth auth_attempt;
|
||||
|
||||
// TODO rework with reader analyzer
|
||||
MfUltralightAuthReceivedCallback auth_received_callback;
|
||||
void* context;
|
||||
} MfUltralightEmulator;
|
||||
|
||||
void mf_ul_reset(MfUltralightData* data);
|
||||
|
||||
Submodule
+1
Submodule lib/scons added at c2d1f09f61
Reference in New Issue
Block a user