Skip to content

Commit

Permalink
searching for error with tmp file being open
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lee committed Dec 9, 2023
1 parent 49cfa7f commit c934ddd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
9 changes: 6 additions & 3 deletions helpers/meal_pager_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ static void meal_pager_close_config_file(FlipperFormat* file) {
flipper_format_free(file);
}

FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context) {
FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context, Storage* storage) {
// 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);
//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);
bool stored = storage_simply_remove(storage, MEAL_PAGER_TMP_FILE);
if (!stored) {
FURI_LOG_D(TAG, "Cannot remove file, seems to be open");
}
}

// Open File, create if not exists
Expand Down
2 changes: 1 addition & 1 deletion helpers/meal_pager_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define MEAL_PAGER_SUBGHZ_FILE_PRESET "FuriHalSubGhzPresetOok650Async"
#define MEAL_PAGER_SUBGHZ_FILE_Protocol "RAW"

FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context);
FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context, Storage* storage);

void meal_pager_save_subghz_buffer_stop(void* context, FlipperFormat* ff);

Expand Down
4 changes: 3 additions & 1 deletion helpers/retekess/meal_pager_retekess_t119.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ void meal_pager_retekess_t119_generate_all(void* context) {
app->current_pager = 1;
app->current_station = app->first_station;

FlipperFormat* ff = meal_pager_save_subghz_buffer_file_start(app);
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* ff = meal_pager_save_subghz_buffer_file_start(app, storage);

for (u_int32_t i = app->current_station;i <= app->last_station; i++) {
meal_pager_retekess_t119_generate_station(app, i, ff);
Expand All @@ -197,5 +198,6 @@ void meal_pager_retekess_t119_generate_all(void* context) {
}

meal_pager_save_subghz_buffer_stop(app, ff);
furi_record_close(RECORD_STORAGE);
}

8 changes: 4 additions & 4 deletions helpers/subghz/subghz.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ void subghz_send(void* context) {

subghz_load_protocol_from_file(subghz);

Storage* storage = furi_record_open(RECORD_STORAGE);
/*Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* ff = flipper_format_file_alloc(storage);
if(!flipper_format_file_open_existing(ff, MEAL_PAGER_TMP_FILE)) {
//totp_close_config_file(fff_file);
FURI_LOG_E(TAG, "Error reading Temp File %s", MEAL_PAGER_TMP_FILE);
furi_record_close(RECORD_STORAGE);
return;
}
}*/

//subghz_txrx_tx_start(subghz->txrx, ff);
subghz_txrx_tx_start(subghz->txrx, subghz_txrx_get_fff_data(subghz->txrx)); //Seems like it must be done this way

flipper_format_rewind(ff);
/*flipper_format_rewind(ff);
flipper_format_file_close(ff);
flipper_format_free(ff);
furi_record_close(RECORD_STORAGE);
furi_record_close(RECORD_STORAGE);*/


subghz_free(subghz);
Expand Down

0 comments on commit c934ddd

Please sign in to comment.