Skip to content

Commit

Permalink
[FL-2427] SubGhz: fix Sub-Ghz RAW not working in Japan region (flippe…
Browse files Browse the repository at this point in the history
…rdevices#1099)

Co-authored-by: あく <[email protected]>
  • Loading branch information
Skorpionm and skotopes authored Apr 7, 2022
1 parent d635890 commit 435205d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
37 changes: 36 additions & 1 deletion applications/subghz/subghz_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions applications/subghz/subghz_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 435205d

Please sign in to comment.