From 5d6231f4b9d32474b9d8e033b7ec175db59836a2 Mon Sep 17 00:00:00 2001 From: Leeroy <135471162+LeeroysHub@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:50:17 +1100 Subject: [PATCH] Fix TX time on Repeater --- .../main/subghz/scenes/subghz_scene_receiver.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index dcaa91408f..9c508d2dfd 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -364,25 +364,32 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { subghz->history, subghz_history_get_last_index(subghz->history) - 1); uint32_t tmpTe = 300; + uint32_t tmpBits = 1000; + if(!flipper_format_rewind(key_repeat_data)) { FURI_LOG_E(TAG, "Rewind error"); } else if(!flipper_format_read_uint32(key_repeat_data, "TE", (uint32_t*)&tmpTe, 1)) { FURI_LOG_E(TAG, "Missing TE"); + } else if(!flipper_format_read_uint32(key_repeat_data, "Bit", (uint32_t*)&tmpBits, 1)) { + FURI_LOG_E(TAG, "Missing Bit"); } - if(subghz_txrx_tx_start(subghz->txrx, key_repeat_data) != SubGhzTxRxStartTxStateOk) { + //Te * Bits gives us the total key TX time. + uint32_t key_tx_length = tmpTe * tmpBits; + + if(!subghz_tx_start(subghz, key_repeat_data)) { view_dispatcher_send_custom_event( subghz->view_dispatcher, SubGhzCustomEventViewRepeaterStop); } else { subghz->state_notifications = SubGhzNotificationStateTx; notification_message(subghz->notifications, &subghz_sequence_tx_beep); - uint32_t repeatnormal = (tmpTe > 1000) ? 1 : 3; + uint32_t repeatnormal = (key_tx_length > 1000) ? 1 : 3; uint32_t repeat_time = ((subghz->repeater & SubGhzRepeaterStateOnLong) != 0) ? - 2 * repeatnormal * tmpTe : + 2 * repeatnormal * key_tx_length : ((subghz->repeater & SubGhzRepeaterStateOnShort) != 0) ? - 1 * tmpTe : - repeatnormal * tmpTe; + 1 * key_tx_length : + repeatnormal * key_tx_length; furi_timer_start(subghz->timer, repeat_time); } subghz_rx_key_state_set(subghz, SubGhzRxKeyStateTX);