move addBusyBits and setBusyBits to P25 utilities class;

3.0-rcon_maint
Bryan Biedenkapp 3 years ago
parent cdaaac620c
commit 10d4a940fd

@ -1175,7 +1175,7 @@ void Control::writeRF_TDU(bool noNetwork)
m_nid.encode(data + 2U, P25_DUID_TDU);
// Add busy bits
addBusyBits(data + 2U, P25_TDU_FRAME_LENGTH_BITS, true, true);
P25Utils::addBusyBits(data + 2U, P25_TDU_FRAME_LENGTH_BITS, true, true);
if (!noNetwork)
m_voice->writeNetwork(data + 2U, P25_DUID_TDU);
@ -1187,44 +1187,3 @@ void Control::writeRF_TDU(bool noNetwork)
addFrame(data, P25_TDU_FRAME_LENGTH_BYTES + 2U);
}
}
/// <summary>
/// Helper to set the busy status bits on P25 frame data.
/// </summary>
/// <param name="data"></param>
/// <param name="ssOffset"></param>
/// <param name="b1"></param>
/// <param name="b2"></param>
void Control::setBusyBits(uint8_t* data, uint32_t ssOffset, bool b1, bool b2)
{
assert(data != nullptr);
WRITE_BIT(data, ssOffset, b1);
WRITE_BIT(data, ssOffset + 1U, b2);
}
/// <summary>
/// Helper to add the busy status bits on P25 frame data.
/// </summary>
/// <param name="data"></param>
/// <param name="length"></param>
/// <param name="b1"></param>
/// <param name="b2"></param>
void Control::addBusyBits(uint8_t* data, uint32_t length, bool b1, bool b2)
{
assert(data != nullptr);
// insert the "10" (Unknown, use for inbound or outbound) status bits
for (uint32_t ss0Pos = P25_SS0_START; ss0Pos < length; ss0Pos += P25_SS_INCREMENT) {
uint32_t ss1Pos = ss0Pos + 1U;
WRITE_BIT(data, ss0Pos, true); // 1
WRITE_BIT(data, ss1Pos, false); // 0
}
// interleave the requested status bits (every other)
for (uint32_t ss0Pos = P25_SS0_START; ss0Pos < length; ss0Pos += (P25_SS_INCREMENT * 2)) {
uint32_t ss1Pos = ss0Pos + 1U;
WRITE_BIT(data, ss0Pos, b1);
WRITE_BIT(data, ss1Pos, b2);
}
}

@ -232,11 +232,6 @@ namespace p25
void writeRF_Preamble(uint32_t preambleCount = 0, bool force = false);
/// <summary>Helper to write a P25 TDU packet.</summary>
void writeRF_TDU(bool noNetwork);
/// <summary>Helper to set the busy status bits on P25 frame data.</summary>
void setBusyBits(uint8_t* data, uint32_t ssOffset, bool b1, bool b2);
/// <summary>Helper to add the busy status bits on P25 frame data.</summary>
void addBusyBits(uint8_t* data, uint32_t length, bool b1, bool b2);
};
} // namespace p25

@ -40,6 +40,47 @@ using namespace p25;
// Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Helper to set the busy status bits on P25 frame data.
/// </summary>
/// <param name="data"></param>
/// <param name="ssOffset"></param>
/// <param name="b1"></param>
/// <param name="b2"></param>
void P25Utils::setBusyBits(uint8_t* data, uint32_t ssOffset, bool b1, bool b2)
{
assert(data != nullptr);
WRITE_BIT(data, ssOffset, b1);
WRITE_BIT(data, ssOffset + 1U, b2);
}
/// <summary>
/// Helper to add the busy status bits on P25 frame data.
/// </summary>
/// <param name="data"></param>
/// <param name="length"></param>
/// <param name="b1"></param>
/// <param name="b2"></param>
void P25Utils::addBusyBits(uint8_t* data, uint32_t length, bool b1, bool b2)
{
assert(data != nullptr);
// insert the "10" (Unknown, use for inbound or outbound) status bits
for (uint32_t ss0Pos = P25_SS0_START; ss0Pos < length; ss0Pos += P25_SS_INCREMENT) {
uint32_t ss1Pos = ss0Pos + 1U;
WRITE_BIT(data, ss0Pos, true); // 1
WRITE_BIT(data, ss1Pos, false); // 0
}
// interleave the requested status bits (every other)
for (uint32_t ss0Pos = P25_SS0_START; ss0Pos < length; ss0Pos += (P25_SS_INCREMENT * 2)) {
uint32_t ss1Pos = ss0Pos + 1U;
WRITE_BIT(data, ss0Pos, b1);
WRITE_BIT(data, ss1Pos, b2);
}
}
/// <summary>
/// Decode bit interleaving.
/// </summary>

@ -108,6 +108,11 @@ namespace p25
return id;
}
/// <summary>Helper to set the busy status bits on P25 frame data.</summary>
static void setBusyBits(uint8_t* data, uint32_t ssOffset, bool b1, bool b2);
/// <summary>Helper to add the busy status bits on P25 frame data.</summary>
static void addBusyBits(uint8_t* data, uint32_t length, bool b1, bool b2);
/// <summary>Decode bit interleaving.</summary>
static uint32_t decode(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop);
/// <summary>Encode bit interleaving.</summary>

@ -149,10 +149,10 @@ void DFSITrunk::writeRF_TSDU_SBF(lc::TSBK* tsbk, bool noNetwork, bool clearBefor
}
// Add busy bits
m_p25->addBusyBits(data + 2U, P25_TSDU_FRAME_LENGTH_BITS, true, false);
P25Utils::addBusyBits(data + 2U, P25_TSDU_FRAME_LENGTH_BITS, true, false);
// Set first busy bits to 1,1
m_p25->setBusyBits(data + 2U, P25_SS0_START, true, true);
P25Utils::setBusyBits(data + 2U, P25_SS0_START, true, true);
if (!noNetwork)
writeNetworkRF(tsbk, data + 2U, true);

@ -387,7 +387,7 @@ bool DFSIVoice::process(uint8_t* data, uint32_t len)
m_rfLC.encodeHDU(buffer + 2U);
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_HDU_FRAME_LENGTH_BITS, false, true);
P25Utils::addBusyBits(buffer + 2U, P25_HDU_FRAME_LENGTH_BITS, false, true);
writeNetwork(buffer, P25_DUID_HDU);
@ -462,7 +462,7 @@ bool DFSIVoice::process(uint8_t* data, uint32_t len)
m_rfFrames++;
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
P25Utils::addBusyBits(buffer + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
writeNetwork(buffer + 2U, P25_DUID_LDU1);
@ -554,7 +554,7 @@ bool DFSIVoice::process(uint8_t* data, uint32_t len)
m_rfFrames++;
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
P25Utils::addBusyBits(buffer + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
writeNetwork(buffer + 2U, P25_DUID_LDU2);
@ -585,7 +585,7 @@ bool DFSIVoice::process(uint8_t* data, uint32_t len)
m_p25->m_nid.encode(data + 2U, P25_DUID_TDU);
// Add busy bits
m_p25->addBusyBits(data + 2U, P25_TDU_FRAME_LENGTH_BITS, true, true);
P25Utils::addBusyBits(data + 2U, P25_TDU_FRAME_LENGTH_BITS, true, true);
writeNetwork(data + 2U, P25_DUID_TDU);

@ -717,7 +717,7 @@ void Data::writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls)
m_p25->m_nid.encode(data + 2U, P25_DUID_PDU);
// Add busy bits
m_p25->addBusyBits(data + 2U, newBitLength, false, true);
P25Utils::addBusyBits(data + 2U, newBitLength, false, true);
if (m_p25->m_duplex) {
data[0U] = modem::TAG_DATA;

@ -1435,7 +1435,7 @@ void Trunk::writeRF_TDULC(lc::TDULC* lc, bool noNetwork)
lc->encode(data + 2U);
// Add busy bits
m_p25->addBusyBits(data + 2U, P25_TDULC_FRAME_LENGTH_BITS, true, true);
P25Utils::addBusyBits(data + 2U, P25_TDULC_FRAME_LENGTH_BITS, true, true);
m_p25->m_rfTimeout.stop();
@ -1476,7 +1476,7 @@ void Trunk::writeNet_TDULC(lc::TDULC* lc)
lc->encode(buffer + 2U);
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_TDULC_FRAME_LENGTH_BITS, true, true);
P25Utils::addBusyBits(buffer + 2U, P25_TDULC_FRAME_LENGTH_BITS, true, true);
m_p25->addFrame(buffer, P25_TDULC_FRAME_LENGTH_BYTES + 2U, true);
@ -1587,10 +1587,10 @@ void Trunk::writeRF_TSDU_SBF(lc::TSBK* tsbk, bool noNetwork, bool clearBeforeWri
}
// Add busy bits
m_p25->addBusyBits(data + 2U, P25_TSDU_FRAME_LENGTH_BITS, true, false);
P25Utils::addBusyBits(data + 2U, P25_TSDU_FRAME_LENGTH_BITS, true, false);
// Set first busy bits to 1,1
m_p25->setBusyBits(data + 2U, P25_SS0_START, true, true);
P25Utils::setBusyBits(data + 2U, P25_SS0_START, true, true);
if (!noNetwork)
writeNetworkRF(tsbk, data + 2U, true);
@ -1646,10 +1646,10 @@ void Trunk::writeNet_TSDU(lc::TSBK* tsbk)
tsbk->encode(buffer + 2U);
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_TSDU_FRAME_LENGTH_BYTES, true, false);
P25Utils::addBusyBits(buffer + 2U, P25_TSDU_FRAME_LENGTH_BYTES, true, false);
// Set first busy bits to 1,1
m_p25->setBusyBits(buffer + 2U, P25_SS0_START, true, true);
P25Utils::setBusyBits(buffer + 2U, P25_SS0_START, true, true);
m_p25->addFrame(buffer, P25_TSDU_FRAME_LENGTH_BYTES + 2U, true);
@ -1742,7 +1742,7 @@ void Trunk::writeRF_TSDU_MBF(lc::TSBK* tsbk, bool clearBeforeWrite)
P25Utils::encode(tsdu, data + 2U, 114U, 720U);
// Add busy bits
m_p25->addBusyBits(data + 2U, P25_TSDU_TRIPLE_FRAME_LENGTH_BITS, true, false);
P25Utils::addBusyBits(data + 2U, P25_TSDU_TRIPLE_FRAME_LENGTH_BITS, true, false);
// Add idle bits
addIdleBits(data + 2U, P25_TSDU_TRIPLE_FRAME_LENGTH_BITS, true, true);
@ -2633,10 +2633,10 @@ void Trunk::writeNet_TSDU_From_RF(lc::TSBK* tsbk, uint8_t* data)
tsbk->encode(data);
// Add busy bits
m_p25->addBusyBits(data, P25_TSDU_FRAME_LENGTH_BYTES, true, false);
P25Utils::addBusyBits(data, P25_TSDU_FRAME_LENGTH_BYTES, true, false);
// Set first busy bits to 1,1
m_p25->setBusyBits(data, P25_SS0_START, true, true);
P25Utils::setBusyBits(data, P25_SS0_START, true, true);
}
/// <summary>

@ -404,7 +404,7 @@ bool Voice::process(uint8_t* data, uint32_t len)
m_rfLC.encodeHDU(buffer + 2U);
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_HDU_FRAME_LENGTH_BITS, false, true);
P25Utils::addBusyBits(buffer + 2U, P25_HDU_FRAME_LENGTH_BITS, false, true);
writeNetwork(buffer, P25_DUID_HDU);
@ -530,7 +530,7 @@ bool Voice::process(uint8_t* data, uint32_t len)
m_rfFrames++;
// Add busy bits
m_p25->addBusyBits(data + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
P25Utils::addBusyBits(data + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
writeNetwork(data + 2U, P25_DUID_LDU1);
@ -609,7 +609,7 @@ bool Voice::process(uint8_t* data, uint32_t len)
m_rfFrames++;
// Add busy bits
m_p25->addBusyBits(data + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
P25Utils::addBusyBits(data + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
writeNetwork(data + 2U, P25_DUID_LDU2);
@ -982,7 +982,7 @@ void Voice::writeNet_TDU()
m_p25->m_nid.encode(buffer + 2U, P25_DUID_TDU);
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_TDU_FRAME_LENGTH_BITS, true, true);
P25Utils::addBusyBits(buffer + 2U, P25_TDU_FRAME_LENGTH_BITS, true, true);
m_p25->addFrame(buffer, P25_TDU_FRAME_LENGTH_BYTES + 2U, true);
@ -1215,7 +1215,7 @@ void Voice::writeNet_LDU1()
m_netLC.encodeHDU(buffer + 2U);
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_HDU_FRAME_LENGTH_BITS, false, true);
P25Utils::addBusyBits(buffer + 2U, P25_HDU_FRAME_LENGTH_BITS, false, true);
buffer[0U] = modem::TAG_DATA;
buffer[1U] = 0x00U;
@ -1274,7 +1274,7 @@ void Voice::writeNet_LDU1()
m_netLSD.encode(buffer + 2U);
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
P25Utils::addBusyBits(buffer + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
buffer[0U] = modem::TAG_DATA;
buffer[1U] = 0x00U;
@ -1379,7 +1379,7 @@ void Voice::writeNet_LDU2()
m_netLSD.encode(buffer + 2U);
// Add busy bits
m_p25->addBusyBits(buffer + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
P25Utils::addBusyBits(buffer + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true);
buffer[0U] = modem::TAG_DATA;
buffer[1U] = 0x00U;

Loading…
Cancel
Save

Powered by TurnKey Linux.