mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
SubGhz Autosave option (#331)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "../subghz_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <lib/subghz/protocols/bin_raw.h>
|
||||
#include <toolbox/name_generator.h>
|
||||
|
||||
#define TAG "SubGhzSceneReceiver"
|
||||
|
||||
@@ -196,6 +197,34 @@ static void subghz_scene_add_to_history_callback(
|
||||
subghz_history_get_type_protocol(history, idx),
|
||||
subghz_history_get_repeats(history, idx));
|
||||
|
||||
if(decoder_base->protocol->flag & SubGhzProtocolFlag_Save &&
|
||||
subghz->last_settings->autosave) {
|
||||
// File name
|
||||
char file[SUBGHZ_MAX_LEN_NAME] = {0};
|
||||
const char* suf = subghz->last_settings->protocol_file_names ?
|
||||
decoder_base->protocol->name :
|
||||
SUBGHZ_APP_FILENAME_PREFIX;
|
||||
FuriHalRtcDateTime time = subghz_history_get_datetime(history, idx);
|
||||
name_generator_make_detailed_datetime(file, sizeof(file), suf, &time, true);
|
||||
// Dir name
|
||||
FuriString* path = furi_string_alloc_set(SUBGHZ_APP_FOLDER "/Autosave");
|
||||
char* dir = strdup(furi_string_get_cstr(path));
|
||||
// Find non-existent path
|
||||
const char* ext = SUBGHZ_APP_FILENAME_EXTENSION;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_get_next_filename(storage, dir, file, ext, path, sizeof(file));
|
||||
strlcpy(file, furi_string_get_cstr(path), sizeof(file));
|
||||
furi_string_printf(path, "%s/%s%s", dir, file, ext);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
free(dir);
|
||||
// Save
|
||||
subghz_save_protocol_to_file(
|
||||
subghz,
|
||||
subghz_history_get_raw_data(history, idx),
|
||||
furi_string_get_cstr(path));
|
||||
furi_string_free(path);
|
||||
}
|
||||
|
||||
subghz_scene_receiver_update_statusbar(subghz);
|
||||
if(!subghz->last_settings->delete_old_signals &&
|
||||
subghz_history_full(subghz->history)) {
|
||||
|
||||
Reference in New Issue
Block a user