From 7cb639027d08186f7532414df136220eaef7d17d Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Mon, 31 Jul 2023 11:09:35 -0400 Subject: [PATCH] add support to transmit LC_FAILSOFT during conventional fallback (an option, no one uses yet...); --- src/p25/Control.cpp | 3 +- src/p25/P25Defines.h | 3 ++ src/p25/lc/tdulc/LC_FAILSOFT.cpp | 80 ++++++++++++++++++++++++++++++++ src/p25/lc/tdulc/LC_FAILSOFT.h | 57 +++++++++++++++++++++++ src/p25/lc/tdulc/TDULCFactory.h | 4 +- src/p25/packet/Trunk.cpp | 9 +++- 6 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 src/p25/lc/tdulc/LC_FAILSOFT.cpp create mode 100644 src/p25/lc/tdulc/LC_FAILSOFT.h diff --git a/src/p25/Control.cpp b/src/p25/Control.cpp index 81545f53..3d9f3ff7 100644 --- a/src/p25/Control.cpp +++ b/src/p25/Control.cpp @@ -567,7 +567,8 @@ bool Control::processFrame(uint8_t* data, uint32_t len) } break; } - if (!m_dedicatedControl) + + if (!m_dedicatedControl || m_trunk->m_convFallback) ret = m_voice->process(data, len); else { if (m_voiceOnControl && m_affiliations.isChBusy(m_siteData.channelNo())) { diff --git a/src/p25/P25Defines.h b/src/p25/P25Defines.h index 3cb43aa4..36339434 100644 --- a/src/p25/P25Defines.h +++ b/src/p25/P25Defines.h @@ -285,6 +285,9 @@ namespace p25 const uint8_t LC_NET_STS_BCAST = 0x24U; // NET STS BCAST - Network Status Broadcast const uint8_t LC_CONV_FALLBACK = 0x2AU; // CONV FALLBACK - Conventional Fallback + // LDUx/TDULC Motorola Link Control Opcode(s) + const uint8_t LC_FAILSOFT = 0x02U; // FAILSOFT - Failsoft + // TSBK ISP/OSP Shared Opcode(s) const uint8_t TSBK_IOSP_GRP_VCH = 0x00U; // GRP VCH REQ - Group Voice Channel Request (ISP), GRP VCH GRANT - Group Voice Channel Grant (OSP) const uint8_t TSBK_IOSP_UU_VCH = 0x04U; // UU VCH REQ - Unit-to-Unit Voice Channel Request (ISP), UU VCH GRANT - Unit-to-Unit Voice Channel Grant (OSP) diff --git a/src/p25/lc/tdulc/LC_FAILSOFT.cpp b/src/p25/lc/tdulc/LC_FAILSOFT.cpp new file mode 100644 index 00000000..81a2ba52 --- /dev/null +++ b/src/p25/lc/tdulc/LC_FAILSOFT.cpp @@ -0,0 +1,80 @@ +/** +* Digital Voice Modem - Host Software +* GPLv2 Open Source. Use is subject to license terms. +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* @package DVM / Host Software +* +*/ +/* +* Copyright (C) 2023 by Bryan Biedenkapp N2PLL +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include "Defines.h" +#include "p25/lc/tdulc/LC_FAILSOFT.h" +#include "Log.h" +#include "Utils.h" + +using namespace p25::lc::tdulc; +using namespace p25::lc; +using namespace p25; + +#include +#include + +// --------------------------------------------------------------------------- +// Public Class Members +// --------------------------------------------------------------------------- + +/// +/// Initializes a new instance of the LC_FAILSOFT class. +/// +LC_FAILSOFT::LC_FAILSOFT() : TDULC() +{ + m_lco = p25::LC_FAILSOFT; + m_mfId = p25::P25_MFG_MOT; +} + +/// +/// Decode a terminator data unit w/ link control. +/// +/// +/// True, if TDULC was decoded, otherwise false. +bool LC_FAILSOFT::decode(const uint8_t* data) +{ + assert(data != NULL); + + /* stub */ + + return true; +} + +/// +/// Encode a terminator data unit w/ link control. +/// +/// +void LC_FAILSOFT::encode(uint8_t* data) +{ + assert(data != NULL); + + ulong64_t rsValue = 0U; + + rsValue = m_mfId; + rsValue = (rsValue << 56); + + std::unique_ptr rs = TDULC::fromValue(rsValue); + TDULC::encode(data, rs.get()); +} diff --git a/src/p25/lc/tdulc/LC_FAILSOFT.h b/src/p25/lc/tdulc/LC_FAILSOFT.h new file mode 100644 index 00000000..5d06a86f --- /dev/null +++ b/src/p25/lc/tdulc/LC_FAILSOFT.h @@ -0,0 +1,57 @@ +/** +* Digital Voice Modem - Host Software +* GPLv2 Open Source. Use is subject to license terms. +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* @package DVM / Host Software +* +*/ +/* +* Copyright (C) 2023 by Bryan Biedenkapp N2PLL +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#if !defined(__P25_LC_TSBK__LC_FAILSOFT_H__) +#define __P25_LC_TSBK__LC_FAILSOFT_H__ + +#include "Defines.h" +#include "p25/lc/TDULC.h" + +namespace p25 +{ + namespace lc + { + namespace tdulc + { + // --------------------------------------------------------------------------- + // Class Declaration + // Implements FAILSOFT - Failsoft + // --------------------------------------------------------------------------- + + class HOST_SW_API LC_FAILSOFT : public TDULC { + public: + /// Initializes a new instance of the LC_FAILSOFT class. + LC_FAILSOFT(); + + /// Decode a terminator data unit w/ link control. + bool decode(const uint8_t* data); + /// Encode a terminator data unit w/ link control. + void encode(uint8_t* data); + }; + } // namespace tdulc + } // namespace lc +} // namespace p25 + +#endif // __P25_LC_TSBK__LC_FAILSOFT_H__ diff --git a/src/p25/lc/tdulc/TDULCFactory.h b/src/p25/lc/tdulc/TDULCFactory.h index 0dfc4f4e..ac193038 100644 --- a/src/p25/lc/tdulc/TDULCFactory.h +++ b/src/p25/lc/tdulc/TDULCFactory.h @@ -7,7 +7,7 @@ * */ /* -* Copyright (C) 2022 by Bryan Biedenkapp N2PLL +* Copyright (C) 2023 by Bryan Biedenkapp N2PLL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,6 +42,8 @@ #include "p25/lc/tdulc/LC_SYS_SRV_BCAST.h" #include "p25/lc/tdulc/LC_TEL_INT_VCH_USER.h" +#include "p25/lc/tdulc/LC_FAILSOFT.h" + namespace p25 { namespace lc diff --git a/src/p25/packet/Trunk.cpp b/src/p25/packet/Trunk.cpp index 05f292fe..695848d9 100644 --- a/src/p25/packet/Trunk.cpp +++ b/src/p25/packet/Trunk.cpp @@ -1316,10 +1316,9 @@ void Trunk::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS) if (m_convFallback) { bool fallbackTx = (frameCnt % 253U) == 0U; - if (fallbackTx && n == 7U) { + if (fallbackTx && n == 8U) { if (m_convFallbackPacketDelay >= CONV_FALLBACK_PACKET_DELAY) { std::unique_ptr lc = new_unique(lc::tdulc::LC_CONV_FALLBACK); - for (uint8_t i = 0U; i < 3U; i++) { writeRF_TDULC(lc.get(), true); } @@ -1329,6 +1328,12 @@ void Trunk::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS) m_convFallbackPacketDelay++; } } + else { + if (n == 8U) { + std::unique_ptr lc = new_unique(lc::tdulc::LC_FAILSOFT); + writeRF_TDULC(lc.get(), true); + } + } return; }