|
|
@@ -15,6 +15,64 @@ static void meal_pager_close_config_file(FlipperFormat* file) {
|
|
|
flipper_format_free(file);
|
|
|
}
|
|
|
|
|
|
+FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context) {
|
|
|
+ // SubGhz TXRX can only be loaded with files, makes sense as to save RAM
|
|
|
+ Meal_Pager* app = context;
|
|
|
+ UNUSED(app);
|
|
|
+ FURI_LOG_D(TAG, "Creating Temp File");
|
|
|
+ Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
+ FlipperFormat* ff = flipper_format_file_alloc(storage);
|
|
|
+
|
|
|
+ // Overwrite wont work, so delete first
|
|
|
+ if(storage_file_exists(storage, MEAL_PAGER_TMP_FILE)) {
|
|
|
+ storage_simply_remove(storage, MEAL_PAGER_TMP_FILE);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Open File, create if not exists
|
|
|
+ if(!storage_common_stat(storage, MEAL_PAGER_TMP_FILE, NULL) == FSE_OK) {
|
|
|
+ FURI_LOG_D(TAG, "Config file %s is not found. Will create new.", MEAL_PAGER_SETTINGS_SAVE_PATH);
|
|
|
+ if(storage_common_stat(storage, CONFIG_FILE_DIRECTORY_PATH, NULL) == FSE_NOT_EXIST) {
|
|
|
+ FURI_LOG_D(
|
|
|
+ TAG,
|
|
|
+ "Directory %s doesn't exist. Will create new.",
|
|
|
+ CONFIG_FILE_DIRECTORY_PATH);
|
|
|
+ if(!storage_simply_mkdir(storage, CONFIG_FILE_DIRECTORY_PATH)) {
|
|
|
+ FURI_LOG_D(TAG, "Error creating directory %s", CONFIG_FILE_DIRECTORY_PATH);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!flipper_format_file_open_new(ff, MEAL_PAGER_TMP_FILE)) {
|
|
|
+ //totp_close_config_file(fff_file);
|
|
|
+ FURI_LOG_D(TAG, "Error creating new file %s", MEAL_PAGER_TMP_FILE);
|
|
|
+ meal_pager_close_storage();
|
|
|
+ return ff;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool success = flipper_format_write_header_cstr(ff, MEAL_PAGER_SUBGHZ_FILE_TYPE, MEAL_PAGER_SUBGHZ_FILE_VERSION) &&
|
|
|
+ flipper_format_write_string_cstr(ff, "Frequency", MEAL_PAGER_SUBGHZ_FILE_FREQUENCY) &&
|
|
|
+ flipper_format_write_string_cstr(ff, "Preset", MEAL_PAGER_SUBGHZ_FILE_PRESET) &&
|
|
|
+ flipper_format_write_string_cstr(ff, "Protocol", MEAL_PAGER_SUBGHZ_FILE_Protocol);
|
|
|
+ UNUSED(success);
|
|
|
+
|
|
|
+ return ff;
|
|
|
+}
|
|
|
+
|
|
|
+void meal_pager_save_subghz_buffer_stop(void* context, FlipperFormat* ff) {
|
|
|
+ Meal_Pager* app = context;
|
|
|
+ UNUSED(app);
|
|
|
+ FURI_LOG_D(TAG, "Closing Temp File");
|
|
|
+ if(!flipper_format_rewind(ff)) {
|
|
|
+ meal_pager_close_config_file(ff);
|
|
|
+ FURI_LOG_E(TAG, "Rewind error");
|
|
|
+ meal_pager_close_storage();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ meal_pager_close_config_file(ff);
|
|
|
+ meal_pager_close_storage();
|
|
|
+}
|
|
|
+
|
|
|
void meal_pager_save_settings(void* context) {
|
|
|
Meal_Pager* app = context;
|
|
|
if (app->save_settings == 0) {
|