From 7da1282ecbbade18b51f0ffc2fac2d3ed82abd19 Mon Sep 17 00:00:00 2001 From: Marius Muja Date: Thu, 19 Oct 2023 14:56:32 -0700 Subject: [PATCH] Automatically tune the optimal baud value for the next packet (#69) Co-authored-by: J. Nick Koston --- components/ratgdo/__init__.py | 8 ++++---- components/ratgdo/ratgdo.cpp | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/ratgdo/__init__.py b/components/ratgdo/__init__.py index c871a68..076caa7 100644 --- a/components/ratgdo/__init__.py +++ b/components/ratgdo/__init__.py @@ -84,11 +84,11 @@ async def to_code(config): cg.add_library( name="secplus", - repository="https://github.com/esphome-ratgdo/secplus", - version="f98c3220356c27717a25102c0b35815ebbd26ccc", + repository="https://github.com/ratgdo/secplus#f98c3220356c27717a25102c0b35815ebbd26ccc", + version=None, ) cg.add_library( name="espsoftwareserial", - repository="https://github.com/esphome-ratgdo/espsoftwareserial", - version="2f408224633316b997f82339e5b2731b1e561060", + repository="https://github.com/ratgdo/espsoftwareserial#autobaud", + version=None, ) diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index e24b0d4..251ad8f 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -55,6 +55,7 @@ namespace ratgdo { } this->sw_serial_.begin(9600, SWSERIAL_8N1, this->input_gdo_pin_->get_pin(), this->output_gdo_pin_->get_pin(), true); this->sw_serial_.enableIntTx(false); + this->sw_serial_.enableAutoBaud(true); ESP_LOGV(TAG, "Syncing rolling code counter after reboot..."); @@ -400,6 +401,7 @@ namespace ratgdo { // if we are at the start of a message, capture the next 16 bytes if (msg_start == 0x550100) { + ESP_LOG1(TAG, "Baud: %d", this->sw_serial_.baudRate()); rx_packet[0] = 0x55; rx_packet[1] = 0x01; rx_packet[2] = 0x00;