From 5853e0bdd9c7ef76ac9ed9bb05b262bf9fc5b374 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Thu, 19 Jan 2023 16:27:07 +0300 Subject: [PATCH 1/2] Block usage of hopping with detect raw at same time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enough, it will not be enabled back, do not ask for it, its efficiency is almost 0, if you didn’t know it looses signals and all that you can capture is a micro part of end of the signal Detect raw also will be removed in a future (and replaced with more correct solution) --- .../subghz/scenes/subghz_scene_receiver.c | 1 - .../scenes/subghz_scene_receiver_config.c | 88 +++++++++---------- applications/main/subghz/subghz_history.c | 13 --- applications/main/subghz/subghz_history.h | 7 -- 4 files changed, 44 insertions(+), 65 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index cab19f730..4f7f7be6c 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -173,7 +173,6 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { subghz_sleep(subghz); } subghz->txrx->hopper_state = SubGhzHopperStateOFF; - subghz_history_set_hopper_state(subghz->txrx->history, false); subghz->txrx->idx_menu_chosen = 0; subghz_receiver_set_rx_callback(subghz->txrx->receiver, NULL, subghz); diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index 82debf4c0..c9fa8c222 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -231,64 +231,64 @@ static void subghz_scene_receiver_config_set_detect_raw(VariableItem* item) { SubGhz* subghz = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); - //if(subghz->txrx->hopper_state == 0) { - variable_item_set_current_value_text(item, detect_raw_text[index]); + if(subghz->txrx->hopper_state == 0) { + variable_item_set_current_value_text(item, detect_raw_text[index]); #ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING - subghz->last_settings->detect_raw = index; + subghz->last_settings->detect_raw = index; - subghz_last_settings_set_detect_raw_values(subghz); + subghz_last_settings_set_detect_raw_values(subghz); #else - subghz_receiver_set_filter(subghz->txrx->receiver, detect_raw_value[index]); + subghz_receiver_set_filter(subghz->txrx->receiver, detect_raw_value[index]); - subghz_protocol_decoder_raw_set_auto_mode( - subghz_receiver_search_decoder_base_by_name( - subghz->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME), - (index == 1)); + subghz_protocol_decoder_raw_set_auto_mode( + subghz_receiver_search_decoder_base_by_name( + subghz->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME), + (index == 1)); #endif - /*} else { + } else { variable_item_set_current_value_index(item, 0); - }*/ + } } static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) { SubGhz* subghz = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); - //if(subghz_receiver_get_filter(subghz->txrx->receiver) == SubGhzProtocolFlag_Decodable) { - variable_item_set_current_value_text(item, hopping_text[index]); - if(hopping_value[index] == SubGhzHopperStateOFF) { - char text_buf[10] = {0}; - snprintf( - text_buf, - sizeof(text_buf), - "%lu.%02lu", - subghz_setting_get_default_frequency(subghz->setting) / 1000000, - (subghz_setting_get_default_frequency(subghz->setting) % 1000000) / 10000); - variable_item_set_current_value_text( - (VariableItem*)scene_manager_get_scene_state( - subghz->scene_manager, SubGhzSceneReceiverConfig), - text_buf); - subghz->txrx->preset->frequency = subghz_setting_get_default_frequency(subghz->setting); - variable_item_set_current_value_index( - (VariableItem*)scene_manager_get_scene_state( - subghz->scene_manager, SubGhzSceneReceiverConfig), - subghz_setting_get_frequency_default_index(subghz->setting)); - } else { - variable_item_set_current_value_text( - (VariableItem*)scene_manager_get_scene_state( - subghz->scene_manager, SubGhzSceneReceiverConfig), - " -----"); - variable_item_set_current_value_index( - (VariableItem*)scene_manager_get_scene_state( - subghz->scene_manager, SubGhzSceneReceiverConfig), - subghz_setting_get_frequency_default_index(subghz->setting)); - } + if(subghz_receiver_get_filter(subghz->txrx->receiver) == SubGhzProtocolFlag_Decodable) { + variable_item_set_current_value_text(item, hopping_text[index]); + if(hopping_value[index] == SubGhzHopperStateOFF) { + char text_buf[10] = {0}; + snprintf( + text_buf, + sizeof(text_buf), + "%lu.%02lu", + subghz_setting_get_default_frequency(subghz->setting) / 1000000, + (subghz_setting_get_default_frequency(subghz->setting) % 1000000) / 10000); + variable_item_set_current_value_text( + (VariableItem*)scene_manager_get_scene_state( + subghz->scene_manager, SubGhzSceneReceiverConfig), + text_buf); + subghz->txrx->preset->frequency = + subghz_setting_get_default_frequency(subghz->setting); + variable_item_set_current_value_index( + (VariableItem*)scene_manager_get_scene_state( + subghz->scene_manager, SubGhzSceneReceiverConfig), + subghz_setting_get_frequency_default_index(subghz->setting)); + } else { + variable_item_set_current_value_text( + (VariableItem*)scene_manager_get_scene_state( + subghz->scene_manager, SubGhzSceneReceiverConfig), + " -----"); + variable_item_set_current_value_index( + (VariableItem*)scene_manager_get_scene_state( + subghz->scene_manager, SubGhzSceneReceiverConfig), + subghz_setting_get_frequency_default_index(subghz->setting)); + } - subghz->txrx->hopper_state = hopping_value[index]; - subghz_history_set_hopper_state(subghz->txrx->history, (index == 1)); - /*} else { + subghz->txrx->hopper_state = hopping_value[index]; + } else { variable_item_set_current_value_index(item, 0); - }*/ + } } static void subghz_scene_receiver_config_set_speaker(VariableItem* item) { diff --git a/applications/main/subghz/subghz_history.c b/applications/main/subghz/subghz_history.c index c84af3a78..4a4980cee 100644 --- a/applications/main/subghz/subghz_history.c +++ b/applications/main/subghz/subghz_history.c @@ -46,7 +46,6 @@ struct SubGhzHistory { uint8_t code_last_hash_data; FuriString* tmp_string; bool write_tmp_files; - bool is_hopper_running; Storage* storage; SubGhzHistoryStruct* history; }; @@ -140,8 +139,6 @@ SubGhzHistory* subghz_history_alloc(void) { instance->storage = furi_record_open(RECORD_STORAGE); instance->write_tmp_files = subghz_history_check_sdcard(instance); - instance->is_hopper_running = false; - if(!instance->write_tmp_files) { FURI_LOG_E(TAG, "Unstable work! Cannot use SD Card!"); } @@ -217,12 +214,6 @@ void subghz_history_reset(SubGhzHistory* instance) { instance->code_last_hash_data = 0; } -void subghz_history_set_hopper_state(SubGhzHistory* instance, bool hopper_state) { - furi_assert(instance); - - instance->is_hopper_running = hopper_state; -} - uint16_t subghz_history_get_item(SubGhzHistory* instance) { furi_assert(instance); return instance->last_index_write; @@ -372,10 +363,6 @@ bool subghz_history_add_to_history( item->protocol_name, "%s", furi_string_get_cstr(instance->tmp_string)); } if(!strcmp(furi_string_get_cstr(instance->tmp_string), "RAW")) { - // Check if hopper enabled we need to add little delay - if(instance->is_hopper_running) { - furi_delay_ms(40); - } // Enable writing temp files to micro sd tmp_file_for_raw = true; // Write display name diff --git a/applications/main/subghz/subghz_history.h b/applications/main/subghz/subghz_history.h index ee1ee1a4d..607dbeae2 100644 --- a/applications/main/subghz/subghz_history.h +++ b/applications/main/subghz/subghz_history.h @@ -110,10 +110,3 @@ bool subghz_history_add_to_history( * @return SubGhzProtocolCommonLoad* */ FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx); - -/** Set hopper state for internal usage in history - * - * @param instance - SubGhzHistory instance - * @param hopper_state - bool is hopper running? - */ -void subghz_history_set_hopper_state(SubGhzHistory* instance, bool hopper_state); From f8cc914a15d9ff18096593d3165822a8fe3abfec Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Thu, 19 Jan 2023 18:14:05 +0300 Subject: [PATCH 2/2] Change default hopping frequency list Change it to use only most common frequencies --- documentation/SubGHzSettings.md | 4 ++-- lib/subghz/subghz_setting.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/SubGHzSettings.md b/documentation/SubGHzSettings.md index 906da27f2..bfcfcccfa 100644 --- a/documentation/SubGHzSettings.md +++ b/documentation/SubGHzSettings.md @@ -88,10 +88,10 @@ Your frequencies will be added after default ones ### Default hopper list ``` - 310000000, 315000000, - 318000000, + 330000000, 390000000, + 433420000, 433920000, 868350000, ``` \ No newline at end of file diff --git a/lib/subghz/subghz_setting.c b/lib/subghz/subghz_setting.c index 4261a5d39..35ba54a8a 100644 --- a/lib/subghz/subghz_setting.c +++ b/lib/subghz/subghz_setting.c @@ -76,10 +76,10 @@ static const uint32_t subghz_frequency_list[] = { }; static const uint32_t subghz_hopper_frequency_list[] = { - 310000000, 315000000, - 318000000, + 330000000, 390000000, + 433420000, 433920000, 868350000, 0,