Skip to content

Commit

Permalink
fix issue where next MI wouldn't be calculated from the HDU MI if we …
Browse files Browse the repository at this point in the history
…received a valid HDU; fix issue with first superframe LDU1 containing a non-standard MFID resulting in incorrect destination IDs (if this happens and we've received a valid HDU, attempt to use the HDUs destination ID);
  • Loading branch information
gatekeep committed Jul 15, 2024
1 parent da2f613 commit 07d6d3c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/host/p25/packet/Voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ void Voice::resetRF()

m_rfLC = lc;
//m_rfLastHDU = lc;
m_rfLastHDUValid = false;
m_rfLastLDU1 = lc;
m_rfLastLDU2 = lc;
m_rfFirstLDU2 = true;

m_rfFrames = 0U;
m_rfErrs = 0U;
Expand Down Expand Up @@ -171,6 +173,7 @@ bool Voice::process(uint8_t* data, uint32_t len)
m_p25->m_rfLastSrcId = lc.getSrcId();

m_rfLastHDU = lc;
m_rfLastHDUValid = true;

if (m_p25->m_rfState == RS_RF_LISTENING) {
if (!m_p25->m_dedicatedControl) {
Expand Down Expand Up @@ -206,6 +209,10 @@ bool Voice::process(uint8_t* data, uint32_t len)

uint32_t srcId = lc.getSrcId();
uint32_t dstId = lc.getDstId();
if (dstId == 0U && !lc.isStandardMFId() && m_rfLastHDUValid) {
dstId = m_rfLastHDU.getDstId();
}

bool group = lc.getGroup();
bool encrypted = lc.getEncrypted();

Expand Down Expand Up @@ -767,19 +774,28 @@ bool Voice::process(uint8_t* data, uint32_t len)
uint8_t nextMI[MI_LENGTH_BYTES];
::memset(nextMI, 0x00U, MI_LENGTH_BYTES);

m_rfLastLDU2.getMI(lastMI);
getNextMI(lastMI, nextMI);
if (m_rfFirstLDU2) {
m_rfFirstLDU2 = false;
if (m_rfLastHDUValid) {
m_rfLastHDU.getMI(lastMI);
}
}
else {
m_rfLastLDU2.getMI(lastMI);
}

getNextMI(lastMI, nextMI);
if (m_verbose && m_debug) {
Utils::dump(1U, "Previous P25 HDU MI", lastMI, MI_LENGTH_BYTES);
Utils::dump(1U, "Calculated next P25 HDU MI", nextMI, MI_LENGTH_BYTES);
Utils::dump(1U, "Previous P25 MI", lastMI, MI_LENGTH_BYTES);
Utils::dump(1U, "Calculated next P25 MI", nextMI, MI_LENGTH_BYTES);
}

m_rfLC.setMI(nextMI);
m_rfLastLDU2.setMI(nextMI);
}
else {
m_rfLastLDU2 = m_rfLC;
m_rfFirstLDU2 = false;
}

m_inbound = true;
Expand Down Expand Up @@ -1371,8 +1387,10 @@ Voice::Voice(Control* p25, bool debug, bool verbose) :
m_audio(),
m_rfLC(),
m_rfLastHDU(),
m_rfLastHDUValid(false),
m_rfLastLDU1(),
m_rfLastLDU2(),
m_rfFirstLDU2(true),
m_netLC(),
m_netLastLDU1(),
m_netLastFrameType(FrameType::DATA_UNIT),
Expand Down
2 changes: 2 additions & 0 deletions src/host/p25/packet/Voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ namespace p25

lc::LC m_rfLC;
lc::LC m_rfLastHDU;
bool m_rfLastHDUValid;
lc::LC m_rfLastLDU1;
lc::LC m_rfLastLDU2;
bool m_rfFirstLDU2;

lc::LC m_netLC;
lc::LC m_netLastLDU1;
Expand Down

0 comments on commit 07d6d3c

Please sign in to comment.