From c4baf3194ef776b0b2fbbf46125ce4e790762311 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Tue, 13 Jun 2023 22:17:54 +0300 Subject: [PATCH 1/3] SubGhz App: change load custom presets --- applications/main/subghz/subghz.c | 83 +++++++++++++---------------- firmware/targets/f7/api_symbols.csv | 3 +- lib/subghz/subghz_setting.c | 32 +++++++++++ lib/subghz/subghz_setting.h | 2 + 4 files changed, 73 insertions(+), 47 deletions(-) diff --git a/applications/main/subghz/subghz.c b/applications/main/subghz/subghz.c index 97e2e8c34b..aab154f2d4 100644 --- a/applications/main/subghz/subghz.c +++ b/applications/main/subghz/subghz.c @@ -51,6 +51,42 @@ static void subghz_rpc_command_callback(RpcAppSystemEvent event, void* context) } } +static void subghz_load_custom_presets(SubGhzSetting* setting) { + furi_assert(setting); + + const char* presets[][2] = { + {"FM95", + "02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 83 10 67 15 24 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00"}, + + // #2-FSK 200khz BW / 135kHz Filter/ 15.86Khz Deviation + Ramping + {"FM15k", + "02 0D 03 47 08 32 0B 06 15 32 14 00 13 00 12 00 11 32 10 A7 18 18 19 1D 1D 92 1C 00 1B 04 20 FB 22 17 21 B6 00 00 00 12 0E 34 60 C5 C1 C0"}, + + // Pagers + {"Pagers", + "02 0D 07 04 08 32 0B 06 10 64 11 93 12 0C 13 02 14 00 15 15 18 18 19 16 1B 07 1C 00 1D 91 20 FB 21 56 22 10 00 00 C0 00 00 00 00 00 00 00"}, + + // # HND - FM preset + {"HND_1", + "02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 36 10 69 15 32 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00"}, + }; + + FlipperFormat* fff_temp = flipper_format_string_alloc(); + + for(uint8_t i = 0; i < COUNT_OF(presets); i++) { + flipper_format_insert_or_update_string_cstr(fff_temp, "Custom_preset_data", presets[i][1]); + + flipper_format_rewind(fff_temp); + subghz_setting_load_custom_preset(setting, presets[i][0], fff_temp); + } + + flipper_format_free(fff_temp); + +#ifdef FURI_DEBUG + subghz_setting_customs_presets_to_log(setting); +#endif +} + SubGhz* subghz_alloc(bool alloc_for_tx_only) { SubGhz* subghz = malloc(sizeof(SubGhz)); @@ -177,52 +213,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) { SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx); - // Custom Presets load without using config file - if(!alloc_for_tx_only) { - FlipperFormat* temp_fm_preset = flipper_format_string_alloc(); - flipper_format_write_string_cstr( - temp_fm_preset, - (const char*)"Custom_preset_data", - (const char*)"02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 83 10 67 15 24 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00"); - flipper_format_rewind(temp_fm_preset); - subghz_setting_load_custom_preset(setting, (const char*)"FM95", temp_fm_preset); - - flipper_format_free(temp_fm_preset); - - // #2-FSK 200khz BW / 135kHz Filter/ 15.86Khz Deviation + Ramping - FlipperFormat* temp_fm_preset2 = flipper_format_string_alloc(); - flipper_format_write_string_cstr( - temp_fm_preset2, - (const char*)"Custom_preset_data", - (const char*)"02 0D 03 47 08 32 0B 06 15 32 14 00 13 00 12 00 11 32 10 A7 18 18 19 1D 1D 92 1C 00 1B 04 20 FB 22 17 21 B6 00 00 00 12 0E 34 60 C5 C1 C0"); - flipper_format_rewind(temp_fm_preset2); - subghz_setting_load_custom_preset(setting, (const char*)"FM15k", temp_fm_preset2); - - flipper_format_free(temp_fm_preset2); - - // Pagers - FlipperFormat* temp_fm_preset3 = flipper_format_string_alloc(); - flipper_format_write_string_cstr( - temp_fm_preset3, - (const char*)"Custom_preset_data", - (const char*)"02 0D 07 04 08 32 0B 06 10 64 11 93 12 0C 13 02 14 00 15 15 18 18 19 16 1B 07 1C 00 1D 91 20 FB 21 56 22 10 00 00 C0 00 00 00 00 00 00 00"); - flipper_format_rewind(temp_fm_preset3); - subghz_setting_load_custom_preset(setting, (const char*)"Pagers", temp_fm_preset3); - - flipper_format_free(temp_fm_preset3); - - // # HND - FM preset - FlipperFormat* temp_fm_preset4 = flipper_format_string_alloc(); - flipper_format_write_string_cstr( - temp_fm_preset4, - (const char*)"Custom_preset_data", - (const char*)"02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 36 10 69 15 32 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00"); - flipper_format_rewind(temp_fm_preset4); - subghz_setting_load_custom_preset(setting, (const char*)"HND_1", temp_fm_preset4); - - flipper_format_free(temp_fm_preset4); - } - // custom presets loading - end + subghz_load_custom_presets(setting); // Load last used values for Read, Read RAW, etc. or default subghz->last_settings = subghz_last_settings_alloc(); diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 8a7f947e6f..aed57c63c0 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,30.1,, +Version,+,30.2,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, @@ -2784,6 +2784,7 @@ Function,+,subghz_receiver_search_decoder_base_by_name,SubGhzProtocolDecoderBase Function,+,subghz_receiver_set_filter,void,"SubGhzReceiver*, SubGhzProtocolFlag" Function,+,subghz_receiver_set_rx_callback,void,"SubGhzReceiver*, SubGhzReceiverCallback, void*" Function,+,subghz_setting_alloc,SubGhzSetting*, +Function,-,subghz_setting_customs_presets_to_log,uint8_t,SubGhzSetting* Function,+,subghz_setting_delete_custom_preset,_Bool,"SubGhzSetting*, const char*" Function,+,subghz_setting_free,void,SubGhzSetting* Function,+,subghz_setting_get_default_frequency,uint32_t,SubGhzSetting* diff --git a/lib/subghz/subghz_setting.c b/lib/subghz/subghz_setting.c index cd9d0466eb..46e39b38b1 100644 --- a/lib/subghz/subghz_setting.c +++ b/lib/subghz/subghz_setting.c @@ -482,3 +482,35 @@ uint32_t subghz_setting_get_default_frequency(SubGhzSetting* instance) { return subghz_setting_get_frequency( instance, subghz_setting_get_frequency_default_index(instance)); } + +uint8_t subghz_setting_customs_presets_to_log(SubGhzSetting* instance) { + furi_assert(instance); +#ifndef FURI_DEBUG + FURI_LOG_I(TAG, "Logging loaded presets allow only Debug build"); +#else + uint8_t count = 0; + FuriString* temp = furi_string_alloc(); + + FURI_LOG_I(TAG, "Loaded presets"); + for + M_EACH(item, instance->preset->data, SubGhzSettingCustomPresetItemArray_t) { + furi_string_reset(temp); + + for(uint8_t i = 0; i < item->custom_preset_data_size; i++) { + furi_string_cat_printf(temp, "%02u ", item->custom_preset_data[i]); + } + + FURI_LOG_I( + TAG, "%u - %s", count + 1, furi_string_get_cstr(item->custom_preset_name)); + FURI_LOG_I(TAG, " Size: %u", item->custom_preset_data_size); + FURI_LOG_I(TAG, " Data: %s", furi_string_get_cstr(temp)); + + count++; + } + + furi_string_free(temp); + + return count; +#endif + return 0; +} diff --git a/lib/subghz/subghz_setting.h b/lib/subghz/subghz_setting.h index 3cb07ff6db..3e705312f6 100644 --- a/lib/subghz/subghz_setting.h +++ b/lib/subghz/subghz_setting.h @@ -53,6 +53,8 @@ uint32_t subghz_setting_get_default_frequency(SubGhzSetting* instance); void subghz_setting_set_default_frequency(SubGhzSetting* instance, uint32_t frequency_to_setup); +uint8_t subghz_setting_customs_presets_to_log(SubGhzSetting* instance); + #ifdef __cplusplus } #endif From 7b44221d9a6101996c67ffe753b83f2215bb1d3e Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Tue, 13 Jun 2023 22:36:34 +0300 Subject: [PATCH 2/3] Drop timestamp_file_names in hal --- .../main/subghz/scenes/subghz_scene_radio_settings.c | 3 +-- applications/main/subghz/scenes/subghz_scene_save_name.c | 2 +- applications/main/subghz/subghz_last_settings.c | 3 --- firmware/targets/f7/api_symbols.csv | 4 +--- firmware/targets/f7/furi_hal/furi_hal_subghz.c | 9 --------- firmware/targets/f7/furi_hal/furi_hal_subghz.h | 8 -------- 6 files changed, 3 insertions(+), 26 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_radio_settings.c b/applications/main/subghz/scenes/subghz_scene_radio_settings.c index b60ea0b2dc..3020c1b23a 100644 --- a/applications/main/subghz/scenes/subghz_scene_radio_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_radio_settings.c @@ -111,7 +111,6 @@ static void subghz_scene_receiver_config_set_timestamp_file_names(VariableItem* variable_item_set_current_value_text(item, timestamp_names_text[index]); - furi_hal_subghz_set_timestamp_file_names((index == 1)); subghz->last_settings->timestamp_file_names = (index == 1); subghz_last_settings_save(subghz->last_settings); } @@ -148,7 +147,7 @@ void subghz_scene_radio_settings_on_enter(void* context) { TIMESTAMP_NAMES_COUNT, subghz_scene_receiver_config_set_timestamp_file_names, subghz); - value_index = furi_hal_subghz_get_timestamp_file_names(); + value_index = subghz->last_settings->timestamp_file_names; variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, timestamp_names_text[value_index]); diff --git a/applications/main/subghz/scenes/subghz_scene_save_name.c b/applications/main/subghz/scenes/subghz_scene_save_name.c index c05d0d9627..5c52ed9577 100644 --- a/applications/main/subghz/scenes/subghz_scene_save_name.c +++ b/applications/main/subghz/scenes/subghz_scene_save_name.c @@ -56,7 +56,7 @@ void subghz_scene_save_name_on_enter(void* context) { if(!subghz_path_is_file(subghz->file_path)) { char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0}; - if(furi_hal_subghz_get_timestamp_file_names()) { + if(subghz->last_settings->timestamp_file_names) { SubGhzProtocolDecoderBase* decoder_result = subghz_txrx_get_decoder(subghz->txrx); if(decoder_result != 0x0) { if(decoder_result != NULL) { diff --git a/applications/main/subghz/subghz_last_settings.c b/applications/main/subghz/subghz_last_settings.c index 7ee2554b0d..614e0baa63 100644 --- a/applications/main/subghz/subghz_last_settings.c +++ b/applications/main/subghz/subghz_last_settings.c @@ -119,9 +119,6 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count instance->timestamp_file_names = temp_timestamp_file_names; - // Set globally - furi_hal_subghz_set_timestamp_file_names(instance->timestamp_file_names); - if(instance->external_module_power_5v_disable) { furi_hal_subghz_set_external_power_disable(true); furi_hal_subghz_disable_ext_power(); diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index aed57c63c0..1e1ced11a8 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,30.2,, +Version,+,31.0,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, @@ -1405,7 +1405,6 @@ Function,+,furi_hal_subghz_get_lqi,uint8_t, Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType, Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t, Function,+,furi_hal_subghz_get_rssi,float, -Function,+,furi_hal_subghz_get_timestamp_file_names,_Bool, Function,+,furi_hal_subghz_idle,void, Function,-,furi_hal_subghz_init,void, Function,-,furi_hal_subghz_init_check,_Bool, @@ -1429,7 +1428,6 @@ Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath Function,-,furi_hal_subghz_set_rolling_counter_mult,void,uint8_t -Function,-,furi_hal_subghz_set_timestamp_file_names,void,_Bool Function,-,furi_hal_subghz_shutdown,void, Function,+,furi_hal_subghz_sleep,void, Function,+,furi_hal_subghz_start_async_rx,void,"FuriHalSubGhzCaptureCallback, void*" diff --git a/firmware/targets/f7/furi_hal/furi_hal_subghz.c b/firmware/targets/f7/furi_hal/furi_hal_subghz.c index 8125971e96..aa7438b0b8 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_subghz.c +++ b/firmware/targets/f7/furi_hal/furi_hal_subghz.c @@ -41,7 +41,6 @@ volatile FuriHalSubGhz furi_hal_subghz = { .cc1101_g0_pin = &gpio_cc1101_g0, .rolling_counter_mult = 1, .ext_module_power_disabled = false, - .timestamp_file_names = false, .dangerous_frequency_i = false, }; @@ -90,14 +89,6 @@ bool furi_hal_subghz_get_external_power_disable(void) { return furi_hal_subghz.ext_module_power_disabled; } -void furi_hal_subghz_set_timestamp_file_names(bool state) { - furi_hal_subghz.timestamp_file_names = state; -} - -bool furi_hal_subghz_get_timestamp_file_names(void) { - return furi_hal_subghz.timestamp_file_names; -} - void furi_hal_subghz_set_dangerous_frequency(bool state_i) { furi_hal_subghz.dangerous_frequency_i = state_i; } diff --git a/firmware/targets/f7/furi_hal/furi_hal_subghz.h b/firmware/targets/f7/furi_hal/furi_hal_subghz.h index 0ef7bd90a6..ae6876d456 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_subghz.h +++ b/firmware/targets/f7/furi_hal/furi_hal_subghz.h @@ -332,14 +332,6 @@ void furi_hal_subghz_set_external_power_disable(bool state); */ bool furi_hal_subghz_get_external_power_disable(void); -/** If true - disable generation of random name and add timestamp to filenames instead - */ -void furi_hal_subghz_set_timestamp_file_names(bool state); - -/** Get the current state of the timestamp instead of random name flag - */ -bool furi_hal_subghz_get_timestamp_file_names(void); - /** Set what radio module we will be using */ void furi_hal_subghz_select_radio_type(SubGhzRadioType state); From 417dedd3176605f9b921ba0f6d91f623d1adb0d5 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Wed, 14 Jun 2023 01:24:05 +0300 Subject: [PATCH 3/3] SubGhz App: remove kostily and velosipedy --- .../subghz/scenes/subghz_scene_receiver.c | 78 +++++++------------ .../scenes/subghz_scene_receiver_config.c | 70 ++++++++--------- applications/main/subghz/subghz.c | 1 + applications/main/subghz/subghz_i.h | 5 +- lib/subghz/protocols/kia.c | 3 +- lib/subghz/protocols/magellan.c | 3 +- lib/subghz/protocols/scher_khan.c | 2 +- lib/subghz/protocols/star_line.c | 3 +- lib/subghz/types.h | 3 + 9 files changed, 75 insertions(+), 93 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index d9fd38836f..8bba21b2b7 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -92,35 +92,41 @@ static void subghz_scene_add_to_history_callback( void* context) { furi_assert(context); SubGhz* subghz = context; - SubGhzHistory* history = subghz->history; - FuriString* item_name = furi_string_alloc(); - FuriString* item_time = furi_string_alloc(); - uint16_t idx = subghz_history_get_item(history); - SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx); - if(subghz_history_add_to_history(history, decoder_base, &preset)) { - furi_string_reset(item_name); - furi_string_reset(item_time); + // The check can be moved to /lib/subghz/receiver.c, but may result in false positives + if((decoder_base->protocol->flag & subghz->ignore_filter) == 0) { + SubGhzHistory* history = subghz->history; + FuriString* item_name = furi_string_alloc(); + FuriString* item_time = furi_string_alloc(); + uint16_t idx = subghz_history_get_item(history); - subghz->state_notifications = SubGhzNotificationStateRxDone; + SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx); + if(subghz_history_add_to_history(history, decoder_base, &preset)) { + furi_string_reset(item_name); + furi_string_reset(item_time); - subghz_history_get_text_item_menu(history, item_name, idx); - subghz_history_get_time_item_menu(history, item_time, idx); - subghz_view_receiver_add_item_to_menu( - subghz->subghz_receiver, - furi_string_get_cstr(item_name), - furi_string_get_cstr(item_time), - subghz_history_get_type_protocol(history, idx)); + subghz->state_notifications = SubGhzNotificationStateRxDone; + + subghz_history_get_text_item_menu(history, item_name, idx); + subghz_history_get_time_item_menu(history, item_time, idx); + subghz_view_receiver_add_item_to_menu( + subghz->subghz_receiver, + furi_string_get_cstr(item_name), + furi_string_get_cstr(item_time), + subghz_history_get_type_protocol(history, idx)); - subghz_scene_receiver_update_statusbar(subghz); - if(subghz_history_get_text_space_left(subghz->history, NULL)) { - notification_message(subghz->notifications, &sequence_error); + subghz_scene_receiver_update_statusbar(subghz); + if(subghz_history_get_text_space_left(subghz->history, NULL)) { + notification_message(subghz->notifications, &sequence_error); + } } + subghz_receiver_reset(receiver); + furi_string_free(item_name); + furi_string_free(item_time); + subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey); + } else { + FURI_LOG_I(TAG, "%s protocol ignored", decoder_base->protocol->name); } - subghz_receiver_reset(receiver); - furi_string_free(item_name); - furi_string_free(item_time); - subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey); } void subghz_scene_receiver_on_enter(void* context) { @@ -161,32 +167,6 @@ void subghz_scene_receiver_on_enter(void* context) { subghz->subghz_receiver, subghz_scene_receiver_callback, subghz); subghz_txrx_set_rx_calback(subghz->txrx, subghz_scene_add_to_history_callback, subghz); - // TODO: Replace with proper solution based on protocol flags, remove kostily and velosipedy from here - // Needs to be done after subghz refactoring merge!!! - if(subghz->ignore_starline == true) { - if(subghz_txrx_load_decoder_by_name_protocol(subghz->txrx, "Star Line")) { - subghz_protocol_decoder_base_set_decoder_callback( - subghz_txrx_get_decoder(subghz->txrx), NULL, NULL); - } - } - if(subghz->ignore_auto_alarms == true) { - if(subghz_txrx_load_decoder_by_name_protocol(subghz->txrx, "KIA Seed")) { - subghz_protocol_decoder_base_set_decoder_callback( - subghz_txrx_get_decoder(subghz->txrx), NULL, NULL); - } - - if(subghz_txrx_load_decoder_by_name_protocol(subghz->txrx, "Scher-Khan")) { - subghz_protocol_decoder_base_set_decoder_callback( - subghz_txrx_get_decoder(subghz->txrx), NULL, NULL); - } - } - if(subghz->ignore_magellan == true) { - if(subghz_txrx_load_decoder_by_name_protocol(subghz->txrx, "Magellan")) { - subghz_protocol_decoder_base_set_decoder_callback( - subghz_txrx_get_decoder(subghz->txrx), NULL, NULL); - } - } - if(!subghz_history_get_text_space_left(subghz->history, NULL)) { subghz->state_notifications = SubGhzNotificationStateRx; } diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index 29d55c03a3..62ee538712 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -71,20 +71,8 @@ const uint32_t bin_raw_value[BIN_RAW_COUNT] = { SubGhzProtocolFlag_Decodable, SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_BinRAW, }; -#define STARLINE_COUNT 2 -const char* const starline_text[STARLINE_COUNT] = { - "OFF", - "ON", -}; - -#define AUTO_ALARMS_COUNT 2 -const char* const auto_alarms_text[AUTO_ALARMS_COUNT] = { - "OFF", - "ON", -}; - -#define MAGELLAN_COUNT 2 -const char* const magellan_text[MAGELLAN_COUNT] = { +#define PROTOCOL_IGNORE_COUNT 2 +const char* const protocol_ignore_text[PROTOCOL_IGNORE_COUNT] = { "OFF", "ON", }; @@ -257,28 +245,35 @@ static void subghz_scene_receiver_config_set_raw_threshold_rssi(VariableItem* it subghz_threshold_rssi_set(subghz->threshold_rssi, raw_threshold_rssi_value[index]); } -static void subghz_scene_receiver_config_set_starline(VariableItem* item) { +static inline void + subghz_scene_receiver_config_set_ignore_filter(VariableItem* item, SubGhzProtocolFlag filter) { SubGhz* subghz = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, starline_text[index]); - subghz->ignore_starline = (index == 1); + variable_item_set_current_value_text(item, protocol_ignore_text[index]); + + if(index == 0) { + CLEAR_BIT(subghz->ignore_filter, filter); + } else { + SET_BIT(subghz->ignore_filter, filter); + } +} +static inline bool subghz_scene_receiver_config_ignore_filter_get_index( + SubGhzProtocolFlag filter, + SubGhzProtocolFlag flag) { + return READ_BIT(filter, flag) > 0; +} + +static void subghz_scene_receiver_config_set_starline(VariableItem* item) { + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_StarLine); } static void subghz_scene_receiver_config_set_auto_alarms(VariableItem* item) { - SubGhz* subghz = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - - variable_item_set_current_value_text(item, auto_alarms_text[index]); - subghz->ignore_auto_alarms = (index == 1); + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_AutoAlarms); } static void subghz_scene_receiver_config_set_magellan(VariableItem* item) { - SubGhz* subghz = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - - variable_item_set_current_value_text(item, magellan_text[index]); - subghz->ignore_magellan = (index == 1); + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_Magelan); } static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) { @@ -362,35 +357,38 @@ void subghz_scene_receiver_config_on_enter(void* context) { item = variable_item_list_add( subghz->variable_item_list, "Ignore Starline:", - STARLINE_COUNT, + PROTOCOL_IGNORE_COUNT, subghz_scene_receiver_config_set_starline, subghz); - value_index = subghz->ignore_starline; + value_index = subghz_scene_receiver_config_ignore_filter_get_index( + subghz->ignore_filter, SubGhzProtocolFlag_StarLine); variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, starline_text[value_index]); + variable_item_set_current_value_text(item, protocol_ignore_text[value_index]); item = variable_item_list_add( subghz->variable_item_list, "Ignore Cars:", - AUTO_ALARMS_COUNT, + PROTOCOL_IGNORE_COUNT, subghz_scene_receiver_config_set_auto_alarms, subghz); - value_index = subghz->ignore_auto_alarms; + value_index = subghz_scene_receiver_config_ignore_filter_get_index( + subghz->ignore_filter, SubGhzProtocolFlag_AutoAlarms); variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, auto_alarms_text[value_index]); + variable_item_set_current_value_text(item, protocol_ignore_text[value_index]); item = variable_item_list_add( subghz->variable_item_list, "Ignore Magellan:", - MAGELLAN_COUNT, + PROTOCOL_IGNORE_COUNT, subghz_scene_receiver_config_set_magellan, subghz); - value_index = subghz->ignore_magellan; + value_index = subghz_scene_receiver_config_ignore_filter_get_index( + subghz->ignore_filter, SubGhzProtocolFlag_Magelan); variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, magellan_text[value_index]); + variable_item_set_current_value_text(item, protocol_ignore_text[value_index]); } // Enable speaker, will send all incoming noises and signals to speaker so you can listen how your remote sounds like :) diff --git a/applications/main/subghz/subghz.c b/applications/main/subghz/subghz.c index aab154f2d4..db63ab1fe9 100644 --- a/applications/main/subghz/subghz.c +++ b/applications/main/subghz/subghz.c @@ -242,6 +242,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) { subghz->secure_data = malloc(sizeof(SecureData)); subghz->filter = SubGhzProtocolFlag_Decodable; + subghz->ignore_filter = 0x0; subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter); subghz_txrx_set_need_save_callback(subghz->txrx, subghz_save_to_file, subghz); diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h index 3d1c2db9cf..08658e9b2d 100644 --- a/applications/main/subghz/subghz_i.h +++ b/applications/main/subghz/subghz_i.h @@ -89,13 +89,10 @@ struct SubGhz { SubGhzLastSettings* last_settings; SubGhzProtocolFlag filter; + SubGhzProtocolFlag ignore_filter; FuriString* error_str; SubGhzLock lock; - bool ignore_starline; - bool ignore_auto_alarms; - bool ignore_magellan; - SecureData* secure_data; SubGhzFileEncoderWorker* decode_raw_file_worker_encoder; diff --git a/lib/subghz/protocols/kia.c b/lib/subghz/protocols/kia.c index 1d134f7bab..2d2ceaa1d4 100644 --- a/lib/subghz/protocols/kia.c +++ b/lib/subghz/protocols/kia.c @@ -63,7 +63,8 @@ const SubGhzProtocolEncoder subghz_protocol_kia_encoder = { const SubGhzProtocol subghz_protocol_kia = { .name = SUBGHZ_PROTOCOL_KIA_NAME, .type = SubGhzProtocolTypeDynamic, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_FM | SubGhzProtocolFlag_Decodable, + .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_FM | SubGhzProtocolFlag_Decodable | + SubGhzProtocolFlag_AutoAlarms, .decoder = &subghz_protocol_kia_decoder, .encoder = &subghz_protocol_kia_encoder, diff --git a/lib/subghz/protocols/magellan.c b/lib/subghz/protocols/magellan.c index 2d02a866c2..be819ff318 100644 --- a/lib/subghz/protocols/magellan.c +++ b/lib/subghz/protocols/magellan.c @@ -64,7 +64,8 @@ const SubGhzProtocol subghz_protocol_magellan = { .name = SUBGHZ_PROTOCOL_MAGELLAN_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, + SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send | + SubGhzProtocolFlag_Magelan, .decoder = &subghz_protocol_magellan_decoder, .encoder = &subghz_protocol_magellan_encoder, diff --git a/lib/subghz/protocols/scher_khan.c b/lib/subghz/protocols/scher_khan.c index c2fa77b2f1..53b7935d69 100644 --- a/lib/subghz/protocols/scher_khan.c +++ b/lib/subghz/protocols/scher_khan.c @@ -70,7 +70,7 @@ const SubGhzProtocol subghz_protocol_scher_khan = { .name = SUBGHZ_PROTOCOL_SCHER_KHAN_NAME, .type = SubGhzProtocolTypeDynamic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_FM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_Save | SubGhzProtocolFlag_AutoAlarms, .decoder = &subghz_protocol_scher_khan_decoder, .encoder = &subghz_protocol_scher_khan_encoder, diff --git a/lib/subghz/protocols/star_line.c b/lib/subghz/protocols/star_line.c index 05afd80a67..bf338b35d0 100644 --- a/lib/subghz/protocols/star_line.c +++ b/lib/subghz/protocols/star_line.c @@ -79,7 +79,8 @@ const SubGhzProtocol subghz_protocol_star_line = { .name = SUBGHZ_PROTOCOL_STAR_LINE_NAME, .type = SubGhzProtocolTypeDynamic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, + SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send | + SubGhzProtocolFlag_StarLine, .decoder = &subghz_protocol_star_line_decoder, .encoder = &subghz_protocol_star_line_encoder, diff --git a/lib/subghz/types.h b/lib/subghz/types.h index ce65789a9a..70a57d3f9e 100644 --- a/lib/subghz/types.h +++ b/lib/subghz/types.h @@ -117,6 +117,9 @@ typedef enum { SubGhzProtocolFlag_Load = (1 << 8), SubGhzProtocolFlag_Send = (1 << 9), SubGhzProtocolFlag_BinRAW = (1 << 10), + SubGhzProtocolFlag_StarLine = (1 << 11), + SubGhzProtocolFlag_AutoAlarms = (1 << 12), + SubGhzProtocolFlag_Magelan = (1 << 13), } SubGhzProtocolFlag; struct SubGhzProtocol {