From 1387d8d5d652c81b9eeb8c5a193dc6b0dca75718 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sat, 6 May 2023 17:28:16 +0300 Subject: [PATCH] SubGhz: check load type file --- applications/main/subghz/helpers/subghz_types.h | 7 +++++++ applications/main/subghz/scenes/subghz_scene_saved.c | 2 +- applications/main/subghz/subghz.c | 2 +- applications/main/subghz/subghz_i.c | 7 +++++++ applications/main/subghz/subghz_i.h | 3 +++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/applications/main/subghz/helpers/subghz_types.h b/applications/main/subghz/helpers/subghz_types.h index 3c5982427..700049237 100644 --- a/applications/main/subghz/helpers/subghz_types.h +++ b/applications/main/subghz/helpers/subghz_types.h @@ -80,6 +80,13 @@ typedef enum { SubGhzViewIdTestPacket, } SubGhzViewId; +/** SubGhz load type file */ +typedef enum { + SubGhzLoadTypeFileNoLoad, + SubGhzLoadTypeFileKey, + SubGhzLoadTypeFileRaw, +} SubGhzLoadTypeFile; + typedef enum { SubGhzViewReceiverModeLive, SubGhzViewReceiverModeFile, diff --git a/applications/main/subghz/scenes/subghz_scene_saved.c b/applications/main/subghz/scenes/subghz_scene_saved.c index 62ade3508..23d8ac39f 100644 --- a/applications/main/subghz/scenes/subghz_scene_saved.c +++ b/applications/main/subghz/scenes/subghz_scene_saved.c @@ -4,7 +4,7 @@ void subghz_scene_saved_on_enter(void* context) { SubGhz* subghz = context; if(subghz_load_protocol_from_file(subghz)) { - if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) { + if((subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw)) { subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad; scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW); } else { diff --git a/applications/main/subghz/subghz.c b/applications/main/subghz/subghz.c index f2bb87c8a..6d565be5d 100644 --- a/applications/main/subghz/subghz.c +++ b/applications/main/subghz/subghz.c @@ -478,7 +478,7 @@ int32_t subghz_app(void* p) { if(subghz_key_load(subghz, p, true)) { furi_string_set(subghz->file_path, (const char*)p); - if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) { + if((subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw)) { //Load Raw TX subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad; scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW); diff --git a/applications/main/subghz/subghz_i.c b/applications/main/subghz/subghz_i.c index e94f937bd..d8da55973 100644 --- a/applications/main/subghz/subghz_i.c +++ b/applications/main/subghz/subghz_i.c @@ -356,8 +356,10 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) { } if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) { //if RAW + subghz->txrx->load_type_file = SubGhzLoadTypeFileRaw; subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, file_path); } else { + subghz->txrx->load_type_file = SubGhzLoadTypeFileKey; stream_copy_full( flipper_format_get_raw_stream(fff_data_file), flipper_format_get_raw_stream(subghz->txrx->fff_data)); @@ -412,6 +414,11 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) { } } +SubGhzLoadTypeFile subghz_get_load_type_file(SubGhz* subghz) { + furi_assert(subghz); + return subghz->txrx->load_type_file; +} + bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) { furi_assert(subghz); diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h index 7e3e9bab0..4be2b6e5f 100644 --- a/applications/main/subghz/subghz_i.h +++ b/applications/main/subghz/subghz_i.h @@ -86,6 +86,7 @@ struct SubGhzTxRx { bool ignore_magellan; SubGhzRxKeyState rx_key_state; + SubGhzLoadTypeFile load_type_file; bool debug_pin_state; }; @@ -189,5 +190,7 @@ void subghz_lock(SubGhz* subghz); void subghz_unlock(SubGhz* subghz); bool subghz_is_locked(SubGhz* subghz); +SubGhzLoadTypeFile subghz_get_load_type_file(SubGhz* subghz); + extern const NotificationSequence subghz_sequence_rx; extern const NotificationSequence subghz_sequence_rx_locked;