diff --git a/applications/main/subghz/scenes/subghz_scene_radio_settings.c b/applications/main/subghz/scenes/subghz_scene_radio_settings.c index ec4fee4a1c..e16a422f0d 100644 --- a/applications/main/subghz/scenes/subghz_scene_radio_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_radio_settings.c @@ -20,12 +20,6 @@ const char* const timestamp_names_text[TIMESTAMP_NAMES_COUNT] = { "ON", }; -#define EXT_MOD_POWER_AMP_COUNT 2 -const char* const ext_mod_power_amp_text[EXT_MOD_POWER_AMP_COUNT] = { - "OFF", - "ON", -}; - #define DEBUG_P_COUNT 2 const char* const debug_pin_text[DEBUG_P_COUNT] = { "OFF", @@ -94,27 +88,6 @@ static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) { furi_hal_subghz_set_rolling_counter_mult(debug_counter_val[index]); } -static void subghz_scene_reciever_config_set_ext_mod_power_amp_text(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, ext_mod_power_amp_text[index]); - - subghz->last_settings->external_module_power_amp = index == 1; - - // Set globally in furi hal - furi_hal_subghz_set_ext_power_amp(subghz->last_settings->external_module_power_amp); - - subghz_last_settings_save(subghz->last_settings); - - // reinit external device - const SubGhzRadioDeviceType current = subghz_txrx_radio_device_get(subghz->txrx); - if(current != SubGhzRadioDeviceTypeInternal) { - subghz_txrx_radio_device_set(subghz->txrx, SubGhzRadioDeviceTypeInternal); - subghz_txrx_radio_device_set(subghz->txrx, current); - } -} - static void subghz_scene_receiver_config_set_timestamp_file_names(VariableItem* item) { SubGhz* subghz = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); @@ -147,16 +120,6 @@ void subghz_scene_radio_settings_on_enter(void* context) { variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, radio_device_text[value_index]); - item = variable_item_list_add( - variable_item_list, - "Ext Power Amp", - EXT_MOD_POWER_AMP_COUNT, - subghz_scene_reciever_config_set_ext_mod_power_amp_text, - subghz); - value_index = subghz->last_settings->external_module_power_amp ? 1 : 0; - variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, ext_mod_power_amp_text[value_index]); - item = variable_item_list_add( variable_item_list, "Protocol Names", diff --git a/applications/main/subghz/subghz_dangerous_freq.c b/applications/main/subghz/subghz_dangerous_freq.c index 9722d28b6c..699c42754b 100644 --- a/applications/main/subghz/subghz_dangerous_freq.c +++ b/applications/main/subghz/subghz_dangerous_freq.c @@ -27,9 +27,6 @@ void subghz_dangerous_freq() { SubGhzLastSettings* last_settings = subghz_last_settings_alloc(); subghz_last_settings_load(last_settings, 0); - // Set globally in furi hal - furi_hal_subghz_set_ext_power_amp(last_settings->external_module_power_amp); - subghz_last_settings_free(last_settings); furi_record_close(RECORD_STORAGE); diff --git a/applications/main/subghz/subghz_last_settings.c b/applications/main/subghz/subghz_last_settings.c index 5dd2680e24..262f60c638 100644 --- a/applications/main/subghz/subghz_last_settings.c +++ b/applications/main/subghz/subghz_last_settings.c @@ -4,17 +4,14 @@ #define TAG "SubGhzLastSettings" #define SUBGHZ_LAST_SETTING_FILE_TYPE "Flipper SubGhz Last Setting File" -#define SUBGHZ_LAST_SETTING_FILE_VERSION 1 +#define SUBGHZ_LAST_SETTING_FILE_VERSION 2 #define SUBGHZ_LAST_SETTINGS_PATH EXT_PATH("subghz/assets/last_subghz.settings") #define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY "Frequency" #define SUBGHZ_LAST_SETTING_FIELD_PRESET "Preset" // AKA Modulation #define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_FEEDBACK_LEVEL "FeedbackLevel" #define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_TRIGGER "FATrigger" -#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_ENABLED "External" -#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER "ExtPower" #define SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES "TimestampNames" -#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP "ExtPowerAmp" #define SUBGHZ_LAST_SETTING_FIELD_HOPPING_ENABLE "Hopping" #define SUBGHZ_LAST_SETTING_FIELD_IGNORE_FILTER "IgnoreFilter" #define SUBGHZ_LAST_SETTING_FIELD_FILTER "Filter" @@ -40,9 +37,6 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count uint32_t temp_frequency = 0; uint32_t temp_frequency_analyzer_feedback_level = 0; float temp_frequency_analyzer_trigger = 0; - bool temp_external_module_enabled = false; - bool temp_external_module_power_5v_disable = false; - bool temp_external_module_power_amp = false; bool temp_timestamp_file_names = false; bool temp_enable_hopping = false; bool temp_delete_old_sig = false; @@ -58,62 +52,63 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count bool frequency_analyzer_feedback_level_was_read = false; bool frequency_analyzer_trigger_was_read = false; + FuriString* temp_str = furi_string_alloc(); + uint32_t config_version = 0; + if(FSE_OK == storage_sd_status(storage) && SUBGHZ_LAST_SETTINGS_PATH && flipper_format_file_open_existing(fff_data_file, SUBGHZ_LAST_SETTINGS_PATH)) { - preset_was_read = flipper_format_read_uint32( - fff_data_file, SUBGHZ_LAST_SETTING_FIELD_PRESET, (uint32_t*)&temp_preset, 1); - flipper_format_read_uint32( - fff_data_file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, (uint32_t*)&temp_frequency, 1); - frequency_analyzer_feedback_level_was_read = flipper_format_read_uint32( - fff_data_file, - SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_FEEDBACK_LEVEL, - (uint32_t*)&temp_frequency_analyzer_feedback_level, - 1); - frequency_analyzer_trigger_was_read = flipper_format_read_float( - fff_data_file, - SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_TRIGGER, - (float*)&temp_frequency_analyzer_trigger, - 1); - flipper_format_read_bool( - fff_data_file, - SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_ENABLED, - (bool*)&temp_external_module_enabled, - 1); - flipper_format_read_bool( - fff_data_file, - SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER, - (bool*)&temp_external_module_power_5v_disable, - 1); - flipper_format_read_bool( - fff_data_file, - SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES, - (bool*)&temp_timestamp_file_names, - 1); - flipper_format_read_bool( - fff_data_file, - SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP, - (bool*)&temp_external_module_power_amp, - 1); - flipper_format_read_bool( - fff_data_file, - SUBGHZ_LAST_SETTING_FIELD_HOPPING_ENABLE, - (bool*)&temp_enable_hopping, - 1); - rssi_was_read = flipper_format_read_float( - fff_data_file, SUBGHZ_LAST_SETTING_FIELD_RSSI_THRESHOLD, (float*)&temp_rssi, 1); - ignore_filter_was_read = flipper_format_read_uint32( - fff_data_file, - SUBGHZ_LAST_SETTING_FIELD_IGNORE_FILTER, - (uint32_t*)&temp_ignore_filter, - 1); - filter_was_read = flipper_format_read_uint32( - fff_data_file, SUBGHZ_LAST_SETTING_FIELD_FILTER, (uint32_t*)&temp_filter, 1); - flipper_format_read_bool( - fff_data_file, SUBGHZ_LAST_SETTING_FIELD_DELETE_OLD, (bool*)&temp_delete_old_sig, 1); + do { + if(!flipper_format_read_header(fff_data_file, temp_str, &config_version)) break; + if((strcmp(furi_string_get_cstr(temp_str), SUBGHZ_LAST_SETTING_FILE_TYPE) != 0) || + (config_version != SUBGHZ_LAST_SETTING_FILE_VERSION)) { + break; + } + + preset_was_read = flipper_format_read_uint32( + fff_data_file, SUBGHZ_LAST_SETTING_FIELD_PRESET, (uint32_t*)&temp_preset, 1); + flipper_format_read_uint32( + fff_data_file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, (uint32_t*)&temp_frequency, 1); + frequency_analyzer_feedback_level_was_read = flipper_format_read_uint32( + fff_data_file, + SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_FEEDBACK_LEVEL, + (uint32_t*)&temp_frequency_analyzer_feedback_level, + 1); + frequency_analyzer_trigger_was_read = flipper_format_read_float( + fff_data_file, + SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_TRIGGER, + (float*)&temp_frequency_analyzer_trigger, + 1); + flipper_format_read_bool( + fff_data_file, + SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES, + (bool*)&temp_timestamp_file_names, + 1); + flipper_format_read_bool( + fff_data_file, + SUBGHZ_LAST_SETTING_FIELD_HOPPING_ENABLE, + (bool*)&temp_enable_hopping, + 1); + rssi_was_read = flipper_format_read_float( + fff_data_file, SUBGHZ_LAST_SETTING_FIELD_RSSI_THRESHOLD, (float*)&temp_rssi, 1); + ignore_filter_was_read = flipper_format_read_uint32( + fff_data_file, + SUBGHZ_LAST_SETTING_FIELD_IGNORE_FILTER, + (uint32_t*)&temp_ignore_filter, + 1); + filter_was_read = flipper_format_read_uint32( + fff_data_file, SUBGHZ_LAST_SETTING_FIELD_FILTER, (uint32_t*)&temp_filter, 1); + flipper_format_read_bool( + fff_data_file, + SUBGHZ_LAST_SETTING_FIELD_DELETE_OLD, + (bool*)&temp_delete_old_sig, + 1); + } while(0); } else { FURI_LOG_E(TAG, "Error open file %s", SUBGHZ_LAST_SETTINGS_PATH); } + furi_string_free(temp_str); + if(temp_frequency == 0 || !furi_hal_subghz_is_tx_allowed(temp_frequency)) { FURI_LOG_W(TAG, "Last used frequency not found or can't be used!"); @@ -122,9 +117,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count instance->frequency_analyzer_feedback_level = SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_FEEDBACK_LEVEL; instance->frequency_analyzer_trigger = SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_TRIGGER; - instance->external_module_enabled = false; instance->timestamp_file_names = false; - instance->external_module_power_amp = false; instance->enable_hopping = false; instance->delete_old_signals = false; instance->ignore_filter = 0x00; @@ -155,17 +148,10 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count } else { instance->preset_index = temp_preset; } - instance->external_module_enabled = temp_external_module_enabled; - - instance->external_module_power_5v_disable = temp_external_module_power_5v_disable; - instance->timestamp_file_names = temp_timestamp_file_names; instance->delete_old_signals = temp_delete_old_sig; - // External power amp CC1101 - instance->external_module_power_amp = temp_external_module_power_amp; - instance->rssi = rssi_was_read ? temp_rssi : SUBGHZ_RAW_THRESHOLD_MIN; instance->enable_hopping = temp_enable_hopping; instance->ignore_filter = ignore_filter_was_read ? temp_ignore_filter : 0x00; @@ -180,8 +166,6 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count instance->filter = SubGhzProtocolFlag_Decodable; } #endif - // Set globally in furi hal - furi_hal_subghz_set_ext_power_amp(instance->external_module_power_amp); } flipper_format_file_close(fff_data_file); @@ -233,20 +217,6 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) { 1)) { break; } - if(!flipper_format_insert_or_update_bool( - file, - SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_ENABLED, - &instance->external_module_enabled, - 1)) { - break; - } - if(!flipper_format_insert_or_update_bool( - file, - SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER, - &instance->external_module_power_5v_disable, - 1)) { - break; - } if(!flipper_format_insert_or_update_bool( file, SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES, @@ -254,13 +224,6 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) { 1)) { break; } - if(!flipper_format_insert_or_update_bool( - file, - SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP, - &instance->external_module_power_amp, - 1)) { - break; - } if(!flipper_format_insert_or_update_bool( file, SUBGHZ_LAST_SETTING_FIELD_HOPPING_ENABLE, &instance->enable_hopping, 1)) { break; @@ -312,17 +275,14 @@ void subghz_last_settings_log(SubGhzLastSettings* instance) { FURI_LOG_I( TAG, - "Frequency: %03ld.%02ld, FeedbackLevel: %ld, FATrigger: %.2f, External: %s, ExtPower: %s, TimestampNames: %s, ExtPowerAmp: %s,\n" + "Frequency: %03ld.%02ld, FeedbackLevel: %ld, FATrigger: %.2f, TimestampNames: %s,\n" "Hopping: %s,\nPreset: %ld, RSSI: %.2f, " "Starline: %s, Cars: %s, Magellan: %s, NiceFloR-S: %s, BinRAW: %s", instance->frequency / 1000000 % 1000, instance->frequency / 10000 % 100, instance->frequency_analyzer_feedback_level, (double)instance->frequency_analyzer_trigger, - bool_to_char(instance->external_module_enabled), - bool_to_char(instance->external_module_power_5v_disable), bool_to_char(instance->timestamp_file_names), - bool_to_char(instance->external_module_power_amp), bool_to_char(instance->enable_hopping), instance->preset_index, (double)instance->rssi, diff --git a/applications/main/subghz/subghz_last_settings.h b/applications/main/subghz/subghz_last_settings.h index 74dded4b71..084e767389 100644 --- a/applications/main/subghz/subghz_last_settings.h +++ b/applications/main/subghz/subghz_last_settings.h @@ -20,11 +20,6 @@ typedef struct { uint32_t preset_index; // AKA Modulation uint32_t frequency_analyzer_feedback_level; float frequency_analyzer_trigger; - // TODO not using but saved so as not to change the version - bool external_module_enabled; - bool external_module_power_5v_disable; - bool external_module_power_amp; - // saved so as not to change the version bool timestamp_file_names; bool enable_hopping; uint32_t ignore_filter; diff --git a/lib/subghz/devices/devices.c b/lib/subghz/devices/devices.c index c3fb3168b4..9ae2520172 100644 --- a/lib/subghz/devices/devices.c +++ b/lib/subghz/devices/devices.c @@ -33,7 +33,7 @@ bool subghz_devices_begin(const SubGhzDevice* device) { SubGhzDeviceConf conf = { .ver = 1, .extended_range = false, // TODO - .power_amp = furi_hal_subghz_get_ext_power_amp(), + .power_amp = true, }; ret = device->interconnect->begin(&conf); diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 236a41f9c5..9fe9964f05 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1590,7 +1590,6 @@ Function,-,furi_hal_subghz_dump_state,void, Function,+,furi_hal_subghz_flush_rx,void, Function,+,furi_hal_subghz_flush_tx,void, Function,+,furi_hal_subghz_get_data_gpio,const GpioPin*, -Function,+,furi_hal_subghz_get_ext_power_amp,_Bool, Function,+,furi_hal_subghz_get_lqi,uint8_t, Function,+,furi_hal_subghz_get_rolling_counter_mult,int8_t, Function,+,furi_hal_subghz_get_rssi,float, @@ -1608,7 +1607,6 @@ Function,+,furi_hal_subghz_reset,void, Function,+,furi_hal_subghz_rx,void, Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool, Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin* -Function,+,furi_hal_subghz_set_ext_power_amp,void,_Bool 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 diff --git a/targets/f7/furi_hal/furi_hal_subghz.c b/targets/f7/furi_hal/furi_hal_subghz.c index 29418bfc39..843f637f59 100644 --- a/targets/f7/furi_hal/furi_hal_subghz.c +++ b/targets/f7/furi_hal/furi_hal_subghz.c @@ -52,7 +52,6 @@ typedef struct { const GpioPin* async_mirror_pin; int8_t rolling_counter_mult; - bool ext_power_amp : 1; bool dangerous_frequency_i : 1; } FuriHalSubGhz; @@ -61,7 +60,6 @@ volatile FuriHalSubGhz furi_hal_subghz = { .regulation = SubGhzRegulationTxRx, .async_mirror_pin = NULL, .rolling_counter_mult = 1, - .ext_power_amp = false, .dangerous_frequency_i = false, }; @@ -77,14 +75,6 @@ void furi_hal_subghz_set_dangerous_frequency(bool state_i) { furi_hal_subghz.dangerous_frequency_i = state_i; } -void furi_hal_subghz_set_ext_power_amp(bool enabled) { - furi_hal_subghz.ext_power_amp = enabled; -} - -bool furi_hal_subghz_get_ext_power_amp(void) { - return furi_hal_subghz.ext_power_amp; -} - void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) { furi_hal_subghz.async_mirror_pin = pin; } diff --git a/targets/f7/furi_hal/furi_hal_subghz.h b/targets/f7/furi_hal/furi_hal_subghz.h index 68c040928a..10d89947a9 100644 --- a/targets/f7/furi_hal/furi_hal_subghz.h +++ b/targets/f7/furi_hal/furi_hal_subghz.h @@ -238,54 +238,7 @@ bool furi_hal_subghz_is_async_tx_complete(void); */ void furi_hal_subghz_stop_async_tx(void); -// /** Initialize and switch to power save mode Used by internal API-HAL -// * initialization routine Can be used to reinitialize device to safe state and -// * send it to sleep -// * @return true if initialisation is successfully -// */ -// bool furi_hal_subghz_init_check(void); - -// /** Switching between internal and external radio -// * @param state SubGhzRadioInternal or SubGhzRadioExternal -// * @return true if switching is successful -// */ -// bool furi_hal_subghz_init_radio_type(SubGhzRadioType state); - -// /** Get current radio -// * @return SubGhzRadioInternal or SubGhzRadioExternal -// */ -// SubGhzRadioType furi_hal_subghz_get_radio_type(void); - -// /** Check for a radio module -// * @return true if check is successful -// */ -// bool furi_hal_subghz_check_radio(void); - -// /** Turn on the power of the external radio module -// * @return true if power-up is successful -// */ -// bool furi_hal_subghz_enable_ext_power(void); - -// /** Turn off the power of the external radio module -// */ -// void furi_hal_subghz_disable_ext_power(void); - -// /** If true - disable 5v power of the external radio module -// */ -// void furi_hal_subghz_set_external_power_disable(bool state); - -// /** Get the current state of the external power disable flag -// */ -// bool furi_hal_subghz_get_external_power_disable(void); - -// /** Set what radio module we will be using -// */ -// void furi_hal_subghz_select_radio_type(SubGhzRadioType state); - -// External CC1101 Ebytes power amplifier control -void furi_hal_subghz_set_ext_power_amp(bool enabled); - -bool furi_hal_subghz_get_ext_power_amp(void); +// External CC1101 Ebytes power amplifier control is now enabled by default #ifdef __cplusplus }