Fix P25 bug introduced by PR #853 with following changes - Fix CP25Data::encodeTSDU() with P25_LCF_GROUP/P25_LCF_GRP_VCH_GRANT

- FIx P25Control P25_LCF_GROUP handling with P25_LCF_GRP_VCH_GRANT as LCF value.
This commit is contained in:
Shawn 2026-04-07 19:11:09 +08:00
parent 3ba965ed7e
commit 8fe1c551eb
3 changed files with 12 additions and 2 deletions

View file

@ -432,7 +432,7 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
// Build a Group Voice Channel Grant response
// Save original LCF and set Grant LCF for encoding
unsigned char originalLcf = m_rfData.getLCF();
m_rfData.setLCF(P25_LCF_GROUP);
m_rfData.setLCF(P25_LCF_GRP_VCH_GRANT);
m_rfData.setServiceType(0x00U); // Service options: 0x00 = routine priority, no emergency
// Encode TSDU with Grant response

View file

@ -423,12 +423,21 @@ void CP25Data::encodeTSDU(unsigned char* data)
tsbk[1U] = m_mfId;
switch (m_lcf) {
case P25_LCF_GROUP:
case P25_LCF_GRP_VCH_GRANT:
// Group Voice Channel Grant - format: ServiceOptions(8) + Channel(16) + GroupAddr(16) + SourceAddr(24) = 64 bits
// For conventional P25, channel identifier/number is 0 (no trunking)
tsbkValue = (unsigned long long)(m_serviceType & 0xFFU); // Service Options (8 bits)
tsbkValue = (tsbkValue << 16) + 0U; // Channel ID/Number (16 bits) - 0 for conventional
tsbkValue = (tsbkValue << 16) + (m_dstId & 0xFFFFU); // Group Address (16 bits)
tsbkValue = (tsbkValue << 24) + (m_srcId & 0xFFFFFFU); // Source Radio Address (24 bits)
break;
case P25_LCF_GROUP:
// Group Voice Channel User - format: Options(16) + GroupAddr(16) + SourceAddr(24) + Reserved(8)
tsbkValue = 0U; // Options (16 bits)
tsbkValue = (tsbkValue << 16) + (m_dstId & 0xFFFFU); // Group Address (16 bits)
tsbkValue = (tsbkValue << 24) + (m_srcId & 0xFFFFFFU); // Source Radio Address (24 bits)
tsbkValue = (tsbkValue << 8) + 0U; // Reserved (8 bits)
break;
case P25_LCF_TSBK_CALL_ALERT:
tsbkValue = 0U;
tsbkValue = (tsbkValue << 16) + 0U;

View file

@ -58,6 +58,7 @@ const unsigned int P25_MI_LENGTH_BYTES = 9U;
const unsigned char P25_ALGO_UNENCRYPT = 0x80U;
const unsigned char P25_LCF_GROUP = 0x00U;
const unsigned char P25_LCF_GRP_VCH_GRANT = 0x02U;
const unsigned char P25_LCF_PRIVATE = 0x03U;
const unsigned char P25_LCF_TSBK_CALL_ALERT = 0x1FU;