cleanup AMBT implementation; implement separate writeRF_PDU_User function for generating PDU packets with userdata;

2.0-maint
Bryan Biedenkapp 3 years ago
parent 22356a6557
commit d853175f93

@ -198,6 +198,18 @@ void DFSITrunk::writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite, bool for
writeRF_DSFI_Stop(P25_DFSI_TYPE_TSBK);
}
/// <summary>
/// Helper to write a alternate multi-block trunking PDU packet.
/// </summary>
/// <param name="clearBeforeWrite"></param>
void DFSITrunk::writeRF_TSDU_AMBT(bool clearBeforeWrite)
{
if (!m_p25->m_control)
return;
// for now this is ignored...
}
/// <summary>
/// Helper to write a network single-block P25 TSDU packet.
/// </summary>

@ -74,6 +74,8 @@ namespace p25
/// <summary>Helper to write a single-block P25 TSDU packet.</summary>
virtual void writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite = false, bool force = false);
/// <summary>Helper to write a alternate multi-block trunking PDU packet.</summary>
virtual void writeRF_TSDU_AMBT(bool clearBeforeWrite = false);
/// <summary>Helper to write a network P25 TDU w/ link control packet.</summary>
//virtual void writeNet_TDULC(lc::TDULC lc);

@ -505,6 +505,52 @@ bool Data::hasLLIdFNEReg(uint32_t llId) const
}
}
/// <summary>
/// Helper to write user data as a P25 PDU packet.
/// </summary>
/// <param name="dataHeader"></param>
/// <param name="pduUserData"></param>
/// <param name="clearBeforeWrite"></param>
void Data::writeRF_PDU_User(data::DataHeader dataHeader, const uint8_t* pduUserData, bool clearBeforeWrite)
{
assert(pduUserData != NULL);
uint32_t bitLength = ((dataHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS;
uint32_t offset = P25_PREAMBLE_LENGTH_BITS;
uint8_t data[bitLength / 8U];
::memset(data, 0x00U, bitLength / 8U);
uint8_t block[P25_PDU_FEC_LENGTH_BYTES];
::memset(block, 0x00U, P25_PDU_FEC_LENGTH_BYTES);
// Generate the PDU header and 1/2 rate Trellis
dataHeader.encode(block);
Utils::setBitRange(block, data, offset, P25_PDU_FEC_LENGTH_BITS);
offset += P25_PDU_FEC_LENGTH_BITS;
// Generate the PDU data
DataBlock rspBlock = DataBlock();
uint32_t dataOffset = 0U;
for (uint8_t i = 0; i < dataHeader.getBlocksToFollow(); i++) {
rspBlock.setFormat(PDU_FMT_UNCONFIRMED);
rspBlock.setSerialNo(0U);
rspBlock.setData(pduUserData + dataOffset);
::memset(block, 0x00U, P25_PDU_FEC_LENGTH_BYTES);
rspBlock.encode(block);
Utils::setBitRange(block, data, offset, P25_PDU_FEC_LENGTH_BITS);
offset += P25_PDU_FEC_LENGTH_BITS;
dataOffset += P25_PDU_UNCONFIRMED_LENGTH_BYTES;
}
if (clearBeforeWrite) {
m_p25->m_modem->clearP25Data();
m_p25->m_queue.clear();
}
writeRF_PDU(data, bitLength);
}
/// <summary>
/// Updates the processor by the passed number of milliseconds.
/// </summary>

@ -73,13 +73,15 @@ namespace p25
/// <summary>Helper to check if a logical link ID has registered with data services.</summary>
bool hasLLIdFNEReg(uint32_t llId) const;
/// <summary>Helper to write user data as a P25 PDU packet.</summary>
void writeRF_PDU_User(data::DataHeader dataHeader, const uint8_t* pduUserData, bool clearBeforeWrite = false);
/// <summary>Updates the processor by the passed number of milliseconds.</summary>
void clock(uint32_t ms);
private:
friend class p25::Control;
Control* m_p25;
friend class p25::packet::Trunk;
network::BaseNetwork* m_network;

@ -1670,61 +1670,32 @@ void Trunk::writeRF_TSDU_MBF(bool clearBeforeWrite)
/// Helper to write a alternate multi-block trunking PDU packet.
/// </summary>
/// <param name="clearBeforeWrite"></param>
void Trunk::writeRF_PDU_AMBT(bool clearBeforeWrite)
void Trunk::writeRF_TSDU_AMBT(bool clearBeforeWrite)
{
if (!m_p25->m_control)
return;
DataHeader rspHeader = DataHeader();
uint8_t rspData[P25_PDU_UNCONFIRMED_LENGTH_BYTES * P25_MAX_PDU_COUNT];
::memset(rspData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * P25_MAX_PDU_COUNT);
DataHeader header = DataHeader();
uint8_t pduUserData[P25_PDU_UNCONFIRMED_LENGTH_BYTES * P25_MAX_PDU_COUNT];
::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * P25_MAX_PDU_COUNT);
// Generate TSBK block
m_rfTSBK.setLastBlock(true); // always set last block -- this a Single Block TSDU
m_rfTSBK.encodeMBT(rspHeader, rspData);
m_rfTSBK.encodeMBT(header, pduUserData);
if (m_debug) {
LogDebug(LOG_RF, P25_PDU_STR ", ack = %u, outbound = %u, fmt = $%02X, sap = $%02X, fullMessage = %u, blocksToFollow = %u, padCount = %u, n = %u, seqNo = %u, hdrOffset = %u",
header.getAckNeeded(), header.getOutbound(), header.getFormat(), header.getSAP(), header.getFullMessage(),
header.getBlocksToFollow(), header.getPadCount(), header.getNs(), header.getFSN(),
header.getHeaderOffset());
LogDebug(LOG_RF, P25_PDU_STR " AMBT, lco = $%02X, mfId = $%02X, lastBlock = %u, AIV = %u, EX = %u, srcId = %u, dstId = %u, sysId = $%03X, netId = $%05X",
m_rfTSBK.getLCO(), m_rfTSBK.getMFId(), m_rfTSBK.getLastBlock(), m_rfTSBK.getAIV(), m_rfTSBK.getEX(), m_rfTSBK.getSrcId(), m_rfTSBK.getDstId(),
m_rfTSBK.getSysId(), m_rfTSBK.getNetId());
Utils::dump(1U, "!!! *TSDU (AMBT) TSBK Block Data", rspData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * rspHeader.getBlocksToFollow());
Utils::dump(1U, "!!! *PDU (AMBT) TSBK Block Data", pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * header.getBlocksToFollow());
}
uint32_t bitLength = ((rspHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS;
uint32_t offset = P25_PREAMBLE_LENGTH_BITS;
uint8_t data[bitLength / 8U];
::memset(data, 0x00U, bitLength / 8U);
uint8_t block[P25_PDU_FEC_LENGTH_BYTES];
::memset(block, 0x00U, P25_PDU_FEC_LENGTH_BYTES);
// Generate the PDU header and 1/2 rate Trellis
rspHeader.encode(block);
Utils::setBitRange(block, data, offset, P25_PDU_FEC_LENGTH_BITS);
offset += P25_PDU_FEC_LENGTH_BITS;
// Generate the PDU data
DataBlock rspBlock = DataBlock();
uint32_t dataOffset = 0U;
for (uint8_t i = 0; i < rspHeader.getBlocksToFollow(); i++) {
rspBlock.setFormat(PDU_FMT_UNCONFIRMED);
rspBlock.setSerialNo(0U);
rspBlock.setData(rspData + dataOffset);
::memset(block, 0x00U, P25_PDU_FEC_LENGTH_BYTES);
rspBlock.encode(block);
Utils::setBitRange(block, data, offset, P25_PDU_FEC_LENGTH_BITS);
offset += P25_PDU_FEC_LENGTH_BITS;
dataOffset += P25_PDU_UNCONFIRMED_LENGTH_BYTES;
}
if (clearBeforeWrite) {
m_p25->m_modem->clearP25Data();
m_p25->m_queue.clear();
}
m_p25->m_data->writeRF_PDU(data, bitLength);
m_p25->m_data->writeRF_PDU_User(header, pduUserData, clearBeforeWrite);
}
/// <summary>

@ -83,6 +83,7 @@ namespace p25
/// <summary>Helper to set the TSBK manufacturer ID.</summary>
void setMFId(uint8_t val) { m_rfTSBK.setMFId(val); }
/// <summary>Helper to write a call alert packet.</summary>
void writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a call alert packet.</summary>
@ -179,7 +180,7 @@ namespace p25
/// <summary>Helper to write a multi-block (3-block) P25 TSDU packet.</summary>
void writeRF_TSDU_MBF(bool clearBeforeWrite = false);
/// <summary>Helper to write a alternate multi-block trunking PDU packet.</summary>
void writeRF_PDU_AMBT(bool clearBeforeWrite = false);
virtual void writeRF_TSDU_AMBT(bool clearBeforeWrite = false);
/// <summary>Helper to generate the given control TSBK into the TSDU frame queue.</summary>
void queueRF_TSBK_Ctrl(uint8_t lco);

Loading…
Cancel
Save

Powered by TurnKey Linux.