From c6e5ca1fec4976112d2a7ea579e0861e6f5314df Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 19 Apr 2023 11:51:08 +0300 Subject: [PATCH] Fix keeloq custom buttons bug When you receive couple signals on read screen and open last one it was replacing its button with first one received --- applications/main/subghz/scenes/subghz_scene_receiver_info.c | 3 +++ applications/main/subghz/scenes/subghz_scene_transmitter.c | 4 ++++ lib/subghz/protocols/keeloq.c | 3 --- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c index 99765ee16..58e428785 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c @@ -115,6 +115,9 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) { void subghz_scene_receiver_info_on_enter(void* context) { SubGhz* subghz = context; + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + subghz_scene_receiver_info_draw_widget(subghz); } diff --git a/applications/main/subghz/scenes/subghz_scene_transmitter.c b/applications/main/subghz/scenes/subghz_scene_transmitter.c index 4ee3854da..ab9155fb7 100644 --- a/applications/main/subghz/scenes/subghz_scene_transmitter.c +++ b/applications/main/subghz/scenes/subghz_scene_transmitter.c @@ -52,6 +52,10 @@ bool subghz_scene_transmitter_update_data_show(void* context) { void subghz_scene_transmitter_on_enter(void* context) { SubGhz* subghz = context; + + keeloq_reset_original_btn(); + subghz_custom_btns_reset(); + if(!subghz_scene_transmitter_update_data_show(subghz)) { view_dispatcher_send_custom_event( subghz->view_dispatcher, SubGhzCustomEventViewTransmitterError); diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index 6698f54fe..4900e7e49 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -393,7 +393,6 @@ static bool uint8_t custom_btn_id = subghz_custom_btn_get(); uint8_t original_btn_num = subghz_custom_btn_get_original(); - // Set custom button if(custom_btn_id == 1) { switch(original_btn_num) { @@ -499,11 +498,9 @@ static bool break; } } - if((custom_btn_id == 0) && (original_btn_num != 0)) { btn = original_btn_num; } - // Generate new key if(subghz_protocol_keeloq_gen_data(instance, btn, true)) {