diff --git a/applications/main/subghz/helpers/subghz_error_type.h b/applications/main/subghz/helpers/subghz_error_type.h new file mode 100644 index 00000000..e481aa4b --- /dev/null +++ b/applications/main/subghz/helpers/subghz_error_type.h @@ -0,0 +1,13 @@ +#pragma once + +#include +#include + +/** SubGhzErrorType */ +typedef enum { + SubGhzErrorTypeNoError = 0, /** There are no errors */ + SubGhzErrorTypeParseFile = + 1, /** File parsing error, or wrong file structure, or missing required parameters. more accurate data can be obtained through the debug port */ + SubGhzErrorTypeOnlyRX = + 2, /** Transmission on this frequency is blocked by regional settings */ +} SubGhzErrorType; diff --git a/applications/main/subghz/scenes/subghz_scene_rpc.c b/applications/main/subghz/scenes/subghz_scene_rpc.c index 79295aaa..a1c0e41f 100644 --- a/applications/main/subghz/scenes/subghz_scene_rpc.c +++ b/applications/main/subghz/scenes/subghz_scene_rpc.c @@ -43,6 +43,12 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) { result = subghz_tx_start(subghz, subghz->txrx->fff_data); if(result) subghz_blink_start(subghz); } + if(!result) { + rpc_system_app_set_error_code(subghz->rpc_ctx, SubGhzErrorTypeOnlyRX); + rpc_system_app_set_error_text( + subghz->rpc_ctx, + "Transmission on this frequency is restricted in your region"); + } rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonPress, result); } else if(event.event == SubGhzCustomEventSceneRpcButtonRelease) { bool result = false; @@ -74,6 +80,9 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) { popup_set_text(popup, subghz->file_name_tmp, 89, 44, AlignCenter, AlignTop); furi_string_free(file_name); + } else { + rpc_system_app_set_error_code(subghz->rpc_ctx, SubGhzErrorTypeParseFile); + rpc_system_app_set_error_text(subghz->rpc_ctx, "Cannot parse file"); } } rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventLoadFile, result); diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h index 0a40196b..23436515 100644 --- a/applications/main/subghz/subghz_i.h +++ b/applications/main/subghz/subghz_i.h @@ -1,6 +1,7 @@ #pragma once #include "helpers/subghz_types.h" +#include "helpers/subghz_error_type.h" #include #include "subghz.h" #include "views/receiver.h" diff --git a/applications/services/rpc/rpc_app.c b/applications/services/rpc/rpc_app.c index 4e1af1fb..b96f043a 100644 --- a/applications/services/rpc/rpc_app.c +++ b/applications/services/rpc/rpc_app.c @@ -32,6 +32,7 @@ static void rpc_system_app_start_process(const PB_Main* request, void* context) furi_assert(request->which_content == PB_Main_app_start_request_tag); RpcAppSystem* rpc_app = context; RpcSession* session = rpc_app->session; + rpc_system_app_error_reset(rpc_app); furi_assert(session); char args_temp[RPC_SYSTEM_APP_TEMP_ARGS_SIZE]; @@ -79,6 +80,7 @@ static void rpc_system_app_lock_status_process(const PB_Main* request, void* con furi_assert(request->which_content == PB_Main_app_lock_status_request_tag); RpcAppSystem* rpc_app = context; + rpc_system_app_error_reset(rpc_app); RpcSession* session = rpc_app->session; furi_assert(session); @@ -108,6 +110,7 @@ static void rpc_system_app_exit_request(const PB_Main* request, void* context) { furi_assert(request->which_content == PB_Main_app_exit_request_tag); RpcAppSystem* rpc_app = context; + rpc_system_app_error_reset(rpc_app); RpcSession* session = rpc_app->session; furi_assert(session); @@ -133,6 +136,7 @@ static void rpc_system_app_load_file(const PB_Main* request, void* context) { furi_assert(request->which_content == PB_Main_app_load_file_request_tag); RpcAppSystem* rpc_app = context; + rpc_system_app_error_reset(rpc_app); RpcSession* session = rpc_app->session; furi_assert(session); @@ -158,6 +162,7 @@ static void rpc_system_app_button_press(const PB_Main* request, void* context) { furi_assert(request->which_content == PB_Main_app_button_press_request_tag); RpcAppSystem* rpc_app = context; + rpc_system_app_error_reset(rpc_app); RpcSession* session = rpc_app->session; furi_assert(session); @@ -183,6 +188,7 @@ static void rpc_system_app_button_release(const PB_Main* request, void* context) furi_assert(context); RpcAppSystem* rpc_app = context; + rpc_system_app_error_reset(rpc_app); RpcSession* session = rpc_app->session; furi_assert(session); @@ -222,6 +228,7 @@ static void rpc_system_app_data_exchange_process(const PB_Main* request, void* c furi_assert(context); RpcAppSystem* rpc_app = context; + rpc_system_app_error_reset(rpc_app); RpcSession* session = rpc_app->session; furi_assert(session); @@ -326,6 +333,13 @@ void rpc_system_app_set_error_text(RpcAppSystem* rpc_app, const char* error_text content->text = error_text ? strdup(error_text) : NULL; } +void rpc_system_app_error_reset(RpcAppSystem* rpc_app) { + furi_assert(rpc_app); + + rpc_system_app_set_error_code(rpc_app, 0); + rpc_system_app_set_error_text(rpc_app, NULL); +} + void rpc_system_app_set_data_exchange_callback( RpcAppSystem* rpc_app, RpcAppSystemDataExchangeCallback callback, diff --git a/applications/services/rpc/rpc_app.h b/applications/services/rpc/rpc_app.h index 70febe49..d5c6fee9 100644 --- a/applications/services/rpc/rpc_app.h +++ b/applications/services/rpc/rpc_app.h @@ -33,6 +33,8 @@ void rpc_system_app_set_error_code(RpcAppSystem* rpc_app, uint32_t error_code); void rpc_system_app_set_error_text(RpcAppSystem* rpc_app, const char* error_text); +void rpc_system_app_error_reset(RpcAppSystem* rpc_app); + void rpc_system_app_set_data_exchange_callback( RpcAppSystem* rpc_app, RpcAppSystemDataExchangeCallback callback, diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 1ce76845..7b07bb18 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,10.0,, +Version,+,10.1,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, @@ -2286,6 +2286,7 @@ Function,+,rpc_session_set_context,void,"RpcSession*, void*" Function,+,rpc_session_set_send_bytes_callback,void,"RpcSession*, RpcSendBytesCallback" Function,+,rpc_session_set_terminated_callback,void,"RpcSession*, RpcSessionTerminatedCallback" Function,+,rpc_system_app_confirm,void,"RpcAppSystem*, RpcAppSystemEvent, _Bool" +Function,+,rpc_system_app_error_reset,void,RpcAppSystem* Function,+,rpc_system_app_exchange_data,void,"RpcAppSystem*, const uint8_t*, size_t" Function,+,rpc_system_app_get_data,const char*,RpcAppSystem* Function,+,rpc_system_app_send_exited,void,RpcAppSystem*