From abb57affe2eff22f0977ba37d13c6f78993f604b Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Wed, 23 Aug 2023 13:33:15 -0400 Subject: [PATCH] refactor how GROUP VCH UPDATEs are sent; ensure notifyEnable is set to true by default; --- configs/config.example.yml | 2 +- src/p25/packet/ControlSignaling.cpp | 105 +++++++++++++++------------- src/p25/packet/ControlSignaling.h | 2 + 3 files changed, 58 insertions(+), 51 deletions(-) diff --git a/configs/config.example.yml b/configs/config.example.yml index 5b75c75d..300d4d35 100644 --- a/configs/config.example.yml +++ b/configs/config.example.yml @@ -359,7 +359,7 @@ system: # REST API access password for control channel. restPassword: "PASSWORD" # Flag indicating voice channels will notify the control channel of traffic status. - notifyEnable: false + notifyEnable: true # # Voice Channels diff --git a/src/p25/packet/ControlSignaling.cpp b/src/p25/packet/ControlSignaling.cpp index a5247e74..d2c77285 100644 --- a/src/p25/packet/ControlSignaling.cpp +++ b/src/p25/packet/ControlSignaling.cpp @@ -1798,7 +1798,7 @@ void ControlSignaling::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adj /** update data */ case 5: if (m_p25->m_affiliations.grantSize() > 0) { - queueRF_TSBK_Ctrl(TSBK_OSP_GRP_VCH_GRANT_UPD); + writeRF_TSDU_Grant_Update(); } break; /** extra data */ @@ -1886,55 +1886,6 @@ void ControlSignaling::queueRF_TSBK_Ctrl(uint8_t lco) std::unique_ptr tsbk; switch (lco) { - case TSBK_OSP_GRP_VCH_GRANT_UPD: - // write group voice grant update - if (m_p25->m_affiliations.grantSize() > 0) { - if (m_mbfGrpGrntCnt >= m_p25->m_affiliations.grantSize()) - m_mbfGrpGrntCnt = 0U; - - std::unique_ptr osp = new_unique(OSP_GRP_VCH_GRANT_UPD); - DEBUG_LOG_TSBK(osp->toString()); - - bool noData = false; - uint8_t i = 0U; - std::unordered_map grantTable = m_p25->m_affiliations.grantTable(); - for (auto entry : grantTable) { - // no good very bad way of skipping entries... - if (i != m_mbfGrpGrntCnt) { - i++; - continue; - } - else { - uint32_t dstId = entry.first; - uint32_t chNo = entry.second; - - if (chNo == 0U) { - noData = true; - m_mbfGrpGrntCnt++; - break; - } - else { - // transmit group voice grant update - osp->setLCO(TSBK_OSP_GRP_VCH_GRANT_UPD); - osp->setDstId(dstId); - osp->setGrpVchNo(chNo); - - m_mbfGrpGrntCnt++; - break; - } - } - } - - if (noData) { - return; // don't create anything - } else { - tsbk = std::move(osp); - } - } - else { - return; // don't create anything - } - break; case TSBK_OSP_IDEN_UP: { std::vector<::lookups::IdenTable> entries = m_p25->m_idenTable->list(); @@ -2398,6 +2349,60 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ return true; } +/// +/// Helper to write a grant update packet. +/// +void ControlSignaling::writeRF_TSDU_Grant_Update() +{ + // write group voice grant update + if (m_p25->m_affiliations.grantSize() > 0) { + if (m_mbfGrpGrntCnt >= m_p25->m_affiliations.grantSize()) + m_mbfGrpGrntCnt = 0U; + + std::unique_ptr osp = new_unique(OSP_GRP_VCH_GRANT_UPD); + DEBUG_LOG_TSBK(osp->toString()); + + bool noData = false; + uint8_t i = 0U; + std::unordered_map grantTable = m_p25->m_affiliations.grantTable(); + for (auto entry : grantTable) { + // no good very bad way of skipping entries... + if (i != m_mbfGrpGrntCnt) { + i++; + continue; + } + else { + uint32_t dstId = entry.first; + uint32_t chNo = entry.second; + + if (chNo == 0U) { + noData = true; + m_mbfGrpGrntCnt++; + break; + } + else { + // transmit group voice grant update + osp->setLCO(TSBK_OSP_GRP_VCH_GRANT_UPD); + osp->setDstId(dstId); + osp->setGrpVchNo(chNo); + + m_mbfGrpGrntCnt++; + break; + } + } + } + + if (noData) { + return; // don't create anything + } else { + writeRF_TSDU_SBF(osp.get(), true, false, false, true); + } + } + else { + return; // don't create anything + } +} + /// /// Helper to write a SNDCP grant packet. /// diff --git a/src/p25/packet/ControlSignaling.h b/src/p25/packet/ControlSignaling.h index e6b48406..a7dfb7d4 100644 --- a/src/p25/packet/ControlSignaling.h +++ b/src/p25/packet/ControlSignaling.h @@ -200,6 +200,8 @@ namespace p25 /// Helper to write a grant packet. bool writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp, bool net = false, bool skip = false, uint32_t chNo = 0U); + /// Helper to write a grant update packet. + void writeRF_TSDU_Grant_Update(); /// Helper to write a SNDCP grant packet. bool writeRF_TSDU_SNDCP_Grant(uint32_t srcId, uint32_t dstId, bool skip = false, bool net = false); /// Helper to write a unit to unit answer request packet.