mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-19 09:13:11 +00:00
64bd2f9c84
* Update saved_info and read_success scenes * Update EM4100 rendering * Update HIDExt rendering * Update Gallagher rendering * Update HidProx rendering * Update IOProx rendering * Update H10301 rendering * Update PAC/Stanley rendering * Add strcasecmp() to API, better manufacturer/name handling * Update Viking rendering * Update FDX-A rendering * Update Pyramid rendering * Update Indala26 rendering * Update Idteck rendering * Update Keri rendering * Update Nexwatch rendering * Update Jablotron rendering * Update Paradox rendering * Truncate long Hex string on scene_read_suceess * Fix formatting * Update AWID rendering * Update FDX-B rendering * Tweak string formatting in various screens * More read_success view tweaks * Fix formatting * Fix Pyramid brief rendering * Reset saved key menu when going back * Reset other menus on back where applicable * Update confirmation scenes * Update emulation scene * Update delete scene * Update raw read info screen * Update raw read scene, fix crash * Update raw read success scene * Update write scene * Always return to SceneSelectKey after saving * Update SceneWriteSuccess and SceneDeleteSuccess * Replace closing parens with dots * FL-3798: Fix special formatting in text_box * Simplify SceneReadSuccess * Fix crash when having a trailing newline in text_box * Bump API symbols version * Make PVS happy * Format sources Co-authored-by: あく <alleteam@gmail.com>
96 lines
3.7 KiB
C
96 lines
3.7 KiB
C
#include "../lfrfid_i.h"
|
|
|
|
static void lfrfid_write_callback(LFRFIDWorkerWriteResult result, void* context) {
|
|
LfRfid* app = context;
|
|
uint32_t event = 0;
|
|
|
|
if(result == LFRFIDWorkerWriteOK) {
|
|
event = LfRfidEventWriteOK;
|
|
} else if(result == LFRFIDWorkerWriteProtocolCannotBeWritten) {
|
|
event = LfRfidEventWriteProtocolCannotBeWritten;
|
|
} else if(result == LFRFIDWorkerWriteFobCannotBeWritten) {
|
|
event = LfRfidEventWriteFobCannotBeWritten;
|
|
} else if(result == LFRFIDWorkerWriteTooLongToWrite) {
|
|
event = LfRfidEventWriteTooLongToWrite;
|
|
}
|
|
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
|
}
|
|
|
|
void lfrfid_scene_write_on_enter(void* context) {
|
|
LfRfid* app = context;
|
|
Popup* popup = app->popup;
|
|
|
|
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), 94, 29, AlignCenter, AlignTop);
|
|
} else {
|
|
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);
|
|
}
|
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
|
|
|
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
|
protocol_dict_get_data(app->dict, app->protocol_id, app->old_key_data, size);
|
|
|
|
lfrfid_worker_start_thread(app->lfworker);
|
|
lfrfid_worker_write_start(
|
|
app->lfworker, (LFRFIDProtocol)app->protocol_id, lfrfid_write_callback, app);
|
|
notification_message(app->notifications, &sequence_blink_start_magenta);
|
|
}
|
|
|
|
bool lfrfid_scene_write_on_event(void* context, SceneManagerEvent event) {
|
|
LfRfid* app = context;
|
|
Popup* popup = app->popup;
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
if(event.event == LfRfidEventWriteOK) {
|
|
notification_message(app->notifications, &sequence_success);
|
|
scene_manager_next_scene(app->scene_manager, LfRfidSceneWriteSuccess);
|
|
consumed = true;
|
|
} else if(event.event == LfRfidEventWriteProtocolCannotBeWritten) {
|
|
popup_set_icon(popup, 83, 22, &I_WarningDolphinFlip_45x42);
|
|
popup_set_header(popup, "Error", 64, 3, AlignCenter, AlignTop);
|
|
popup_set_text(popup, "This protocol\ncannot be written", 3, 17, AlignLeft, AlignTop);
|
|
notification_message(app->notifications, &sequence_blink_start_red);
|
|
consumed = true;
|
|
} else if(
|
|
(event.event == LfRfidEventWriteFobCannotBeWritten) ||
|
|
(event.event == LfRfidEventWriteTooLongToWrite)) {
|
|
popup_set_icon(popup, 83, 22, &I_WarningDolphinFlip_45x42);
|
|
popup_set_header(popup, "Still Trying to Write...", 64, 0, AlignCenter, AlignTop);
|
|
popup_set_text(
|
|
popup,
|
|
"Make sure this\n"
|
|
"card is writable\n"
|
|
"and not protected",
|
|
0,
|
|
13,
|
|
AlignLeft,
|
|
AlignTop);
|
|
notification_message(app->notifications, &sequence_blink_start_yellow);
|
|
consumed = true;
|
|
}
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void lfrfid_scene_write_on_exit(void* context) {
|
|
LfRfid* app = context;
|
|
notification_message(app->notifications, &sequence_blink_stop);
|
|
popup_reset(app->popup);
|
|
lfrfid_worker_stop(app->lfworker);
|
|
lfrfid_worker_stop_thread(app->lfworker);
|
|
|
|
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
|
protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size);
|
|
}
|