unleashed-firmware/applications/main/ibutton/scenes/ibutton_scene_rpc.c
RebornedBrain 49e1ae6e87
[FL-3895] Broken file interaction fixes (#3852)
* Show error screen if corrupted filed has been loaded
* Added rpc error codes and error processing to NFC
* Made iButton scene on_enter handler clear to prevent showing scene before file is loaded
* Added rpc error codes and error processing to iButton
* Made lfRfid scene on_enter handler clear to prevent showing scene before file is loaded
* Added rpc error codes and error processing to lfRfid
* Made SubGHz scene on_enter handler clear to prevent showing scene before file is loaded. Also moved file_name_tmp formatting logic to a separate function
* Now function returns loading status and starts rx only if load succeeded
* Added show error logic on tx_button start
* Introduced rpc error codes for infrared
* Adjusted rpc scene logic to show scene only when
loading is fine
* Added new  list of rpc errors which are common within several applications
* Removed same enums from apps
* Same rpc error in different apps replaced with common value from rpc error code list
* SubGHz error codes now start from RpcAppSystemErrorCodesReserved value
* Infrared error codes now start from RpcAppSystemErrorCodesReserved value
* Removed unused enum
* Now all rpc error codes are more generalized and can be used among all apps without any specific enums
* Removed specific error codes, now rpc error codes are used instead
* RPC: no plurals in enums

Co-authored-by: あく <alleteam@gmail.com>
2024-09-05 20:54:49 +01:00

64 lines
2.2 KiB
C

#include "../ibutton_i.h"
void ibutton_scene_rpc_on_enter(void* context) {
UNUSED(context);
}
static void ibutton_rpc_start_emulation(iButton* ibutton) {
Popup* popup = ibutton->popup;
popup_set_header(popup, "iButton", 82, 28, AlignCenter, AlignBottom);
popup_set_text(popup, ibutton->key_name, 82, 32, AlignCenter, AlignTop);
popup_set_icon(popup, 2, 14, &I_iButtonKey_49x44);
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
ibutton_worker_emulate_start(ibutton->worker, ibutton->key);
ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateStart);
notification_message(ibutton->notifications, &sequence_display_backlight_on);
}
bool ibutton_scene_rpc_on_event(void* context, SceneManagerEvent event) {
iButton* ibutton = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
if(event.event == iButtonCustomEventRpcLoadFile) {
bool result = false;
if(ibutton_load_key(ibutton, false)) {
ibutton_rpc_start_emulation(ibutton);
result = true;
} else {
rpc_system_app_set_error_code(ibutton->rpc, RpcAppSystemErrorCodeParseFile);
rpc_system_app_set_error_text(ibutton->rpc, "Cannot load key file");
}
rpc_system_app_confirm(ibutton->rpc, result);
} else if(event.event == iButtonCustomEventRpcExit) {
rpc_system_app_confirm(ibutton->rpc, true);
scene_manager_stop(ibutton->scene_manager);
view_dispatcher_stop(ibutton->view_dispatcher);
} else if(event.event == iButtonCustomEventRpcSessionClose) {
scene_manager_stop(ibutton->scene_manager);
view_dispatcher_stop(ibutton->view_dispatcher);
}
}
return consumed;
}
void ibutton_scene_rpc_on_exit(void* context) {
iButton* ibutton = context;
Popup* popup = ibutton->popup;
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_icon(popup, 0, 0, NULL);
ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop);
}