Skip to content

Commit

Permalink
refactor how GROUP VCH UPDATEs are sent; ensure notifyEnable is set t…
Browse files Browse the repository at this point in the history
…o true by default;
  • Loading branch information
gatekeep committed Aug 23, 2023
1 parent 4ae6a94 commit abb57af
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 51 deletions.
2 changes: 1 addition & 1 deletion configs/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
105 changes: 55 additions & 50 deletions src/p25/packet/ControlSignaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -1886,55 +1886,6 @@ void ControlSignaling::queueRF_TSBK_Ctrl(uint8_t lco)
std::unique_ptr<lc::TSBK> 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_GRP_VCH_GRANT_UPD> osp = new_unique(OSP_GRP_VCH_GRANT_UPD);
DEBUG_LOG_TSBK(osp->toString());

bool noData = false;
uint8_t i = 0U;
std::unordered_map<uint32_t, uint32_t> 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();
Expand Down Expand Up @@ -2398,6 +2349,60 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_
return true;
}

/// <summary>
/// Helper to write a grant update packet.
/// </summary>
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_GRP_VCH_GRANT_UPD> osp = new_unique(OSP_GRP_VCH_GRANT_UPD);
DEBUG_LOG_TSBK(osp->toString());

bool noData = false;
uint8_t i = 0U;
std::unordered_map<uint32_t, uint32_t> 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
}
}

/// <summary>
/// Helper to write a SNDCP grant packet.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/p25/packet/ControlSignaling.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ namespace p25

/// <summary>Helper to write a grant packet.</summary>
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);
/// <summary>Helper to write a grant update packet.</summary>
void writeRF_TSDU_Grant_Update();
/// <summary>Helper to write a SNDCP grant packet.</summary>
bool writeRF_TSDU_SNDCP_Grant(uint32_t srcId, uint32_t dstId, bool skip = false, bool net = false);
/// <summary>Helper to write a unit to unit answer request packet.</summary>
Expand Down

0 comments on commit abb57af

Please sign in to comment.