add support for marking whether or not a talkgroup was granted on a channel by RF or network;

pull/41/head
Bryan Biedenkapp 2 years ago
parent df2a2b3f14
commit 21555a1119

@ -63,8 +63,9 @@ DMRAffiliationLookup::~DMRAffiliationLookup()
/// <param name="dstId"></param> /// <param name="dstId"></param>
/// <param name="srcId"></param> /// <param name="srcId"></param>
/// <param name="grantTimeout"></param> /// <param name="grantTimeout"></param>
/// <param name="netGranted"></param>
/// <returns></returns> /// <returns></returns>
bool DMRAffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout) bool DMRAffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout, bool netGranted)
{ {
uint32_t chNo = m_rfChTable.at(0); uint32_t chNo = m_rfChTable.at(0);
uint8_t slot = getAvailableSlotForChannel(chNo); uint8_t slot = getAvailableSlotForChannel(chNo);
@ -73,7 +74,7 @@ bool DMRAffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t gran
return false; return false;
} }
return grantChSlot(dstId, srcId, slot, grantTimeout); return grantChSlot(dstId, srcId, slot, grantTimeout, netGranted);
} }
/// <summary> /// <summary>
@ -83,8 +84,9 @@ bool DMRAffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t gran
/// <param name="srcId"></param> /// <param name="srcId"></param>
/// <param name="slot"></param> /// <param name="slot"></param>
/// <param name="grantTimeout"></param> /// <param name="grantTimeout"></param>
/// <param name="netGranted"></param>
/// <returns></returns> /// <returns></returns>
bool DMRAffiliationLookup::grantChSlot(uint32_t dstId, uint32_t srcId, uint8_t slot, uint32_t grantTimeout) bool DMRAffiliationLookup::grantChSlot(uint32_t dstId, uint32_t srcId, uint8_t slot, uint32_t grantTimeout, bool netGranted)
{ {
if (dstId == 0U) { if (dstId == 0U) {
return false; return false;
@ -109,6 +111,8 @@ bool DMRAffiliationLookup::grantChSlot(uint32_t dstId, uint32_t srcId, uint8_t s
m_grantChSlotTable[dstId] = std::make_tuple(chNo, slot); m_grantChSlotTable[dstId] = std::make_tuple(chNo, slot);
m_rfGrantChCnt++; m_rfGrantChCnt++;
m_netGrantedTable[dstId] = netGranted;
m_grantTimers[dstId] = Timer(1000U, grantTimeout); m_grantTimers[dstId] = Timer(1000U, grantTimeout);
m_grantTimers[dstId].start(); m_grantTimers[dstId].start();
@ -166,6 +170,7 @@ bool DMRAffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll)
m_grantChTable.erase(dstId); m_grantChTable.erase(dstId);
m_grantSrcIdTable.erase(dstId); m_grantSrcIdTable.erase(dstId);
m_grantChSlotTable.erase(dstId); m_grantChSlotTable.erase(dstId);
m_netGrantedTable.erase(dstId);
auto it = std::find(m_rfChTable.begin(), m_rfChTable.end(), chNo); auto it = std::find(m_rfChTable.begin(), m_rfChTable.end(), chNo);
if (it == m_rfChTable.end()) { if (it == m_rfChTable.end()) {

@ -49,9 +49,9 @@ namespace dmr
virtual ~DMRAffiliationLookup(); virtual ~DMRAffiliationLookup();
/// <summary>Helper to grant a channel.</summary> /// <summary>Helper to grant a channel.</summary>
bool grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout) override; bool grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout, bool netGranted) override;
/// <summary>Helper to grant a channel and slot.</summary> /// <summary>Helper to grant a channel and slot.</summary>
bool grantChSlot(uint32_t dstId, uint32_t srcId, uint8_t slot, uint32_t grantTimeout); bool grantChSlot(uint32_t dstId, uint32_t srcId, uint8_t slot, uint32_t grantTimeout, bool netGranted);
/// <summary>Helper to release the channel grant for the destination ID.</summary> /// <summary>Helper to release the channel grant for the destination ID.</summary>
bool releaseGrant(uint32_t dstId, bool releaseAll) override; bool releaseGrant(uint32_t dstId, bool releaseAll) override;
/// <summary>Helper to determine if the channel number is busy.</summary> /// <summary>Helper to determine if the channel number is busy.</summary>

@ -861,7 +861,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_
} }
} }
else { else {
if (m_tscc->m_affiliations->grantCh(dstId, srcId, GRANT_TIMER_TIMEOUT)) { if (m_tscc->m_affiliations->grantCh(dstId, srcId, GRANT_TIMER_TIMEOUT, net)) {
chNo = m_tscc->m_affiliations->getGrantedCh(dstId); chNo = m_tscc->m_affiliations->getGrantedCh(dstId);
slot = m_tscc->m_affiliations->getGrantedSlot(dstId); slot = m_tscc->m_affiliations->getGrantedSlot(dstId);
//m_tscc->m_siteData.setChCnt(m_tscc->m_affiliations->getRFChCnt() + m_tscc->m_affiliations->getGrantedRFChCnt()); //m_tscc->m_siteData.setChCnt(m_tscc->m_affiliations->getRFChCnt() + m_tscc->m_affiliations->getGrantedRFChCnt());
@ -1150,7 +1150,7 @@ bool ControlSignaling::writeRF_CSBK_Data_Grant(uint32_t srcId, uint32_t dstId, u
} }
} }
else { else {
if (m_tscc->m_affiliations->grantCh(dstId, srcId, GRANT_TIMER_TIMEOUT)) { if (m_tscc->m_affiliations->grantCh(dstId, srcId, GRANT_TIMER_TIMEOUT, net)) {
chNo = m_tscc->m_affiliations->getGrantedCh(dstId); chNo = m_tscc->m_affiliations->getGrantedCh(dstId);
slot = m_tscc->m_affiliations->getGrantedSlot(dstId); slot = m_tscc->m_affiliations->getGrantedSlot(dstId);

@ -50,6 +50,7 @@ AffiliationLookup::AffiliationLookup(const char* name, bool verbose) :
m_grpAffTable(), m_grpAffTable(),
m_grantChTable(), m_grantChTable(),
m_grantSrcIdTable(), m_grantSrcIdTable(),
m_netGrantedTable(),
m_grantTimers(), m_grantTimers(),
m_releaseGrant(nullptr), m_releaseGrant(nullptr),
m_name(name), m_name(name),
@ -245,8 +246,9 @@ std::vector<uint32_t> AffiliationLookup::clearGroupAff(uint32_t dstId, bool rele
/// <param name="dstId"></param> /// <param name="dstId"></param>
/// <param name="srcId"></param> /// <param name="srcId"></param>
/// <param name="grantTimeout"></param> /// <param name="grantTimeout"></param>
/// <param name="netGranted"></param>
/// <returns></returns> /// <returns></returns>
bool AffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout) bool AffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout, bool netGranted)
{ {
if (dstId == 0U) { if (dstId == 0U) {
return false; return false;
@ -264,6 +266,8 @@ bool AffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTi
m_grantSrcIdTable[dstId] = srcId; m_grantSrcIdTable[dstId] = srcId;
m_rfGrantChCnt++; m_rfGrantChCnt++;
m_netGrantedTable[dstId] = netGranted;
m_grantTimers[dstId] = Timer(1000U, grantTimeout); m_grantTimers[dstId] = Timer(1000U, grantTimeout);
m_grantTimers[dstId].start(); m_grantTimers[dstId].start();
@ -334,6 +338,7 @@ bool AffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll)
m_grantChTable.erase(dstId); m_grantChTable.erase(dstId);
m_grantSrcIdTable.erase(dstId); m_grantSrcIdTable.erase(dstId);
m_netGrantedTable.erase(dstId);
m_rfChTable.push_back(chNo); m_rfChTable.push_back(chNo);
if (m_rfGrantChCnt > 0U) { if (m_rfGrantChCnt > 0U) {
@ -396,6 +401,26 @@ bool AffiliationLookup::isGranted(uint32_t dstId) const
} }
} }
/// <summary>
/// Helper to determine if the destination ID is network granted.
/// </summary>
/// <param name="dstId"></param>
/// <returns></returns>
bool AffiliationLookup::isNetGranted(uint32_t dstId) const
{
if (dstId == 0U) {
return false;
}
// lookup dynamic channel grant table entry
try {
bool net = m_netGrantedTable.at(dstId);
return net;
} catch (...) {
return false;
}
}
/// <summary> /// <summary>
/// Helper to get the channel granted for the given destination ID. /// Helper to get the channel granted for the given destination ID.
/// </summary> /// </summary>

@ -138,7 +138,7 @@ namespace lookups
/// <summary>Gets the grant table.</summary> /// <summary>Gets the grant table.</summary>
std::unordered_map<uint32_t, uint32_t> grantTable() const { return m_grantChTable; } std::unordered_map<uint32_t, uint32_t> grantTable() const { return m_grantChTable; }
/// <summary>Helper to grant a channel.</summary> /// <summary>Helper to grant a channel.</summary>
virtual bool grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout); virtual bool grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout, bool netGranted);
/// <summary>Helper to start the destination ID grant timer.</summary> /// <summary>Helper to start the destination ID grant timer.</summary>
virtual void touchGrant(uint32_t dstId); virtual void touchGrant(uint32_t dstId);
/// <summary>Helper to release the channel grant for the destination ID.</summary> /// <summary>Helper to release the channel grant for the destination ID.</summary>
@ -147,6 +147,8 @@ namespace lookups
virtual bool isChBusy(uint32_t chNo) const; virtual bool isChBusy(uint32_t chNo) const;
/// <summary>Helper to determine if the destination ID is already granted.</summary> /// <summary>Helper to determine if the destination ID is already granted.</summary>
virtual bool isGranted(uint32_t dstId) const; virtual bool isGranted(uint32_t dstId) const;
/// <summary>Helper to determine if the destination ID is granted by network traffic.</summary>
virtual bool isNetGranted(uint32_t dstId) const;
/// <summary>Helper to get the channel granted for the given destination ID.</summary> /// <summary>Helper to get the channel granted for the given destination ID.</summary>
virtual uint32_t getGrantedCh(uint32_t dstId); virtual uint32_t getGrantedCh(uint32_t dstId);
/// <summary>Helper to get the source ID granted for the given destination ID.</summary> /// <summary>Helper to get the source ID granted for the given destination ID.</summary>
@ -184,6 +186,7 @@ namespace lookups
std::unordered_map<uint32_t, uint32_t> m_grantChTable; std::unordered_map<uint32_t, uint32_t> m_grantChTable;
std::unordered_map<uint32_t, uint32_t> m_grantSrcIdTable; std::unordered_map<uint32_t, uint32_t> m_grantSrcIdTable;
std::unordered_map<uint32_t, bool> m_netGrantedTable;
std::unordered_map<uint32_t, Timer> m_grantTimers; std::unordered_map<uint32_t, Timer> m_grantTimers;
// chNo dstId slot // chNo dstId slot

@ -563,7 +563,7 @@ bool ControlSignaling::writeRF_Message_Grant(uint32_t srcId, uint32_t dstId, uin
} }
} }
else { else {
if (m_nxdn->m_affiliations.grantCh(dstId, srcId, GRANT_TIMER_TIMEOUT)) { if (m_nxdn->m_affiliations.grantCh(dstId, srcId, GRANT_TIMER_TIMEOUT, net)) {
chNo = m_nxdn->m_affiliations.getGrantedCh(dstId); chNo = m_nxdn->m_affiliations.getGrantedCh(dstId);
} }
} }

@ -2190,7 +2190,7 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_
} }
} }
else { else {
if (m_p25->m_affiliations.grantCh(dstId, srcId, GRANT_TIMER_TIMEOUT)) { if (m_p25->m_affiliations.grantCh(dstId, srcId, GRANT_TIMER_TIMEOUT, net)) {
chNo = m_p25->m_affiliations.getGrantedCh(dstId); chNo = m_p25->m_affiliations.getGrantedCh(dstId);
m_p25->m_siteData.setChCnt(m_p25->m_affiliations.getRFChCnt() + m_p25->m_affiliations.getGrantedRFChCnt()); m_p25->m_siteData.setChCnt(m_p25->m_affiliations.getRFChCnt() + m_p25->m_affiliations.getGrantedRFChCnt());
} }
@ -2449,7 +2449,7 @@ bool ControlSignaling::writeRF_TSDU_SNDCP_Grant(uint32_t srcId, uint32_t dstId,
return false; return false;
} }
else { else {
if (m_p25->m_affiliations.grantCh(srcId, srcId, GRANT_TIMER_TIMEOUT)) { if (m_p25->m_affiliations.grantCh(srcId, srcId, GRANT_TIMER_TIMEOUT, net)) {
uint32_t chNo = m_p25->m_affiliations.getGrantedCh(srcId); uint32_t chNo = m_p25->m_affiliations.getGrantedCh(srcId);
osp->setGrpVchNo(chNo); osp->setGrpVchNo(chNo);
osp->setDataChnNo(chNo); osp->setDataChnNo(chNo);

Loading…
Cancel
Save

Powered by TurnKey Linux.