diff --git a/src/sysview/CMakeLists.txt b/src/sysview/CMakeLists.txt index c6b4e961..1d9459e0 100644 --- a/src/sysview/CMakeLists.txt +++ b/src/sysview/CMakeLists.txt @@ -15,6 +15,8 @@ file(GLOB sysView_SRC "src/remote/RESTClient.cpp" "src/remote/RESTClient.h" + "src/sysview/p25/tsbk/*.h" + "src/sysview/p25/tsbk/*.cpp" "src/sysview/network/*.h" "src/sysview/network/*.cpp" "src/sysview/*.h" diff --git a/src/sysview/SysViewApplication.h b/src/sysview/SysViewApplication.h index ac9dbbf3..c5618098 100644 --- a/src/sysview/SysViewApplication.h +++ b/src/sysview/SysViewApplication.h @@ -28,6 +28,7 @@ #include "common/nxdn/lc/RTCH.h" #include "common/Log.h" #include "common/StopWatch.h" +#include "p25/tsbk/OSP_GRP_AFF.h" #include "network/PeerNetwork.h" #include "SysViewMain.h" #include "SysViewMainWnd.h" @@ -627,9 +628,9 @@ protected: break; case P25DEF::TSBKO::IOSP_GRP_AFF: { - lc::tsbk::IOSP_GRP_AFF* iosp = static_cast(tsbk.get()); - LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, anncId = %u (%s), srcId = %u (%s), dstId = %u (%s), response = $%02X", tsbk->toString().c_str(), - iosp->getSysId(), iosp->getAnnounceGroup(), resolveTGID(iosp->getAnnounceGroup()).c_str(), + lc::tsbk::OSP_GRP_AFF* iosp = static_cast(tsbk.get()); + LogMessage(LOG_NET, P25_TSDU_STR ", %s, anncId = %u (%s), srcId = %u (%s), dstId = %u (%s), response = $%02X", tsbk->toString().c_str(), + iosp->getAnnounceGroup(), resolveTGID(iosp->getAnnounceGroup()).c_str(), srcId, resolveRID(srcId).c_str(), dstId, resolveTGID(dstId).c_str(), iosp->getResponse()); } diff --git a/src/sysview/p25/tsbk/OSP_GRP_AFF.cpp b/src/sysview/p25/tsbk/OSP_GRP_AFF.cpp new file mode 100644 index 00000000..49b7fb46 --- /dev/null +++ b/src/sysview/p25/tsbk/OSP_GRP_AFF.cpp @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - FNE System View + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ +#include "Defines.h" +#include "p25/tsbk/OSP_GRP_AFF.h" + +using namespace p25; +using namespace p25::defines; +using namespace p25::lc; +using namespace p25::lc::tsbk; + +#include + +// --------------------------------------------------------------------------- +// Public Class Members +// --------------------------------------------------------------------------- + +/* Initializes a new instance of the OSP_GRP_AFF class. */ + +OSP_GRP_AFF::OSP_GRP_AFF() : TSBK(), + m_announceGroup(WUID_ALL) +{ + m_lco = TSBKO::IOSP_GRP_AFF; +} + +/* Decode a trunking signalling block. */ + +bool OSP_GRP_AFF::decode(const uint8_t* data, bool rawTSBK) +{ + assert(data != nullptr); + + uint8_t tsbk[P25_TSBK_LENGTH_BYTES + 1U]; + ::memset(tsbk, 0x00U, P25_TSBK_LENGTH_BYTES); + + bool ret = TSBK::decode(data, tsbk, rawTSBK); + if (!ret) + return false; + + ulong64_t tsbkValue = TSBK::toValue(tsbk); + + m_response = (uint8_t)((tsbkValue >> 56) & 0x3U); // Affiliation Response + m_announceGroup = (uint32_t)((tsbkValue >> 40) & 0xFFFFU); // Announcement Group Address + m_dstId = (uint32_t)((tsbkValue >> 24) & 0xFFFFU); // Talkgroup Address + m_srcId = (uint32_t)(tsbkValue & 0xFFFFFFU); // Source Radio Address + + return true; +} + +/* Encode a trunking signalling block. */ + +void OSP_GRP_AFF::encode(uint8_t* data, bool rawTSBK, bool noTrellis) +{ + assert(data != nullptr); + + /* stub */ +} + +/* Returns a string that represents the current TSBK. */ + +std::string OSP_GRP_AFF::toString(bool isp) +{ + return std::string("TSBKO, OSP_GRP_AFF (Group Affiliation Response)"); +} + +// --------------------------------------------------------------------------- +// Private Class Members +// --------------------------------------------------------------------------- + +/* Internal helper to copy the the class. */ + +void OSP_GRP_AFF::copy(const OSP_GRP_AFF& data) +{ + TSBK::copy(data); + + m_announceGroup = data.m_announceGroup; +} diff --git a/src/sysview/p25/tsbk/OSP_GRP_AFF.h b/src/sysview/p25/tsbk/OSP_GRP_AFF.h new file mode 100644 index 00000000..6d19d555 --- /dev/null +++ b/src/sysview/p25/tsbk/OSP_GRP_AFF.h @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - FNE System View + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file IOSP_GRP_AFF.h + * @ingroup fneSysView + * @file IOSP_GRP_AFF.cpp + * @ingroup fneSysView + */ +#if !defined(__SYSVIEW_P25_TSBK__IOSP_GRP_AFF_H__) +#define __SYSVIEW_P25_TSBK__IOSP_GRP_AFF_H__ + +#include "common/Defines.h" +#include "common/p25/lc/TSBK.h" + +namespace p25 +{ + namespace lc + { + namespace tsbk + { + // --------------------------------------------------------------------------- + // Class Declaration + // --------------------------------------------------------------------------- + + /** + * @brief Implements GRP AFF RSP - Group Affiliation Response (OSP) + * @ingroup fneSysView + */ + class HOST_SW_API OSP_GRP_AFF : public TSBK { + public: + /** + * @brief Initializes a new instance of the OSP_GRP_AFF class. + */ + OSP_GRP_AFF(); + + /** + * @brief Decode a trunking signalling block. + * @param[in] data Buffer containing a TSBK to decode. + * @param rawTSBK Flag indicating whether or not the passed buffer is raw. + * @returns bool True, if TSBK decoded, otherwise false. + */ + bool decode(const uint8_t* data, bool rawTSBK = false) override; + /** + * @brief Encode a trunking signalling block. + * @param[out] data Buffer to encode a TSBK. + * @param rawTSBK Flag indicating whether or not the output buffer is raw. + * @param noTrellis Flag indicating whether or not the encoded data should be Trellis encoded. + */ + void encode(uint8_t* data, bool rawTSBK = false, bool noTrellis = false) override; + + /** + * @brief Returns a string that represents the current TSBK. + * @returns std::string String representation of the TSBK. + */ + std::string toString(bool isp = false) override; + + public: + /** + * @brief Announcement group. + */ + __PROPERTY(uint32_t, announceGroup, AnnounceGroup); + + __COPY(OSP_GRP_AFF); + }; + } // namespace tsbk + } // namespace lc +} // namespace p25 + +#endif // __SYSVIEW_P25_TSBK__IOSP_GRP_AFF_H__