From 3b7b48be4aa3628254e3205e944981e8132af465 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Tue, 4 Apr 2023 17:38:33 +0300 Subject: [PATCH] Fix Repeat in subghz remote --- .../main/subghz_remote/subghz_remote_app.c | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/applications/main/subghz_remote/subghz_remote_app.c b/applications/main/subghz_remote/subghz_remote_app.c index 7e3626b07..9e4e23152 100644 --- a/applications/main/subghz_remote/subghz_remote_app.c +++ b/applications/main/subghz_remote/subghz_remote_app.c @@ -385,17 +385,35 @@ bool subghz_remote_key_load( FURI_LOG_E(TAG, "Could not read Protocol."); break; } + if(!furi_string_cmp_str(preset->protocol, "RAW")) { subghz_protocol_raw_gen_fff_data(fff_data, path); + // repeat + if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &preset->repeat, 1)) { + FURI_LOG_E(TAG, "Unable to insert or update Repeat"); + break; + } + if(!flipper_format_rewind(fff_data)) { + FURI_LOG_E(TAG, "Rewind error"); + return false; + } } else { stream_copy_full( flipper_format_get_raw_stream(fff_file), flipper_format_get_raw_stream(fff_data)); + // repeat + if(!flipper_format_insert_or_update_uint32(fff_data, "Repeat", &preset->repeat, 1)) { + FURI_LOG_E(TAG, "Unable to insert or update Repeat"); + break; + } + if(!flipper_format_rewind(fff_data)) { + FURI_LOG_E(TAG, "Rewind error"); + return false; + } } - // repeat - if(!flipper_format_insert_or_update_uint32(fff_file, "Repeat", &preset->repeat, 1)) { - FURI_LOG_E(TAG, "Unable to insert or update Repeat"); - break; + if(!flipper_format_rewind(fff_file)) { + FURI_LOG_E(TAG, "Rewind error"); + return false; } preset->decoder = subghz_receiver_search_decoder_base_by_name( @@ -478,11 +496,11 @@ void subghz_remote_tx_stop(SubGHzRemote* app) { protocol_registry_items, furi_string_get_cstr(app->txpreset->protocol)); //FURI_LOG_D(TAG, "Protocol-TYPE %d", proto->type); - // Remove repeat if it was present - flipper_format_delete_key(app->tx_fff_data, "Repeat"); - if(proto && proto->type == SubGhzProtocolTypeDynamic) { //FURI_LOG_D(TAG, "Protocol is dynamic. Saving key"); + // Remove repeat if it was present + flipper_format_delete_key(app->tx_fff_data, "Repeat"); + subghz_remote_save_protocol_to_file(app->tx_fff_data, app->tx_file_path); keeloq_reset_mfname();