From 5b3b37996aa7b33ff65b97041c93c197354ef80b Mon Sep 17 00:00:00 2001 From: r3df0xx Date: Fri, 27 May 2022 22:18:41 +0300 Subject: [PATCH] Revert "fixes" This reverts commit 310e140024be7acbbd5d195fb2575739e0d40c5d. --- .../subghz/scenes/subghz_scene_read_raw.c | 18 +++++++++++------- .../subghz/scenes/subghz_scene_set_type.c | 8 ++++---- applications/subghz/subghz.c | 18 ++++++------------ applications/subghz/subghz_i.h | 12 ++++++------ 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/applications/subghz/scenes/subghz_scene_read_raw.c b/applications/subghz/scenes/subghz_scene_read_raw.c index 93991cd8d..5323bfe58 100644 --- a/applications/subghz/scenes/subghz_scene_read_raw.c +++ b/applications/subghz/scenes/subghz_scene_read_raw.c @@ -25,7 +25,7 @@ bool subghz_scene_read_raw_update_filename(SubGhz* subghz) { break; } - string_set(subghz->file_path, temp_str); + strncpy(subghz->file_path, string_get_cstr(temp_str), SUBGHZ_MAX_LEN_NAME); ret = true; } while(false); @@ -75,13 +75,13 @@ void subghz_scene_read_raw_on_enter(void* context) { subghz_read_raw_set_status(subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, ""); break; case SubGhzRxKeyStateRAWLoad: - path_extract_filename(subghz->file_path, file_name, true); + path_extract_filename_no_ext(subghz->file_path, file_name); subghz_read_raw_set_status( subghz->subghz_read_raw, SubGhzReadRAWStatusLoadKeyTX, string_get_cstr(file_name)); subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; break; case SubGhzRxKeyStateRAWSave: - path_extract_filename(subghz->file_path, file_name, true); + path_extract_filename_no_ext(subghz->file_path, file_name); subghz_read_raw_set_status( subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, string_get_cstr(file_name)); subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; @@ -170,6 +170,10 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { case SubGhzCustomEventViewReadRAWErase: subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; + if(subghz_scene_read_raw_update_filename(subghz)) { + strncpy(subghz->file_path_tmp, subghz->file_path, SUBGHZ_MAX_LEN_NAME); + subghz_delete_file(subghz); + } notification_message(subghz->notifications, &sequence_reset_rgb); return true; break; @@ -249,7 +253,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { ); string_printf( - temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION); + temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, strings[0], SUBGHZ_APP_EXTENSION); subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, string_get_cstr(temp_str)); string_clear(temp_str); @@ -280,7 +284,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { if(subghz_protocol_raw_save_to_file_init( (SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, - RAW_FILE_NAME,, + strings[0], subghz->txrx->frequency, subghz->txrx->preset)) { DOLPHIN_DEED(DolphinDeedSubGhzRawRec); @@ -292,7 +296,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { subghz->state_notifications = SubGhzNotificationStateRx; subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey; } else { - string_set_str(subghz->error_str, "Function requires\nan SD card."); + string_set(subghz->error_str, "Function requires\nan SD card."); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); } } @@ -346,4 +350,4 @@ void subghz_scene_read_raw_on_exit(void* context) { //filter restoration subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable); -} \ No newline at end of file +} diff --git a/applications/subghz/scenes/subghz_scene_set_type.c b/applications/subghz/scenes/subghz_scene_set_type.c index a2034e976..206863f4d 100644 --- a/applications/subghz/scenes/subghz_scene_set_type.c +++ b/applications/subghz/scenes/subghz_scene_set_type.c @@ -49,7 +49,7 @@ bool subghz_scene_set_type_submenu_gen_data_protocol( subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, protocol_name); if(subghz->txrx->decoder_result == NULL) { - string_set_str(subghz->error_str, "Protocol not found"); + string_set(subghz->error_str, "Protocol not found"); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub); return false; } @@ -340,7 +340,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { } subghz_transmitter_free(subghz->txrx->transmitter); if(!generated_protocol) { - string_set_str( + string_set( subghz->error_str, "Function requires\nan SD card with\nfresh databases."); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); } @@ -364,7 +364,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { } subghz_transmitter_free(subghz->txrx->transmitter); if(!generated_protocol) { - string_set_str( + string_set( subghz->error_str, "Function requires\nan SD card with\nfresh databases."); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); } @@ -472,4 +472,4 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { void subghz_scene_set_type_on_exit(void* context) { SubGhz* subghz = context; submenu_reset(subghz->submenu); -} \ No newline at end of file +} diff --git a/applications/subghz/subghz.c b/applications/subghz/subghz.c index 2dd573eee..99c9db452 100644 --- a/applications/subghz/subghz.c +++ b/applications/subghz/subghz.c @@ -1,7 +1,5 @@ /* Abandon hope, all ye who enter here. */ -#include "m-string.h" -#include "subghz/types.h" #include "subghz_i.h" #include @@ -26,9 +24,6 @@ void subghz_tick_event_callback(void* context) { SubGhz* subghz_alloc() { SubGhz* subghz = malloc(sizeof(SubGhz)); - string_init(subghz->file_path); - string_init(subghz->file_path_tmp); - // GUI subghz->gui = furi_record_open("gui"); @@ -256,9 +251,9 @@ void subghz_free(SubGhz* subghz) { furi_record_close("notification"); subghz->notifications = NULL; - // Path strings - string_clear(subghz->file_path); - string_clear(subghz->file_path_tmp); + // About birds + furi_assert(subghz->file_path[SUBGHZ_MAX_LEN_NAME] == 0); + furi_assert(subghz->file_path_tmp[SUBGHZ_MAX_LEN_NAME] == 0); // The rest free(subghz); @@ -275,7 +270,7 @@ int32_t subghz_app(void* p) { // Check argument and run corresponding scene if(p) { if(subghz_key_load(subghz, p)) { - string_set_str(subghz->file_path, p); + strncpy(subghz->file_path, p, SUBGHZ_MAX_LEN_NAME); if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) { //Load Raw TX @@ -291,13 +286,12 @@ int32_t subghz_app(void* p) { view_dispatcher_stop(subghz->view_dispatcher); } } else { - string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER); if(load_database) { scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart); } else { scene_manager_set_scene_state( subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerSet); - string_set_str( + string_set( subghz->error_str, "No SD card or\ndatabase found.\nSome app function\nmay be reduced."); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); @@ -313,4 +307,4 @@ int32_t subghz_app(void* p) { subghz_free(subghz); return 0; -} \ No newline at end of file +} diff --git a/applications/subghz/subghz_i.h b/applications/subghz/subghz_i.h index 8a2f0b8bc..b1a932836 100644 --- a/applications/subghz/subghz_i.h +++ b/applications/subghz/subghz_i.h @@ -36,7 +36,7 @@ #include #include -#define SUBGHZ_MAX_LEN_NAME 64 +#define SUBGHZ_MAX_LEN_NAME 250 /** SubGhzNotification state */ typedef enum { @@ -128,9 +128,10 @@ struct SubGhz { ByteInput* byte_input; Widget* widget; DialogsApp* dialogs; - string_t file_path; - string_t file_path_tmp; - char file_name_tmp[SUBGHZ_MAX_LEN_NAME]; + char file_path[SUBGHZ_MAX_LEN_NAME + 1]; + char file_path_tmp[SUBGHZ_MAX_LEN_NAME + 1]; + //ToDo you can get rid of it, you need to refactor text input to return the path to the folder + char file_dir[SUBGHZ_MAX_LEN_NAME + 1]; SubGhzNotificationState state_notifications; SubGhzViewReceiver* subghz_receiver; @@ -182,6 +183,5 @@ bool subghz_load_protocol_from_file(SubGhz* subghz); bool subghz_rename_file(SubGhz* subghz); bool subghz_delete_file(SubGhz* subghz); void subghz_file_name_clear(SubGhz* subghz); -bool subghz_path_is_file(string_t path); uint32_t subghz_random_serial(void); -void subghz_hopper_update(SubGhz* subghz); \ No newline at end of file +void subghz_hopper_update(SubGhz* subghz);