2022-09-05 00:32:58 +03:00
|
|
|
#include "flipfrid_scene_load_custom_uids.h"
|
|
|
|
#include "flipfrid_scene_run_attack.h"
|
|
|
|
#include "flipfrid_scene_entrypoint.h"
|
|
|
|
|
|
|
|
#define LFRFID_UIDS_EXTENSION ".txt"
|
2022-09-05 14:05:43 +03:00
|
|
|
#define RFIDFUZZER_APP_PATH_FOLDER "/ext/rfidfuzzer"
|
2022-09-05 00:32:58 +03:00
|
|
|
|
|
|
|
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
|
2022-09-05 14:05:43 +03:00
|
|
|
string_t uid_path;
|
|
|
|
string_init(uid_path);
|
|
|
|
string_set_str(uid_path, RFIDFUZZER_APP_PATH_FOLDER);
|
|
|
|
|
2022-09-14 21:04:04 +03:00
|
|
|
DialogsFileBrowserOptions browser_options;
|
|
|
|
dialog_file_browser_set_basic_options(&browser_options, LFRFID_UIDS_EXTENSION, &I_125_10px);
|
|
|
|
browser_options.hide_ext = false;
|
|
|
|
|
|
|
|
bool res = dialog_file_browser_show(context->dialogs, uid_path, uid_path, &browser_options);
|
2022-09-05 00:32:58 +03:00
|
|
|
|
|
|
|
if(res) {
|
2022-09-05 14:05:43 +03:00
|
|
|
res = flipfrid_load_uids(context, string_get_cstr(uid_path));
|
2022-09-05 00:32:58 +03:00
|
|
|
}
|
2022-09-05 14:05:43 +03:00
|
|
|
|
|
|
|
string_clear(uid_path);
|
|
|
|
|
2022-09-05 00:32:58 +03:00
|
|
|
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);
|
|
|
|
}
|