Revert "fixes"

This reverts commit 310e140024.
This commit is contained in:
r3df0xx
2022-05-27 22:18:41 +03:00
parent b23b3c9e8d
commit 5b3b37996a
4 changed files with 27 additions and 29 deletions

View File

@@ -25,7 +25,7 @@ bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
break; break;
} }
string_set(subghz->file_path, temp_str); strncpy(subghz->file_path, string_get_cstr(temp_str), SUBGHZ_MAX_LEN_NAME);
ret = true; ret = true;
} while(false); } 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, ""); subghz_read_raw_set_status(subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, "");
break; break;
case SubGhzRxKeyStateRAWLoad: 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_read_raw_set_status(
subghz->subghz_read_raw, SubGhzReadRAWStatusLoadKeyTX, string_get_cstr(file_name)); subghz->subghz_read_raw, SubGhzReadRAWStatusLoadKeyTX, string_get_cstr(file_name));
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
break; break;
case SubGhzRxKeyStateRAWSave: 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_read_raw_set_status(
subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, string_get_cstr(file_name)); subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, string_get_cstr(file_name));
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
@@ -170,6 +170,10 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
case SubGhzCustomEventViewReadRAWErase: case SubGhzCustomEventViewReadRAWErase:
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; 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); notification_message(subghz->notifications, &sequence_reset_rgb);
return true; return true;
break; break;
@@ -249,7 +253,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
); );
string_printf( 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)); subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, string_get_cstr(temp_str));
string_clear(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( if(subghz_protocol_raw_save_to_file_init(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, (SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result,
RAW_FILE_NAME,, strings[0],
subghz->txrx->frequency, subghz->txrx->frequency,
subghz->txrx->preset)) { subghz->txrx->preset)) {
DOLPHIN_DEED(DolphinDeedSubGhzRawRec); DOLPHIN_DEED(DolphinDeedSubGhzRawRec);
@@ -292,7 +296,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz->state_notifications = SubGhzNotificationStateRx; subghz->state_notifications = SubGhzNotificationStateRx;
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey; subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
} else { } 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); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
} }
} }

View File

@@ -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); subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, protocol_name);
if(subghz->txrx->decoder_result == NULL) { 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); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
return false; return false;
} }
@@ -340,7 +340,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
} }
subghz_transmitter_free(subghz->txrx->transmitter); subghz_transmitter_free(subghz->txrx->transmitter);
if(!generated_protocol) { if(!generated_protocol) {
string_set_str( string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases."); subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); 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); subghz_transmitter_free(subghz->txrx->transmitter);
if(!generated_protocol) { if(!generated_protocol) {
string_set_str( string_set(
subghz->error_str, "Function requires\nan SD card with\nfresh databases."); subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
} }

View File

@@ -1,7 +1,5 @@
/* Abandon hope, all ye who enter here. */ /* Abandon hope, all ye who enter here. */
#include "m-string.h"
#include "subghz/types.h"
#include "subghz_i.h" #include "subghz_i.h"
#include <lib/toolbox/path.h> #include <lib/toolbox/path.h>
@@ -26,9 +24,6 @@ void subghz_tick_event_callback(void* context) {
SubGhz* subghz_alloc() { SubGhz* subghz_alloc() {
SubGhz* subghz = malloc(sizeof(SubGhz)); SubGhz* subghz = malloc(sizeof(SubGhz));
string_init(subghz->file_path);
string_init(subghz->file_path_tmp);
// GUI // GUI
subghz->gui = furi_record_open("gui"); subghz->gui = furi_record_open("gui");
@@ -256,9 +251,9 @@ void subghz_free(SubGhz* subghz) {
furi_record_close("notification"); furi_record_close("notification");
subghz->notifications = NULL; subghz->notifications = NULL;
// Path strings // About birds
string_clear(subghz->file_path); furi_assert(subghz->file_path[SUBGHZ_MAX_LEN_NAME] == 0);
string_clear(subghz->file_path_tmp); furi_assert(subghz->file_path_tmp[SUBGHZ_MAX_LEN_NAME] == 0);
// The rest // The rest
free(subghz); free(subghz);
@@ -275,7 +270,7 @@ int32_t subghz_app(void* p) {
// Check argument and run corresponding scene // Check argument and run corresponding scene
if(p) { if(p) {
if(subghz_key_load(subghz, 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"))) { if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
//Load Raw TX //Load Raw TX
@@ -291,13 +286,12 @@ int32_t subghz_app(void* p) {
view_dispatcher_stop(subghz->view_dispatcher); view_dispatcher_stop(subghz->view_dispatcher);
} }
} else { } else {
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
if(load_database) { if(load_database) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart);
} else { } else {
scene_manager_set_scene_state( scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerSet); subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerSet);
string_set_str( string_set(
subghz->error_str, subghz->error_str,
"No SD card or\ndatabase found.\nSome app function\nmay be reduced."); "No SD card or\ndatabase found.\nSome app function\nmay be reduced.");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);

View File

@@ -36,7 +36,7 @@
#include <gui/modules/variable_item_list.h> #include <gui/modules/variable_item_list.h>
#include <lib/toolbox/path.h> #include <lib/toolbox/path.h>
#define SUBGHZ_MAX_LEN_NAME 64 #define SUBGHZ_MAX_LEN_NAME 250
/** SubGhzNotification state */ /** SubGhzNotification state */
typedef enum { typedef enum {
@@ -128,9 +128,10 @@ struct SubGhz {
ByteInput* byte_input; ByteInput* byte_input;
Widget* widget; Widget* widget;
DialogsApp* dialogs; DialogsApp* dialogs;
string_t file_path; char file_path[SUBGHZ_MAX_LEN_NAME + 1];
string_t file_path_tmp; char file_path_tmp[SUBGHZ_MAX_LEN_NAME + 1];
char file_name_tmp[SUBGHZ_MAX_LEN_NAME]; //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; SubGhzNotificationState state_notifications;
SubGhzViewReceiver* subghz_receiver; SubGhzViewReceiver* subghz_receiver;
@@ -182,6 +183,5 @@ bool subghz_load_protocol_from_file(SubGhz* subghz);
bool subghz_rename_file(SubGhz* subghz); bool subghz_rename_file(SubGhz* subghz);
bool subghz_delete_file(SubGhz* subghz); bool subghz_delete_file(SubGhz* subghz);
void subghz_file_name_clear(SubGhz* subghz); void subghz_file_name_clear(SubGhz* subghz);
bool subghz_path_is_file(string_t path);
uint32_t subghz_random_serial(void); uint32_t subghz_random_serial(void);
void subghz_hopper_update(SubGhz* subghz); void subghz_hopper_update(SubGhz* subghz);