From d97a3ef1616877d84833e7e2582fd81bec96b095 Mon Sep 17 00:00:00 2001 From: Der Skythe Date: Fri, 16 Sep 2022 21:35:26 +0400 Subject: [PATCH] fix: change SUBGHZ_HISTORY_MAX to 50 according off-firm --- .../subghz/scenes/subghz_scene_show_error.c | 4 ++-- applications/main/subghz/subghz_history.c | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_show_error.c b/applications/main/subghz/scenes/subghz_scene_show_error.c index 5632a859e..7b0350bf7 100644 --- a/applications/main/subghz/scenes/subghz_scene_show_error.c +++ b/applications/main/subghz/scenes/subghz_scene_show_error.c @@ -1,7 +1,7 @@ #include "../subghz_i.h" #include "../helpers/subghz_custom_event.h" -static const NotificationSequence subghs_sequence_sd_error = { +static const NotificationSequence subghz_sequence_sd_error = { &message_red_255, &message_green_255, &message_do_not_reset, @@ -39,7 +39,7 @@ void subghz_scene_show_error_on_enter(void* context) { widget_add_button_element( subghz->widget, GuiButtonTypeRight, "OK", subghz_scene_show_error_callback, subghz); } else { - notification_message(subghz->notifications, &subghs_sequence_sd_error); + notification_message(subghz->notifications, &subghz_sequence_sd_error); } widget_add_button_element( diff --git a/applications/main/subghz/subghz_history.c b/applications/main/subghz/subghz_history.c index b806b9568..427ee624c 100644 --- a/applications/main/subghz/subghz_history.c +++ b/applications/main/subghz/subghz_history.c @@ -1,7 +1,7 @@ #include "subghz_history.h" #include -#define SUBGHZ_HISTORY_MAX 65 +#define SUBGHZ_HISTORY_MAX 50 #define TAG "SubGhzHistory" typedef struct { @@ -37,15 +37,9 @@ SubGhzHistory* subghz_history_alloc(void) { void subghz_history_free(SubGhzHistory* instance) { furi_assert(instance); - string_clear(instance->tmp_string); - for - M_EACH(item, instance->history->data, SubGhzHistoryItemArray_t) { - string_clear(item->item_str); - string_clear(item->preset->name); - free(item->preset); - flipper_format_free(item->flipper_string); - item->type = 0; - } + + // Call method instead of code duplicate + subghz_history_reset(instance); SubGhzHistoryItemArray_clear(instance->history->data); free(instance->history); free(instance); @@ -139,16 +133,22 @@ bool subghz_history_add_to_history( furi_assert(instance); furi_assert(context); - if(instance->last_index_write >= SUBGHZ_HISTORY_MAX) return false; + if(instance->last_index_write >= SUBGHZ_HISTORY_MAX) { + FURI_LOG_W(TAG, "Out of history slots!"); + return false; + } SubGhzProtocolDecoderBase* decoder_base = context; if((instance->code_last_hash_data == subghz_protocol_decoder_base_get_hash_data(decoder_base)) && ((furi_get_tick() - instance->last_update_timestamp) < 500)) { + FURI_LOG_W(TAG, "Too short period for add"); instance->last_update_timestamp = furi_get_tick(); return false; } + FURI_LOG_I(TAG, "Add to history. Total: %d", instance->last_index_write + 1); + instance->code_last_hash_data = subghz_protocol_decoder_base_get_hash_data(decoder_base); instance->last_update_timestamp = furi_get_tick();