diff --git a/src/dmr/Control.cpp b/src/dmr/Control.cpp index 30a55aa5..c61c31cb 100644 --- a/src/dmr/Control.cpp +++ b/src/dmr/Control.cpp @@ -77,6 +77,8 @@ Control::Control(bool authoritative, uint32_t colorCode, uint32_t callHang, uint m_idenTable(idenTable), m_ridLookup(ridLookup), m_tidLookup(tidLookup), + m_tsccCnt(0U), + m_tsccCntInterval(1000U, 0U, DMR_SLOT_TIME / 2U), m_tsccSlotNo(0U), m_tsccPayloadActive(false), m_ccRunning(false), @@ -96,6 +98,8 @@ Control::Control(bool authoritative, uint32_t colorCode, uint32_t callHang, uint m_slot1 = new Slot(1U, timeout, tgHang, queueSize, dumpDataPacket, repeatDataPacket, dumpCSBKData, debug, verbose); m_slot2 = new Slot(2U, timeout, tgHang, queueSize, dumpDataPacket, repeatDataPacket, dumpCSBKData, debug, verbose); + + m_tsccCntInterval.start(); } /// @@ -314,9 +318,10 @@ uint32_t Control::getFrame(uint32_t slotNo, uint8_t* data) } /// -/// Updates the processor. +/// Updates the processor by the passed number of milliseconds. /// -void Control::clock() +/// +void Control::clock(uint32_t ms) { if (m_network != nullptr) { data::Data data; @@ -337,6 +342,16 @@ void Control::clock() } } + m_tsccCntInterval.clock(ms); + if (m_tsccCntInterval.isRunning() && m_tsccCntInterval.hasExpired()) { + m_tsccCnt++; + if (m_tsccCnt == TSCC_MAX_CSC_CNT) { + m_tsccCnt = 0U; + } + + m_tsccCntInterval.start(); + } + m_slot1->clock(); m_slot2->clock(); } diff --git a/src/dmr/Control.h b/src/dmr/Control.h index 7f0266b6..83bef7f1 100644 --- a/src/dmr/Control.h +++ b/src/dmr/Control.h @@ -89,7 +89,7 @@ namespace dmr uint32_t getFrame(uint32_t slotNo, uint8_t* data); /// Updates the processor. - void clock(); + void clock(uint32_t ms); /// Permits a TGID on a non-authoritative host. void permittedTG(uint32_t dstId, uint8_t slot); @@ -141,6 +141,9 @@ namespace dmr ::lookups::RadioIdLookup* m_ridLookup; ::lookups::TalkgroupIdLookup* m_tidLookup; + uint16_t m_tsccCnt; + Timer m_tsccCntInterval; + uint8_t m_tsccSlotNo; bool m_tsccPayloadActive; bool m_ccRunning; diff --git a/src/dmr/DMRDefines.h b/src/dmr/DMRDefines.h index b8dbc6c2..bdfe0f28 100644 --- a/src/dmr/DMRDefines.h +++ b/src/dmr/DMRDefines.h @@ -111,6 +111,8 @@ namespace dmr const uint8_t DATA_HEADER_CRC_MASK[] = { 0xCCU, 0xCCU }; const uint8_t CSBK_CRC_MASK[] = { 0xA5U, 0xA5U }; + const uint16_t TSCC_MAX_CSC_CNT = 511U; + const uint32_t DMR_SLOT_TIME = 60U; const uint32_t AMBE_PER_SLOT = 3U; diff --git a/src/dmr/Slot.cpp b/src/dmr/Slot.cpp index 4e659c8b..ef0c72b2 100644 --- a/src/dmr/Slot.cpp +++ b/src/dmr/Slot.cpp @@ -45,12 +45,6 @@ using namespace dmr::packet; #include #include -// --------------------------------------------------------------------------- -// Constants -// --------------------------------------------------------------------------- - -const uint16_t TSCC_MAX_CNT = 511U; - // --------------------------------------------------------------------------- // Static Class Members // --------------------------------------------------------------------------- @@ -97,8 +91,6 @@ bool Slot::m_voice2 = true; bool Slot::m_verifyReg = false; -uint16_t Slot::m_tsccCnt = 0U; - uint8_t Slot::m_alohaNRandWait = DEFAULT_NRAND_WAIT; uint8_t Slot::m_alohaBackOff = 1U; @@ -139,7 +131,7 @@ Slot::Slot(uint32_t slotNo, uint32_t timeout, uint32_t tgHang, uint32_t queueSiz m_rfTGHang(1000U, tgHang), m_netTimeoutTimer(1000U, timeout), m_packetTimer(1000U, 0U, 50U), - m_ccPacketInterval(1000U, 0U, 60U), + m_ccPacketInterval(1000U, 0U, DMR_SLOT_TIME), m_interval(), m_elapsed(), m_rfFrames(0U), @@ -421,6 +413,8 @@ void Slot::clock() // if we have control enabled; do clocking to generate a CC data stream if (m_enableTSCC) { + m_modem->setDMRIgnoreCACH_AT(m_slotNo); + // clock all the grant timers m_affiliations->clock(ms); @@ -442,26 +436,21 @@ void Slot::clock() } if (m_ccPacketInterval.isRunning() && m_ccPacketInterval.hasExpired()) { - m_tsccCnt++; - if (m_tsccCnt == TSCC_MAX_CNT) { - m_tsccCnt = 0U; - } - if (m_ccRunning) { if (m_ccSeq == 3U) { m_ccSeq = 0U; } if (m_dmr->m_tsccPayloadActive) { - if ((m_tsccCnt % 2) == 0) { - setShortLC_TSCC(m_siteData, m_tsccCnt); + if ((m_dmr->m_tsccCnt % 2) == 0) { + setShortLC_Payload(m_siteData, m_dmr->m_tsccCnt); } } else { - setShortLC_TSCC(m_siteData, m_tsccCnt); + setShortLC_TSCC(m_siteData, m_dmr->m_tsccCnt); } - writeRF_ControlData(m_tsccCnt, m_ccSeq); + writeRF_ControlData(m_dmr->m_tsccCnt, m_ccSeq); m_ccSeq++; } @@ -480,13 +469,10 @@ void Slot::clock() if (m_dmr->m_tsccPayloadActive) { if (m_rfState == RS_RF_LISTENING && m_netState == RS_NET_IDLE) { if (m_tsccPayloadDstId > 0U) { - if ((m_tsccCnt % 2) > 0) { + if ((m_dmr->m_tsccCnt % 2) > 0) { setShortLC(m_slotNo, m_tsccPayloadDstId, m_tsccPayloadGroup ? FLCO_GROUP : FLCO_PRIVATE, false); } } - else { - setShortLC_TSCC(m_siteData, m_tsccCnt); - } } else { clearTSCCActivated(); @@ -861,7 +847,7 @@ void Slot::writeEndRF(bool writeEnd) if (m_netState == RS_NET_IDLE) { if (m_enableTSCC) - setShortLC_TSCC(m_siteData, m_tsccCnt); + setShortLC_Payload(m_siteData, m_dmr->m_tsccCnt); else setShortLC(m_slotNo, 0U); } diff --git a/src/dmr/Slot.h b/src/dmr/Slot.h index 487e6db9..31e7af74 100644 --- a/src/dmr/Slot.h +++ b/src/dmr/Slot.h @@ -243,8 +243,6 @@ namespace dmr static bool m_verifyReg; - static uint16_t m_tsccCnt; - static uint8_t m_alohaNRandWait; static uint8_t m_alohaBackOff; diff --git a/src/host/Host.cpp b/src/host/Host.cpp index 667e27fd..d0754d3d 100644 --- a/src/host/Host.cpp +++ b/src/host/Host.cpp @@ -1324,7 +1324,7 @@ int Host::run() #if defined(ENABLE_DMR) if (dmr != nullptr) - dmr->clock(); + dmr->clock(ms); #endif // defined(ENABLE_DMR) #if defined(ENABLE_P25) if (p25 != nullptr)