Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FL-3340] SubGhz: fix flipper crashes after exiting broadcast blocking message and crash cli #2714

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions applications/main/subghz/helpers/subghz_error_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ typedef enum {
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 */
SubGhzErrorTypeParserOthers = 3, /** Error in protocol parameters description */
} SubGhzErrorType;
33 changes: 22 additions & 11 deletions applications/main/subghz/scenes/subghz_scene_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,36 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
} else if(event.event == SubGhzCustomEventSceneRpcButtonPress) {
bool result = false;
if((state == SubGhzRpcStateLoaded)) {
result = subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
state = SubGhzRpcStateTx;
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");
switch(
subghz_txrx_tx_start(subghz->txrx, subghz_txrx_get_fff_data(subghz->txrx))) {
case SubGhzTxRxStartTxStateErrorOnlyRx:
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");
break;
case SubGhzTxRxStartTxStateErrorParserOthers:
rpc_system_app_set_error_code(subghz->rpc_ctx, SubGhzErrorTypeParserOthers);
rpc_system_app_set_error_text(
subghz->rpc_ctx, "Error in protocol parameters description");
break;

default: //if(SubGhzTxRxStartTxStateOk)
result = true;
subghz_blink_start(subghz);
state = SubGhzRpcStateTx;
break;
}
}
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonPress, result);
} else if(event.event == SubGhzCustomEventSceneRpcButtonRelease) {
bool result = false;
if(state == SubGhzRpcStateTx) {
subghz_txrx_stop(subghz->txrx);
subghz_blink_stop(subghz);
state = SubGhzRpcStateIdle;
result = true;
}
state = SubGhzRpcStateIdle;
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonRelease, result);
} else if(event.event == SubGhzCustomEventSceneRpcLoad) {
bool result = false;
Expand Down Expand Up @@ -95,7 +106,7 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
void subghz_scene_rpc_on_exit(void* context) {
SubGhz* subghz = context;
SubGhzRpcState state = scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneRpc);
if(state != SubGhzRpcStateIdle) {
if(state == SubGhzRpcStateTx) {
subghz_txrx_stop(subghz->txrx);
subghz_blink_stop(subghz);
}
Expand Down
17 changes: 10 additions & 7 deletions applications/main/subghz/subghz_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,19 @@ void subghz_cli_command_tx(Cli* cli, FuriString* args, void* context) {

furi_hal_power_suppress_charge_enter();

furi_hal_subghz_start_async_tx(subghz_transmitter_yield, transmitter);
if(furi_hal_subghz_start_async_tx(subghz_transmitter_yield, transmitter)) {
while(!(furi_hal_subghz_is_async_tx_complete() || cli_cmd_interrupt_received(cli))) {
printf(".");
fflush(stdout);
furi_delay_ms(333);
}
furi_hal_subghz_stop_async_tx();

while(!(furi_hal_subghz_is_async_tx_complete() || cli_cmd_interrupt_received(cli))) {
printf(".");
fflush(stdout);
furi_delay_ms(333);
} else {
printf("Transmission on this frequency is restricted in your region\r\n");
}
furi_hal_subghz_stop_async_tx();
furi_hal_subghz_sleep();

furi_hal_subghz_sleep();
furi_hal_power_suppress_charge_exit();

flipper_format_free(flipper_format);
Expand Down