mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-01 00:39:12 +00:00
4bf29827f8
* Quicksave 1 * Header stage complete * Source stage complete * Lint & merge fixes * Includes * Documentation step 1 * FBT: output free size considering BT STACK * Documentation step 2 * py lint * Fix music player plugin * unit test stage 1: string allocator, mem, getters, setters, appends, compare, search. * unit test: string equality * unit test: string replace * unit test: string start_with, end_with * unit test: string trim * unit test: utf-8 * Rename * Revert fw_size changes * Simplify CLI backspace handling * Simplify CLI character insert * Merge fixes * Furi: correct filenaming and spelling * Bt: remove furi string include Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
68 lines
2.6 KiB
C
68 lines
2.6 KiB
C
#include "../lfrfid_i.h"
|
|
|
|
void lfrfid_scene_rpc_on_enter(void* context) {
|
|
LfRfid* app = context;
|
|
Popup* popup = app->popup;
|
|
|
|
popup_set_header(popup, "LF RFID", 89, 42, AlignCenter, AlignBottom);
|
|
popup_set_text(popup, "RPC mode", 89, 44, AlignCenter, AlignTop);
|
|
popup_set_icon(popup, 0, 12, &I_RFIDDolphinSend_97x61);
|
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
|
|
|
notification_message(app->notifications, &sequence_display_backlight_on);
|
|
|
|
app->rpc_state = LfRfidRpcStateIdle;
|
|
}
|
|
|
|
bool lfrfid_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
|
LfRfid* app = context;
|
|
Popup* popup = app->popup;
|
|
UNUSED(event);
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
consumed = true;
|
|
if(event.event == LfRfidEventExit) {
|
|
rpc_system_app_confirm(app->rpc_ctx, RpcAppEventAppExit, true);
|
|
scene_manager_stop(app->scene_manager);
|
|
view_dispatcher_stop(app->view_dispatcher);
|
|
} else if(event.event == LfRfidEventRpcSessionClose) {
|
|
scene_manager_stop(app->scene_manager);
|
|
view_dispatcher_stop(app->view_dispatcher);
|
|
} else if(event.event == LfRfidEventRpcLoadFile) {
|
|
const char* arg = rpc_system_app_get_data(app->rpc_ctx);
|
|
bool result = false;
|
|
if(arg && (app->rpc_state == LfRfidRpcStateIdle)) {
|
|
furi_string_set(app->file_path, arg);
|
|
if(lfrfid_load_key_data(app, app->file_path, false)) {
|
|
lfrfid_worker_start_thread(app->lfworker);
|
|
lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id);
|
|
app->rpc_state = LfRfidRpcStateEmulating;
|
|
|
|
lfrfid_text_store_set(
|
|
app, "emulating\n%s", furi_string_get_cstr(app->file_name));
|
|
popup_set_text(popup, app->text_store, 89, 44, AlignCenter, AlignTop);
|
|
|
|
notification_message(app->notifications, &sequence_blink_start_magenta);
|
|
result = true;
|
|
}
|
|
}
|
|
rpc_system_app_confirm(app->rpc_ctx, RpcAppEventLoadFile, result);
|
|
}
|
|
}
|
|
return consumed;
|
|
}
|
|
|
|
void lfrfid_scene_rpc_on_exit(void* context) {
|
|
LfRfid* app = context;
|
|
Popup* popup = app->popup;
|
|
|
|
if(app->rpc_state == LfRfidRpcStateEmulating) {
|
|
lfrfid_worker_stop(app->lfworker);
|
|
lfrfid_worker_stop_thread(app->lfworker);
|
|
notification_message(app->notifications, &sequence_blink_stop);
|
|
}
|
|
|
|
popup_reset(popup);
|
|
}
|