From 4b3f6015eedad7c1c63651d564b48cf20b92c367 Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 4 Oct 2026 14:28:53 +0200 Subject: [PATCH] tests for gateway speeds --- src/core/emsesp.cpp | 12 +++++++++++- src/core/emsesp.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/emsesp.cpp b/src/core/emsesp.cpp index 4c79eb7db..e460992f0 100644 --- a/src/core/emsesp.cpp +++ b/src/core/emsesp.cpp @@ -55,6 +55,8 @@ uint32_t EMSESP::gateway_hold_start_ = 0; uint32_t EMSESP::gateway_cooldown_until_ = 0; uint32_t EMSESP::gateway_window_start_ = 0; uint8_t EMSESP::gateway_window_count_ = 0; +uint32_t EMSESP::gateway_fast_start_ = 0; +uint8_t EMSESP::gateway_fast_count_ = 0; uint8_t EMSESP::last_version_request_src_ = 0; uint32_t EMSESP::last_version_request_time_ = 0; #endif @@ -1771,9 +1773,17 @@ void EMSESP::gateway_rx_check(const uint8_t * data, const uint8_t length) { gateway_window_start_ = now; gateway_window_count_ = 0; } - if (++gateway_window_count_ >= GATEWAY_BURST_THRESHOLD) { + if (now - gateway_fast_start_ > GATEWAY_FAST_WINDOW) { + gateway_fast_start_ = now; + gateway_fast_count_ = 0; + } + ++gateway_window_count_; + ++gateway_fast_count_; + if (gateway_window_count_ >= GATEWAY_BURST_THRESHOLD || gateway_fast_count_ >= GATEWAY_FAST_THRESHOLD) { gateway_window_start_ = now; gateway_window_count_ = 0; + gateway_fast_start_ = now; + gateway_fast_count_ = 0; gateway_tx_hold_start(); } } diff --git a/src/core/emsesp.h b/src/core/emsesp.h index 4fc1db8da..ac15d7fb5 100644 --- a/src/core/emsesp.h +++ b/src/core/emsesp.h @@ -300,6 +300,8 @@ class EMSESP { static constexpr uint32_t GATEWAY_BURST_WINDOW = 30000; // ms window for counting gateway read requests static constexpr uint8_t GATEWAY_BURST_THRESHOLD = 15; // read requests within window to treat gateway as busy + static constexpr uint32_t GATEWAY_FAST_WINDOW = 5000; // short window to catch the start of a burst quickly + static constexpr uint8_t GATEWAY_FAST_THRESHOLD = 8; // normal polling is ~1 read per 2s, a sync starts at >10/s static constexpr uint32_t GATEWAY_HOLD_TIME = 60000; // keep holding Tx this long after the last busy window static constexpr uint32_t GATEWAY_HOLD_MAX = 600000; // never hold longer than 10 minutes in one go static constexpr uint32_t GATEWAY_HOLD_COOLDOWN = 600000; // after hitting the max, don't hold again for 10 minutes @@ -309,6 +311,8 @@ class EMSESP { static uint32_t gateway_cooldown_until_; static uint32_t gateway_window_start_; static uint8_t gateway_window_count_; + static uint32_t gateway_fast_start_; + static uint8_t gateway_fast_count_; static uint8_t last_version_request_src_; static uint32_t last_version_request_time_; #endif