From 435205de331d7d589e3549b021ee02640df83e83 Mon Sep 17 00:00:00 2001 From: Skorpionm <85568270+Skorpionm@users.noreply.github.com> Date: Thu, 7 Apr 2022 19:48:07 +0400 Subject: [PATCH] [FL-2427] SubGhz: fix Sub-Ghz RAW not working in Japan region (#1099) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- applications/subghz/subghz_i.c | 37 +++++++++++++++++++++++++++++++++- applications/subghz/subghz_i.h | 1 + 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/applications/subghz/subghz_i.c b/applications/subghz/subghz_i.c index 8f7f2cc6..80d7a52c 100644 --- a/applications/subghz/subghz_i.c +++ b/applications/subghz/subghz_i.c @@ -197,6 +197,22 @@ void subghz_tx_stop(SubGhz* subghz) { notification_message(subghz->notifications, &sequence_reset_red); } +void subghz_dialog_message_show_only_rx(SubGhz* subghz) { + DialogsApp* dialogs = subghz->dialogs; + DialogMessage* message = dialog_message_alloc(); + dialog_message_set_text( + message, + "This frequency can\nonly be used for RX\nin your region", + 38, + 23, + AlignCenter, + AlignCenter); + dialog_message_set_icon(message, &I_DolphinFirstStart7_61x51, 67, 12); + dialog_message_set_buttons(message, "Back", NULL, NULL); + dialog_message_show(dialogs, message); + dialog_message_free(message); +} + bool subghz_key_load(SubGhz* subghz, const char* file_path) { furi_assert(subghz); furi_assert(file_path); @@ -205,6 +221,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) { FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); Stream* fff_data_stream = flipper_format_get_raw_stream(subghz->txrx->fff_data); + uint8_t err = 1; bool loaded = false; string_t temp_str; string_init(temp_str); @@ -239,6 +256,12 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) { FURI_LOG_E(TAG, "Frequency not supported"); break; } + + if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { + FURI_LOG_E(TAG, "This frequency can only be used for RX in your region"); + err = 2; + break; + } subghz->txrx->frequency = temp_data32; if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) { @@ -281,7 +304,19 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) { } while(0); if(!loaded) { - dialog_message_show_storage_error(subghz->dialogs, "Cannot parse\nfile"); + switch(err) { + case 1: + dialog_message_show_storage_error(subghz->dialogs, "Cannot parse\nfile"); + break; + + case 2: + subghz_dialog_message_show_only_rx(subghz); + break; + + default: + furi_crash(NULL); + break; + } } string_clear(temp_str); diff --git a/applications/subghz/subghz_i.h b/applications/subghz/subghz_i.h index 65e8b3e3..bfa80df3 100644 --- a/applications/subghz/subghz_i.h +++ b/applications/subghz/subghz_i.h @@ -155,6 +155,7 @@ void subghz_rx_end(SubGhz* subghz); void subghz_sleep(SubGhz* subghz); bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format); void subghz_tx_stop(SubGhz* subghz); +void subghz_dialog_message_show_only_rx(SubGhz* subghz); bool subghz_key_load(SubGhz* subghz, const char* file_path); bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len); bool subghz_save_protocol_to_file(