diff --git a/helpers/meal_pager_storage.c b/helpers/meal_pager_storage.c index 05bcddf389d..b7bfb02a731 100644 --- a/helpers/meal_pager_storage.c +++ b/helpers/meal_pager_storage.c @@ -15,19 +15,21 @@ static void meal_pager_close_config_file(FlipperFormat* file) { flipper_format_free(file); } -FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context, Storage* storage) { +bool meal_pager_save_subghz_buffer_file_start(void* context, FlipperFormat* ff, Storage* storage) { // SubGhz TXRX can only be loaded with files, makes sense as to save RAM Meal_Pager* app = context; UNUSED(app); + bool success = false; FURI_LOG_D(TAG, "Creating Temp File"); //Storage* storage = furi_record_open(RECORD_STORAGE); - FlipperFormat* ff = flipper_format_file_alloc(storage); + //FlipperFormat* ff = flipper_format_file_alloc(storage); // Overwrite wont work, so delete first if(storage_file_exists(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"); + return success; } } @@ -49,16 +51,16 @@ FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context, Storage* //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; + return success; } - bool success = flipper_format_write_header_cstr(ff, MEAL_PAGER_SUBGHZ_FILE_TYPE, MEAL_PAGER_SUBGHZ_FILE_VERSION) && + 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; + //UNUSED(success); + return success; + //return ff; } void meal_pager_save_subghz_buffer_stop(void* context, FlipperFormat* ff) { diff --git a/helpers/meal_pager_storage.h b/helpers/meal_pager_storage.h index f937f87304a..48941f681a3 100644 --- a/helpers/meal_pager_storage.h +++ b/helpers/meal_pager_storage.h @@ -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, Storage* storage); +bool meal_pager_save_subghz_buffer_file_start(void* context, FlipperFormat* ff, Storage* storage); void meal_pager_save_subghz_buffer_stop(void* context, FlipperFormat* ff); diff --git a/helpers/retekess/meal_pager_retekess_t119.c b/helpers/retekess/meal_pager_retekess_t119.c index d5050019778..7a6b842caad 100644 --- a/helpers/retekess/meal_pager_retekess_t119.c +++ b/helpers/retekess/meal_pager_retekess_t119.c @@ -180,15 +180,23 @@ static void meal_pager_retekess_t119_generate_station(void* context, uint32_t st } } -void meal_pager_retekess_t119_generate_all(void* context) { +bool meal_pager_retekess_t119_generate_all(void* context) { Meal_Pager* app = context; app->current_pager = 1; app->current_station = app->first_station; Storage* storage = furi_record_open(RECORD_STORAGE); - FlipperFormat* ff = meal_pager_save_subghz_buffer_file_start(app, storage); - + FlipperFormat* ff = flipper_format_file_alloc(storage); + bool success = meal_pager_save_subghz_buffer_file_start(app, ff, storage); + + if (!success) { + FURI_LOG_D(TAG, "failed to save buffer"); + meal_pager_save_subghz_buffer_stop(app, ff); + furi_record_close(RECORD_STORAGE); + return success; + } + for (u_int32_t i = app->current_station;i <= app->last_station; i++) { meal_pager_retekess_t119_generate_station(app, i, ff); //furi_thread_flags_wait(0, FuriFlagWaitAny, 100); @@ -199,5 +207,6 @@ void meal_pager_retekess_t119_generate_all(void* context) { meal_pager_save_subghz_buffer_stop(app, ff); furi_record_close(RECORD_STORAGE); + return success; } diff --git a/helpers/retekess/meal_pager_retekess_t119.h b/helpers/retekess/meal_pager_retekess_t119.h index c49ddfe90bd..feaac1a08eb 100644 --- a/helpers/retekess/meal_pager_retekess_t119.h +++ b/helpers/retekess/meal_pager_retekess_t119.h @@ -15,4 +15,4 @@ void customConcat(char* dest, const char* src); //void meal_pager_retekess_t119_generate_station(void* context, uint32_t station); -void meal_pager_retekess_t119_generate_all(void* context); \ No newline at end of file +bool meal_pager_retekess_t119_generate_all(void* context); \ No newline at end of file diff --git a/helpers/subghz/subghz_txrx.c b/helpers/subghz/subghz_txrx.c index 4204a9875e5..bf5258db486 100644 --- a/helpers/subghz/subghz_txrx.c +++ b/helpers/subghz/subghz_txrx.c @@ -308,7 +308,7 @@ SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* } if(ret != SubGhzTxRxStartTxStateOk) { FURI_LOG_D(TAG, "state not ok"); - //subghz_transmitter_free(instance->transmitter); // Crashes here + subghz_transmitter_free(instance->transmitter); // Crashes here if(instance->txrx_state != SubGhzTxRxStateIDLE) { subghz_txrx_idle(instance); } diff --git a/scenes/meal_pager_scene_transmit.c b/scenes/meal_pager_scene_transmit.c index 25530d5f59c..798f3921618 100644 --- a/scenes/meal_pager_scene_transmit.c +++ b/scenes/meal_pager_scene_transmit.c @@ -23,7 +23,12 @@ void meal_pager_scene_transmit_on_enter(void* context) { meal_pager_transmit_model_set_pager(app->meal_pager_transmit, app->current_pager); meal_pager_transmit_set_callback(app->meal_pager_transmit, meal_pager_transmit_callback, app); view_dispatcher_switch_to_view(app->view_dispatcher, Meal_PagerViewIdTransmit); - meal_pager_retekess_t119_generate_all(app); + bool generated = meal_pager_retekess_t119_generate_all(app); + if (!generated) { + FURI_LOG_D(TAG, "Could not generate temp file"); + meal_pager_blink_stop(app); + return; + } FURI_LOG_D(TAG, "Generated tmp.sub"); meal_pager_blink_start_subghz(app); FURI_LOG_D(TAG, "Start Transmitting");