diff --git a/applications/main/subghz/scenes/subghz_scene_radio_settings.c b/applications/main/subghz/scenes/subghz_scene_radio_settings.c index 6768b3ddf..731eceeac 100644 --- a/applications/main/subghz/scenes/subghz_scene_radio_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_radio_settings.c @@ -162,13 +162,13 @@ static void subghz_scene_receiver_config_set_gps(VariableItem* item) { } } -static void subghz_scene_receiver_config_set_timestamp_file_names(VariableItem* item) { +static void subghz_scene_receiver_config_set_protocol_file_names(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, timestamp_names_text[index]); - subghz->last_settings->timestamp_file_names = (index == 1); + subghz->last_settings->protocol_file_names = (index == 1); subghz_last_settings_save(subghz->last_settings); } @@ -221,9 +221,9 @@ void subghz_scene_radio_settings_on_enter(void* context) { variable_item_list, "Protocol Names", TIMESTAMP_NAMES_COUNT, - subghz_scene_receiver_config_set_timestamp_file_names, + subghz_scene_receiver_config_set_protocol_file_names, subghz); - value_index = subghz->last_settings->timestamp_file_names; + value_index = subghz->last_settings->protocol_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 80aedcb0d..60d27fd9f 100644 --- a/applications/main/subghz/scenes/subghz_scene_save_name.c +++ b/applications/main/subghz/scenes/subghz_scene_save_name.c @@ -12,36 +12,6 @@ void subghz_scene_save_name_text_input_callback(void* context) { view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneSaveName); } -void subghz_scene_save_name_get_timefilename( - FuriString* name, - const char* proto_name, - bool fulldate) { - FuriHalRtcDateTime datetime = {0}; - furi_hal_rtc_get_datetime(&datetime); - if(fulldate) { - furi_string_printf( - name, - "%s_%.4d%.2d%.2d-%.2d%.2d%.2d", - proto_name, - datetime.year, - datetime.month, - datetime.day, - datetime.hour, - datetime.minute, - datetime.second); - } else { - furi_string_printf( - name, - "%s_%.2d%.2d-%.2d%.2d%.2d", - proto_name, - datetime.month, - datetime.day, - datetime.hour, - datetime.minute, - datetime.second); - } -} - void subghz_scene_save_name_on_enter(void* context) { SubGhz* subghz = context; @@ -52,35 +22,19 @@ void subghz_scene_save_name_on_enter(void* context) { FuriString* file_name = furi_string_alloc(); FuriString* dir_name = furi_string_alloc(); + char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0}; if(!subghz_path_is_file(subghz->file_path)) { - char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0}; - if(subghz->last_settings->timestamp_file_names) { - SubGhzProtocolDecoderBase* decoder_result = subghz_txrx_get_decoder(subghz->txrx); - if(decoder_result != 0x0) { - if(decoder_result != NULL) { - if(strlen(decoder_result->protocol->name) != 0) { - if(scene_manager_has_previous_scene( - subghz->scene_manager, SubGhzSceneSetType)) { - subghz_scene_save_name_get_timefilename(file_name, "S", true); - } else { - subghz_scene_save_name_get_timefilename( - file_name, decoder_result->protocol->name, false); - } - - } else { - subghz_scene_save_name_get_timefilename(file_name, "S", true); - } - } else { - subghz_scene_save_name_get_timefilename(file_name, "S", true); - } - } else { - subghz_scene_save_name_get_timefilename(file_name, "S", true); - } + SubGhzProtocolDecoderBase* decoder_result = subghz_txrx_get_decoder(subghz->txrx); + if(subghz->last_settings->protocol_file_names && decoder_result != NULL && + strlen(decoder_result->protocol->name) != 0 && + !scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneSetType)) { + name_generator_make_auto( + file_name_buf, SUBGHZ_MAX_LEN_NAME, decoder_result->protocol->name); } else { name_generator_make_auto( file_name_buf, SUBGHZ_MAX_LEN_NAME, SUBGHZ_APP_FILENAME_PREFIX); - furi_string_set(file_name, file_name_buf); } + furi_string_set(file_name, file_name_buf); furi_string_set(subghz->file_path, SUBGHZ_APP_FOLDER); //highlighting the entire filename by default dev_name_empty = true; @@ -94,7 +48,13 @@ void subghz_scene_save_name_on_enter(void* context) { if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) == SubGhzCustomEventManagerSetRAW) { dev_name_empty = true; - subghz_scene_save_name_get_timefilename(file_name, "RAW", true); + if(subghz->last_settings->protocol_file_names) { + name_generator_make_auto(file_name_buf, SUBGHZ_MAX_LEN_NAME, "RAW"); + } else { + name_generator_make_auto( + file_name_buf, SUBGHZ_MAX_LEN_NAME, SUBGHZ_APP_FILENAME_PREFIX); + } + furi_string_set(file_name, file_name_buf); } } furi_string_set(subghz->file_path, dir_name); diff --git a/applications/main/subghz/subghz_last_settings.c b/applications/main/subghz/subghz_last_settings.c index f581a5940..264aa4745 100644 --- a/applications/main/subghz/subghz_last_settings.c +++ b/applications/main/subghz/subghz_last_settings.c @@ -13,7 +13,7 @@ #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_PROTOCOL_FILE_NAMES "TimestampNames" #define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP "ExtPowerAmp" #define SUBGHZ_LAST_SETTING_FIELD_GPS "Gps" #define SUBGHZ_LAST_SETTING_FIELD_HOPPING_ENABLE "Hopping" @@ -47,7 +47,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count 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_protocol_file_names = false; bool temp_enable_hopping = false; bool temp_enable_sound = false; uint32_t temp_repeater_state; @@ -98,8 +98,8 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count 1); flipper_format_read_bool( fff_data_file, - SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES, - (bool*)&temp_timestamp_file_names, + SUBGHZ_LAST_SETTING_FIELD_PROTOCOL_FILE_NAMES, + (bool*)&temp_protocol_file_names, 1); flipper_format_read_bool( fff_data_file, @@ -147,7 +147,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count 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->protocol_file_names = false; instance->external_module_power_amp = false; instance->gps_baudrate = 0; instance->enable_hopping = false; @@ -186,7 +186,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count instance->external_module_power_5v_disable = temp_external_module_power_5v_disable; - instance->timestamp_file_names = temp_timestamp_file_names; + instance->protocol_file_names = temp_protocol_file_names; instance->delete_old_signals = temp_delete_old_sig; @@ -281,8 +281,8 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) { } if(!flipper_format_insert_or_update_bool( file, - SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES, - &instance->timestamp_file_names, + SUBGHZ_LAST_SETTING_FIELD_PROTOCOL_FILE_NAMES, + &instance->protocol_file_names, 1)) { break; } @@ -372,7 +372,7 @@ void subghz_last_settings_log(SubGhzLastSettings* instance) { (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->protocol_file_names), bool_to_char(instance->external_module_power_amp), instance->gps_baudrate, bool_to_char(instance->enable_hopping), diff --git a/applications/main/subghz/subghz_last_settings.h b/applications/main/subghz/subghz_last_settings.h index 88554ed83..515d2479e 100644 --- a/applications/main/subghz/subghz_last_settings.h +++ b/applications/main/subghz/subghz_last_settings.h @@ -25,7 +25,7 @@ typedef struct { bool external_module_power_5v_disable; bool external_module_power_amp; // saved so as not to change the version - bool timestamp_file_names; + bool protocol_file_names; uint32_t gps_baudrate; bool enable_hopping; uint32_t repeater_state;