mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 13:48:35 -07:00
Merge branch 'dev' of https://github.com/flipperdevices/flipperzero-firmware into mntm-dev
This commit is contained in:
@@ -1,45 +1,50 @@
|
||||
#include "../lfrfid_i.h"
|
||||
|
||||
#define LFRFID_SCENE_DELETE_MAX_HEX_WIDTH (7UL)
|
||||
|
||||
void lfrfid_scene_delete_confirm_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Widget* widget = app->widget;
|
||||
|
||||
FuriString* tmp_string;
|
||||
tmp_string = furi_string_alloc();
|
||||
FuriString* display_text = furi_string_alloc_printf(
|
||||
"\e#Delete %s?\e#\n"
|
||||
"Hex: ",
|
||||
furi_string_get_cstr(app->file_name));
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", lfrfid_widget_callback, app);
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "Delete", lfrfid_widget_callback, app);
|
||||
const size_t data_size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
||||
uint8_t* data = malloc(data_size);
|
||||
|
||||
furi_string_printf(tmp_string, "Delete %s?", furi_string_get_cstr(app->file_name));
|
||||
widget_add_string_element(
|
||||
widget, 64, 0, AlignCenter, AlignTop, FontPrimary, furi_string_get_cstr(tmp_string));
|
||||
protocol_dict_get_data(app->dict, app->protocol_id, data, data_size);
|
||||
|
||||
furi_string_reset(tmp_string);
|
||||
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
||||
uint8_t* data = (uint8_t*)malloc(size);
|
||||
protocol_dict_get_data(app->dict, app->protocol_id, data, size);
|
||||
for(uint8_t i = 0; i < MIN(size, (size_t)8); i++) {
|
||||
if(i != 0) {
|
||||
furi_string_cat_printf(tmp_string, " ");
|
||||
for(size_t i = 0; i < data_size; i++) {
|
||||
if(i == LFRFID_SCENE_DELETE_MAX_HEX_WIDTH) {
|
||||
furi_string_cat(display_text, " ...");
|
||||
break;
|
||||
}
|
||||
|
||||
furi_string_cat_printf(tmp_string, "%02X", data[i]);
|
||||
furi_string_cat_printf(display_text, "%s%02X", i != 0 ? " " : "", data[i]);
|
||||
}
|
||||
|
||||
furi_string_push_back(display_text, '\n');
|
||||
|
||||
free(data);
|
||||
|
||||
widget_add_string_element(
|
||||
widget, 64, 19, AlignCenter, AlignTop, FontSecondary, furi_string_get_cstr(tmp_string));
|
||||
widget_add_string_element(
|
||||
widget,
|
||||
64,
|
||||
49,
|
||||
AlignCenter,
|
||||
AlignBottom,
|
||||
FontSecondary,
|
||||
protocol_dict_get_name(app->dict, app->protocol_id));
|
||||
const char* protocol = protocol_dict_get_name(app->dict, app->protocol_id);
|
||||
const char* manufacturer = protocol_dict_get_manufacturer(app->dict, app->protocol_id);
|
||||
|
||||
if(strcasecmp(protocol, manufacturer) != 0 && strcasecmp(manufacturer, "N/A") != 0) {
|
||||
furi_string_cat_printf(display_text, "%s ", manufacturer);
|
||||
}
|
||||
|
||||
furi_string_cat(display_text, protocol);
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 64, AlignCenter, AlignTop, furi_string_get_cstr(display_text), true);
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Cancel", lfrfid_widget_callback, app);
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "Delete", lfrfid_widget_callback, app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
|
||||
furi_string_free(tmp_string);
|
||||
furi_string_free(display_text);
|
||||
}
|
||||
|
||||
bool lfrfid_scene_delete_confirm_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
@@ -18,10 +18,9 @@ bool lfrfid_scene_delete_success_on_event(void* context, SceneManagerEvent event
|
||||
LfRfid* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if((event.type == SceneManagerEventTypeBack) ||
|
||||
((event.type == SceneManagerEventTypeCustom) && (event.event == LfRfidEventPopupClosed))) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, LfRfidSceneSelectKey);
|
||||
if(event.type == SceneManagerEventTypeBack || event.type == SceneManagerEventTypeCustom) {
|
||||
// Always return to SceneSelectKey from here
|
||||
scene_manager_search_and_switch_to_another_scene(app->scene_manager, LfRfidSceneSelectKey);
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,21 +11,22 @@ void lfrfid_scene_emulate_popup_callback(void* context) {
|
||||
|
||||
void lfrfid_scene_emulate_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Popup* popup = app->popup;
|
||||
Widget* widget = app->widget;
|
||||
|
||||
popup_set_header(popup, "Emulating", 89, 30, AlignCenter, AlignTop);
|
||||
if(!furi_string_empty(app->file_name)) {
|
||||
popup_set_text(popup, furi_string_get_cstr(app->file_name), 89, 43, AlignCenter, AlignTop);
|
||||
FuriString* display_text = furi_string_alloc_set("\e#Emulating\e#\n");
|
||||
|
||||
if(furi_string_empty(app->file_name)) {
|
||||
furi_string_cat(display_text, "Unsaved\n");
|
||||
furi_string_cat(display_text, protocol_dict_get_name(app->dict, app->protocol_id));
|
||||
} else {
|
||||
popup_set_text(
|
||||
popup,
|
||||
protocol_dict_get_name(app->dict, app->protocol_id),
|
||||
89,
|
||||
43,
|
||||
AlignCenter,
|
||||
AlignTop);
|
||||
furi_string_cat(display_text, app->file_name);
|
||||
}
|
||||
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
|
||||
|
||||
widget_add_icon_element(widget, 0, 0, &I_NFC_dolphin_emulation_51x64);
|
||||
widget_add_text_box_element(
|
||||
widget, 55, 16, 67, 48, AlignCenter, AlignTop, furi_string_get_cstr(display_text), true);
|
||||
|
||||
furi_string_free(display_text);
|
||||
|
||||
lfrfid_worker_start_thread(app->lfworker);
|
||||
lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id);
|
||||
@@ -39,7 +40,7 @@ void lfrfid_scene_emulate_on_enter(void* context) {
|
||||
momentum_settings.favorite_timeout * furi_kernel_get_tick_frequency());
|
||||
}
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
|
||||
}
|
||||
|
||||
bool lfrfid_scene_emulate_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -71,7 +72,7 @@ void lfrfid_scene_emulate_on_exit(void* context) {
|
||||
}
|
||||
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
popup_reset(app->popup);
|
||||
widget_reset(app->widget);
|
||||
lfrfid_worker_stop(app->lfworker);
|
||||
lfrfid_worker_stop_thread(app->lfworker);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ void lfrfid_scene_exit_confirm_on_enter(void* context) {
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Exit", lfrfid_widget_callback, app);
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "Stay", lfrfid_widget_callback, app);
|
||||
widget_add_string_element(
|
||||
widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Exit to RFID Menu?");
|
||||
widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Exit to RFID Menu?");
|
||||
widget_add_string_element(
|
||||
widget, 64, 31, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost!");
|
||||
widget, 64, 13, AlignCenter, AlignTop, FontSecondary, "All unsaved data will be lost");
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
|
||||
}
|
||||
|
||||
@@ -94,6 +94,9 @@ bool lfrfid_scene_extra_actions_on_event(void* context, SceneManagerEvent event)
|
||||
consumed = true;
|
||||
}
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneExtraActions, event.event);
|
||||
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneExtraActions, 0);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
|
||||
@@ -4,37 +4,39 @@ void lfrfid_scene_raw_info_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Widget* widget = app->widget;
|
||||
|
||||
// FuriString* tmp_string;
|
||||
// tmp_string = furi_string_alloc();
|
||||
|
||||
bool sd_exist = storage_sd_status(app->storage) == FSE_OK;
|
||||
if(!sd_exist) {
|
||||
widget_add_icon_element(widget, 0, 0, &I_SDQuestion_35x43);
|
||||
widget_add_string_multiline_element(
|
||||
widget,
|
||||
81,
|
||||
4,
|
||||
AlignCenter,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
"No SD card found.\nThis function will not\nwork without\nSD card.");
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", lfrfid_widget_callback, app);
|
||||
} else {
|
||||
if(storage_sd_status(app->storage) != FSE_OK) {
|
||||
widget_add_icon_element(widget, 83, 22, &I_WarningDolphinFlip_45x42);
|
||||
widget_add_string_element(
|
||||
widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "No SD Card!");
|
||||
widget_add_string_multiline_element(
|
||||
widget,
|
||||
0,
|
||||
1,
|
||||
13,
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
"RAW RFID data reader\n1) Put the Flipper on your card\n2) Press OK\n3) Wait until data is read");
|
||||
"Insert an SD card\n"
|
||||
"to use this function");
|
||||
|
||||
} else {
|
||||
widget_add_text_box_element(
|
||||
widget,
|
||||
0,
|
||||
0,
|
||||
128,
|
||||
64,
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
"\e#RAW RFID Data Reader\e#\n"
|
||||
"1. Hold card next to Flipper\n"
|
||||
"2. Press OK\n"
|
||||
"3. Wait until data is read",
|
||||
false);
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeCenter, "OK", lfrfid_widget_callback, app);
|
||||
}
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
|
||||
//furi_string_free(tmp_string);
|
||||
}
|
||||
|
||||
bool lfrfid_scene_raw_info_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../lfrfid_i.h"
|
||||
|
||||
#define RAW_READ_TIME 5000
|
||||
#define RAW_READ_TIME_MS (5000UL)
|
||||
|
||||
typedef struct {
|
||||
FuriString* string_file_name;
|
||||
@@ -29,23 +29,28 @@ void lfrfid_scene_raw_read_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Popup* popup = app->popup;
|
||||
|
||||
LfRfidReadRawState* state = malloc(sizeof(LfRfidReadRawState));
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneRawRead, (uint32_t)state);
|
||||
state->string_file_name = furi_string_alloc();
|
||||
popup_set_icon(popup, 0, 3, &I_RFIDDolphinReceive_97x61);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
||||
lfrfid_worker_start_thread(app->lfworker);
|
||||
lfrfid_make_app_folder(app);
|
||||
popup_set_icon(popup, 0, 0, &I_NFC_dolphin_emulation_51x64);
|
||||
popup_set_header(popup, "Reading ASK", 91, 16, AlignCenter, AlignTop);
|
||||
popup_set_text(popup, "Don't move\nfor 5 sec.", 91, 29, AlignCenter, AlignTop);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
||||
|
||||
LfRfidReadRawState* state = malloc(sizeof(LfRfidReadRawState));
|
||||
state->string_file_name = furi_string_alloc();
|
||||
state->timer = furi_timer_alloc(timer_callback, FuriTimerTypeOnce, app);
|
||||
furi_timer_start(state->timer, RAW_READ_TIME);
|
||||
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneRawRead, (uint32_t)state);
|
||||
|
||||
furi_string_printf(
|
||||
state->string_file_name,
|
||||
"%s/%s%s",
|
||||
LFRFID_SD_FOLDER,
|
||||
furi_string_get_cstr(app->raw_file_name),
|
||||
LFRFID_APP_RAW_ASK_EXTENSION);
|
||||
popup_set_header(popup, "Reading\nRAW RFID\nASK", 89, 30, AlignCenter, AlignTop);
|
||||
|
||||
lfrfid_make_app_folder(app);
|
||||
|
||||
lfrfid_worker_start_thread(app->lfworker);
|
||||
lfrfid_worker_read_raw_start(
|
||||
app->lfworker,
|
||||
furi_string_get_cstr(state->string_file_name),
|
||||
@@ -53,6 +58,7 @@ void lfrfid_scene_raw_read_on_enter(void* context) {
|
||||
lfrfid_read_callback,
|
||||
app);
|
||||
|
||||
furi_timer_start(state->timer, RAW_READ_TIME_MS);
|
||||
notification_message(app->notifications, &sequence_blink_start_cyan);
|
||||
|
||||
state->is_psk = false;
|
||||
@@ -69,43 +75,53 @@ bool lfrfid_scene_raw_read_on_event(void* context, SceneManagerEvent event) {
|
||||
furi_assert(state);
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == LfRfidEventReadError) {
|
||||
consumed = true;
|
||||
state->error = true;
|
||||
popup_set_header(
|
||||
popup, "Reading\nRAW RFID\nFile error", 89, 30, AlignCenter, AlignTop);
|
||||
notification_message(app->notifications, &sequence_blink_start_red);
|
||||
if(event.event == LfRfidEventReadError || event.event == LfRfidEventReadOverrun) {
|
||||
furi_timer_stop(state->timer);
|
||||
|
||||
popup_set_icon(popup, 83, 22, &I_WarningDolphinFlip_45x42);
|
||||
popup_set_header(popup, "RAW Reading error!", 64, 0, AlignCenter, AlignTop);
|
||||
popup_set_text(
|
||||
popup, "This may be\ncaused by SD\ncard issues", 0, 13, AlignLeft, AlignTop);
|
||||
|
||||
notification_message(app->notifications, &sequence_blink_start_red);
|
||||
state->error = true;
|
||||
|
||||
} else if(event.event == LfRfidEventReadDone) {
|
||||
consumed = true;
|
||||
if(!state->error) {
|
||||
if(state->is_psk) {
|
||||
notification_message(app->notifications, &sequence_success);
|
||||
scene_manager_next_scene(app->scene_manager, LfRfidSceneRawSuccess);
|
||||
|
||||
} else {
|
||||
popup_set_header(
|
||||
popup, "Reading\nRAW RFID\nPSK", 89, 30, AlignCenter, AlignTop);
|
||||
notification_message(app->notifications, &sequence_blink_start_yellow);
|
||||
lfrfid_worker_stop(app->lfworker);
|
||||
lfrfid_worker_stop_thread(app->lfworker);
|
||||
lfrfid_worker_start_thread(app->lfworker);
|
||||
|
||||
state->is_psk = true;
|
||||
|
||||
furi_string_printf(
|
||||
state->string_file_name,
|
||||
"%s/%s%s",
|
||||
LFRFID_SD_FOLDER,
|
||||
furi_string_get_cstr(app->raw_file_name),
|
||||
LFRFID_APP_RAW_PSK_EXTENSION);
|
||||
|
||||
lfrfid_worker_start_thread(app->lfworker);
|
||||
lfrfid_worker_read_raw_start(
|
||||
app->lfworker,
|
||||
furi_string_get_cstr(state->string_file_name),
|
||||
LFRFIDWorkerReadTypePSKOnly,
|
||||
lfrfid_read_callback,
|
||||
app);
|
||||
furi_timer_start(state->timer, RAW_READ_TIME);
|
||||
state->is_psk = true;
|
||||
|
||||
furi_timer_start(state->timer, RAW_READ_TIME_MS);
|
||||
|
||||
popup_set_header(popup, "Reading PSK", 91, 16, AlignCenter, AlignTop);
|
||||
notification_message(app->notifications, &sequence_blink_start_yellow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
@@ -116,12 +132,13 @@ void lfrfid_scene_raw_read_on_exit(void* context) {
|
||||
LfRfidReadRawState* state =
|
||||
(LfRfidReadRawState*)scene_manager_get_scene_state(app->scene_manager, LfRfidSceneRawRead);
|
||||
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
popup_reset(app->popup);
|
||||
lfrfid_worker_stop(app->lfworker);
|
||||
lfrfid_worker_stop_thread(app->lfworker);
|
||||
furi_timer_free(state->timer);
|
||||
|
||||
furi_timer_free(state->timer);
|
||||
furi_string_free(state->string_file_name);
|
||||
free(state);
|
||||
|
||||
popup_reset(app->popup);
|
||||
notification_message(app->notifications, &sequence_blink_stop);
|
||||
}
|
||||
|
||||
@@ -4,16 +4,20 @@ void lfrfid_scene_raw_success_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Widget* widget = app->widget;
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeCenter, "OK", lfrfid_widget_callback, app);
|
||||
|
||||
widget_add_string_multiline_element(
|
||||
widget_add_text_box_element(
|
||||
widget,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
128,
|
||||
64,
|
||||
AlignLeft,
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
"RAW RFID read success!\nNow you can analyze files\nOr send them to developers");
|
||||
"\e#RAW RFID Read Success\e#\n"
|
||||
"Now you can analyze files or\n"
|
||||
"send them to developers",
|
||||
false);
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeCenter, "OK", lfrfid_widget_callback, app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
|
||||
}
|
||||
@@ -24,12 +28,16 @@ bool lfrfid_scene_raw_success_on_event(void* context, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
if(event.event == GuiButtonTypeCenter) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
scene_manager, LfRfidSceneExtraActions);
|
||||
}
|
||||
consumed = true;
|
||||
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ bool lfrfid_scene_read_key_menu_on_event(void* context, SceneManagerEvent event)
|
||||
consumed = true;
|
||||
}
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneReadKeyMenu, event.event);
|
||||
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneReadKeyMenu, 0);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
|
||||
@@ -1,56 +1,55 @@
|
||||
#include "../lfrfid_i.h"
|
||||
|
||||
#define LFRFID_SCENE_READ_SUCCESS_MAX_HEX_WIDTH (7UL)
|
||||
|
||||
void lfrfid_scene_read_success_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Widget* widget = app->widget;
|
||||
FuriString* display_text = furi_string_alloc();
|
||||
|
||||
FuriString* tmp_string;
|
||||
tmp_string = furi_string_alloc();
|
||||
const char* protocol = protocol_dict_get_name(app->dict, app->protocol_id);
|
||||
const char* manufacturer = protocol_dict_get_manufacturer(app->dict, app->protocol_id);
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Retry", lfrfid_widget_callback, app);
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "More", lfrfid_widget_callback, app);
|
||||
|
||||
furi_string_printf(
|
||||
tmp_string,
|
||||
"%s[%s]",
|
||||
protocol_dict_get_name(app->dict, app->protocol_id),
|
||||
protocol_dict_get_manufacturer(app->dict, app->protocol_id));
|
||||
|
||||
widget_add_string_element(
|
||||
widget, 16, 3, AlignLeft, AlignTop, FontPrimary, furi_string_get_cstr(tmp_string));
|
||||
|
||||
furi_string_reset(tmp_string);
|
||||
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
||||
uint8_t* data = (uint8_t*)malloc(size);
|
||||
protocol_dict_get_data(app->dict, app->protocol_id, data, size);
|
||||
for(uint8_t i = 0; i < size; i++) {
|
||||
if(i >= 9) {
|
||||
furi_string_cat_printf(tmp_string, "..");
|
||||
break;
|
||||
} else {
|
||||
if(i != 0) {
|
||||
furi_string_cat_printf(tmp_string, ":");
|
||||
}
|
||||
furi_string_cat_printf(tmp_string, "%02X", data[i]);
|
||||
}
|
||||
if(strcasecmp(protocol, manufacturer) != 0 && strcasecmp(manufacturer, "N/A") != 0) {
|
||||
furi_string_printf(display_text, "\e#%s %s\e#", manufacturer, protocol);
|
||||
} else {
|
||||
furi_string_printf(display_text, "\e#%s\e#", protocol);
|
||||
}
|
||||
|
||||
furi_string_cat(display_text, "\nHex: ");
|
||||
|
||||
const size_t data_size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
||||
uint8_t* data = malloc(data_size);
|
||||
|
||||
protocol_dict_get_data(app->dict, app->protocol_id, data, data_size);
|
||||
|
||||
for(size_t i = 0; i < data_size; i++) {
|
||||
if(i == LFRFID_SCENE_READ_SUCCESS_MAX_HEX_WIDTH) {
|
||||
furi_string_cat(display_text, " ...");
|
||||
break;
|
||||
}
|
||||
|
||||
furi_string_cat_printf(display_text, "%s%02X", i != 0 ? " " : "", data[i]);
|
||||
}
|
||||
|
||||
free(data);
|
||||
|
||||
FuriString* render_data;
|
||||
render_data = furi_string_alloc();
|
||||
protocol_dict_render_brief_data(app->dict, render_data, app->protocol_id);
|
||||
furi_string_cat_printf(tmp_string, "\r\n%s", furi_string_get_cstr(render_data));
|
||||
furi_string_free(render_data);
|
||||
FuriString* rendered_data = furi_string_alloc();
|
||||
protocol_dict_render_brief_data(app->dict, rendered_data, app->protocol_id);
|
||||
furi_string_cat_printf(display_text, "\n%s", furi_string_get_cstr(rendered_data));
|
||||
furi_string_free(rendered_data);
|
||||
|
||||
widget_add_string_multiline_element(
|
||||
widget, 0, 16, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_string));
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 52, AlignLeft, AlignTop, furi_string_get_cstr(display_text), true);
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Retry", lfrfid_widget_callback, app);
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "More", lfrfid_widget_callback, app);
|
||||
|
||||
widget_add_icon_element(app->widget, 0, 0, &I_RFIDSmallChip_14x14);
|
||||
|
||||
notification_message_block(app->notifications, &sequence_set_green_255);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
|
||||
furi_string_free(tmp_string);
|
||||
furi_string_free(display_text);
|
||||
}
|
||||
|
||||
bool lfrfid_scene_read_success_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
@@ -4,12 +4,11 @@ void lfrfid_scene_retry_confirm_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Widget* widget = app->widget;
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Exit", lfrfid_widget_callback, app);
|
||||
widget_add_button_element(widget, GuiButtonTypeLeft, "Retry", lfrfid_widget_callback, app);
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "Stay", lfrfid_widget_callback, app);
|
||||
widget_add_string_element(widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Retry Reading?");
|
||||
widget_add_string_element(
|
||||
widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Retry Reading?");
|
||||
widget_add_string_element(
|
||||
widget, 64, 29, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost!");
|
||||
widget, 64, 13, AlignCenter, AlignTop, FontSecondary, "All unsaved data will be lost");
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
|
||||
}
|
||||
|
||||
@@ -21,16 +21,9 @@ bool lfrfid_scene_save_success_on_event(void* context, SceneManagerEvent event)
|
||||
LfRfid* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
const uint32_t prev_scenes[] = {LfRfidSceneReadKeyMenu, LfRfidSceneSelectKey};
|
||||
|
||||
if((event.type == SceneManagerEventTypeBack) ||
|
||||
((event.type == SceneManagerEventTypeCustom) && (event.event == LfRfidEventPopupClosed))) {
|
||||
bool result = scene_manager_search_and_switch_to_previous_scene_one_of(
|
||||
app->scene_manager, prev_scenes, COUNT_OF(prev_scenes));
|
||||
if(!result) {
|
||||
scene_manager_search_and_switch_to_another_scene(
|
||||
app->scene_manager, LfRfidSceneSelectKey);
|
||||
}
|
||||
if(event.type == SceneManagerEventTypeBack || event.type == SceneManagerEventTypeCustom) {
|
||||
// Always return to SceneSelectKey from here
|
||||
scene_manager_search_and_switch_to_another_scene(app->scene_manager, LfRfidSceneSelectKey);
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,38 +4,42 @@ void lfrfid_scene_saved_info_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Widget* widget = app->widget;
|
||||
|
||||
FuriString* tmp_string;
|
||||
tmp_string = furi_string_alloc();
|
||||
FuriString* display_text = furi_string_alloc();
|
||||
|
||||
furi_string_printf(
|
||||
tmp_string,
|
||||
"%s [%s]\r\n",
|
||||
furi_string_get_cstr(app->file_name),
|
||||
protocol_dict_get_name(app->dict, app->protocol_id));
|
||||
furi_string_printf(display_text, "Name: %s\n", furi_string_get_cstr(app->file_name));
|
||||
|
||||
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
||||
uint8_t* data = (uint8_t*)malloc(size);
|
||||
protocol_dict_get_data(app->dict, app->protocol_id, data, size);
|
||||
for(uint8_t i = 0; i < size; i++) {
|
||||
if(i != 0) {
|
||||
furi_string_cat_printf(tmp_string, ":");
|
||||
}
|
||||
const char* protocol = protocol_dict_get_name(app->dict, app->protocol_id);
|
||||
const char* manufacturer = protocol_dict_get_manufacturer(app->dict, app->protocol_id);
|
||||
|
||||
furi_string_cat_printf(tmp_string, "%02X", data[i]);
|
||||
if(strcasecmp(protocol, manufacturer) != 0 && strcasecmp(manufacturer, "N/A") != 0) {
|
||||
furi_string_cat_printf(display_text, "\e#%s %s", manufacturer, protocol);
|
||||
} else {
|
||||
furi_string_cat_printf(display_text, "\e#%s", protocol);
|
||||
}
|
||||
|
||||
furi_string_cat(display_text, "\nHex: ");
|
||||
|
||||
const size_t data_size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
||||
uint8_t* data = malloc(data_size);
|
||||
|
||||
protocol_dict_get_data(app->dict, app->protocol_id, data, data_size);
|
||||
|
||||
for(size_t i = 0; i < data_size; i++) {
|
||||
furi_string_cat_printf(display_text, "%s%02X", i != 0 ? " " : "", data[i]);
|
||||
}
|
||||
|
||||
free(data);
|
||||
|
||||
FuriString* render_data;
|
||||
render_data = furi_string_alloc();
|
||||
protocol_dict_render_data(app->dict, render_data, app->protocol_id);
|
||||
furi_string_cat_printf(tmp_string, "\r\n%s", furi_string_get_cstr(render_data));
|
||||
furi_string_free(render_data);
|
||||
FuriString* rendered_data;
|
||||
rendered_data = furi_string_alloc();
|
||||
protocol_dict_render_data(app->dict, rendered_data, app->protocol_id);
|
||||
furi_string_cat_printf(display_text, "\n%s", furi_string_get_cstr(rendered_data));
|
||||
furi_string_free(rendered_data);
|
||||
|
||||
widget_add_string_multiline_element(
|
||||
widget, 0, 1, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_string));
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 64, furi_string_get_cstr(display_text));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
|
||||
furi_string_free(tmp_string);
|
||||
furi_string_free(display_text);
|
||||
}
|
||||
|
||||
bool lfrfid_scene_saved_info_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
@@ -71,6 +71,9 @@ bool lfrfid_scene_saved_key_menu_on_event(void* context, SceneManagerEvent event
|
||||
consumed = true;
|
||||
}
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneSavedKeyMenu, event.event);
|
||||
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneSavedKeyMenu, 0);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
|
||||
@@ -6,7 +6,9 @@ void lfrfid_scene_select_key_on_enter(void* context) {
|
||||
if(lfrfid_load_key_from_file_select(app)) {
|
||||
scene_manager_next_scene(app->scene_manager, LfRfidSceneSavedKeyMenu);
|
||||
} else {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
// Always select "Saved" menu item when returning from this scene
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneStart, LfRfidMenuIndexSaved);
|
||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, LfRfidSceneStart);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
#include "../lfrfid_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexRead,
|
||||
SubmenuIndexSaved,
|
||||
SubmenuIndexAddManually,
|
||||
SubmenuIndexExtraActions,
|
||||
} SubmenuIndex;
|
||||
|
||||
static void lfrfid_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
LfRfid* app = context;
|
||||
|
||||
@@ -18,15 +11,20 @@ void lfrfid_scene_start_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_add_item(submenu, "Read", SubmenuIndexRead, lfrfid_scene_start_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
submenu, "Saved", SubmenuIndexSaved, lfrfid_scene_start_submenu_callback, app);
|
||||
submenu, "Read", LfRfidMenuIndexRead, lfrfid_scene_start_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
submenu, "Add Manually", SubmenuIndexAddManually, lfrfid_scene_start_submenu_callback, app);
|
||||
submenu, "Saved", LfRfidMenuIndexSaved, lfrfid_scene_start_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Add Manually",
|
||||
LfRfidMenuIndexAddManually,
|
||||
lfrfid_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Extra Actions",
|
||||
SubmenuIndexExtraActions,
|
||||
LfRfidMenuIndexExtraActions,
|
||||
lfrfid_scene_start_submenu_callback,
|
||||
app);
|
||||
|
||||
@@ -46,26 +44,28 @@ bool lfrfid_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexRead) {
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneStart, SubmenuIndexRead);
|
||||
if(event.event == LfRfidMenuIndexRead) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, LfRfidSceneStart, LfRfidMenuIndexRead);
|
||||
scene_manager_next_scene(app->scene_manager, LfRfidSceneRead);
|
||||
dolphin_deed(DolphinDeedRfidRead);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexSaved) {
|
||||
} else if(event.event == LfRfidMenuIndexSaved) {
|
||||
// Like in the other apps, explicitly save the scene state
|
||||
// in each branch in case the user cancels loading a file.
|
||||
scene_manager_set_scene_state(app->scene_manager, LfRfidSceneStart, SubmenuIndexSaved);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, LfRfidSceneStart, LfRfidMenuIndexSaved);
|
||||
furi_string_set(app->file_path, LFRFID_APP_FOLDER);
|
||||
scene_manager_next_scene(app->scene_manager, LfRfidSceneSelectKey);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexAddManually) {
|
||||
} else if(event.event == LfRfidMenuIndexAddManually) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, LfRfidSceneStart, SubmenuIndexAddManually);
|
||||
app->scene_manager, LfRfidSceneStart, LfRfidMenuIndexAddManually);
|
||||
scene_manager_next_scene(app->scene_manager, LfRfidSceneSaveType);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexExtraActions) {
|
||||
} else if(event.event == LfRfidMenuIndexExtraActions) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, LfRfidSceneStart, SubmenuIndexExtraActions);
|
||||
app->scene_manager, LfRfidSceneStart, LfRfidMenuIndexExtraActions);
|
||||
scene_manager_next_scene(app->scene_manager, LfRfidSceneExtraActions);
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
@@ -21,19 +21,19 @@ void lfrfid_scene_write_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Popup* popup = app->popup;
|
||||
|
||||
popup_set_header(popup, "Writing", 89, 30, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 8, &I_NFC_manual_60x50);
|
||||
popup_set_header(popup, "Writing", 94, 16, AlignCenter, AlignTop);
|
||||
|
||||
if(!furi_string_empty(app->file_name)) {
|
||||
popup_set_text(popup, furi_string_get_cstr(app->file_name), 89, 43, AlignCenter, AlignTop);
|
||||
popup_set_text(popup, furi_string_get_cstr(app->file_name), 94, 29, AlignCenter, AlignTop);
|
||||
} else {
|
||||
popup_set_text(
|
||||
popup,
|
||||
protocol_dict_get_name(app->dict, app->protocol_id),
|
||||
89,
|
||||
43,
|
||||
AlignCenter,
|
||||
AlignTop);
|
||||
snprintf(
|
||||
app->text_store,
|
||||
LFRFID_TEXT_STORE_SIZE,
|
||||
"Unsaved\n%s",
|
||||
protocol_dict_get_name(app->dict, app->protocol_id));
|
||||
popup_set_text(popup, app->text_store, 94, 29, AlignCenter, AlignTop);
|
||||
}
|
||||
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
||||
|
||||
@@ -66,12 +66,14 @@ bool lfrfid_scene_write_on_event(void* context, SceneManagerEvent event) {
|
||||
(event.event == LfRfidEventWriteFobCannotBeWritten) ||
|
||||
(event.event == LfRfidEventWriteTooLongToWrite)) {
|
||||
popup_set_icon(popup, 83, 22, &I_WarningDolphinFlip_45x42);
|
||||
popup_set_header(popup, "Still trying to write...", 64, 3, AlignCenter, AlignTop);
|
||||
popup_set_header(popup, "Still Trying to Write...", 64, 0, AlignCenter, AlignTop);
|
||||
popup_set_text(
|
||||
popup,
|
||||
"Make sure this\ncard is writable\nand not\nprotected.",
|
||||
3,
|
||||
17,
|
||||
"Make sure this\n"
|
||||
"card is writable\n"
|
||||
"and not protected",
|
||||
0,
|
||||
13,
|
||||
AlignLeft,
|
||||
AlignTop);
|
||||
notification_message(app->notifications, &sequence_blink_start_yellow);
|
||||
|
||||
@@ -19,12 +19,12 @@ bool lfrfid_scene_write_success_on_event(void* context, SceneManagerEvent event)
|
||||
LfRfid* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
const uint32_t prev_scenes[] = {LfRfidSceneReadKeyMenu, LfRfidSceneSelectKey};
|
||||
|
||||
if((event.type == SceneManagerEventTypeBack) ||
|
||||
((event.type == SceneManagerEventTypeCustom) && (event.event == LfRfidEventPopupClosed))) {
|
||||
scene_manager_search_and_switch_to_previous_scene_one_of(
|
||||
app->scene_manager, prev_scenes, COUNT_OF(prev_scenes));
|
||||
if(event.type == SceneManagerEventTypeBack || event.type == SceneManagerEventTypeCustom) {
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, LfRfidSceneReadKeyMenu)) {
|
||||
scene_manager_search_and_switch_to_another_scene(
|
||||
app->scene_manager, LfRfidSceneSelectKey);
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user