fix: change SUBGHZ_HISTORY_MAX to 50 according off-firm

This commit is contained in:
Der Skythe 2022-09-16 21:35:26 +04:00
parent d67d5da034
commit d97a3ef161
2 changed files with 13 additions and 13 deletions

View File

@ -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(

View File

@ -1,7 +1,7 @@
#include "subghz_history.h"
#include <lib/subghz/receiver.h>
#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();