diff --git a/sources/config.h b/sources/config.h index b34b162..5739d4f 100644 --- a/sources/config.h +++ b/sources/config.h @@ -19,6 +19,7 @@ constexpr auto LOG_FILES_COUNT = 9; // kee constexpr auto PERFORMANCE_LOGGER_INTERVAL = 1000; // print stats every n frames constexpr auto RECORDER_FLUSH_INTERVAL = std::chrono::milliseconds(100); // flush recordings to mqtt every 2 * n bytes constexpr auto RESAMPLER_THRESHOLD = 125; // max interpolation or decimation factor of RESAMPLER +constexpr auto TRANSMISSION_MAX_TIME = std::chrono::minutes(10); // break transmission if longer that // SCANNING SETTINGS constexpr auto NOISE_LEARNING_TIME = std::chrono::milliseconds(2000); // noise learnig time diff --git a/sources/radio/blocks/transmission.cpp b/sources/radio/blocks/transmission.cpp index ed92c14..a295dbf 100644 --- a/sources/radio/blocks/transmission.cpp +++ b/sources/radio/blocks/transmission.cpp @@ -62,7 +62,7 @@ void Transmission::process(const float* power) { void Transmission::clearSignals(const float* avgPower, const float* rawPower, const std::chrono::milliseconds now) { for (auto it = m_signals.begin(); it != m_signals.cend();) { const auto& [index, signal] = *it; - if (signal.isTimeout(now)) { + if (signal.isTimeout(now) || signal.isMaximalTime(now)) { Logger::info( LABEL, "stop, frequency: {}, center frequency: {}, avg power: {}, raw power:{}", diff --git a/sources/radio/signal.cpp b/sources/radio/signal.cpp index 9975c59..85f2b39 100644 --- a/sources/radio/signal.cpp +++ b/sources/radio/signal.cpp @@ -21,6 +21,8 @@ void Signal::newData(const Index, const float avgPower, const Index rawIndex, co bool Signal::isMinimalTime(const std::chrono::milliseconds& now) const { return m_firstDataTime + m_config.recordingMinTime() <= now; } +bool Signal::isMaximalTime(const std::chrono::milliseconds& now) const { return m_firstDataTime + TRANSMISSION_MAX_TIME <= now; } + bool Signal::isTimeout(const std::chrono::milliseconds& now) const { return m_lastDataTime + m_config.recordingTimeout() <= now; } bool Signal::needFlush(const std::chrono::milliseconds& now) const { return m_lastDataTime == now && isMinimalTime(now); } diff --git a/sources/radio/signal.h b/sources/radio/signal.h index 3d8dd3f..2da0773 100644 --- a/sources/radio/signal.h +++ b/sources/radio/signal.h @@ -17,6 +17,7 @@ class Signal { void newData(const Index avgIndex, const float avgPower, const Index rawIndex, const float rawPower, const std::chrono::milliseconds& now); bool isMinimalTime(const std::chrono::milliseconds& now) const; + bool isMaximalTime(const std::chrono::milliseconds& now) const; bool isTimeout(const std::chrono::milliseconds& now) const; bool needFlush(const std::chrono::milliseconds& now) const; float getPower() const;