From 8fe1c551eb7a604bb514a58d72bd7d7bec212c29 Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 7 Apr 2026 19:11:09 +0800 Subject: [PATCH] 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. --- P25Control.cpp | 2 +- P25Data.cpp | 11 ++++++++++- P25Defines.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/P25Control.cpp b/P25Control.cpp index d35c26e..eb4c4bf 100644 --- a/P25Control.cpp +++ b/P25Control.cpp @@ -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 diff --git a/P25Data.cpp b/P25Data.cpp index 889e45c..2eb72de 100644 --- a/P25Data.cpp +++ b/P25Data.cpp @@ -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; diff --git a/P25Defines.h b/P25Defines.h index 7824751..0a25ff7 100644 --- a/P25Defines.h +++ b/P25Defines.h @@ -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;