[FL-2427] SubGhz: fix Sub-Ghz RAW not working in Japan region (#1099)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Skorpionm 2022-04-07 19:48:07 +04:00 committed by GitHub
parent d635890342
commit 435205de33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

View File

@ -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) {
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);

View File

@ -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(