From d1b2b19c08f44309b10c12defb0afe375a7840b2 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Tue, 19 Dec 2023 21:10:15 -0500 Subject: [PATCH] refactor how we clock ADJ_STS_BCAST; correct wrongly used site data for ADJ_STS_BCAST; --- src/host/Host.cpp | 11 ----------- src/p25/Control.cpp | 22 +++++++++++++--------- src/p25/Control.h | 5 ++--- src/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp | 13 ++++++------- src/p25/packet/ControlSignaling.cpp | 5 +++++ 5 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/host/Host.cpp b/src/host/Host.cpp index 0203b126..bb0bd9cb 100644 --- a/src/host/Host.cpp +++ b/src/host/Host.cpp @@ -1205,7 +1205,6 @@ int Host::run() if (m_state != STATE_P25) setState(STATE_P25); - p25->writeAdjSSNetwork(); p25->setCCRunning(true); // hide this message for continuous CC -- otherwise display every time we process @@ -1241,16 +1240,6 @@ int Host::run() } } } - else { - // simply use the P25 CC interval timer in a non-broadcast state to transmit adjacent site data over - // the network - if (p25BcastIntervalTimer.isRunning() && p25BcastIntervalTimer.hasExpired()) { - if ((m_state == STATE_IDLE || m_state == STATE_P25) && !m_modem->hasTX()) { - p25->writeAdjSSNetwork(); - p25BcastIntervalTimer.start(); - } - } - } } } #endif // defined(ENABLE_P25) diff --git a/src/p25/Control.cpp b/src/p25/Control.cpp index 85297ed9..ea2d52e8 100644 --- a/src/p25/Control.cpp +++ b/src/p25/Control.cpp @@ -131,6 +131,7 @@ Control::Control(bool authoritative, uint32_t nac, uint32_t callHang, uint32_t q m_netTimeout(1000U, timeout), m_netTGHang(1000U, 2U), m_networkWatchdog(1000U, 0U, 1500U), + m_adjSiteUpdate(1000U, 75U), m_ccPacketInterval(1000U, 0U, 10U), m_hangCount(3U * 8U), m_tduPreambleCount(8U), @@ -728,14 +729,6 @@ uint32_t Control::getFrame(uint8_t* data) return len; } -/// -/// Helper to write P25 adjacent site information to the network. -/// -void Control::writeAdjSSNetwork() -{ - m_control->writeAdjSSNetwork(); -} - /// /// Helper to write end of voice call frame data. /// @@ -796,6 +789,10 @@ void Control::clock(uint32_t ms) if (m_enableControl) { if (m_ccRunning && !m_ccPacketInterval.isRunning()) { m_ccPacketInterval.start(); + if (!m_adjSiteUpdate.isRunning()) { + m_control->writeAdjSSNetwork(); + m_adjSiteUpdate.start(); + } } if (m_ccHalted) { @@ -823,6 +820,13 @@ void Control::clock(uint32_t ms) writeRF_ControlEnd(); m_ccPrevRunning = m_ccRunning; } + + // do we need to network announce ourselves? + m_adjSiteUpdate.clock(ms); + if (m_adjSiteUpdate.isRunning() && m_adjSiteUpdate.hasExpired()) { + m_control->writeAdjSSNetwork(); + m_adjSiteUpdate.start(); + } } // handle timeouts and hang timers @@ -1501,7 +1505,6 @@ bool Control::writeRF_ControlData() return false; if (m_ccFrameCnt == 254U) { - m_control->writeAdjSSNetwork(); m_ccFrameCnt = 0U; } @@ -1542,6 +1545,7 @@ bool Control::writeRF_ControlEnd() m_txQueue.clear(); m_ccPacketInterval.stop(); + m_adjSiteUpdate.stop(); if (m_netState == RS_NET_IDLE && m_rfState == RS_RF_LISTENING) { for (uint32_t i = 0; i < TSBK_PCH_CCH_CNT; i++) { diff --git a/src/p25/Control.h b/src/p25/Control.h index 59a1cf9a..4fdc5221 100644 --- a/src/p25/Control.h +++ b/src/p25/Control.h @@ -103,9 +103,6 @@ namespace p25 /// Get frame data from data ring buffer. uint32_t getFrame(uint8_t* data); - /// Helper to write P25 adjacent site information to the network. - void writeAdjSSNetwork(); - /// Helper to write end of voice call frame data. bool writeRF_VoiceEnd(); @@ -211,6 +208,8 @@ namespace p25 Timer m_netTGHang; Timer m_networkWatchdog; + Timer m_adjSiteUpdate; + Timer m_ccPacketInterval; uint32_t m_hangCount; diff --git a/src/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp b/src/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp index 799db6c1..c075ed9a 100644 --- a/src/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp +++ b/src/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp @@ -95,14 +95,13 @@ void OSP_ADJ_STS_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) ulong64_t tsbkValue = 0U; tsbkValue = m_siteData.lra(); // Location Registration Area - tsbkValue = (tsbkValue << 4) + - (m_siteData.netActive()) ? P25_CFVA_NETWORK : 0U; // CFVA + tsbkValue = (tsbkValue << 4) + m_adjCFVA; // CFVA tsbkValue = (tsbkValue << 12) + m_siteData.sysId(); // System ID - tsbkValue = (tsbkValue << 8) + m_siteData.rfssId(); // RF Sub-System ID - tsbkValue = (tsbkValue << 8) + m_siteData.siteId(); // Site ID - tsbkValue = (tsbkValue << 4) + m_siteData.channelId(); // Channel ID - tsbkValue = (tsbkValue << 12) + m_siteData.channelNo(); // Channel Number - tsbkValue = (tsbkValue << 8) + m_siteData.serviceClass(); // System Service Class + tsbkValue = (tsbkValue << 8) + m_adjRfssId; // RF Sub-System ID + tsbkValue = (tsbkValue << 8) + m_adjSiteId; // Site ID + tsbkValue = (tsbkValue << 4) + m_adjChannelId; // Channel ID + tsbkValue = (tsbkValue << 12) + m_adjChannelNo; // Channel Number + tsbkValue = (tsbkValue << 8) + m_adjServiceClass; // System Service Class std::unique_ptr tsbk = TSBK::fromValue(tsbkValue); TSBK::encode(data, tsbk.get(), rawTSBK, noTrellis); diff --git a/src/p25/packet/ControlSignaling.cpp b/src/p25/packet/ControlSignaling.cpp index c6564b2c..0ab219a2 100644 --- a/src/p25/packet/ControlSignaling.cpp +++ b/src/p25/packet/ControlSignaling.cpp @@ -2026,6 +2026,11 @@ void ControlSignaling::queueRF_TSBK_Ctrl(uint8_t lco) else { SiteData site = entry.second; + // this should never happen -- but prevent announcing ourselves as a neighbor + if (site.channelId() == m_p25->m_siteData.channelId() && site.channelNo() == m_p25->m_siteData.channelNo() && + site.siteId() == m_p25->m_siteData.siteId() && site.sysId() == m_p25->m_siteData.sysId()) + continue; + uint8_t cfva = P25_CFVA_NETWORK; if (m_adjSiteUpdateCnt[site.siteId()] == 0U) { cfva |= P25_CFVA_FAILURE;