diff --git a/dmr/Control.cpp b/dmr/Control.cpp index f5ebbf64..79d68711 100644 --- a/dmr/Control.cpp +++ b/dmr/Control.cpp @@ -323,6 +323,25 @@ void Control::clock() m_slot2->clock(); } +/// +/// Helper to return the slot carrying the TSCC. +/// +/// Pointer to the TSCC slot instance. +Slot* Control::getTSCCSlot() const +{ + switch (m_tsccSlotNo) { + case 1U: + return m_slot1; + break; + case 2U: + return m_slot2; + break; + default: + LogError(LOG_NET, "DMR, invalid slot, TSCC disabled, slotNo = %u", m_tsccSlotNo); + return NULL; + } +} + /// /// Helper to write a DMR extended function packet on the RF interface. /// @@ -399,26 +418,3 @@ void Control::setCSBKVerbose(bool verbose) m_slot1->setCSBKVerbose(verbose); m_slot2->setCSBKVerbose(verbose); } - -// --------------------------------------------------------------------------- -// Private Class Members -// --------------------------------------------------------------------------- - -/// -/// Helper to return the slot carrying the TSCC. -/// -/// Pointer to the TSCC slot instance. -Slot* Control::getTSCCSlot() const -{ - switch (m_tsccSlotNo) { - case 1U: - return m_slot1; - break; - case 2U: - return m_slot2; - break; - default: - LogError(LOG_NET, "DMR, invalid slot, TSCC disabled, slotNo = %u", m_tsccSlotNo); - return NULL; - } -} diff --git a/dmr/Control.h b/dmr/Control.h index 9cbea67e..102654f4 100644 --- a/dmr/Control.h +++ b/dmr/Control.h @@ -90,6 +90,9 @@ namespace dmr /// Updates the processor. void clock(); + /// Helper to return the slot carrying the TSCC. + Slot* getTSCCSlot() const; + /// Helper to write a DMR extended function packet on the RF interface. void writeRF_Ext_Func(uint32_t slotNo, uint32_t func, uint32_t arg, uint32_t dstId); /// Helper to write a DMR call alert packet on the RF interface. @@ -111,7 +114,6 @@ namespace dmr private: friend class Slot; - friend class packet::ControlSignaling; uint32_t m_colorCode; @@ -132,9 +134,6 @@ namespace dmr bool m_dumpCSBKData; bool m_verbose; bool m_debug; - - /// Helper to return the slot carrying the TSCC. - Slot* getTSCCSlot() const; }; } // namespace dmr diff --git a/dmr/Slot.cpp b/dmr/Slot.cpp index a6199857..57078c97 100644 --- a/dmr/Slot.cpp +++ b/dmr/Slot.cpp @@ -203,6 +203,14 @@ bool Slot::processFrame(uint8_t *data, uint32_t len) LogMessage(LOG_RF, "DMR Slot %u, total frames: %d, total bits: %d, errors: %d, BER: %.4f%%", m_slotNo, m_rfFrames, m_rfBits, m_rfErrs, float(m_rfErrs * 100U) / float(m_rfBits)); + // release trunked grant (if necessary) + Slot *m_tscc = m_dmr->getTSCCSlot(); + if (m_tscc != NULL) { + if (m_tscc->m_enableTSCC && m_rfLC != NULL) { + m_tscc->m_affiliations->releaseGrant(m_rfLC->getDstId(), false); + } + } + if (m_rfTimeout) { writeEndRF(); return false; diff --git a/dmr/packet/Data.cpp b/dmr/packet/Data.cpp index bc8b9a28..630da83b 100644 --- a/dmr/packet/Data.cpp +++ b/dmr/packet/Data.cpp @@ -116,6 +116,14 @@ bool Data::process(uint8_t* data, uint32_t len) LogMessage(LOG_RF, DMR_DT_TERMINATOR_WITH_LC ", slot = %u, dstId = %u", m_slot->m_slotNo, m_slot->m_rfLC->getDstId()); } + // release trunked grant (if necessary) + Slot *m_tscc = m_slot->m_dmr->getTSCCSlot(); + if (m_tscc != NULL) { + if (m_tscc->m_enableTSCC) { + m_tscc->m_affiliations->releaseGrant(m_slot->m_rfLC->getDstId(), false); + } + } + if (m_slot->m_rssi != 0U) { ::ActivityLog("DMR", true, "Slot %u RF end of voice transmission, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_slot->m_slotNo, float(m_slot->m_rfFrames) / 16.667F, float(m_slot->m_rfErrs * 100U) / float(m_slot->m_rfBits),