mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-25 20:23:07 +00:00
79 lines
2.4 KiB
C
79 lines
2.4 KiB
C
#include "flipfrid_scene_load_custom_uids.h"
|
|
#include "flipfrid_scene_run_attack.h"
|
|
#include "flipfrid_scene_entrypoint.h"
|
|
|
|
#define LFRFID_UIDS_EXTENSION ".txt"
|
|
#define RFIDFUZZER_APP_PATH_FOLDER "/ext/rfidfuzzer"
|
|
|
|
bool flipfrid_load_uids(FlipFridState* context, const char* file_path) {
|
|
bool result = false;
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
context->uids_stream = buffered_file_stream_alloc(storage);
|
|
result =
|
|
buffered_file_stream_open(context->uids_stream, file_path, FSAM_READ, FSOM_OPEN_EXISTING);
|
|
// Close if loading fails
|
|
if(!result) {
|
|
buffered_file_stream_close(context->uids_stream);
|
|
return false;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
bool flipfrid_load_custom_uids_from_file(FlipFridState* context) {
|
|
// Input events and views are managed by file_select
|
|
string_t uid_path;
|
|
string_init(uid_path);
|
|
string_set_str(uid_path, RFIDFUZZER_APP_PATH_FOLDER);
|
|
|
|
bool res = dialog_file_browser_show(
|
|
context->dialogs, uid_path, uid_path, LFRFID_UIDS_EXTENSION, true, &I_125_10px, false);
|
|
|
|
if(res) {
|
|
res = flipfrid_load_uids(context, string_get_cstr(uid_path));
|
|
}
|
|
|
|
string_clear(uid_path);
|
|
|
|
return res;
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_enter(FlipFridState* context) {
|
|
if(flipfrid_load_custom_uids_from_file(context)) {
|
|
// Force context loading
|
|
flipfrid_scene_run_attack_on_enter(context);
|
|
context->current_scene = SceneAttack;
|
|
} else {
|
|
flipfrid_scene_entrypoint_on_enter(context);
|
|
context->current_scene = SceneEntryPoint;
|
|
}
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_exit(FlipFridState* context) {
|
|
UNUSED(context);
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_tick(FlipFridState* context) {
|
|
UNUSED(context);
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_event(FlipFridEvent event, FlipFridState* context) {
|
|
if(event.evt_type == EventTypeKey) {
|
|
if(event.input_type == InputTypeShort) {
|
|
switch(event.key) {
|
|
case InputKeyDown:
|
|
case InputKeyUp:
|
|
case InputKeyLeft:
|
|
case InputKeyRight:
|
|
case InputKeyOk:
|
|
case InputKeyBack:
|
|
context->current_scene = SceneEntryPoint;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_draw(Canvas* canvas, FlipFridState* context) {
|
|
UNUSED(context);
|
|
UNUSED(canvas);
|
|
}
|