[FL-3002] SubGhz: add RPC error (#2097)
* [FL-3002] SubGhz: add RPC error * RPC_APP: rpc_system_app_error_reset, automatic error reset when a new event is executed * SubGhz: fix text error * SubGhz: fix text error 2 * SubGhz: add error description * Format sources Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
c535b8f4ce
commit
6a470a464e
13
applications/main/subghz/helpers/subghz_error_type.h
Normal file
13
applications/main/subghz/helpers/subghz_error_type.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <furi.h>
|
||||||
|
#include <furi_hal.h>
|
||||||
|
|
||||||
|
/** 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;
|
@ -43,6 +43,12 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
|||||||
result = subghz_tx_start(subghz, subghz->txrx->fff_data);
|
result = subghz_tx_start(subghz, subghz->txrx->fff_data);
|
||||||
if(result) subghz_blink_start(subghz);
|
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);
|
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonPress, result);
|
||||||
} else if(event.event == SubGhzCustomEventSceneRpcButtonRelease) {
|
} else if(event.event == SubGhzCustomEventSceneRpcButtonRelease) {
|
||||||
bool result = false;
|
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);
|
popup_set_text(popup, subghz->file_name_tmp, 89, 44, AlignCenter, AlignTop);
|
||||||
|
|
||||||
furi_string_free(file_name);
|
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);
|
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventLoadFile, result);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "helpers/subghz_types.h"
|
#include "helpers/subghz_types.h"
|
||||||
|
#include "helpers/subghz_error_type.h"
|
||||||
#include <lib/subghz/types.h>
|
#include <lib/subghz/types.h>
|
||||||
#include "subghz.h"
|
#include "subghz.h"
|
||||||
#include "views/receiver.h"
|
#include "views/receiver.h"
|
||||||
|
@ -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);
|
furi_assert(request->which_content == PB_Main_app_start_request_tag);
|
||||||
RpcAppSystem* rpc_app = context;
|
RpcAppSystem* rpc_app = context;
|
||||||
RpcSession* session = rpc_app->session;
|
RpcSession* session = rpc_app->session;
|
||||||
|
rpc_system_app_error_reset(rpc_app);
|
||||||
furi_assert(session);
|
furi_assert(session);
|
||||||
char args_temp[RPC_SYSTEM_APP_TEMP_ARGS_SIZE];
|
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);
|
furi_assert(request->which_content == PB_Main_app_lock_status_request_tag);
|
||||||
RpcAppSystem* rpc_app = context;
|
RpcAppSystem* rpc_app = context;
|
||||||
|
rpc_system_app_error_reset(rpc_app);
|
||||||
RpcSession* session = rpc_app->session;
|
RpcSession* session = rpc_app->session;
|
||||||
furi_assert(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);
|
furi_assert(request->which_content == PB_Main_app_exit_request_tag);
|
||||||
RpcAppSystem* rpc_app = context;
|
RpcAppSystem* rpc_app = context;
|
||||||
|
rpc_system_app_error_reset(rpc_app);
|
||||||
RpcSession* session = rpc_app->session;
|
RpcSession* session = rpc_app->session;
|
||||||
furi_assert(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);
|
furi_assert(request->which_content == PB_Main_app_load_file_request_tag);
|
||||||
RpcAppSystem* rpc_app = context;
|
RpcAppSystem* rpc_app = context;
|
||||||
|
rpc_system_app_error_reset(rpc_app);
|
||||||
RpcSession* session = rpc_app->session;
|
RpcSession* session = rpc_app->session;
|
||||||
furi_assert(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);
|
furi_assert(request->which_content == PB_Main_app_button_press_request_tag);
|
||||||
RpcAppSystem* rpc_app = context;
|
RpcAppSystem* rpc_app = context;
|
||||||
|
rpc_system_app_error_reset(rpc_app);
|
||||||
RpcSession* session = rpc_app->session;
|
RpcSession* session = rpc_app->session;
|
||||||
furi_assert(session);
|
furi_assert(session);
|
||||||
|
|
||||||
@ -183,6 +188,7 @@ static void rpc_system_app_button_release(const PB_Main* request, void* context)
|
|||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
|
|
||||||
RpcAppSystem* rpc_app = context;
|
RpcAppSystem* rpc_app = context;
|
||||||
|
rpc_system_app_error_reset(rpc_app);
|
||||||
RpcSession* session = rpc_app->session;
|
RpcSession* session = rpc_app->session;
|
||||||
furi_assert(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);
|
furi_assert(context);
|
||||||
|
|
||||||
RpcAppSystem* rpc_app = context;
|
RpcAppSystem* rpc_app = context;
|
||||||
|
rpc_system_app_error_reset(rpc_app);
|
||||||
RpcSession* session = rpc_app->session;
|
RpcSession* session = rpc_app->session;
|
||||||
furi_assert(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;
|
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(
|
void rpc_system_app_set_data_exchange_callback(
|
||||||
RpcAppSystem* rpc_app,
|
RpcAppSystem* rpc_app,
|
||||||
RpcAppSystemDataExchangeCallback callback,
|
RpcAppSystemDataExchangeCallback callback,
|
||||||
|
@ -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_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(
|
void rpc_system_app_set_data_exchange_callback(
|
||||||
RpcAppSystem* rpc_app,
|
RpcAppSystem* rpc_app,
|
||||||
RpcAppSystemDataExchangeCallback callback,
|
RpcAppSystemDataExchangeCallback callback,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
entry,status,name,type,params
|
entry,status,name,type,params
|
||||||
Version,+,10.0,,
|
Version,+,10.1,,
|
||||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||||
Header,+,applications/services/cli/cli.h,,
|
Header,+,applications/services/cli/cli.h,,
|
||||||
Header,+,applications/services/cli/cli_vcp.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_send_bytes_callback,void,"RpcSession*, RpcSendBytesCallback"
|
||||||
Function,+,rpc_session_set_terminated_callback,void,"RpcSession*, RpcSessionTerminatedCallback"
|
Function,+,rpc_session_set_terminated_callback,void,"RpcSession*, RpcSessionTerminatedCallback"
|
||||||
Function,+,rpc_system_app_confirm,void,"RpcAppSystem*, RpcAppSystemEvent, _Bool"
|
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_exchange_data,void,"RpcAppSystem*, const uint8_t*, size_t"
|
||||||
Function,+,rpc_system_app_get_data,const char*,RpcAppSystem*
|
Function,+,rpc_system_app_get_data,const char*,RpcAppSystem*
|
||||||
Function,+,rpc_system_app_send_exited,void,RpcAppSystem*
|
Function,+,rpc_system_app_send_exited,void,RpcAppSystem*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user