add doxygen configuration for dvmhost project; add doxygen output directory; convert common static library to use doxygen style commenting and documentation;

pull/61/head
Bryan Biedenkapp 2 years ago
parent 4137db2399
commit 10e1e12be0

File diff suppressed because it is too large Load Diff

@ -1,17 +1,13 @@
// SPDX-License-Identifier: MIT
/**
* Digital Voice Modem - Common Library
* MIT Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom C++ AES (https://github.com/SergeyBel/AES)
* @license MIT License (https://opensource.org/license/MIT)
*
* Copyright (C) 2019 SergeyBel
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* MIT Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2019 SergeyBel
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "AESCrypto.h"
#include "Log.h"
@ -246,9 +242,7 @@ static const uint8_t INV_CMDS[4][4] = { {14, 11, 13, 9}, {9, 14, 11, 13}, {13, 9
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the AES class.
/// </summary>
/* Initializes a new instance of the AES class. */
AES::AES(const AESKeyLength keyLength) {
switch (keyLength) {
case AESKeyLength::AES_128:
@ -266,13 +260,7 @@ AES::AES(const AESKeyLength keyLength) {
}
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="inLen"></param>
/// <param name="key"></param>
/// <returns></returns>
/* Encrypt input buffer with given key in AES-ECB. */
uint8_t* AES::encryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[])
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -294,13 +282,7 @@ uint8_t* AES::encryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[]
return out;
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="inLen"></param>
/// <param name="key"></param>
/// <returns></returns>
/* Decrypt input buffer with given key in AES-ECB. */
uint8_t* AES::decryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[])
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -322,14 +304,7 @@ uint8_t* AES::decryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[]
return out;
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="inLen"></param>
/// <param name="key"></param>
/// <param name="iv"></param>
/// <returns></returns>
/* Encrypt input buffer with given key and IV in AES-CBC. */
uint8_t* AES::encryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t* iv)
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -355,14 +330,7 @@ uint8_t* AES::encryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[]
return out;
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="inLen"></param>
/// <param name="key"></param>
/// <param name="iv"></param>
/// <returns></returns>
/* Decrypt input buffer with given key and IV in AES-CBC. */
uint8_t* AES::decryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t *iv)
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -388,14 +356,7 @@ uint8_t* AES::decryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[]
return out;
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="inLen"></param>
/// <param name="key"></param>
/// <param name="iv"></param>
/// <returns></returns>
/* Encrypt input buffer with given key and IV in AES-CFB. */
uint8_t* AES::encryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t *iv)
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -422,14 +383,7 @@ uint8_t* AES::encryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[]
return out;
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="inLen"></param>
/// <param name="key"></param>
/// <param name="iv"></param>
/// <returns></returns>
/* Decrypt input buffer with given key and IV in AES-CFB. */
uint8_t* AES::decryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t *iv)
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -460,10 +414,7 @@ uint8_t* AES::decryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[]
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="state"></param>
/* */
void AES::subBytes(uint8_t state[4][AES_NB])
{
for (uint32_t i = 0; i < 4; i++) {
@ -474,10 +425,7 @@ void AES::subBytes(uint8_t state[4][AES_NB])
}
}
/// <summary>
///
/// </summary>
/// <param name="state"></param>
/* */
void AES::invSubBytes(uint8_t state[4][AES_NB])
{
for (uint32_t i = 0; i < 4; i++) {
@ -488,12 +436,7 @@ void AES::invSubBytes(uint8_t state[4][AES_NB])
}
}
/// <summary>
/// Shift row i on n positions.
/// </summary>
/// <param name="state"></param>
/// <param name="i"></param>
/// <param name="n"></param>
/* Shift row i on n positions. */
void AES::shiftRow(uint8_t state[4][AES_NB], uint32_t i, uint32_t n)
{
uint8_t tmp[AES_NB];
@ -503,10 +446,7 @@ void AES::shiftRow(uint8_t state[4][AES_NB], uint32_t i, uint32_t n)
memcpy(state[i], tmp, AES_NB * sizeof(uint8_t));
}
/// <summary>
///
/// </summary>
/// <param name="state"></param>
/* */
void AES::shiftRows(uint8_t state[4][AES_NB])
{
shiftRow(state, 1, 1);
@ -514,10 +454,7 @@ void AES::shiftRows(uint8_t state[4][AES_NB])
shiftRow(state, 3, 3);
}
/// <summary>
///
/// </summary>
/// <param name="state"></param>
/* */
void AES::invShiftRows(uint8_t state[4][AES_NB])
{
shiftRow(state, 1, AES_NB - 1);
@ -525,10 +462,7 @@ void AES::invShiftRows(uint8_t state[4][AES_NB])
shiftRow(state, 3, AES_NB - 3);
}
/// <summary>
///
/// </summary>
/// <param name="state"></param>
/* */
void AES::mixColumns(uint8_t state[4][AES_NB]) {
uint8_t tempState[4][AES_NB];
for (size_t i = 0; i < 4; ++i) {
@ -551,10 +485,7 @@ void AES::mixColumns(uint8_t state[4][AES_NB]) {
}
}
/// <summary>
///
/// </summary>
/// <param name="state"></param>
/* */
void AES::invMixColumns(uint8_t state[4][AES_NB]) {
uint8_t tempState[4][AES_NB];
for (size_t i = 0; i < 4; ++i) {
@ -574,11 +505,7 @@ void AES::invMixColumns(uint8_t state[4][AES_NB]) {
}
}
/// <summary>
///
/// </summary>
/// <param name="state"></param>
/// <param name="key"></param>
/* */
void AES::addRoundKey(uint8_t state[4][AES_NB], uint8_t* key)
{
for (uint32_t i = 0; i < 4; i++) {
@ -588,10 +515,7 @@ void AES::addRoundKey(uint8_t state[4][AES_NB], uint8_t* key)
}
}
/// <summary>
///
/// </summary>
/// <param name="a"></param>
/* */
void AES::subWord(uint8_t* a)
{
for (uint32_t i = 0; i < 4; i++) {
@ -599,10 +523,7 @@ void AES::subWord(uint8_t* a)
}
}
/// <summary>
///
/// </summary>
/// <param name="a"></param>
/* */
void AES::rotWord(uint8_t* a)
{
uint8_t c = a[0];
@ -612,12 +533,7 @@ void AES::rotWord(uint8_t* a)
a[3] = c;
}
/// <summary>
///
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="c"></param>
/* */
void AES::xorWords(uint8_t* a, uint8_t* b, uint8_t* c)
{
for (uint32_t i = 0; i < 4; i++) {
@ -625,11 +541,7 @@ void AES::xorWords(uint8_t* a, uint8_t* b, uint8_t* c)
}
}
/// <summary>
///
/// </summary>
/// <param name="a"></param>
/// <param name="n"></param>
/* */
void AES::rCon(uint8_t *a, uint32_t n)
{
uint8_t c = 1;
@ -641,11 +553,7 @@ void AES::rCon(uint8_t *a, uint32_t n)
a[1] = a[2] = a[3] = 0;
}
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="w"></param>
/* */
void AES::keyExpansion(const uint8_t key[], uint8_t w[]) {
uint8_t temp[4], rcon[4];
@ -679,12 +587,7 @@ void AES::keyExpansion(const uint8_t key[], uint8_t w[]) {
}
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="out"></param>
/// <param name="roundKeys"></param>
/* */
void AES::encryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys)
{
uint8_t state[4][AES_NB];
@ -714,12 +617,7 @@ void AES::encryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys)
}
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="out"></param>
/// <param name="roundKeys"></param>
/* */
void AES::decryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys)
{
uint8_t state[4][AES_NB];
@ -749,13 +647,7 @@ void AES::decryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys)
}
}
/// <summary>
///
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="c"></param>
/// <param name="len"></param>
/* */
void AES::xorBlocks(const uint8_t *a, const uint8_t *b, uint8_t *c, uint32_t len)
{
for (uint32_t i = 0; i < len; i++) {

@ -1,17 +1,23 @@
// SPDX-License-Identifier: MIT
/*
* Digital Voice Modem - Common Library
* MIT Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2019 SergeyBel
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* MIT Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom C++ AES (https://github.com/SergeyBel/AES)
* @license MIT License (https://opensource.org/license/MIT)
*
* Copyright (C) 2019 SergeyBel
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
* @defgroup crypto Cryptography
* @brief Defines and implements cryptography routines.
* @ingroup common
*
* @file AESCrypto.h
* @ingroup crypto
* @file AESCrypto.cpp
* @ingroup crypto
*/
#if !defined(__AES_CRYPTO_H__)
#define __AES_CRYPTO_H__
@ -26,32 +32,80 @@ namespace crypto
const uint8_t AES_NB = 4;
/**
* AES Key Length
* @brief Enumeration of AES key lengths.
* @ingroup crypto
*/
enum class AESKeyLength { AES_128, AES_192, AES_256 };
// ---------------------------------------------------------------------------
// Class Declaration
// Implements the AES encryption algorithm.
// ---------------------------------------------------------------------------
/**
* @brief Advanced Encryption Standard Algorithm.
* @ingroup crypto
*/
class HOST_SW_API AES {
public:
/// <summary>Initializes a new instance of the AES class.</summary>
/**
* @brief Initializes a new instance of the AES class.
* @param keyLength Encryption key length from the AESKeyLength enumeration.
*/
explicit AES(const AESKeyLength keyLength = AESKeyLength::AES_256);
/// <summary></summary>
/**
* @brief Encrypt input buffer with given key in AES-ECB.
* @param in Input buffer.
* @param inLen Input buffer length.
* @param key Encryption key.
* @returns uint8_t* Encrypted input buffer.
*/
uint8_t* encryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[]);
/// <summary></summary>
/**
* @brief Decrypt input buffer with the given key in AES-ECB.
* @param in Input buffer.
* @param inLen Input buffer length.
* @param key Encryption key.
* @returns uint8_t* Decrypted input buffer.
*/
uint8_t* decryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[]);
/// <summary></summary>
/**
* @brief Encrypt input buffer with given key and IV in AES-CBC.
* @param in Input buffer.
* @param inLen Input buffer length.
* @param key Encryption key.
* @param iv Initialization Vector buffer.
* @return uint8_t* Encrypted input buffer.
*/
uint8_t* encryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t* iv);
/// <summary></summary>
/**
* @brief Decrypt input buffer with given key and IV in AES-CBC.
* @param in Input buffer.
* @param inLen Input buffer length.
* @param key Encryption key.
* @param iv Initialization Vector buffer.
* @return uint8_t* Decrypted input buffer.
*/
uint8_t* decryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t* iv);
/// <summary></summary>
/**
* @brief Encrypt input buffer with given key and IV in AES-CFB.
* @param in Input buffer.
* @param inLen Input buffer length.
* @param key Encryption key.
* @param iv Initialization Vector buffer.
* @return uint8_t* Encrypted input buffer.
*/
uint8_t* encryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t* iv);
/// <summary></summary>
/**
* @brief Decrypt input buffer with given key and IV in AES-CFB.
* @param in Input buffer.
* @param inLen Input buffer length.
* @param key Encryption key.
* @param iv Initialization Vector buffer.
* @return uint8_t* Decrypted input buffer.
*/
uint8_t* decryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t* iv);
static constexpr uint32_t BLOCK_BYTES_LEN = 4 * AES_NB * sizeof(uint8_t);

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "Clock.h"
#include "Log.h"
@ -29,12 +26,7 @@ static const uint64_t NTP_SCALE_FRAC = 4294967296ULL;
// Global Functions
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="older"></param>
/// <param name="newer"></param>
/// <returns></returns>
/* */
static inline uint32_t ntpDiffMS(uint64_t older, uint64_t newer)
{
if (older > newer) {
@ -56,10 +48,7 @@ static inline uint32_t ntpDiffMS(uint64_t older, uint64_t newer)
return (uint32_t)r;
}
/// <summary>
/// Get current time in NTP units.
/// </summary>
/// <returns>NTP timestamp.</returns>
/* Get current time in NTP units. */
uint64_t ntp::now()
{
struct timeval tv;
@ -71,92 +60,59 @@ uint64_t ntp::now()
return (tv_ntp << 32) | tv_usecs;
}
/// <summary>
/// Calculate the time difference of two NTP times.
/// </summary>
/// <param name="ntp1">First NTP timestamp</param>
/// <param name="ntp2">Second NTP timestamp</param>
/// <returns>Difference of the timestamps in milliseconds.</returns>
/* Calculate the time difference of two NTP times. */
uint64_t ntp::diff(uint64_t ntp1, uint64_t ntp2)
{
return ntpDiffMS(ntp1, ntp2);
}
/// <summary>
/// Calculate the time difference of two NTP times.
///
/// This function calls clock::ntp::now() and then subtracts the input
/// parameter from that timestamp value.
/// </summary>
/// <param name="then">NTP timestamp</param>
/// <returns>Difference of the timestamps in milliseconds.</returns>
/*
* Calculate the time difference of two NTP times.
* This function calls clock::ntp::now() and then subtracts the input parameter from that timestamp value.
*/
uint64_t ntp::diffNow(uint64_t then)
{
uint64_t now = ntp::now();
return ntpDiffMS(then, now);
}
/// <summary>
/// Get current time in HRC units.
/// </summary>
/// <returns>NTP timestamp.</returns>
/* Get current time in HRC units. */
hrc::hrc_t hrc::now()
{
return std::chrono::high_resolution_clock::now();
}
/// <summary>
/// Calculate the time difference of two HRC times.
/// </summary>
/// <param name="hrc1">First HRC timestamp</param>
/// <param name="hrc2">Second HRC timestamp</param>
/// <returns>Difference of the timestamps in milliseconds.</returns>
/* Calculate the time difference of two HRC times. */
uint64_t hrc::diff(hrc::hrc_t hrc1, hrc::hrc_t hrc2)
{
return std::chrono::duration_cast<std::chrono::milliseconds>(hrc1 - hrc2).count();
}
/// <summary>
/// Calculate the time difference of two HRC times.
///
/// This function calls clock::hrc::now() and then subtracts the input
/// parameter from that timestamp value.
/// </summary>
/// <param name="then">HRC timestamp</param>
/// <returns>Difference of the timestamps in milliseconds.</returns>
/*
* Calculate the time difference of two HRC times.
* This function calls clock::hrc::now() and then subtracts the input parameter from that timestamp value.
*/
uint64_t hrc::diffNow(hrc::hrc_t then)
{
return (uint64_t)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - then).count();
}
/// <summary>
/// Calculate the time difference of two HRC times.
///
/// This function calls clock::hrc::now() and then subtracts the input
/// parameter from that timestamp value.
/// </summary>
/// <param name="then">HRC timestamp</param>
/// <returns>Difference of the timestamps in microseconds.</returns>
/*
* Calculate the time difference of two HRC times.
* This function calls clock::hrc::now() and then subtracts the input parameter from that timestamp value.
*/
uint64_t hrc::diffNowUS(hrc::hrc_t& then)
{
return (uint64_t)std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - then).count();
}
/// <summary>
///
/// </summary>
/// <param name="ms"></param>
/// <returns></returns>
/* Convert milliseconds to jiffies. */
uint64_t system_clock::msToJiffies(uint64_t ms)
{
return (uint64_t)(((double)ms / 1000) * 65536);
}
/// <summary>
///
/// </summary>
/// <param name="ms"></param>
/// <returns></returns>
/* Convert jiffies to milliseconds. */
uint64_t system_clock::jiffiesToMs(uint64_t jiffies)
{
return (uint64_t)(((double)jiffies / 65536) * 1000);

@ -1,15 +1,22 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
* @defgroup system_clock Clock Routines
* @brief Defines and implements common high-resolution system clock routines.
* @ingroup common
*
* @file Clock.h
* @ingroup system_clock
* @file Clock.cpp
* @ingroup system_clock
*/
#if !defined(__CLOCK_H__)
#define __CLOCK_H__
@ -23,36 +30,83 @@ namespace system_clock
/*
** Network Time Protocol
*/
namespace ntp
{
/// <summary>Get current time in NTP units.</summary>
/**
* @brief Get current time in NTP units.
* @ingroup system_clock
* @returns uint64_t Current time in NTP units.
*/
uint64_t now();
/// <summary>Calculate the time difference of two NTP times.</summary>
/**
* @brief Calculate the time difference of two NTP times.
* @ingroup system_clock
* @param ntp1 Time in NTP units to compare.
* @param ntp2 Time in NTP units to compare.
* @returns uint64_t Difference in NTP units between ntp1 and ntp2.
*/
uint64_t diff(uint64_t ntp1, uint64_t ntp2);
/// <summary>Calculate the time difference of two NTP times.</summary>
/**
* @brief Calculate the time difference the given NTP time and now.
* @ingroup system_clock
* @param then Time in NTP units to compare.
* @returns uint64_t Difference in NTP units between now and then.
*/
uint64_t diffNow(uint64_t then);
} // namespace ntp
/*
** High-Resolution Clock
*/
namespace hrc
{
typedef std::chrono::high_resolution_clock::time_point hrc_t;
/// <summary>Get current time in HRC units.</summary>
/**
* @brief Get current time in HRC units.
* @ingroup system_clock
* @returns hrc_t Current time in HRC units.
*/
hrc_t now();
/// <summary>Calculate the time difference of two HRC times.</summary>
/**
* @brief Calculate the time difference of two HRC times.
* @ingroup system_clock
* @param hrc1 Time in HRC units to compare.
* @param hrc2 Time in HRC units to compare.
* @returns uint64_t Difference in HRC units between hrc1 and hrc2.
*/
uint64_t diff(hrc_t hrc1, hrc_t hrc2);
/// <summary>Calculate the time difference of two HRC times.</summary>
/**
* @brief Calculate the time difference the given HRC time and now.
* @ingroup system_clock
* @param then Time in HRC units to compare.
* @returns uint64_t Difference in HRC units between now and then.
*/
uint64_t diffNow(hrc_t then);
/// <summary>Calculate the time difference of two HRC times.</summary>
/**
* @brief Calculate the time difference the given HRC time and now in microseconds.
* @ingroup system_clock
* @param then Time in HRC units to compare.
* @returns uint64_t Difference in HRC units between now and then.
*/
uint64_t diffNowUS(hrc_t& then);
} // namespace hrc
/// <summary></summary>
/**
* @brief Convert milliseconds to jiffies.
* @ingroup system_clock
* @param ms Milliseconds.
* @returns uint64_t Milliseconds in jiffies.
*/
uint64_t msToJiffies(uint64_t ms);
/// <summary></summary>
/**
* @brief Convert jiffies to milliseconds.
* @ingroup system_clock
* @param jiffies Jiffies.
* @returns uint64_t Jiffes in miilliseconds.
*/
uint64_t jiffiesToMs(uint64_t jiffies);
} // namespace system_clock

@ -1,17 +1,26 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2024 Bryan Biedenkapp, N2PLL
*
*/
* @defgroup common Common Library
* @brief Digital Voice Modem - Common Library
* @details This library implements common core code used by the majority of dvmhost projects.
* @ingroup common
*
* @defgroup edac Error Detection and Correction
* @brief Implementation for various Error Detection and Correction methods.
* @ingroup common
*
* @file Defines.h
* @ingroup common
*/
#if !defined(__COMMON_DEFINES_H__)
#define __COMMON_DEFINES_H__
@ -74,6 +83,16 @@ typedef long long long64_t;
typedef unsigned long long ulong64_t;
#endif // __ULONG64_TYPE__
#if defined(__GNUC__) || defined(__GNUG__)
#define __forceinline __attribute__((always_inline))
#endif
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__GNUC__) || defined(__GNUG__)
#define PACK(decl) decl __attribute__((__packed__))
#else
#define PACK(decl) __pragma(pack(push, 1)) decl __pragma(pack(pop))
#endif
// ---------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------
@ -112,19 +131,14 @@ typedef unsigned long long ulong64_t;
#define HOST_SW_API
/**
* @addtogroup common
* @{
*/
#define DEFAULT_CONF_FILE "config.yml"
#define DEFAULT_LOCK_FILE "/tmp/dvm.lock"
#if defined(__GNUC__) || defined(__GNUG__)
#define __forceinline __attribute__((always_inline))
#endif
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__GNUC__) || defined(__GNUG__)
#define PACK(decl) decl __attribute__((__packed__))
#else
#define PACK(decl) __pragma(pack(push, 1)) decl __pragma(pack(pop))
#endif
#define NULL_PORT "null"
#define UART_PORT "uart"
#define PTY_PORT "pty"
@ -133,29 +147,36 @@ const uint32_t REMOTE_MODEM_PORT = 3334;
const uint32_t TRAFFIC_DEFAULT_PORT = 62031;
const uint32_t REST_API_DEFAULT_PORT = 9990;
const uint8_t BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U };
/**
* @brief Operational Host States
*/
enum HOST_STATE {
FNE_STATE = 240U,
FNE_STATE = 240U, //! FNE (only used by dvmfne)
HOST_STATE_LOCKOUT = 250U,
HOST_STATE_ERROR = 254U,
HOST_STATE_QUIT = 255U,
HOST_STATE_LOCKOUT = 250U, //! Lockout (dvmhost traffic lockout state)
HOST_STATE_ERROR = 254U, //! Error (dvmhost error state)
HOST_STATE_QUIT = 255U, //! Quit (dvmhost quit state)
};
/**
* @brief Operational RF States
*/
enum RPT_RF_STATE {
RS_RF_LISTENING,
RS_RF_LATE_ENTRY,
RS_RF_AUDIO,
RS_RF_DATA,
RS_RF_REJECTED,
RS_RF_INVALID
RS_RF_LISTENING, //! Modem Listening
RS_RF_LATE_ENTRY, //! Traffic Late Entry
RS_RF_AUDIO, //! Audio
RS_RF_DATA, //! Data
RS_RF_REJECTED, //! Traffic Rejected
RS_RF_INVALID //! Traffic Invalid
};
/**
* @brief Operational Network States
*/
enum RPT_NET_STATE {
RS_NET_IDLE,
RS_NET_AUDIO,
RS_NET_DATA
RS_NET_IDLE, //! Idle
RS_NET_AUDIO, //! Audio
RS_NET_DATA //! Data
};
const uint8_t UDP_COMPRESS_NONE = 0x00U;
@ -171,8 +192,12 @@ const uint8_t IP_COMPRESS_RFC1144_UNCOMPRESS = 0x02U;
/**
* Class Copy Code Pattern
*/
/// <summary>Creates a private copy implementation.</summary>
/// <remarks>This requires the copy(const type& data) to be declared in the class definition.</remarks>
/**
* @brief Creates a private copy implementation.
* This requires the copy(const type& data) to be declared in the class definition.
* @param type Atomic type.
*/
#define __COPY(type) \
private: virtual void copy(const type& data); \
public: __forceinline type& operator=(const type& data) { \
@ -181,8 +206,11 @@ const uint8_t IP_COMPRESS_RFC1144_UNCOMPRESS = 0x02U;
} \
return *this; \
}
/// <summary>Creates a protected copy implementation.</summary>
/// <remarks>This requires the copy(const type& data) to be declared in the class definition.</remarks>
/**
* @brief Creates a protected copy implementation.
* This requires the copy(const type& data) to be declared in the class definition.
* @param type Atomic type.
*/
#define __PROTECTED_COPY(type) \
protected: virtual void copy(const type& data); \
public: __forceinline type& operator=(const type& data) { \
@ -196,44 +224,82 @@ const uint8_t IP_COMPRESS_RFC1144_UNCOMPRESS = 0x02U;
* Property Creation
* These macros should always be used LAST in the "public" section of a class definition.
*/
/// <summary>Creates a read-only get property.</summary>
/**
* @brief Creates a read-only get property.
* @param type Atomic type for property.
* @param variableName Variable name for property.
* @param propName Property name.
*/
#define __READONLY_PROPERTY(type, variableName, propName) \
private: type m_##variableName; \
public: __forceinline type get##propName(void) const { return m_##variableName; }
/// <summary>Creates a read-only get property.</summary>
/**
* @brief Creates a read-only get property.
* @param type Atomic type for property.
* @param variableName Variable name for property.
* @param propName Property name.
*/
#define __PROTECTED_READONLY_PROPERTY(type, variableName, propName) \
protected: type m_##variableName; \
public: __forceinline type get##propName(void) const { return m_##variableName; }
/// <summary>Creates a read-only get property, does not use "get".</summary>
/**
* @brief Creates a read-only get property, does not use "get".
* @param type Atomic type for property.
* @param variableName Variable name for property.
*/
#define __PROTECTED_READONLY_PROPERTY_PLAIN(type, variableName) \
protected: type m_##variableName; \
public: __forceinline type variableName(void) const { return m_##variableName; }
/// <summary>Creates a read-only get property, does not use "get".</summary>
/**
* @brief Creates a read-only get property, does not use "get".
* @param type Atomic type for property.
* @param variableName Variable name for property.
*/
#define __READONLY_PROPERTY_PLAIN(type, variableName) \
private: type m_##variableName; \
public: __forceinline type variableName(void) const { return m_##variableName; }
/// <summary>Creates a get and set private property.</summary>
/**
* @brief Creates a get and set private property.
* @param type Atomic type for property.
* @param variableName Variable name for property.
* @param propName Property name.
*/
#define __PROPERTY(type, variableName, propName) \
private: type m_##variableName; \
public: __forceinline type get##propName(void) const { return m_##variableName; } \
__forceinline void set##propName(type val) { m_##variableName = val; }
/// <summary>Creates a get and set protected property.</summary>
/**
* @brief Creates a get and set protected property.
* @param type Atomic type for property.
* @param variableName Variable name for property.
* @param propName Property name.
*/
#define __PROTECTED_PROPERTY(type, variableName, propName) \
protected: type m_##variableName; \
public: __forceinline type get##propName(void) const { return m_##variableName; } \
__forceinline void set##propName(type val) { m_##variableName = val; }
/// <summary>Creates a get and set private property, does not use "get"/"set".</summary>
/**
* @brief Creates a get and set private property, does not use "get"/"set".
* @param type Atomic type for property.
* @param variableName Variable name for property.
*/
#define __PROPERTY_PLAIN(type, variableName) \
private: type m_##variableName; \
public: __forceinline type variableName(void) const { return m_##variableName; }\
__forceinline void variableName(type val) { m_##variableName = val; }
/// <summary>Creates a get and set protected property, does not use "get"/"set".</summary>
/**
* @brief Creates a get and set protected property, does not use "get"/"set".
* @param type Atomic type for property.
* @param variableName Variable name for property.
*/
#define __PROTECTED_PROPERTY_PLAIN(type, variableName) \
protected: type m_##variableName; \
public: __forceinline type variableName(void) const { return m_##variableName; }\
__forceinline void variableName(type val) { m_##variableName = val; }
/** @} */
#endif // __COMMON_DEFINES_H__

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Log.h"
#include "network/BaseNetwork.h"
@ -65,28 +61,16 @@ static char LEVELS[] = " DMIWEF";
// Global Functions
// ---------------------------------------------------------------------------
/// <summary>
/// Helper to get the current log file level.
/// </summary>
/// <returns></returns>
/* Helper to get the current log file level. */
uint32_t CurrentLogFileLevel() { return m_fileLevel; }
/// <summary>
/// Helper to get the current log file path.
/// </summary>
/// <returns></returns>
/* Helper to get the current log file path. */
std::string LogGetFilePath() { return m_filePath; }
/// <summary>
/// Helper to get the current log file root.
/// </summary>
/// <returns></returns>
/* Helper to get the current log file root. */
std::string LogGetFileRoot() { return m_fileRoot; }
/// <summary>
/// Helper to open the detailed log file, file handle.
/// </summary>
/// <returns>True, if log file is opened, otherwise false.
/* Helper to open the detailed log file, file handle. */
static bool LogOpen()
{
#if defined(CATCH2_TEST_COMPILATION)
@ -143,26 +127,20 @@ static bool LogOpen()
}
}
/// <summary>
/// Internal helper to set an output stream to direct logging to.
/// </summary>
/// <param name="stream"></param>
/* Internal helper to set an output stream to direct logging to. */
void __InternalOutputStream(std::ostream& stream)
{
m_outStream.rdbuf(stream.rdbuf());
}
/// <summary>Gets the instance of the Network class to transfer the activity log with.</summary>
/* Gets the instance of the Network class to transfer the activity log with. */
void* LogGetNetwork()
{
// NO GOOD, VERY BAD, TERRIBLE HACK
return (void*)m_network;
}
/// <summary>
/// Sets the instance of the Network class to transfer the activity log with.
/// </summary>
/// <param name="network">Instance of the Network class.</param>
/* Sets the instance of the Network class to transfer the activity log with. */
void LogSetNetwork(void* network)
{
#if defined(CATCH2_TEST_COMPILATION)
@ -173,15 +151,7 @@ void LogSetNetwork(void* network)
m_network = (network::BaseNetwork*)network;
}
/// <summary>
/// Initializes the diagnostics log.
/// </summary>
/// <param name="filePath">Full-path to the detailed log file.</param>
/// <param name="fileRoot">Prefix of the detailed log file name.</param>
/// <param name="fileLevel">File logging level.</param>
/// <param name="displayLevel">Console logging level.</param>
/// <param name="disableTimeDisplay">Disable display of date/time on the console log.</param>
/// <param name="useSyslog">Flag indicating whether or not logging should be sent to the syslog.</param>
/* Initializes the diagnostics log. */
bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uint32_t fileLevel, uint32_t displayLevel, bool disableTimeDisplay, bool useSyslog)
{
m_filePath = filePath;
@ -194,9 +164,7 @@ bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uin
return ::LogOpen();
}
/// <summary>
/// Finalizes the diagnostics log.
/// </summary>
/* Finalizes the diagnostics log. */
void LogFinalise()
{
#if defined(CATCH2_TEST_COMPILATION)
@ -208,13 +176,7 @@ void LogFinalise()
closelog();
}
/// <summary>
/// Writes a new entry to the diagnostics log.
/// </summary>
/// <remarks>This is a variable argument function.</remarks>
/// <param name="level">Log level.</param>
/// <param name="module">Module name the log entry was genearted from.</param>
/// <param name="fmt">Formatted string to write to the log.</param>
/* Writes a new entry to the diagnostics log. */
void Log(uint32_t level, const char *module, const char* fmt, ...)
{
assert(fmt != nullptr);

@ -1,17 +1,23 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2024 Bryan Biedenkapp, N2PLL
*
*/
* @defgroup logging Logging Routines
* @brief Defines and implements logging routines.
* @ingroup common
*
* @file Log.h
* @ingroup logging
* @file Log.cpp
* @ingroup logging
*/
#if !defined(__LOG_H__)
#define __LOG_H__
@ -19,10 +25,17 @@
#include <string>
/**
* @addtogroup logging
* @{
*/
// ---------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------
/** @cond */
#define LOG_HOST "HOST"
#define LOG_REST "RESTAPI"
#define LOG_MODEM "MODEM"
@ -35,51 +48,148 @@
#define LOG_SETUP "SETUP"
#define LOG_SERIAL "SERIAL"
/** @endcond */
// ---------------------------------------------------------------------------
// Macros
// ---------------------------------------------------------------------------
/**
* @brief Macro helper to create a debug log entry.
* @param _module Name of module generating log entry.
* @param fmt String format.
*
* This is a variable argument function.
*/
#define LogDebug(_module, fmt, ...) Log(1U, _module, fmt, ##__VA_ARGS__)
/**
* @brief Macro helper to create a message log entry.
* @param _module Name of module generating log entry.
* @param fmt String format.
*
* This is a variable argument function.
*/
#define LogMessage(_module, fmt, ...) Log(2U, _module, fmt, ##__VA_ARGS__)
/**
* @brief Macro helper to create a informational log entry.
* @param _module Name of module generating log entry.
* @param fmt String format.
*
* This is a variable argument function. LogInfo() does not use a module
* name when creating a log entry.
*/
#define LogInfo(fmt, ...) Log(3U, nullptr, fmt, ##__VA_ARGS__)
/**
* @brief Macro helper to create a informational log entry with module name.
* @param _module Name of module generating log entry.
* @param fmt String format.
*
* This is a variable argument function.
*/
#define LogInfoEx(_module, fmt, ...) Log(3U, _module, fmt, ##__VA_ARGS__)
/**
* @brief Macro helper to create a warning log entry.
* @param _module Name of module generating log entry.
* @param fmt String format.
*
* This is a variable argument function.
*/
#define LogWarning(_module, fmt, ...) Log(4U, _module, fmt, ##__VA_ARGS__)
/**
* @brief Macro helper to create a error log entry.
* @param _module Name of module generating log entry.
* @param fmt String format.
*
* This is a variable argument function.
*/
#define LogError(_module, fmt, ...) Log(5U, _module, fmt, ##__VA_ARGS__)
/**
* @brief Macro helper to create a fatal log entry.
* @param _module Name of module generating log entry.
* @param fmt String format.
*
* This is a variable argument function.
*/
#define LogFatal(_module, fmt, ...) Log(6U, _module, fmt, ##__VA_ARGS__)
// ---------------------------------------------------------------------------
// Externs
// ---------------------------------------------------------------------------
/**
* @brief (Global) Display log level.
*/
extern uint32_t g_logDisplayLevel;
/**
* @brief (Global) Flag for displaying timestamps on log entries (does not apply to syslog logging).
*/
extern bool g_disableTimeDisplay;
/**
* @brief (Global) Flag indicating whether or not logging goes to the syslog.
*/
extern bool g_useSyslog;
// ---------------------------------------------------------------------------
// Global Functions
// ---------------------------------------------------------------------------
/// <summary>Internal helper to set an output stream to direct logging to.</summary>
/**
* @brief Internal helper to set an output stream to direct logging to.
* @param stream
*/
extern HOST_SW_API void __InternalOutputStream(std::ostream& stream);
/// <summary>Helper to get the current log file level.</summary>
/**
* @brief Helper to get the current log file level.
* @returns uint32_t Current log file level.
*/
extern HOST_SW_API uint32_t CurrentLogFileLevel();
/// <summary>Helper to get the current log file path.</summary>
/**
* @brief Helper to get the current log file path.
* @returns std::string Current log file path.
*/
extern HOST_SW_API std::string LogGetFilePath();
/// <summary>Helper to get the current log file root.</summary>
/**
* @brief Helper to get the current log file root.
* @returns std::string Current log file root.
*/
extern HOST_SW_API std::string LogGetFileRoot();
/// <summary>Gets the instance of the Network class to transfer the activity log with.</summary>
/**
* @brief Gets the instance of the Network class to transfer the activity log with.
* @returns void*
*/
extern HOST_SW_API void* LogGetNetwork();
/// <summary>Sets the instance of the Network class to transfer the activity log with.</summary>
/**
* @brief Sets the instance of the Network class to transfer the activity log with.
* @param network
*/
extern HOST_SW_API void LogSetNetwork(void* network);
/// <summary>Initializes the diagnostics log.</summary>
/**
* @brief Initializes the diagnostics log.
* @param filePath File path for the log file.
* @param fileRoot Root name for log file.
* @param fileLevel File log level.
* @param displaylevel Display log level.
* @param displayTimeDisplay Flag to disable the date and time stamp for the log entries.
* @param syslog Flag indicating whether or not logs will be sent to syslog.
* @returns
*/
extern HOST_SW_API bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uint32_t fileLevel, uint32_t displayLevel, bool disableTimeDisplay = false, bool useSyslog = false);
/// <summary>Finalizes the diagnostics log.</summary>
/**
* @brief Finalizes the diagnostics log.
*/
extern HOST_SW_API void LogFinalise();
/// <summary>Writes a new entry to the diagnostics log.</summary>
/**
* @brief Writes a new entry to the diagnostics log.
* @param level Log level for entry.
* @param module Name of module generating log entry.
* @param fmt String format.
*
* This is a variable argument function.
*/
extern HOST_SW_API void Log(uint32_t level, const char* module, const char* fmt, ...);
/** @} */
#endif // __LOG_H__

@ -1,16 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2006-2009,2012,2013,2015,2016 Jonathan Naylor, G4KLX
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2006-2009,2012,2013,2015,2016 Jonathan Naylor, G4KLX
*
*/
* @file Ringbuffer.h
* @ingroup common
*/
#if !defined(__RING_BUFFER_H__)
#define __RING_BUFFER_H__
@ -23,15 +23,21 @@
// ---------------------------------------------------------------------------
// Class Declaration
// Implements a circular buffer for storing data.
// ---------------------------------------------------------------------------
/**
* @brief Cirular buffer for storing data.
* @ingroup common
* @tparam T Type of data to store in RingBuffer.
*/
template<class T>
class HOST_SW_API RingBuffer {
public:
/// <summary>Initializes a new instance of the RingBuffer class.</summary>
/// <param name="length">Length of ring buffer.</param>
/// <param name="name">Name of buffer.</param>
/**
* @brief Initializes a new instance of the RingBuffer class.
* @param length Length of ring buffer.
* @param name Name of buffer.
*/
RingBuffer(uint32_t length, const char* name) :
m_length(length),
m_name(name),
@ -45,16 +51,20 @@ public:
::memset(m_buffer, 0x00, m_length * sizeof(T));
}
/// <summary>Finalizes a instance of the RingBuffer class.</summary>
/**
* @brief Finalizes a instance of the RingBuffer class.
*/
~RingBuffer()
{
delete[] m_buffer;
}
/// <summary>Adds data to the end of the ring buffer.</summary>
/// <param name="buffer">Data buffer.</param>
/// <param name="length">Length of data in buffer.</param>
/// <returns>True, if data is added to ring buffer, otherwise false.</returns>
/**
* @brief Adds data to the end of the ring buffer.
* @param buffer Data buffer.
* @param length Length of data in buffer.
* @return bool True, if data is added to ring buffer, otherwise false.
*/
bool addData(const T* buffer, uint32_t length)
{
if (length > freeSpace()) {
@ -77,10 +87,12 @@ public:
return true;
}
/// <summary>Gets data from the ring buffer.</summary>
/// <param name="buffer">Buffer to write data to be retrieved.</param>
/// <param name="length">Length of data to retrieve.</param>
/// <returns>True, if data is read from ring buffer, otherwise false.</returns>
/**
* @brief Gets data from the ring buffer.
* @param buffer Buffer to write data to be retrieved.
* @param length Length of data to retrieve.
* @return bool True, if data is read from ring buffer, otherwise false.
*/
bool get(T* buffer, uint32_t length)
{
if (dataSize() < length) {
@ -102,10 +114,12 @@ public:
return true;
}
/// <summary>Gets data from ring buffer without moving buffer pointers.</summary>
/// <param name="buffer">Buffer to write data to be retrieved.</param>
/// <param name="length">Length of data to retrieve.</param>
/// <returns>True, if data is read from ring buffer, otherwise false.</returns>
/**
* @brief Gets data from ring buffer without moving buffer pointers.
* @param buffer Buffer to write data to be retrieved.
* @param length Length of data to retrieve.
* @return bool True, if data is read from ring buffer, otherwise false.
*/
bool peek(T* buffer, uint32_t length)
{
if (dataSize() < length) {
@ -124,7 +138,9 @@ public:
return true;
}
/// <summary>Clears ring buffer and resets data pointers.</summary>
/**
* @brief Clears ring buffer and resets data pointers.
*/
void clear()
{
m_iPtr = 0U;
@ -133,8 +149,10 @@ public:
::memset(m_buffer, 0x00, m_length * sizeof(T));
}
/// <summary>Resizes the ring buffer to the specified length.</summary>
/// <param name="length">New length of the ring buffer.</param>
/**
* @brief Resizes the ring buffer to the specified length.
* @param length New length of the ring buffer.
*/
void resize(uint32_t length)
{
clear();
@ -147,8 +165,10 @@ public:
clear();
}
/// <summary>Returns the currently available space in the ring buffer.</summary>
/// <returns>Space free in the ring buffer.</returns>
/**
* @brief Returns the currently available space in the ring buffer.
* @return uint32_t Space free in the ring buffer.
*/
uint32_t freeSpace() const
{
uint32_t len = m_length;
@ -164,36 +184,47 @@ public:
return len;
}
/// <summary>Returns the size of the data currently stored in the ring buffer.</summary>
/// <returns>Size of data stored in the ring buffer.</returns>
/**
* @brief Returns the size of the data currently stored in the ring buffer.
* @return uint32_t Size of data stored in the ring buffer.
*/
uint32_t dataSize() const
{
return m_length - freeSpace();
}
/// <summary>Gets the length of the ring buffer.</summary>
/// <returns>Length of ring buffer.</returns>
/**
* @brief Gets the length of the ring buffer.
* @return uint32_t Length of ring buffer.
*/
uint32_t length() const
{
return m_length;
}
/// <summary>Helper to test if the given length of data would fit in the ring buffer.</summary>
/// <returns>True, if specified length will fit in buffer, otherwise false.</returns>
/**
* @brief Helper to test if the given length of data would fit in the ring buffer.
* @param length Length to check.
* @return bool True, if specified length will fit in buffer, otherwise false.
*/
bool hasSpace(uint32_t length) const
{
return freeSpace() > length;
}
/// <summary>Helper to return whether the ring buffer contains data.</summary>
/// <returns>True, if ring buffer contains data, otherwise false.</returns>
/**
* @brief Helper to return whether the ring buffer contains data.
* @return bool True, if ring buffer contains data, otherwise false.
*/
bool hasData() const
{
return m_oPtr != m_iPtr;
}
/// <summary>Helper to return whether the ring buffer is empty or not.</summary>
/// <returns>True, if the ring buffer is empty, otherwise false.</returns>
/**
* @brief Helper to return whether the ring buffer is empty or not.
* @return bool True, if the ring buffer is empty, otherwise false.
*/
bool isEmpty() const
{
return m_oPtr == m_iPtr;

@ -1,16 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
#include "StopWatch.h"
#include <cstdio>
@ -20,27 +16,20 @@
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the StopWatch class.
/// </summary>
/* Initializes a new instance of the StopWatch class. */
StopWatch::StopWatch() :
m_startMS(0ULL)
{
/* stub */
}
/// <summary>
/// Finalizes a instance of the StopWatch class.
/// </summary>
/* Finalizes a instance of the StopWatch class. */
StopWatch::~StopWatch()
{
/* stub */
}
/// <summary>
/// Gets the current running time.
/// </summary>
/// <returns></returns>
/* Gets the current running time. */
ulong64_t StopWatch::time() const
{
struct timeval now;
@ -49,10 +38,7 @@ ulong64_t StopWatch::time() const
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
}
/// <summary>
/// Starts the stopwatch.
/// </summary>
/// <returns></returns>
/* Starts the stopwatch. */
ulong64_t StopWatch::start()
{
struct timespec now;
@ -63,10 +49,7 @@ ulong64_t StopWatch::start()
return m_startMS;
}
/// <summary>
/// Gets the elapsed time since the stopwatch started.
/// </summary>
/// <returns></returns>
/* Gets the elapsed time since the stopwatch started. */
uint32_t StopWatch::elapsed()
{
struct timespec now;

@ -1,16 +1,22 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
* @defgroup timers Timers
* @brief Defines and implements various timing routines.
* @ingroup common
*
* @file StopWatch.h
* @ingroup timers
* @file StopWatch.cpp
* @ingroup timers
*/
#if !defined(__STOPWATCH_H__)
#define __STOPWATCH_H__
@ -20,22 +26,38 @@
// ---------------------------------------------------------------------------
// Class Declaration
// Implements a stopwatch.
// ---------------------------------------------------------------------------
/**
* @brief StopWatch Provides a set of methods and properties that you can use to accurately measure elapsed time.
* @ingroup timers
*/
class HOST_SW_API StopWatch {
public:
/// <summary>Initializes a new instance of the StopWatch class.</summary>
/**
* @brief Initializes a new instance of the StopWatch class.
*/
StopWatch();
/// <summary>Finalizes a instance of the StopWatch class.</summary>
/**
* @brief Finalizes a instance of the StopWatch class.
*/
~StopWatch();
/// <summary>Gets the current running time.</summary>
/**
* @brief Gets the current running time.
* @returns ulong64_t Current running time.
*/
ulong64_t time() const;
/// <summary>Starts the stopwatch.</summary>
/**
* @brief Starts the Stopwatch.
* @returns ulong64_t Start time.
*/
ulong64_t start();
/// <summary>Gets the elapsed time since the stopwatch started.</summary>
/**
* @brief Gets the elapsed time since the Stopwatch started.
* @returns uint32_t Elapsed time since Stopwatch started.
*/
uint32_t elapsed();
private:

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
#include "Thread.h"
#include "Log.h"
@ -23,9 +19,7 @@
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the Thread class.
/// </summary>
/* Initializes a new instance of the Thread class. */
Thread::Thread() :
m_thread(),
m_started(false)
@ -33,15 +27,10 @@ Thread::Thread() :
/* stub */
}
/// <summary>
/// Finalizes a instance of the Thread class.
/// </summary>
/* Finalizes a instance of the Thread class. */
Thread::~Thread() = default;
/// <summary>
/// Starts the thread execution.
/// </summary>
/// <returns>True, if thread started, otherwise false.</returns>
/* Starts the thread execution. */
bool Thread::run()
{
if (m_started)
@ -57,18 +46,13 @@ bool Thread::run()
return true;
}
/// <summary>
/// Make calling thread wait for termination of the thread.
/// </summary>
/* Make calling thread wait for termination of the thread. */
void Thread::wait()
{
::pthread_join(m_thread, NULL);
}
/// <summary>
/// Set thread name visible in the kernel and its interfaces.
/// </summary>
/// <param name="name"></param>
/* Set thread name visible in the kernel and its interfaces. */
void Thread::setName(std::string name)
{
if (!m_started)
@ -80,12 +64,11 @@ void Thread::setName(std::string name)
#endif // _GNU_SOURCE
}
/// <summary>
/// Indicate that the thread is never to be joined with wait().
/// The resources of thread will therefore be freed immediately when it
/// terminates, instead of waiting for another thread to perform wait()
/// on it.
/// </summary>
/*
* Indicate that the thread is never to be joined with wait().
* The resources of thread will therefore be freed immediately when it terminates, instead
* of waiting for another thread to perform wait() on it.
*/
void Thread::detach()
{
if (!m_started)
@ -93,10 +76,7 @@ void Thread::detach()
::pthread_detach(m_thread);
}
/// <summary>
///
/// </summary>
/// <param name="ms"></param>
/* */
void Thread::sleep(uint32_t ms)
{
::usleep(ms * 1000);
@ -106,11 +86,7 @@ void Thread::sleep(uint32_t ms)
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper thats used as the entry point for the thread.
/// </summary>
/// <param name="arg"></param>
/// <returns></returns>
/* Internal helper thats used as the entry point for the thread. */
void* Thread::helper(void* arg)
{
Thread* p = (Thread*)arg;

@ -1,17 +1,23 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
* @defgroup threading Threading
* @brief Defines and implements threading routines.
* @ingroup common
* @file Thread.h
* @ingroup threading
* @file Thread.cpp
* @ingroup threading
*/
#if !defined(__THREAD_H__)
#define __THREAD_H__
@ -23,45 +29,71 @@
// ---------------------------------------------------------------------------
// Class Declaration
// Implements a simple threading mechanism.
// ---------------------------------------------------------------------------
/**
* @brief Creates and controls a thread.
* @ingroup threading
*/
class HOST_SW_API Thread {
public:
/// <summary>Initializes a new instance of the Thread class.</summary>
/**
* @brief Initializes a new instance of the Thread class.
*/
Thread();
/// <summary>Finalizes a instance of the Thread class.</summary>
/**
* @brief Finalizes a instance of the Thread class.
*/
virtual ~Thread();
/// <summary>Starts the thread execution.</summary>
/**
* @brief Starts the thread execution.
* @returns bool True, if thread started, otherwise false.
*/
virtual bool run();
/// <summary>User-defined function to run for the thread main.</summary>
/**
* @brief User-defined function to run for the thread main.
*/
virtual void entry() = 0;
/// <summary>Make calling thread wait for termination of the thread.</summary>
/**
* @brief Make calling thread wait for termination of the thread.
*/
virtual void wait();
/// <summary>Set thread name visible in the kernel and its interfaces.</summary>
/**
* @brief Set thread name visible in the kernel and its interfaces.
* @param name Textual name for thread.
*/
virtual void setName(std::string name);
/// <summary>Indicate that the thread is never to be joined with wait().
/// The resources of thread will therefore be freed immediately when it
/// terminates, instead of waiting for another thread to perform wait()
/// on it.</summary>
/**
* @brief The resources of thread will therefore be freed immediately when it
* terminates, instead of waiting for another thread to perform wait()
*/
virtual void detach();
/// <summary></summary>
/**
* @brief Helper to sleep the current thread.
* @param ms Time in milliseconds to sleep.
*/
static void sleep(uint32_t ms);
private:
pthread_t m_thread;
/// <summary>Internal helper thats used as the entry point for the thread.</summary>
/**
* @brief Internal helper thats used as the entry point for the thread.
* @param arg
* @returns void*
*/
static void* helper(void* arg);
public:
/// <summary>Flag indicating if the thread was started.</summary>
/**
* @brief Flag indicating if the thread was started.
*/
__PROTECTED_READONLY_PROPERTY_PLAIN(bool, started);
};

@ -1,15 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
* @file ThreadFunc.h
* @ingroup threading
*/
#if !defined(__THREAD_FUNC_H__)
#define __THREAD_FUNC_H__
@ -20,19 +21,27 @@
// ---------------------------------------------------------------------------
// Class Declaration
// Implements a simple function threading mechanism.
// ---------------------------------------------------------------------------
/**
* @brief Creates and controls a thread based around an anonymous lambda function.
* @ingroup threading
*/
class HOST_SW_API ThreadFunc : public Thread {
public:
/// <summary>Initializes a new instance of the ThreadFunc class.</summary>
/**
* @brief Initializes a new instance of the ThreadFunc class.
* @param e Anonymous function to use as the thread main.
*/
ThreadFunc(std::function<void()>&& e) : Thread(),
m_entry(e)
{
assert(e != nullptr);
}
/// <summary>User-defined function to run for the thread main.</summary>
/**
* @brief User-defined function to run for the thread main.
*/
void entry() override
{
if (m_entry != nullptr)

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2009,2010,2015 Jonathan Naylor, G4KLX
* Copyright (C) 2017-2019 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2009,2010,2015 Jonathan Naylor, G4KLX
* Copyright (C) 2017-2019 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "Timer.h"
@ -22,9 +18,7 @@
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the Timer class.
/// </summary>
/* Initializes a new instance of the Timer class. */
Timer::Timer() :
m_ticksPerSec(1000U),
m_timeout(0U),
@ -34,12 +28,7 @@ Timer::Timer() :
/* stub */
}
/// <summary>
/// Initializes a new instance of the Timer class.
/// </summary>
/// <param name="ticksPerSec"></param>
/// <param name="secs"></param>
/// <param name="msecs"></param>
/* Initializes a new instance of the Timer class. */
Timer::Timer(uint32_t ticksPerSec, uint32_t secs, uint32_t msecs) :
m_ticksPerSec(ticksPerSec),
m_timeout(0U),
@ -55,16 +44,10 @@ Timer::Timer(uint32_t ticksPerSec, uint32_t secs, uint32_t msecs) :
}
}
/// <summary>
/// Finalizes a instance of the Timer class.
/// </summary>
/* Finalizes a instance of the Timer class. */
Timer::~Timer() = default;
/// <summary>
/// Sets the timeout for the timer.
/// </summary>
/// <param name="secs"></param>
/// <param name="msecs"></param>
/* Sets the timeout for the timer. */
void Timer::setTimeout(uint32_t secs, uint32_t msecs)
{
if (secs > 0U || msecs > 0U) {
@ -78,10 +61,7 @@ void Timer::setTimeout(uint32_t secs, uint32_t msecs)
}
}
/// <summary>
/// Gets the timeout for the timer.
/// </summary>
/// <returns></returns>
/* Gets the timeout for the timer. */
uint32_t Timer::getTimeout() const
{
if (m_timeout == 0U)
@ -90,10 +70,7 @@ uint32_t Timer::getTimeout() const
return (m_timeout - 1U) / m_ticksPerSec;
}
/// <summary>
/// Gets the current time for the timer.
/// </summary>
/// <returns></returns>
/* Gets the current time for the timer. */
uint32_t Timer::getTimer() const
{
if (m_timer == 0U)

@ -1,17 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2009,2010,2011,2014 Jonathan Naylor, G4KLX
* Copyright (C) 2017-2019 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2009,2010,2011,2014 Jonathan Naylor, G4KLX
* Copyright (C) 2017-2019 Bryan Biedenkapp, N2PLL
*
*/
* @file Timer.h
* @ingroup timers
* @file Timer.cpp
* @ingroup timers
*/
#if !defined(__TIMER_H__)
#define __TIMER_H__
@ -19,28 +21,52 @@
// ---------------------------------------------------------------------------
// Class Declaration
// Implements a timer.
// ---------------------------------------------------------------------------
/**
* @brief Timer Simple timer that tracks the time and marks if an expiration period has been reached.
* @ingroup timers
*/
class HOST_SW_API Timer {
public:
/// <summary>Initializes a new instance of the Timer class.</summary>
/**
* @brief Initializes a new instance of the Timer class.
*/
Timer();
/// <summary>Initializes a new instance of the Timer class.</summary>
/**
* @brief Initializes a new instance of the Timer class.
* @param ticksPerSec Count of ticks per second.
* @param sec Number of seconds until timer expires.
* @param msec Number of milliseconds until timer expires.
*/
Timer(uint32_t ticksPerSec, uint32_t secs = 0U, uint32_t msecs = 0U);
/// <summary>Finalizes a instance of the Timer class.</summary>
/**
* @brief Finalizes a instance of the Timer class.
*/
~Timer();
/// <summary>Sets the timeout for the timer.</summary>
/**
* @brief Sets the timeout for the timer.
* @param sec Number of seconds until timer expires.
* @param msec Number of milliseconds until timer expires.
*/
void setTimeout(uint32_t secs, uint32_t msecs = 0U);
/// <summary>Gets the timeout for the timer.</summary>
/**
* @brief Gets the timeout for the timer.
* @returns uint32_t Timeout for the timer.
*/
uint32_t getTimeout() const;
/// <summary>Gets the current time for the timer.</summary>
/**
* @brief Gets the current time for the timer.
* @returns uint32_t Current time for the timer.
*/
uint32_t getTimer() const;
/// <summary>Gets the currently remaining time for the timer.</summary>
/// <returns>Amount of time remaining before the timeout.</returns>
/**
* @brief Gets the currently remaining time for the timer.
* @return uint32_t Amount of time remaining before the timeout.
*/
uint32_t getRemaining() const
{
if (m_timeout == 0U || m_timer == 0U)
@ -52,23 +78,29 @@ public:
return (m_timeout - m_timer) / m_ticksPerSec;
}
/// <summary>Flag indicating whether the timer is running.</summary>
/// <returns>True, if the timer is still running, otherwise false.</returns>
/**
* @brief Flag indicating whether the timer is running.
* @return bool True, if the timer is still running, otherwise false.
*/
bool isRunning() const
{
return m_timer > 0U;
}
/// <summary>Flag indicating whether the timer is paused.</summary>
/// <returns>True, if the timer is paused, otherwise false.</returns>
/**
* @brief Flag indicating whether the timer is paused.
* @return bool True, if the timer is paused, otherwise false.
*/
bool isPaused() const
{
return m_paused;
}
/// <summary>Starts the timer.</summary>
/// <param name="secs"></param>
/// <param name="msecs"></param>
/**
* @brief Starts the timer.
* @param sec Number of seconds until timer expires.
* @param msec Number of milliseconds until timer expires.
*/
void start(uint32_t secs, uint32_t msecs = 0U)
{
setTimeout(secs, msecs);
@ -76,7 +108,9 @@ public:
start();
}
/// <summary>Starts the timer.</summary>
/**
* @brief Starts the timer.
*/
void start()
{
if (m_timeout > 0U)
@ -84,27 +118,35 @@ public:
m_paused = false;
}
/// <summary>Stops the timer.</summary>
/**
* @brief Stops the timer.
*/
void stop()
{
m_timer = 0U;
m_paused = false;
}
/// <summary>Pauses the timer.</summary>
/**
* @brief Pauses the timer.
*/
void pause()
{
m_paused = true;
}
/// <summary>Resumes the timer.</summary>
/**
* @brief Resumes the timer.
*/
void resume()
{
m_paused = false;
}
/// <summary>Flag indicating whether or not the timer has reached timeout and expired.</summary>
/// <returns>True, if the timer is expired, otherwise false.</returns>
/**
* @brief Flag indicating whether or not the timer has reached timeout and expired.
* @return bool True, if the timer is expired, otherwise false.
*/
bool hasExpired() const
{
if (m_timeout == 0U || m_timer == 0U)
@ -116,8 +158,10 @@ public:
return false;
}
/// <summary>Updates the timer by the passed number of ticks.</summary>
/// <param name="ticks"></param>
/**
* @brief Updates the timer by the passed number of ticks.
* @param ticks Number of passed ticks.
*/
void clock(uint32_t ticks = 1U)
{
if (m_paused)

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2009,2014,2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2019 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2009,2014,2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2019 Bryan Biedenkapp, N2PLL
*
*/
#include "Utils.h"
#include "Log.h"
@ -33,12 +29,7 @@ const uint8_t BITS_TABLE[] = {
// Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="title"></param>
/// <param name="data"></param>
/// <param name="length"></param>
/* Helper to dump the input buffer and display the hexadecimal output in the log. */
void Utils::dump(const std::string& title, const uint8_t* data, uint32_t length)
{
assert(data != nullptr);
@ -46,13 +37,7 @@ void Utils::dump(const std::string& title, const uint8_t* data, uint32_t length)
dump(2U, title, data, length);
}
/// <summary>
///
/// </summary>
/// <param name="level"></param>
/// <param name="title"></param>
/// <param name="data"></param>
/// <param name="length"></param>
/* Helper to dump the input buffer and display the hexadecimal output in the log. */
void Utils::dump(int level, const std::string& title, const uint8_t* data, uint32_t length)
{
assert(data != nullptr);
@ -99,12 +84,7 @@ void Utils::dump(int level, const std::string& title, const uint8_t* data, uint3
}
}
/// <summary>
///
/// </summary>
/// <param name="title"></param>
/// <param name="bits"></param>
/// <param name="length"></param>
/* Helper to dump the input boolean bit buffer and display the hexadecimal output in the log. */
void Utils::dump(const std::string& title, const bool* bits, uint32_t length)
{
assert(bits != nullptr);
@ -112,13 +92,7 @@ void Utils::dump(const std::string& title, const bool* bits, uint32_t length)
dump(2U, title, bits, length);
}
/// <summary>
///
/// </summary>
/// <param name="level"></param>
/// <param name="title"></param>
/// <param name="bits"></param>
/// <param name="length"></param>
/* Helper to dump the input boolean bit buffer and display the hexadecimal output in the log. */
void Utils::dump(int level, const std::string& title, const bool* bits, uint32_t length)
{
assert(bits != nullptr);
@ -131,12 +105,7 @@ void Utils::dump(int level, const std::string& title, const bool* bits, uint32_t
dump(level, title, bytes, nBytes);
}
/// <summary>
///
/// </summary>
/// <param name="title"></param>
/// <param name="data"></param>
/// <param name="length"></param>
/* Helper to dump the input buffer and display the output as a symbolic microslot output. */
void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t length)
{
assert(data != nullptr);
@ -198,11 +167,7 @@ void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t leng
}
}
/// <summary>
///
/// </summary>
/// <param name="byte"></param>
/// <param name="bits"></param>
/* Helper to convert the input byte to a boolean array of bits in big-endian. */
void Utils::byteToBitsBE(uint8_t byte, bool* bits)
{
assert(bits != nullptr);
@ -217,11 +182,7 @@ void Utils::byteToBitsBE(uint8_t byte, bool* bits)
bits[7U] = (byte & 0x01U) == 0x01U;
}
/// <summary>
///
/// </summary>
/// <param name="byte"></param>
/// <param name="bits"></param>
/* Helper to convert the input byte to a boolean array of bits in little-endian. */
void Utils::byteToBitsLE(uint8_t byte, bool* bits)
{
assert(bits != nullptr);
@ -236,11 +197,7 @@ void Utils::byteToBitsLE(uint8_t byte, bool* bits)
bits[7U] = (byte & 0x80U) == 0x80U;
}
/// <summary>
///
/// </summary>
/// <param name="bits"></param>
/// <param name="byte"></param>
/* Helper to convert the input boolean array of bits to a byte in big-endian. */
void Utils::bitsToByteBE(const bool* bits, uint8_t& byte)
{
assert(bits != nullptr);
@ -255,11 +212,7 @@ void Utils::bitsToByteBE(const bool* bits, uint8_t& byte)
byte |= bits[7U] ? 0x01U : 0x00U;
}
/// <summary>
///
/// </summary>
/// <param name="bits"></param>
/// <param name="byte"></param>
/* Helper to convert the input boolean array of bits to a byte in little-endian. */
void Utils::bitsToByteLE(const bool* bits, uint8_t& byte)
{
assert(bits != nullptr);
@ -274,45 +227,26 @@ void Utils::bitsToByteLE(const bool* bits, uint8_t& byte)
byte |= bits[7U] ? 0x80U : 0x00U;
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/* Helper to reverse the endianness of the passed value. */
uint16_t Utils::reverseEndian(uint16_t value)
{
return (value << 8 & 0xff00) | (value >> 8);
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/* Helper to reverse the endianness of the passed value. */
uint32_t Utils::reverseEndian(uint32_t value)
{
return (value << 24 | (value & 0xFF00U) << 8 | (value & 0xFF0000U) >> 8 | value >> 24);
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/* Helper to reverse the endianness of the passed value. */
uint64_t Utils::reverseEndian(uint64_t value)
{
return (value << 56 | (value & 0xFF00U) << 40 | (value & 0xFF0000U) << 24 | (value & 0xFF000000U) << 8 |
(value & 0xFF00000000U) >> 8 | (value & 0xFF0000000000U) >> 24 | (value & 0xFF000000000000U) >> 40 | value >> 56);
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="out"></param>
/// <param name="start"></param>
/// <param name="stop"></param>
/// <returns></returns>
/* Helper to retreive arbitrary length of bits from an input buffer. */
uint32_t Utils::getBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop)
{
assert(in != nullptr);
@ -327,27 +261,13 @@ uint32_t Utils::getBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_
return n;
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="out"></param>
/// <param name="start"></param>
/// <param name="length"></param>
/// <returns></returns>
/* Helper to retreive arbitrary length of bits from an input buffer. */
uint32_t Utils::getBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length)
{
return getBits(in, out, start, start + length);
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="out"></param>
/// <param name="start"></param>
/// <param name="stop"></param>
/// <returns></returns>
/* Helper to set an arbitrary length of bits from an input buffer. */
uint32_t Utils::setBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop)
{
assert(in != nullptr);
@ -362,25 +282,13 @@ uint32_t Utils::setBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_
return n;
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/// <param name="out"></param>
/// <param name="start"></param>
/// <param name="length"></param>
/// <returns></returns>
/* Helper to set an arbitrary length of bits from an input buffer. */
uint32_t Utils::setBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length)
{
return setBits(in, out, start, start + length);
}
/// <summary>
///
/// </summary>
/// <param name="input"></param>
/// <param name="offset"></param>
/// <returns></returns>
/* Helper to convert a binary input buffer into representative 6-bit byte. */
uint8_t Utils::bin2Hex(const uint8_t* input, uint32_t offset)
{
uint8_t output = 0x00U;
@ -395,13 +303,7 @@ uint8_t Utils::bin2Hex(const uint8_t* input, uint32_t offset)
return output;
}
/// <summary>
///
/// </summary>
/// <param name="input"></param>
/// <param name="output"></param>
/// <param name="offset"></param>
/// <returns></returns>
/* Helper to convert 6-bit input byte into representative binary buffer. */
void Utils::hex2Bin(const uint8_t input, uint8_t* output, uint32_t offset)
{
WRITE_BIT(output, offset + 0U, input & 0x20U);
@ -412,21 +314,13 @@ void Utils::hex2Bin(const uint8_t input, uint8_t* output, uint32_t offset)
WRITE_BIT(output, offset + 5U, input & 0x01U);
}
/// <summary>
/// Returns the count of bits in the passed 8 byte value.
/// </summary>
/// <param name="bits"></param>
/// <returns></returns>
/* Returns the count of bits in the passed 8 byte value. */
uint8_t Utils::countBits8(uint8_t bits)
{
return BITS_TABLE[bits];
}
/// <summary>
/// Returns the count of bits in the passed 32 byte value.
/// </summary>
/// <param name="bits"></param>
/// <returns></returns>
/* Returns the count of bits in the passed 32 byte value. */
uint8_t Utils::countBits32(uint32_t bits)
{
uint8_t* p = (uint8_t*)&bits;
@ -438,11 +332,7 @@ uint8_t Utils::countBits32(uint32_t bits)
return n;
}
/// <summary>
/// Returns the count of bits in the passed 64 byte value.
/// </summary>
/// <param name="bits"></param>
/// <returns></returns>
/* Returns the count of bits in the passed 64 byte value. */
uint8_t Utils::countBits64(ulong64_t bits)
{
uint8_t* p = (uint8_t*)&bits;

@ -1,17 +1,23 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2009,2014,2015 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2019 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2009,2014,2015 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2019 Bryan Biedenkapp, N2PLL
*
*/
* @defgroup utils Utility Routines
* @brief Defines and implements utility routines.
* @ingroup common
*
* @file Utils.h
* @ingroup utils
* @file Utils.cpp
* @ingroup utils
*/
#if !defined(__UTILS_H__)
#define __UTILS_H__
@ -19,81 +25,98 @@
#include <string>
// ---------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------
/**
* @brief Bit mask table used for WRITE_BIT and READ_BIT.
* @ingroup utils
*/
const uint8_t BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U };
// ---------------------------------------------------------------------------
// Inlines
// ---------------------------------------------------------------------------
/// <summary>
/// String from boolean.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/**
* @brief String from boolean.
* @ingroup utils
* @param value Boolean value to convert.
* @return std::string String representation of the boolean value.
*/
inline std::string __BOOL_STR(const bool& value) {
std::stringstream ss;
ss << std::boolalpha << value;
return ss.str();
}
/// <summary>
/// String from integer number.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/**
* @brief String from integer number.
* @ingroup utils
* @param value Integer value to convert.
* @return std::string String representation of the integer value.
*/
inline std::string __INT_STR(const int& value) {
std::stringstream ss;
ss << value;
return ss.str();
}
/// <summary>
/// String from hex integer number.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/**
* @brief String from hex integer number.
* @ingroup utils
* @param value Integer value to convert.
* @return std::string String representation of the integer value in hexadecmial.
*/
inline std::string __INT_HEX_STR(const int& value) {
std::stringstream ss;
ss << std::hex << value;
return ss.str();
}
/// <summary>
/// String from floating point number.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/**
* @brief String from floating point number.
* @ingroup utils
* @param value Floating point value to convert.
* @return std::string String representation of the floating point value.
*/
inline std::string __FLOAT_STR(const float& value) {
std::stringstream ss;
ss << value;
return ss.str();
}
/// <summary>
/// IP address from ulong64_t value.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/**
* @brief IP address from ulong64_t value.
* @ingroup utils
* @param value Packed IP address.
* @return std::string String representation of the packed IP address.
*/
inline std::string __IP_FROM_ULONG(const ulong64_t& value) {
std::stringstream ss;
ss << ((value >> 24) & 0xFFU) << "." << ((value >> 16) & 0xFFU) << "." << ((value >> 8) & 0xFFU) << "." << (value & 0xFFU);
return ss.str();
}
/// <summary>
/// Helper to lower-case an input string.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/**
* @brief Helper to lower-case an input string.
* @ingroup utils
* @param value String to lower-case.
* @return std::string Lowercased string.
*/
inline std::string strtolower(const std::string value) {
std::string v = value;
std::transform(v.begin(), v.end(), v.begin(), ::tolower);
return v;
}
/// <summary>
/// Helper to upper-case an input string.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/**
* @brief Helper to upper-case an input string.
* @ingroup utils
* @param value String to upper-case.
* @return std::string Uppercased string.
*/
inline std::string strtoupper(const std::string value) {
std::string v = value;
std::transform(v.begin(), v.end(), v.begin(), ::toupper);
@ -104,121 +127,270 @@ inline std::string strtoupper(const std::string value) {
// Macros
// ---------------------------------------------------------------------------
/// <summary>Pointer magic to get the memory address of a floating point number.</summary>
/// <param name="x">Floating Point Variable</param>
/**
* @brief Pointer magic to get the memory address of a floating point number.
* @ingroup utils
* @param x Floating Point Variable
*/
#define __FLOAT_ADDR(x) (*(uint32_t*)& x)
/// <summary>Pointer magic to get the memory address of a double precision number.</summary>
/// <param name="x">Double Precision Variable</param>
/**
* @brief Pointer magic to get the memory address of a double precision number.
* @ingroup utils
* @param x Double Precision Variable
*/
#define __DOUBLE_ADDR(x) (*(uint64_t*)& x)
/**
* @brief Macro helper to write a specific bit in a byte array.
* @ingroup utils
* @param p Byte array.
* @param i Bit offset.
* @param b Bit to write.
*/
#define WRITE_BIT(p, i, b) p[(i) >> 3] = (b) ? (p[(i) >> 3] | BIT_MASK_TABLE[(i) & 7]) : (p[(i) >> 3] & ~BIT_MASK_TABLE[(i) & 7])
/**
* @brief Macro helper to read a specific bit from a byte array.
* @ingroup utils
* @param p Byte array.
* @param i Bit offset.
* @returns bool Bit.
*/
#define READ_BIT(p, i) (p[(i) >> 3] & BIT_MASK_TABLE[(i) & 7])
/// <summary>Sets a uint32_t into 4 bytes.</summary>
/// <param name="val">uint32_t value to set</param>
/// <param name="buffer">uint8_t buffer to set value on</param>
/// <param name="offset">Offset within uint8_t buffer</param>
/**
* @brief Sets a uint32_t into 4 bytes.
* @ingroup utils
* @param val uint32_t value to set
* @param buffer uint8_t buffer to set value on
* @param offset Offset within uint8_t buffer
*/
#define __SET_UINT32(val, buffer, offset) \
buffer[0U + offset] = (val >> 24) & 0xFFU; \
buffer[1U + offset] = (val >> 16) & 0xFFU; \
buffer[2U + offset] = (val >> 8) & 0xFFU; \
buffer[3U + offset] = (val >> 0) & 0xFFU;
/// <summary>Gets a uint32_t consisting of 4 bytes.</summary>
/// <param name="buffer">uint8_t buffer to get value from</param>
/// <param name="offset">Offset within uint8_t buffer</param>
/**
* @brief Gets a uint32_t consisting of 4 bytes.
* @ingroup utils
* @param buffer uint8_t buffer to get value from
* @param offset Offset within uint8_t buffer
*/
#define __GET_UINT32(buffer, offset) \
(buffer[offset + 0U] << 24) | \
(buffer[offset + 1U] << 16) | \
(buffer[offset + 2U] << 8) | \
(buffer[offset + 3U] << 0);
/// <summary>Sets a uint32_t into 3 bytes.</summary>
/// <param name="val">uint32_t value to set</param>
/// <param name="buffer">uint8_t buffer to set value on</param>
/// <param name="offset">Offset within uint8_t buffer</param>
/**
* @brief Sets a uint32_t into 3 bytes.
* @ingroup utils
* @param val uint32_t value to set
* @param buffer uint8_t buffer to set value on
* @param offset Offset within uint8_t buffer
*/
#define __SET_UINT16(val, buffer, offset) \
buffer[0U + offset] = (val >> 16) & 0xFFU; \
buffer[1U + offset] = (val >> 8) & 0xFFU; \
buffer[2U + offset] = (val >> 0) & 0xFFU;
/// <summary>Gets a uint32_t consisting of 3 bytes. (This is a shortened uint32_t).</summary>
/// <param name="buffer">uint8_t buffer to get value from</param>
/// <param name="offset">Offset within uint8_t buffer</param>
/**
* @brief Gets a uint32_t consisting of 3 bytes. (This is a shortened uint32_t).
* @ingroup utils
* @param buffer uint8_t buffer to get value from
* @param offset Offset within uint8_t buffer
*/
#define __GET_UINT16(buffer, offset) \
(buffer[offset + 0U] << 16) | \
(buffer[offset + 1U] << 8) | \
(buffer[offset + 2U] << 0);
/// <summary>Sets a uint16_t into 2 bytes.</summary>
/// <param name="val">uint16_t value to set</param>
/// <param name="buffer">uint8_t buffer to set value on</param>
/// <param name="offset">Offset within uint8_t buffer</param>
/**
* @brief Sets a uint16_t into 2 bytes.
* @ingroup utils
* @param val uint16_t value to set
* @param buffer uint8_t buffer to set value on
* @param offset Offset within uint8_t buffer
*/
#define __SET_UINT16B(val, buffer, offset) \
buffer[0U + offset] = (val >> 8) & 0xFFU; \
buffer[1U + offset] = (val >> 0) & 0xFFU;
/// <summary>Gets a uint16_t consisting of 2 bytes.</summary>
/// <param name="buffer">uint8_t buffer to get value from</param>
/// <param name="offset">Offset within uint8_t buffer</param>
/**
* @brief Gets a uint16_t consisting of 2 bytes.
* @ingroup utils
* @param buffer uint8_t buffer to get value from
* @param offset Offset within uint8_t buffer
*/
#define __GET_UINT16B(buffer, offset) \
((buffer[offset + 0U] << 8) & 0xFF00U) | \
((buffer[offset + 1U] << 0) & 0x00FFU);
/// <summary>Unique uint8_t array.</summary>
/**
* @brief Unique uint8_t array.
* @ingroup utils
*/
typedef std::unique_ptr<uint8_t[]> UInt8Array;
// ---------------------------------------------------------------------------
// Class Declaration
// Implements various helper utilities.
// ---------------------------------------------------------------------------
/**
* @brief Various helper utilities.
* @ingroup utils
*/
class HOST_SW_API Utils {
public:
/// <summary></summary>
/**
* @brief Helper to dump the input buffer and display the hexadecimal output in the log.
* @param title Name of buffer.
* @param data Buffer to dump.
* @param length Length of buffer.
*/
static void dump(const std::string& title, const uint8_t* data, uint32_t length);
/// <summary></summary>
/**
* @brief Helper to dump the input buffer and display the hexadecimal output in the log.
* @param level Log level.
* @param title Name of buffer.
* @param data Buffer to dump.
* @param length Length of buffer.
*/
static void dump(int level, const std::string& title, const uint8_t* data, uint32_t length);
/// <summary></summary>
/**
* @brief Helper to dump the input boolean bit buffer and display the hexadecimal output in the log.
* @param title Name of buffer.
* @param data Buffer to dump.
* @param length Length of buffer.
*/
static void dump(const std::string& title, const bool* bits, uint32_t length);
/// <summary></summary>
/**
* @brief Helper to dump the input boolean bit buffer and display the hexadecimal output in the log.
* @param level Log level.
* @param title Name of buffer.
* @param data Buffer to dump.
* @param length Length of buffer.
*/
static void dump(int level, const std::string& title, const bool* bits, uint32_t length);
/// <summary></summary>
/**
* @brief Helper to dump the input buffer and display the output as a symbolic microslot output.
* @param title Name of buffer.
* @param data Buffer to dump.
* @param length Length of buffer.
*/
static void symbols(const std::string& title, const uint8_t* data, uint32_t length);
/// <summary></summary>
/**
* @brief Helper to convert the input byte to a boolean array of bits in big-endian.
* @param byte Input byte.
* @param bits Output bits array.
*/
static void byteToBitsBE(uint8_t byte, bool* bits);
/// <summary></summary>
/**
* @brief Helper to convert the input byte to a boolean array of bits in little-endian.
* @param byte Input byte.
* @param bits Output bits array.
*/
static void byteToBitsLE(uint8_t byte, bool* bits);
/// <summary></summary>
/**
* @brief Helper to convert the input boolean array of bits to a byte in big-endian.
* @param byte Input bits array.
* @param bits Output byte.
*/
static void bitsToByteBE(const bool* bits, uint8_t& byte);
/// <summary></summary>
/**
* @brief Helper to convert the input boolean array of bits to a byte in little-endian.
* @param byte Input bits array.
* @param bits Output byte.
*/
static void bitsToByteLE(const bool* bits, uint8_t& byte);
/// <summary></summary>
/**
* @brief Helper to reverse the endianness of the passed value.
* @param value Value to reverse.
* @returns uint16_t Endian reversed output.
*/
static uint16_t reverseEndian(uint16_t value);
/// <summary></summary>
/**
* @brief Helper to reverse the endianness of the passed value.
* @param value Value to reverse.
* @returns uint32_t Endian reversed output.
*/
static uint32_t reverseEndian(uint32_t value);
/// <summary></summary>
/**
* @brief Helper to reverse the endianness of the passed value.
* @param value Value to reverse.
* @returns uint64_t Endian reversed output.
*/
static uint64_t reverseEndian(uint64_t value);
/// <summary></summary>
/**
* @brief Helper to retreive arbitrary length of bits from an input buffer.
* @param in Input buffer.
* @param out Output buffer.
* @param start Starting bit offset in input buffer to read from.
* @param stop Ending bit offset in input buffer to stop reading.
* @returns uint32_t Count of bits read.
*/
static uint32_t getBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop);
/// <summary></summary>
/**
* @brief Helper to retreive arbitrary length of bits from an input buffer.
* @param in Input buffer.
* @param out Output buffer.
* @param start Starting bit offset in input buffer to read from.
* @param length Number of bits to read.
* @returns uint32_t Count of bits read.
*/
static uint32_t getBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length);
/// <summary></summary>
/**
* @brief Helper to set an arbitrary length of bits from an input buffer.
* @param in Input buffer.
* @param out Output buffer.
* @param start Starting bit offset in input buffer to read from.
* @param stop Ending bit offset in input buffer to stop reading.
* @returns uint32_t Count of bits set.
*/
static uint32_t setBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop);
/// <summary></summary>
/**
* @brief Helper to set arbitrary length of bits from an input buffer.
* @param in Input buffer.
* @param out Output buffer.
* @param start Starting bit offset in input buffer to read from.
* @param length Number of bits to set.
* @returns uint32_t Count of bits set.
*/
static uint32_t setBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length);
/// <summary></summary>
/**
* @brief Helper to convert a binary input buffer into representative 6-bit byte.
* @param input Input buffer.
* @param offset Buffer offset.
* @returns uint8_t Representative 6-bit output.
*/
static uint8_t bin2Hex(const uint8_t* input, uint32_t offset);
/// <summary></summary>
/**
* @brief Helper to convert 6-bit input byte into representative binary buffer.
* @param input Input 6-bit byte.
* @param output Output buffer.
* @param offset Buffer offset.
*/
static void hex2Bin(const uint8_t input, uint8_t* output, uint32_t offset);
/// <summary>Returns the count of bits in the passed 8 byte value.</summary>
/**
* @brief Returns the count of bits in the passed 8 byte value.
* @param bits uint8_t to count bits for.
* @returns uint8_t Count of bits in passed value.
*/
static uint8_t countBits8(uint8_t bits);
/// <summary>Returns the count of bits in the passed 32 byte value.</summary>
/**
* @brief Returns the count of bits in the passed 32 byte value.
* @param bits uint32_t to count bits for.
* @returns uint8_t Count of bits in passed value.
*/
static uint8_t countBits32(uint32_t bits);
/// <summary>Returns the count of bits in the passed 64 byte value.</summary>
/**
* @brief Returns the count of bits in the passed 64 byte value.
* @param bits ulong64_t to count bits for.
* @returns uint8_t Count of bits in passed value.
*/
static uint8_t countBits64(ulong64_t bits);
};

@ -1,17 +1,21 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2019-2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2019-2024 Bryan Biedenkapp, N2PLL
*
*/
* @defgroup dmr Digital Mobile Radio
* @brief Implementation for the ETSI TS-102 Digital Mobile Radio (DMR) standard.
* @ingroup common
*
* @file DMRDefines.h
* @ingroup dmr
*/
#if !defined(__DMR_DEFINES_H__)
#define __DMR_DEFINES_H__
@ -27,6 +31,12 @@ namespace dmr
// Constants
// ---------------------------------------------------------------------------
/**
* @addtogroup dmr
* @{
*/
/** @name Frame Lengths and Misc Constants */
const uint32_t DMR_FRAME_LENGTH_BITS = 264U;
const uint32_t DMR_FRAME_LENGTH_BYTES = 33U;
@ -102,172 +112,177 @@ namespace dmr
const uint32_t MAX_PDU_LENGTH = 512U;
const uint32_t MI_LENGTH_BYTES = 4U; // This was guessed based on OTA data captures -- the message indicator seems to be the same length as a source/destination address
/** @} */
/** Thresholds */
/** @name Thresholds */
/** @brief TSCC maximum CSC count */
const uint16_t TSCC_MAX_CSC_CNT = 511U;
/** @brief DMR slot time in milliseconds */
const uint32_t DMR_SLOT_TIME = 60U;
/** @brief Number of AMBE per slot */
const uint32_t AMBE_PER_SLOT = 3U;
/** @brief Random Access Wait */
const uint8_t DEFAULT_NRAND_WAIT = 8U;
/** @brief Default Silence Threshold */
const uint32_t DEFAULT_SILENCE_THRESHOLD = 21U;
/** @brief Default Frame Loss Threshold */
const uint32_t DEFAULT_FRAME_LOSS_THRESHOLD = 2U;
/** @brief Maximum P25 voice frame errors */
const uint32_t MAX_DMR_VOICE_ERRORS = 141U;
/** @} */
/** Default Values */
/** @name Default Values */
const uint8_t DMR_ALOHA_VER_151 = 0x00U;
const uint8_t DMR_CHNULL = 0x00U;
const uint16_t DMR_LOGICAL_CH_ABSOLUTE = 0xFFFU;
const uint32_t WUID_SUPLI = 0xFFFEC4U; // Supplementary Data Service Working Unit ID
const uint32_t WUID_SDMI = 0xFFFEC5U; // UDT Short Data Service Working Unit ID
const uint32_t WUID_REGI = 0xFFFEC6U; // Registration Working Unit ID
const uint32_t WUID_STUNI = 0xFFFECCU; // MS Stun/Revive Identifier
const uint32_t WUID_AUTHI = 0xFFFECDU; // Authentication Working Unit ID
const uint32_t WUID_KILLI = 0xFFFECFU; // MS Kill Identifier
const uint32_t WUID_TATTSI = 0xFFFED7U; // Talkgroup Subscription/Attachement Service Working Unit ID
const uint32_t WUID_ALLL = 0xFFFFFDU; // All-call Site-wide Working Unit ID
const uint32_t WUID_ALLZ = 0xFFFFFEU; // All-call System-wide Working Unit ID
const uint32_t WUID_ALL = 0xFFFFFFU; // All-call Network-wide Working Unit ID
const uint32_t WUID_SUPLI = 0xFFFEC4U; //! Supplementary Data Service Working Unit ID
const uint32_t WUID_SDMI = 0xFFFEC5U; //! UDT Short Data Service Working Unit ID
const uint32_t WUID_REGI = 0xFFFEC6U; //! Registration Working Unit ID
const uint32_t WUID_STUNI = 0xFFFECCU; //! MS Stun/Revive Identifier
const uint32_t WUID_AUTHI = 0xFFFECDU; //! Authentication Working Unit ID
const uint32_t WUID_KILLI = 0xFFFECFU; //! MS Kill Identifier
const uint32_t WUID_TATTSI = 0xFFFED7U; //! Talkgroup Subscription/Attachement Service Working Unit ID
const uint32_t WUID_ALLL = 0xFFFFFDU; //! All-call Site-wide Working Unit ID
const uint32_t WUID_ALLZ = 0xFFFFFEU; //! All-call System-wide Working Unit ID
const uint32_t WUID_ALL = 0xFFFFFFU; //! All-call Network-wide Working Unit ID
const uint32_t NO_HEADERS_SIMPLEX = 8U;
const uint32_t NO_HEADERS_DUPLEX = 3U;
const uint32_t NO_PREAMBLE_CSBK = 15U;
/** @} */
/// <summary>
/// Data Packet Format
/// </summary>
/** @brief Data Packet Format */
namespace DPF {
// Data Packet Format Enumeration
/** @brief Data Packet Format */
enum E : uint8_t {
UDT = 0x00U, // Unified Data Transport Header
RESPONSE = 0x01U, // Response Data Header
UNCONFIRMED_DATA = 0x02U, // Unconfirmed Data Header
CONFIRMED_DATA = 0x03U, // Confirmed Data Header
DEFINED_SHORT = 0x0DU, // Defined Short Data Header
DEFINED_RAW = 0x0EU, // Defined Raw Data Header
PROPRIETARY = 0x0FU, // Proprietary
UDT = 0x00U, //! Unified Data Transport Header
RESPONSE = 0x01U, //! Response Data Header
UNCONFIRMED_DATA = 0x02U, //! Unconfirmed Data Header
CONFIRMED_DATA = 0x03U, //! Confirmed Data Header
DEFINED_SHORT = 0x0DU, //! Defined Short Data Header
DEFINED_RAW = 0x0EU, //! Defined Raw Data Header
PROPRIETARY = 0x0FU, //! Proprietary
};
};
/// <summary>
/// Data Response Class
/// </summary>
/** @brief Data Response Class */
namespace PDUResponseClass {
/** @brief Data Response Class */
enum : uint8_t {
ACK = 0x00U, // Acknowledge
NACK = 0x01U, // Negative Acknowledge
ACK_RETRY = 0x02U // Acknowlege Retry
ACK = 0x00U, //! Acknowledge
NACK = 0x01U, //! Negative Acknowledge
ACK_RETRY = 0x02U //! Acknowlege Retry
};
};
/// <summary>
/// Data Response Type
/// </summary>
/** @brief Data Response Type */
namespace PDUResponseType {
/** @brief Data Response Type */
enum : uint8_t {
ACK = 0x01U, // Acknowledge
ACK = 0x01U, //! Acknowledge
NACK_ILLEGAL = 0x00U, // Illegal Format
NACK_PACKET_CRC = 0x01U, // Packet CRC
NACK_MEMORY_FULL = 0x02U, // Memory Full
NACK_UNDELIVERABLE = 0x04U // Undeliverable
NACK_ILLEGAL = 0x00U, //! Illegal Format
NACK_PACKET_CRC = 0x01U, //! Packet CRC
NACK_MEMORY_FULL = 0x02U, //! Memory Full
NACK_UNDELIVERABLE = 0x04U //! Undeliverable
};
};
/** Feature IDs */
const uint8_t FID_ETSI = 0x00U; // ETSI Standard Feature Set
const uint8_t FID_DMRA = 0x10U; // Motorola
const uint8_t FID_DVM_OCS = 0x9CU; // DVM; Omaha Communication Systems, LLC ($9C)
/** @name Feature IDs */
/** @brief ETSI Standard Feature Set */
const uint8_t FID_ETSI = 0x00U;
/** @brief Motorola */
const uint8_t FID_DMRA = 0x10U;
/** @brief DVM; Omaha Communication Systems, LLC ($9C) */
const uint8_t FID_DVM_OCS = 0x9CU;
/** @} */
/** LC Service Options */
/** @name LC Service Options */
const uint8_t LC_SVC_OPT_EMERGENCY = 0x80U;
const uint8_t LC_SVC_OPT_PRIVACY = 0x40U;
const uint8_t LC_SVC_OPT_BCAST = 0x08U;
const uint8_t LC_SVC_OPT_OVCM = 0x04U;
/** @} */
/** Call Priorities */
/** @name Call Priorities */
const uint8_t CALL_PRIORITY_NONE = 0x00U;
const uint8_t CALL_PRIORITY_1 = 0x01U;
const uint8_t CALL_PRIORITY_2 = 0x02U;
const uint8_t CALL_PRIORITY_3 = 0x03U;
/** @} */
/// <summary>
/// Short-Link Control Opcode(s)
/// </summary>
/** @brief Short-Link Control Opcode(s) */
namespace SLCO {
// Short-Link Control Opcode Enumeration
/** @brief Short-Link Control Opcode(s) */
enum E : uint8_t {
NONE = 0x00U, // NULL
ACT = 0x01U, //
TSCC = 0x02U, // TSCC
PAYLOAD = 0x03U // Payload
NONE = 0x00U, //! NULL
ACT = 0x01U, //!
TSCC = 0x02U, //! TSCC
PAYLOAD = 0x03U //! Payload
};
}
/// <summary>
/// Full-Link Control Opcode(s)
/// </summary>
/** @brief Full-Link Control Opcode(s) */
namespace FLCO {
// Full-Link Control Opcode Enumeration
/** @brief Full-Link Control Opcode(s) */
enum E : uint8_t {
GROUP = 0x00U, // GRP VCH USER - Group Voice Channel User
PRIVATE = 0x03U, // UU VCH USER - Unit-to-Unit Voice Channel User
GROUP = 0x00U, //! GRP VCH USER - Group Voice Channel User
PRIVATE = 0x03U, //! UU VCH USER - Unit-to-Unit Voice Channel User
TALKER_ALIAS_HEADER = 0x04U, //
TALKER_ALIAS_BLOCK1 = 0x05U, //
TALKER_ALIAS_BLOCK2 = 0x06U, //
TALKER_ALIAS_BLOCK3 = 0x07U, //
TALKER_ALIAS_HEADER = 0x04U, //!
TALKER_ALIAS_BLOCK1 = 0x05U, //!
TALKER_ALIAS_BLOCK2 = 0x06U, //!
TALKER_ALIAS_BLOCK3 = 0x07U, //!
GPS_INFO = 0x08U, //
GPS_INFO = 0x08U, //!
};
}
/// <summary>
/// FID_DMRA Extended Functions.
/// </summary>
/** @brief FID_DMRA Extended Functions. */
namespace ExtendedFunctions {
/** @brief FID_DMRA Extended Functions. */
enum : uint16_t {
CHECK = 0x0000U, // Radio Check
UNINHIBIT = 0x007EU, // Radio Uninhibit
INHIBIT = 0x007FU, // Radio Inhibit
CHECK_ACK = 0x0080U, // Radio Check Ack
UNINHIBIT_ACK = 0x00FEU, // Radio Uninhibit Ack
INHIBIT_ACK = 0x00FFU // Radio Inhibit Ack
CHECK = 0x0000U, //! Radio Check
UNINHIBIT = 0x007EU, //! Radio Uninhibit
INHIBIT = 0x007FU, //! Radio Inhibit
CHECK_ACK = 0x0080U, //! Radio Check Ack
UNINHIBIT_ACK = 0x00FEU, //! Radio Uninhibit Ack
INHIBIT_ACK = 0x00FFU //! Radio Inhibit Ack
};
};
/// <summary>
/// Data Type(s)
/// <summary>
/** @brief Data Type(s) */
namespace DataType {
// Data Type Enumeration
/** @brief Data Type(s) */
enum E : uint8_t {
VOICE_PI_HEADER = 0x00U, // Voice with Privacy Indicator Header
VOICE_LC_HEADER = 0x01U, // Voice with Link Control Header
VOICE_PI_HEADER = 0x00U, //! Voice with Privacy Indicator Header
VOICE_LC_HEADER = 0x01U, //! Voice with Link Control Header
TERMINATOR_WITH_LC = 0x02U, // Terminator with Link Control
TERMINATOR_WITH_LC = 0x02U, //! Terminator with Link Control
CSBK = 0x03U, // CSBK
CSBK = 0x03U, //! CSBK
MBC_HEADER = 0x04U, // Multi-Block Control Header
MBC_DATA = 0x05U, // Multi-Block Control Data
MBC_HEADER = 0x04U, //! Multi-Block Control Header
MBC_DATA = 0x05U, //! Multi-Block Control Data
DATA_HEADER = 0x06U, // Data Header
RATE_12_DATA = 0x07U, // 1/2 Rate Data
RATE_34_DATA = 0x08U, // 3/4 Rate Data
DATA_HEADER = 0x06U, //! Data Header
RATE_12_DATA = 0x07U, //! 1/2 Rate Data
RATE_34_DATA = 0x08U, //! 3/4 Rate Data
IDLE = 0x09U, // Idle
IDLE = 0x09U, //! Idle
RATE_1_DATA = 0x0AU, // Rate 1 Data
RATE_1_DATA = 0x0AU, //! Rate 1 Data
/*
** Internal Data Type(s)
*/
VOICE_SYNC = 0xF0U, // Internal - Voice Sync
VOICE = 0xF1U // Internal - Voice
VOICE_SYNC = 0xF0U, //! Internal - Voice Sync
VOICE = 0xF1U //! Internal - Voice
};
}
@ -282,142 +297,138 @@ namespace dmr
#define DMR_DT_VOICE_SYNC "DMR, VOICE_SYNC (Voice Data with Sync)"
#define DMR_DT_VOICE "DMR, VOICE (Voice Data)"
/// <summary>
/// Site Models
/// </summary>
/** @brief Site Models */
namespace SiteModel {
// Site Model Enumeration
/** @brief Site Models */
enum E : uint8_t {
SM_TINY = 0x00U, // Tiny
SM_SMALL = 0x01U, // Small
SM_LARGE = 0x02U, // Large
SM_HUGE = 0x03U // Huge
SM_TINY = 0x00U, //! Tiny
SM_SMALL = 0x01U, //! Small
SM_LARGE = 0x02U, //! Large
SM_HUGE = 0x03U //! Huge
};
}
// Target Address
/** @name Target Address */
const uint8_t TGT_ADRS_SYSCODE = 0x00U;
const uint8_t TGT_ADRS_TGID = 0x01U;
/** @} */
/// <summary>
/// Talker ID
/// <summary>
/** @brief Talker ID */
namespace TalkerID {
/** @brief Talker ID */
enum : uint8_t {
NONE = 0x00U, // No Talker ID
NONE = 0x00U, //! No Talker ID
HEADER = 0x01U, // Talker ID Header
HEADER = 0x01U, //! Talker ID Header
BLOCK1 = 0x02U, // Talker ID Block 1
BLOCK2 = 0x04U, // Talker ID Block 2
BLOCK3 = 0x08U // Talker ID Block 3
BLOCK1 = 0x02U, //! Talker ID Block 1
BLOCK2 = 0x04U, //! Talker ID Block 2
BLOCK3 = 0x08U //! Talker ID Block 3
};
}
/// <summary>
/// Reason Code(s)
/// <summary>
/** @brief Reason Code(s) */
namespace ReasonCode {
/** @brief Reason Code(s) */
enum : uint8_t {
TS_ACK_RSN_MSG = 0x60U, // TS - Message Accepted
TS_ACK_RSN_REG = 0x62U, // TS - Registration Accepted
TS_ACK_RSN_AUTH_RESP = 0x64U, // TS - Authentication Challenge Response
TS_ACK_RSN_REG_SUB_ATTACH = 0x65U, // TS - Registration Response with subscription
MS_ACK_RSN_MSG = 0x44U, // MS - Message Accepted
MS_ACK_RSN_AUTH_RESP = 0x48U, // MS - Authentication Challenge Response
TS_DENY_RSN_SYS_UNSUPPORTED_SVC = 0x20U,// System Unsupported Service
TS_DENY_RSN_PERM_USER_REFUSED = 0x21U, // User Permenantly Refused
TS_DENY_RSN_TEMP_USER_REFUSED = 0x22U, // User Temporarily Refused
TS_DENY_RSN_TRSN_SYS_REFUSED = 0x23U, // System Refused
TS_DENY_RSN_TGT_NOT_REG = 0x24U, // Target Not Registered
TS_DENY_RSN_TGT_UNAVAILABLE = 0x25U, // Target Unavailable
TS_DENY_RSN_SYS_BUSY = 0x27U, // System Busy
TS_DENY_RSN_SYS_NOT_READY = 0x28U, // System Not Ready
TS_DENY_RSN_CALL_CNCL_REFUSED = 0x29U, // Call Cancel Refused
TS_DENY_RSN_REG_REFUSED = 0x2AU, // Registration Refused
TS_DENY_RSN_REG_DENIED = 0x2BU, // Registration Denied
TS_DENY_RSN_MS_NOT_REG = 0x2DU, // MS Not Registered
TS_DENY_RSN_TGT_BUSY = 0x2EU, // Target Busy
TS_DENY_RSN_TGT_GROUP_NOT_VALID = 0x2FU,// Group Not Valid
TS_QUEUED_RSN_NO_RESOURCE = 0xA0U, // No Resources Available
TS_QUEUED_RSN_SYS_BUSY = 0xA1U, // System Busy
TS_WAIT_RSN = 0xE0U, // Wait
MS_DENY_RSN_UNSUPPORTED_SVC = 0x00U, // Service Unsupported
TS_ACK_RSN_MSG = 0x60U, //! TS - Message Accepted
TS_ACK_RSN_REG = 0x62U, //! TS - Registration Accepted
TS_ACK_RSN_AUTH_RESP = 0x64U, //! TS - Authentication Challenge Response
TS_ACK_RSN_REG_SUB_ATTACH = 0x65U, //! TS - Registration Response with subscription
MS_ACK_RSN_MSG = 0x44U, //! MS - Message Accepted
MS_ACK_RSN_AUTH_RESP = 0x48U, //! MS - Authentication Challenge Response
TS_DENY_RSN_SYS_UNSUPPORTED_SVC = 0x20U,//! System Unsupported Service
TS_DENY_RSN_PERM_USER_REFUSED = 0x21U, //! User Permenantly Refused
TS_DENY_RSN_TEMP_USER_REFUSED = 0x22U, //! User Temporarily Refused
TS_DENY_RSN_TRSN_SYS_REFUSED = 0x23U, //! System Refused
TS_DENY_RSN_TGT_NOT_REG = 0x24U, //! Target Not Registered
TS_DENY_RSN_TGT_UNAVAILABLE = 0x25U, //! Target Unavailable
TS_DENY_RSN_SYS_BUSY = 0x27U, //! System Busy
TS_DENY_RSN_SYS_NOT_READY = 0x28U, //! System Not Ready
TS_DENY_RSN_CALL_CNCL_REFUSED = 0x29U, //! Call Cancel Refused
TS_DENY_RSN_REG_REFUSED = 0x2AU, //! Registration Refused
TS_DENY_RSN_REG_DENIED = 0x2BU, //! Registration Denied
TS_DENY_RSN_MS_NOT_REG = 0x2DU, //! MS Not Registered
TS_DENY_RSN_TGT_BUSY = 0x2EU, //! Target Busy
TS_DENY_RSN_TGT_GROUP_NOT_VALID = 0x2FU,//! Group Not Valid
TS_QUEUED_RSN_NO_RESOURCE = 0xA0U, //! No Resources Available
TS_QUEUED_RSN_SYS_BUSY = 0xA1U, //! System Busy
TS_WAIT_RSN = 0xE0U, //! Wait
MS_DENY_RSN_UNSUPPORTED_SVC = 0x00U, //! Service Unsupported
};
}
/// <summary>
/// Random Access Service Kind
/// </summary>
/** @brief Random Access Service Kind */
namespace ServiceKind {
/** @brief Random Access Service Kind */
enum : uint8_t {
IND_VOICE_CALL = 0x00U, // Individual Voice Call
GRP_VOICE_CALL = 0x01U, // Group Voice Call
IND_DATA_CALL = 0x02U, // Individual Data Call
GRP_DATA_CALL = 0x03U, // Group Data Call
IND_UDT_DATA_CALL = 0x04U, // Individual UDT Short Data Call
GRP_UDT_DATA_CALL = 0x05U, // Group UDT Short Data Call
UDT_SHORT_POLL = 0x06U, // UDT Short Data Polling Service
STATUS_TRANSPORT = 0x07U, // Status Transport Service
CALL_DIVERSION = 0x08U, // Call Diversion Service
CALL_ANSWER = 0x09U, // Call Answer Service
SUPPLEMENTARY_SVC = 0x0DU, // Supplementary Service
REG_SVC = 0x0EU, // Registration Service
CANCEL_CALL = 0x0FU // Cancel Call Service
IND_VOICE_CALL = 0x00U, //! Individual Voice Call
GRP_VOICE_CALL = 0x01U, //! Group Voice Call
IND_DATA_CALL = 0x02U, //! Individual Data Call
GRP_DATA_CALL = 0x03U, //! Group Data Call
IND_UDT_DATA_CALL = 0x04U, //! Individual UDT Short Data Call
GRP_UDT_DATA_CALL = 0x05U, //! Group UDT Short Data Call
UDT_SHORT_POLL = 0x06U, //! UDT Short Data Polling Service
STATUS_TRANSPORT = 0x07U, //! Status Transport Service
CALL_DIVERSION = 0x08U, //! Call Diversion Service
CALL_ANSWER = 0x09U, //! Call Answer Service
SUPPLEMENTARY_SVC = 0x0DU, //! Supplementary Service
REG_SVC = 0x0EU, //! Registration Service
CANCEL_CALL = 0x0FU //! Cancel Call Service
};
}
/// <summary>
/// Broadcast Announcement Type(s)
/// </summary>
/** @brief Broadcast Announcement Type(s) */
namespace BroadcastAnncType {
/** @brief Broadcast Announcement Type(s) */
enum : uint8_t {
ANN_WD_TSCC = 0x00U, // Announce-Withdraw TSCC Channel
CALL_TIMER_PARMS = 0x01U, // Specify Call Timer Parameters
VOTE_NOW = 0x02U, // Vote Now Advice
LOCAL_TIME = 0x03U, // Broadcast Local Time
MASS_REG = 0x04U, // Mass Registration
CHAN_FREQ = 0x05U, // Logical Channel/Frequency
ADJ_SITE = 0x06U, // Adjacent Site Information
SITE_PARMS = 0x07U // General Site Parameters
ANN_WD_TSCC = 0x00U, //! Announce-Withdraw TSCC Channel
CALL_TIMER_PARMS = 0x01U, //! Specify Call Timer Parameters
VOTE_NOW = 0x02U, //! Vote Now Advice
LOCAL_TIME = 0x03U, //! Broadcast Local Time
MASS_REG = 0x04U, //! Mass Registration
CHAN_FREQ = 0x05U, //! Logical Channel/Frequency
ADJ_SITE = 0x06U, //! Adjacent Site Information
SITE_PARMS = 0x07U //! General Site Parameters
};
}
/// <summary>
/// Control Signalling Block Opcode(s)
/// </summary>
/** @brief Control Signalling Block Opcode(s) */
namespace CSBKO {
/** @brief Control Signalling Block Opcode(s) */
enum : uint8_t {
// CSBK ISP/OSP Shared Opcode(s)
NONE = 0x00U, //
UU_V_REQ = 0x04U, // UU VCH REQ - Unit-to-Unit Voice Channel Request
UU_ANS_RSP = 0x05U, // UU ANS RSP - Unit-to-Unit Answer Response
CTCSBK = 0x07U, // CT CSBK - Channel Timing CSBK
ALOHA = 0x19U, // ALOHA - Aloha PDU for Random Access
AHOY = 0x1CU, // AHOY - Enquiry from TSCC
RAND = 0x1FU, // (ETSI) RAND - Random Access / (DMRA) CALL ALRT - Call Alert
ACK_RSP = 0x20U, // ACK RSP - Acknowledge Response
EXT_FNCT = 0x24U, // (DMRA) EXT FNCT - Extended Function
NACK_RSP = 0x26U, // NACK RSP - Negative Acknowledgement Response
BROADCAST = 0x28U, // BCAST - Announcement PDU
MAINT = 0x2AU, // MAINT - Call Maintainence PDU
P_CLEAR = 0x2EU, // P_CLEAR - Payload Channel Clear
PV_GRANT = 0x30U, // PV_GRANT - Private Voice Channel Grant
TV_GRANT = 0x31U, // TV_GRANT - Talkgroup Voice Channel Grant
BTV_GRANT = 0x32U, // BTV_GRANT - Broadcast Talkgroup Voice Channel Grant
PD_GRANT = 0x33U, // PD_GRANT - Private Data Channel Grant
TD_GRANT = 0x34U, // TD_GRANT - Talkgroup Data Channel Grant
BSDWNACT = 0x38U, // BS DWN ACT - BS Outbound Activation
PRECCSBK = 0x3DU, // PRE CSBK - Preamble CSBK
NONE = 0x00U, //!
UU_V_REQ = 0x04U, //! UU VCH REQ - Unit-to-Unit Voice Channel Request
UU_ANS_RSP = 0x05U, //! UU ANS RSP - Unit-to-Unit Answer Response
CTCSBK = 0x07U, //! CT CSBK - Channel Timing CSBK
ALOHA = 0x19U, //! ALOHA - Aloha PDU for Random Access
AHOY = 0x1CU, //! AHOY - Enquiry from TSCC
RAND = 0x1FU, //! (ETSI) RAND - Random Access / (DMRA) CALL ALRT - Call Alert
ACK_RSP = 0x20U, //! ACK RSP - Acknowledge Response
EXT_FNCT = 0x24U, //! (DMRA) EXT FNCT - Extended Function
NACK_RSP = 0x26U, //! NACK RSP - Negative Acknowledgement Response
BROADCAST = 0x28U, //! BCAST - Announcement PDU
MAINT = 0x2AU, //! MAINT - Call Maintainence PDU
P_CLEAR = 0x2EU, //! P_CLEAR - Payload Channel Clear
PV_GRANT = 0x30U, //! PV_GRANT - Private Voice Channel Grant
TV_GRANT = 0x31U, //! TV_GRANT - Talkgroup Voice Channel Grant
BTV_GRANT = 0x32U, //! BTV_GRANT - Broadcast Talkgroup Voice Channel Grant
PD_GRANT = 0x33U, //! PD_GRANT - Private Data Channel Grant
TD_GRANT = 0x34U, //! TD_GRANT - Talkgroup Data Channel Grant
BSDWNACT = 0x38U, //! BS DWN ACT - BS Outbound Activation
PRECCSBK = 0x3DU, //! PRE CSBK - Preamble CSBK
// CSBK DVM Outbound Signalling Packet (OSP) Opcode(s)
DVM_GIT_HASH = 0x3FU //
DVM_GIT_HASH = 0x3FU //!
};
}
/** @} */
} // namespace defines
} // namespace dmr

@ -1,15 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL
*
*/
* @file DMRUtils.h
* @ingroup dmr
*/
#if !defined(__DMR_UTILS_H__)
#define __DMR_UTILS_H__
@ -20,14 +21,19 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements various helper functions for validating DMR data.
// ---------------------------------------------------------------------------
/**
* @brief This class implements various helper functions for validating DMR data.
* @ingroup dmr
*/
class HOST_SW_API DMRUtils {
public:
/// <summary>Helper to test and clamp a DMR color code.</summary>
/// <param name="colorCode">Color Code</param>
/// <returns>Clamped color code.</returns>
/**
* @brief Helper to test and clamp a DMR color code.
* @param colorCode Color Code
* @returns uint32_t Clamped color code.
*/
static uint32_t colorCode(uint32_t colorCode)
{
if (colorCode < 0U) { // clamp to 0
@ -40,10 +46,12 @@ namespace dmr
return colorCode;
}
/// <summary>Helper to test and clamp a DMR site ID.</summary>
/// <param name="id">Site ID</param>
/// <param name="siteModel">Site Model</param>
/// <returns>Clamped site ID.</returns>
/**
* @brief Helper to test and clamp a DMR site ID.
* @param id Site ID
* @param siteModel Site Model
* @returns uint32_t Clamped site ID.
*/
static uint32_t siteId(uint32_t id, defines::SiteModel::E siteModel)
{
using namespace dmr::defines;
@ -86,10 +94,12 @@ namespace dmr
return id;
}
/// <summary>Helper to test and clamp a DMR network ID.</summary>
/// <param name="id">Network ID</param>
/// <param name="siteModel">Site Model</param>
/// <returns>Clamped network ID.</returns>
/**
* @brief Helper to test and clamp a DMR network ID.
* @param id Network ID
* @param siteModel Site Model
* @returns uint32_t Clamped network ID.
*/
static uint32_t netId(uint32_t id, defines::SiteModel::E siteModel)
{
using namespace dmr::defines;

@ -1,15 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL
*
*/
* @file SiteData.h
* @ingroup dmr
*/
#if !defined(__DMR_SITE_DATA_H__)
#define __DMR_SITE_DATA_H__
@ -21,12 +22,17 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents site data for DMR.
// ---------------------------------------------------------------------------
/**
* @brief Represents site data for DMR.
* @ingroup dmr
*/
class HOST_SW_API SiteData {
public:
/// <summary>Initializes a new instance of the SiteData class.</summary>
/**
* @brief Initializes a new instance of the SiteData class.
*/
SiteData() :
m_siteModel(defines::SiteModel::SM_SMALL),
m_netId(1U),
@ -37,12 +43,14 @@ namespace dmr
{
/* stub */
}
/// <summary>Initializes a new instance of the SiteData class.</summary>
/// <param name="siteModel">DMR site model.</param>
/// <param name="netId">DMR Network ID.</param>
/// <param name="siteId">DMR Site ID.</param>
/// <param name="parId">DMR partition ID.</param>
/// <param name="requireReg"></param>
/**
* @brief Initializes a new instance of the SiteData class.
* @param siteModel DMR site model.
* @param netId DMR Network ID.
* @param siteId DMR Site ID.
* @param parId DMR partition ID.
* @param requireReg Flag indicating the site requires registration.
*/
SiteData(defines::SiteModel::E siteModel, uint16_t netId, uint16_t siteId, uint8_t parId, bool requireReq) :
m_siteModel(siteModel),
m_netId(netId),
@ -69,16 +77,20 @@ namespace dmr
parId = 3U;
}
/// <summary>Helper to set the site network active flag.</summary>
/// <param name="netActive">Network active.</param>
/**
* @brief Helper to set the site network active flag.
* @param netActive Network active.
*/
void setNetActive(bool netActive)
{
m_netActive = netActive;
}
/// <summary>Returns the DMR system identity value.</summary>
/// <param name="msb"></param>
/// <returns></returns>
/**
* @brief Returns the DMR system identity value.
* @param msb
* @returns uint32_t System Identity Value.
*/
const uint32_t systemIdentity(bool msb = false)
{
using namespace dmr::defines;
@ -119,10 +131,11 @@ namespace dmr
return value & 0xFFFFU;
}
/// <summary>Equals operator.</summary>
/// <param name="data"></param>
/// <returns></returns>
SiteData & operator=(const SiteData & data)
/**
* @brief Equals operator.
* @param data Instance of SiteData to copy.
*/
SiteData& operator=(const SiteData& data)
{
if (this != &data) {
m_siteModel = data.m_siteModel;
@ -139,18 +152,32 @@ namespace dmr
}
public:
/// <summary>DMR site model type.</summary>
/** @name Site Data */
/**
* @brief DMR site model type.
*/
__READONLY_PROPERTY_PLAIN(defines::SiteModel::E, siteModel);
/// <summary>DMR site network ID.</summary>
/**
* @brief DMR site network ID.
*/
__READONLY_PROPERTY_PLAIN(uint16_t, netId);
/// <summary>DMR site ID.</summary>
/**
* @brief DMR site ID.
*/
__READONLY_PROPERTY_PLAIN(uint16_t, siteId);
/// <summary>DMR partition ID.</summary>
/**
* @brief DMR partition ID.
*/
__READONLY_PROPERTY_PLAIN(uint8_t, parId);
/// <summary>DMR require registration.</summary>
/**
* @brief DMR require registration.
*/
__READONLY_PROPERTY_PLAIN(bool, requireReg);
/// <summary>Flag indicating whether this site is a linked active network member.</summary>
/**
* @brief Flag indicating whether this site is a linked active network member.
*/
__READONLY_PROPERTY_PLAIN(bool, netActive);
/** @} */
};
} // namespace dmr

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
#include "common/dmr/SlotType.h"
#include "common/edac/Golay2087.h"
@ -24,9 +20,7 @@ using namespace dmr::defines;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the SlotType class.
/// </summary>
/* Initializes a new instance of the SlotType class. */
SlotType::SlotType() :
m_colorCode(0U),
m_dataType(DataType::IDLE)
@ -34,15 +28,10 @@ SlotType::SlotType() :
/* stub */
}
/// <summary>
/// Finalizes a instance of the SlotType class.
/// </summary>
/* Finalizes a instance of the SlotType class. */
SlotType::~SlotType() = default;
/// <summary>
/// Decodes DMR slot type.
/// </summary>
/// <param name="data"></param>
/* Decodes DMR slot type. */
void SlotType::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -63,10 +52,7 @@ void SlotType::decode(const uint8_t* data)
m_dataType = (DataType::E)((code >> 0) & 0x0FU);
}
/// <summary>
/// Encodes DMR slot type.
/// </summary>
/// <param name="data"></param>
/* Encodes DMR slot type. */
void SlotType::encode(uint8_t* data) const
{
assert(data != nullptr);

@ -1,17 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
* @file SlotType.h
* @ingroup dmr
* @file SlotType.cpp
* @ingroup dmr
*/
#if !defined(__DMR_SLOT_TYPE_H__)
#define __DMR_SLOT_TYPE_H__
@ -22,26 +24,43 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents DMR slot type.
// ---------------------------------------------------------------------------
/**
* @brief Represents DMR slot type.
* @ingroup dmr
*/
class HOST_SW_API SlotType {
public:
/// <summary>Initializes a new instance of the SlotType class.</summary>
/**
* @brief Initializes a new instance of the SlotType class.
*/
SlotType();
/// <summary>Finalizes a instance of the SlotType class.</summary>
/**
* @brief Finalizes a instance of the SlotType class.
*/
~SlotType();
/// <summary>Decodes DMR slot type.</summary>
/**
* @brief Decodes DMR slot type.
* @param[in] data Buffer containing DMR slot type.
*/
void decode(const uint8_t* data);
/// <summary>Encodes DMR slot type.</summary>
/**
* @brief Encodes DMR slot type.
* @param[out] data Buffer to encode DMR slot type.
*/
void encode(uint8_t* data) const;
public:
/// <summary>DMR access color code.</summary>
/**
* @brief DMR access color code.
*/
__PROPERTY(uint8_t, colorCode, ColorCode);
/// <summary>Slot data type.</summary>
/**
* @brief Slot data type.
*/
__PROPERTY(defines::DataType::E, dataType, DataType);
};
} // namespace dmr

@ -1,16 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/Sync.h"
@ -24,11 +20,7 @@ using namespace dmr::defines;
// Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Helper to append DMR data sync bytes to the passed buffer.
/// </summary>
/// <param name="data">Buffer to append sync bytes to.</param>
/// <param name="duplex">Flag indicating whether this is duplex operation.</param>
/* Helper to append DMR data sync bytes to the passed buffer. */
void Sync::addDMRDataSync(uint8_t* data, bool duplex)
{
assert(data != nullptr);
@ -43,11 +35,7 @@ void Sync::addDMRDataSync(uint8_t* data, bool duplex)
}
}
/// <summary>
/// Helper to append DMR voice sync bytes to the passed buffer.
/// </summary>
/// <param name="data">Buffer to append sync bytes to.</param>
/// <param name="duplex">Flag indicating whether this is duplex operation.</param>
/* Helper to append DMR voice sync bytes to the passed buffer. */
void Sync::addDMRAudioSync(uint8_t* data, bool duplex)
{
assert(data != nullptr);

@ -1,16 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
* @file Sync.h
* @ingroup dmr
* @file Sync.cpp
* @ingroup dmr
*/
#if !defined(__DMR_SYNC_H__)
#define __DMR_SYNC_H__
@ -20,14 +22,25 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Helper class for generating DMR sync data.
// ---------------------------------------------------------------------------
/**
* @brief Helper class for generating DMR sync data.
* @ingroup dmr
*/
class HOST_SW_API Sync {
public:
/// <summary>Helper to append DMR data sync bytes to the passed buffer.</summary>
/**
* @brief Helper to append DMR data sync bytes to the passed buffer.
* @param data Buffer to append DMR data sync bytes to.
* @param duplex Flag indicating whether or not duplex sync is required.
*/
static void addDMRDataSync(uint8_t* data, bool duplex);
/// <summary>Helper to append DMR voice sync bytes to the passed buffer.</summary>
/**
* @brief Helper to append DMR voice sync bytes to the passed buffer.
* @param data Buffer to append DMR voice sync bytes to.
* @param duplex Flag indicating whether or not duplex sync is required.
*/
static void addDMRAudioSync(uint8_t* data, bool duplex);
};
} // namespace dmr

@ -1,18 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2016 Simon Rune, G7RZU
* Copyright (C) 2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2017,2019,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2016 Simon Rune, G7RZU
* Copyright (C) 2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2017,2019,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/acl/AccessControl.h"
@ -25,22 +21,14 @@ using namespace dmr::acl;
RadioIdLookup* AccessControl::m_ridLookup;
TalkgroupRulesLookup* AccessControl::m_tidLookup;
/// <summary>
/// Initializes the DMR access control.
/// </summary>
/// <param name="ridLookup">Instance of the RadioIdLookup class.</param>
/// <param name="tidLookup">Instance of the TalkgroupRulesLookup class.</param>
/* Initializes the DMR access control. */
void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLookup)
{
m_ridLookup = ridLookup;
m_tidLookup = tidLookup;
}
/// <summary>
/// Helper to validate a source radio ID.
/// </summary>
/// <param name="id">Source Radio ID.</param>
/// <returns>True, if source radio ID is valid, otherwise false.</returns>
/* Helper to validate a source radio ID. */
bool AccessControl::validateSrcId(uint32_t id)
{
// check if RID ACLs are enabled
@ -61,12 +49,7 @@ bool AccessControl::validateSrcId(uint32_t id)
return true;
}
/// <summary>
/// Helper to validate a talkgroup ID.
/// </summary>
/// <param name="slotNo">DMR slot number.</param>
/// <param name="id">Talkgroup ID.</param>
/// <returns>True, if talkgroup ID is valid, otherwise false.</returns>
/* Helper to validate a talkgroup ID. */
bool AccessControl::validateTGId(uint32_t slotNo, uint32_t id)
{
// TG0 is never valid
@ -96,12 +79,7 @@ bool AccessControl::validateTGId(uint32_t slotNo, uint32_t id)
}
}
/// <summary>
/// Helper to determine if a talkgroup ID is non-preferred.
/// </summary>
/// <param name="slotNo">DMR slot number.</param>
/// <param name="id">Talkgroup ID.</param>
/// <returns>True, if talkgroup ID is valid, otherwise false.</returns>
/* Helper to determine if a talkgroup ID is non-preferred. */
bool AccessControl::tgidNonPreferred(uint32_t slotNo, uint32_t id)
{
// TG0 is never valid

@ -1,18 +1,20 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2016 Simon Rune, G7RZU
* Copyright (C) 2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2017,2019,2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2016 Simon Rune, G7RZU
* Copyright (C) 2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2017,2019,2024 Bryan Biedenkapp, N2PLL
*
*/
* @file Data.h
* @ingroup dmr
* @file Data.cpp
* @ingroup dmr
*/
#if !defined(__DMR_ACL__ACCESS_CONTROL_H__)
#define __DMR_ACL__ACCESS_CONTROL_H__
@ -28,20 +30,41 @@ namespace dmr
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements radio and talkgroup ID access control checking.
// ---------------------------------------------------------------------------
/**
* @brief Implements radio and talkgroup ID access control checking.
* @ingroup dmr
*/
class HOST_SW_API AccessControl {
public:
/// <summary>Initializes the DMR access control.</summary>
/**
* @brief Initializes the DMR access control.
* @param ridLookup Instance of the RadioIdLooup class.
* @param tidLookup Instance of the TalkgroupRulesLooup class.
*/
static void init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLookup);
/// <summary>Helper to validate a source radio ID.</summary>
/**
* @brief Helper to validate a source radio ID.
* @param id Source Radio ID (RID).
* @returns bool True, if source radio ID is valid, otherwise false.
*/
static bool validateSrcId(uint32_t id);
/// <summary>Helper to validate a talkgroup ID.</summary>
/**
* @brief Helper to validate a talkgroup ID.
* @param slotNo DMR slot number.
* @param id Talkgroup ID (TGID).
* @returns bool True, if talkgroup ID is valid, otherwise false.
*/
static bool validateTGId(uint32_t slotNo, uint32_t id);
/// <summary>Helper to determine if a talkgroup ID is non-preferred.</summary>
/**
* @brief Helper to determine if a talkgroup ID is non-preferred.
* @param slotNo DMR slot number.
* @param id Talkgroup ID (TGID).
* @returns bool True, if talkgroup ID is non-preferred, otherwise false.
*/
static bool tgidNonPreferred(uint32_t slotNo, uint32_t id);
private:

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/data/Data.h"
@ -27,10 +23,7 @@ using namespace dmr::data;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the Data class.
/// </summary>
/// <param name="data"></param>
/* Initializes a new instance of the Data class. */
Data::Data(const Data& data) :
m_slotNo(data.m_slotNo),
m_srcId(data.m_srcId),
@ -47,9 +40,7 @@ Data::Data(const Data& data) :
::memcpy(m_data, data.m_data, 2U * DMR_FRAME_LENGTH_BYTES);
}
/// <summary>
/// Initializes a new instance of the Data class.
/// </summary>
/* Initializes a new instance of the Data class. */
Data::Data() :
m_slotNo(1U),
m_srcId(0U),
@ -65,19 +56,13 @@ Data::Data() :
m_data = new uint8_t[2U * DMR_FRAME_LENGTH_BYTES];
}
/// <summary>
/// Finalizes a instance of the Data class.
/// </summary>
/* Finalizes a instance of the Data class. */
Data::~Data()
{
delete[] m_data;
}
/// <summary>
/// Equals operator.
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
/* Equals operator. */
Data& Data::operator=(const Data& data)
{
if (this != &data) {
@ -97,10 +82,7 @@ Data& Data::operator=(const Data& data)
return *this;
}
/// <summary>
/// Sets raw data.
/// </summary>
/// <param name="buffer">Data buffer.</param>
/* Sets raw data. */
void Data::setData(const uint8_t* buffer)
{
assert(buffer != nullptr);
@ -108,10 +90,7 @@ void Data::setData(const uint8_t* buffer)
::memcpy(m_data, buffer, DMR_FRAME_LENGTH_BYTES);
}
/// <summary>
/// Gets raw data.
/// </summary>
/// <param name="buffer">Data buffer.</param>
/* Gets raw data. */
uint32_t Data::getData(uint8_t* buffer) const
{
assert(buffer != nullptr);

@ -1,17 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
* @file Data.h
* @ingroup dmr
* @file Data.cpp
* @ingroup dmr
*/
#if !defined(__DMR_DATA__DATA_H__)
#define __DMR_DATA__DATA_H__
@ -24,51 +26,88 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents general DMR data.
// ---------------------------------------------------------------------------
/**
* @brief Represents network DMR data.
* @ingroup dmr
*/
class HOST_SW_API Data {
public:
/// <summary>Initializes a new instance of the Data class.</summary>
/**
* @brief Initializes a new instance of the Data class.
* @param data Instance of Data class to copy from.
*/
Data(const Data& data);
/// <summary>Initializes a new instance of the Data class.</summary>
/**
* @brief Initializes a new instance of the Data class.
*/
Data();
/// <summary>Finalizes a instance of the Data class.</summary>
/**
* @brief Finalizes a instance of the Data class.
*/
~Data();
/// <summary>Equals operator.</summary>
/**
* @brief Equals operator.
* @param data Instance of Data class to copy from.
*/
Data& operator=(const Data& data);
/// <summary>Sets raw data.</summary>
/**
* @brief Sets raw data.
* @param[in] buffer Raw data buffer.
*/
void setData(const uint8_t* buffer);
/// <summary>Gets raw data.</summary>
/**
* @brief Gets raw data.
* @param[out] buffer Raw data buffer.
*/
uint32_t getData(uint8_t* buffer) const;
public:
/// <summary>DMR slot number.</summary>
/**
* @brief DMR slot number.
*/
__PROPERTY(uint32_t, slotNo, SlotNo);
/// <summary>Source ID.</summary>
/**
* @brief Source ID.
*/
__PROPERTY(uint32_t, srcId, SrcId);
/// <summary>Destination ID.</summary>
/**
* @brief Destination ID.
*/
__PROPERTY(uint32_t, dstId, DstId);
/// <summary>Sets the full-link control opcode.</summary>
/**
* @brief Sets the full-link control opcode.
*/
__PROPERTY(defines::FLCO::E, flco, FLCO);
/// <summary></summary>
/**
* @brief
*/
__PROPERTY(uint8_t, n, N);
/// <summary>Sequence number.</summary>
/**
* @brief Sequence number.
*/
__PROPERTY(uint8_t, seqNo, SeqNo);
/// <summary>Embedded data type.</summary>
/**
* @brief Embedded data type.
*/
__PROPERTY(defines::DataType::E, dataType, DataType);
/// <summary>Bit Error Rate.</summary>
/**
* @brief Bit Error Rate.
*/
__PROPERTY(uint8_t, ber, BER);
/// <summary>Received Signal Strength Indicator.</summary>
/**
* @brief Received Signal Strength Indicator.
*/
__PROPERTY(uint8_t, rssi, RSSI);
private:

@ -1,18 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2012 Ian Wraith
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2021,2023,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2012 Ian Wraith
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2021,2023,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/data/DataHeader.h"
@ -37,9 +33,7 @@ const uint8_t UDTF_NMEA = 0x05U;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the DataHeader class.
/// </summary>
/* Initializes a new instance of the DataHeader class. */
DataHeader::DataHeader() :
m_GI(false),
m_DPF(DPF::UDT),
@ -67,19 +61,13 @@ DataHeader::DataHeader() :
m_data = new uint8_t[DMR_LC_HEADER_LENGTH_BYTES];
}
/// <summary>
/// Finalizes a instance of the DataHeader class.
/// </summary>
/* Finalizes a instance of the DataHeader class. */
DataHeader::~DataHeader()
{
delete[] m_data;
}
/// <summary>
/// Equals operator.
/// </summary>
/// <param name="header"></param>
/// <returns></returns>
/* Equals operator. */
DataHeader& DataHeader::operator=(const DataHeader& header)
{
if (&header != this) {
@ -111,11 +99,7 @@ DataHeader& DataHeader::operator=(const DataHeader& header)
return *this;
}
/// <summary>
/// Decodes a DMR data header.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if DMR data header was decoded, otherwise false.</returns>
/* Decodes a DMR data header. */
bool DataHeader::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -230,10 +214,7 @@ bool DataHeader::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encodes a DMR data header.
/// </summary>
/// <param name="data"></param>
/* Encodes a DMR data header. */
void DataHeader::encode(uint8_t* data) const
{
assert(data != nullptr);

@ -1,17 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2021 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2021 Bryan Biedenkapp, N2PLL
*
*/
* @file DataHeader.h
* @ingroup dmr
* @file DataHeader.cpp
* @ingroup dmr
*/
#if !defined(__DMR_DATA__DATA_HEADER_H__)
#define __DMR_DATA__DATA_HEADER_H__
@ -23,67 +25,118 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents a DMR data header.
// ---------------------------------------------------------------------------
/**
* @brief Represents a DMR data header.
* @ingroup dmr
*/
class HOST_SW_API DataHeader {
public:
/// <summary>Initializes a new instance of the DataHeader class.</summary>
/**
* @brief Initializes a new instance of the DataHeader class.
*/
DataHeader();
/// <summary>Finalizes a instance of the DataHeader class.</summary>
/**
* @brief Finalizes a instance of the DataHeader class.
*/
~DataHeader();
/// <summary>Equals operator.</summary>
/**
* @brief Equals operator.
* @param header Instance of DataHeader class to copy from.
*/
DataHeader& operator=(const DataHeader& header);
/// <summary>Decodes a DMR data header.</summary>
/**
* @brief Decodes a DMR data header.
* @param[in] data Buffer containing DMR data header.
* @returns bool True, if DMR data header is decoded, otherwise false.
*/
bool decode(const uint8_t* data);
/// <summary>Encodes a DMR data header.</summary>
/**
* @brief Encodes a DMR data header.
* @param[out] data Buffer to encode a DMR data header.
*/
void encode(uint8_t* data) const;
public:
/// <summary>Flag indicating whether the CSBK is group or individual.</summary>
/**
* @brief Flag indicating whether the CSBK is group or individual.
*/
__PROPERTY(bool, GI, GI);
/// <summary>Data packet format.</summary>
/**
* @brief Data packet format.
*/
__PROPERTY(defines::DPF::E, DPF, DPF);
/// <summary>Service access point.</summary>
/**
* @brief Service access point.
*/
__PROPERTY(uint8_t, sap, SAP);
/// <summary>Fragment Sequence Number.</summary>
/**
* @brief Fragment Sequence Number.
*/
__PROPERTY(uint8_t, fsn, FSN);
/// <summary>Send Sequence Number.</summary>
/**
* @brief Send Sequence Number.
*/
__PROPERTY(uint8_t, Ns, Ns);
/// <summary>Count of block padding.</summary>
/**
* @brief Count of block padding.
*/
__PROPERTY(uint8_t, padCount, PadCount);
/// <summary>Full Message Flag.</summary>
/**
* @brief Full Message Flag.
*/
__PROPERTY(bool, F, FullMesage);
/// <summary>Synchronize Flag.</summary>
/**
* @brief Synchronize Flag.
*/
__PROPERTY(bool, S, Synchronize);
/// <summary>Unified Data or Defined Data Format.</summary>
/**
* @brief Unified Data or Defined Data Format.
*/
__PROPERTY(uint8_t, dataFormat, DataFormat);
/// <summary>Source ID.</summary>
/**
* @brief Source ID.
*/
__PROPERTY(uint32_t, srcId, SrcId);
/// <summary>Destination ID.</summary>
/**
* @brief Destination ID.
*/
__PROPERTY(uint32_t, dstId, DstId);
/// <summary>Gets the number of data blocks following the header.</summary>
/**
* @brief Gets the number of data blocks following the header.
*/
__PROPERTY(uint32_t, blocks, Blocks);
/// <summary>Response class.</summary>
/**
* @brief Response class.
*/
__PROPERTY(uint8_t, rspClass, Class);
/// <summary>Response type.</summary>
/**
* @brief Response type.
*/
__PROPERTY(uint8_t, rspType, Type);
/// <summary>Response status.</summary>
/**
* @brief Response status.
*/
__PROPERTY(uint8_t, rspStatus, Status);
/// <summary>Source Port.</summary>
/**
* @brief Source Port.
*/
__PROPERTY(uint8_t, srcPort, SrcPort);
/// <summary>Destination Port.</summary>
/**
* @brief Destination Port.
*/
__PROPERTY(uint8_t, dstPort, DstPort);
private:

@ -1,16 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
#include "Defines.h"
#include "dmr/data/EMB.h"
#include "edac/QR1676.h"
@ -25,9 +21,7 @@ using namespace dmr;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the EMB class.
/// </summary>
/* Initializes a new instance of the EMB class. */
EMB::EMB() :
m_colorCode(0U),
m_PI(false),
@ -36,15 +30,10 @@ EMB::EMB() :
/* stub */
}
/// <summary>
/// Finalizes a instance of the EMB class.
/// </summary>
/* Finalizes a instance of the EMB class. */
EMB::~EMB() = default;
/// <summary>
/// Decodes DMR embedded signalling data.
/// </summary>
/// <param name="data"></param>
/* Decodes DMR embedded signalling data. */
void EMB::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -63,10 +52,7 @@ void EMB::decode(const uint8_t* data)
m_LCSS = (DMREMB[0U] >> 1) & 0x03U;
}
/// <summary>
/// Encodes DMR embedded signalling data.
/// </summary>
/// <param name="data"></param>
/* Encodes DMR embedded signalling data. */
void EMB::encode(uint8_t* data) const
{
assert(data != nullptr);

@ -1,16 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
* @file EMB.h
* @ingroup dmr
* @file EMB.cpp
* @ingroup dmr
*/
#if !defined(__DMR_DATA__EMB_H__)
#define __DMR_DATA__EMB_H__
@ -22,29 +24,48 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents a DMR embedded signalling data.
// ---------------------------------------------------------------------------
/**
* @brief Represents a DMR embedded signalling data.
* @ingroup dmr
*/
class HOST_SW_API EMB {
public:
/// <summary>Initializes a new instance of the EMB class.</summary>
/**
* @brief Initializes a new instance of the EMB class.
*/
EMB();
/// <summary>Finalizes a instance of the EMB class.</summary>
/**
* @brief Finalizes a instance of the EMB class.
*/
~EMB();
/// <summary>Decodes DMR embedded signalling data.</summary>
/**
* @brief Decodes DMR embedded signalling data.
* @param[in] data Buffer containing embedded signalling data.
*/
void decode(const uint8_t* data);
/// <summary>Encodes DMR embedded signalling data.</summary>
/**
* @brief Encodes DMR embedded signalling data.
* @param[out] data Buffer to encode embedded signalling data.
*/
void encode(uint8_t* data) const;
public:
/// <summary>DMR access color code.</summary>
/**
* @brief DMR access color code.
*/
__PROPERTY(uint8_t, colorCode, ColorCode);
/// <summary>Flag indicating whether the privacy indicator is set or not.</summary>
/**
* @brief Flag indicating whether the privacy indicator is set or not.
*/
__PROPERTY(bool, PI, PI);
/// <summary>Link control start/stop.</summary>
/**
* @brief Link control start/stop.
*/
__PROPERTY(uint8_t, LCSS, LCSS);
};
} // namespace data

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/data/EmbeddedData.h"
@ -31,9 +27,7 @@ using namespace dmr::data;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the EmbeddedData class.
/// </summary>
/* Initializes a new instance of the EmbeddedData class. */
EmbeddedData::EmbeddedData() :
m_valid(false),
m_FLCO(FLCO::GROUP),
@ -45,21 +39,14 @@ EmbeddedData::EmbeddedData() :
m_data = new bool[72U];
}
/// <summary>
/// Finalizes a instance of the EmbeddedData class.
/// </summary>
/* Finalizes a instance of the EmbeddedData class. */
EmbeddedData::~EmbeddedData()
{
delete[] m_raw;
delete[] m_data;
}
/// <summary>
/// Add LC data (which may consist of 4 blocks) to the data store.
/// </summary>
/// <param name="data"></param>
/// <param name="lcss"></param>
/// <returns></returns>
/* Add LC data (which may consist of 4 blocks) to the data store. */
bool EmbeddedData::addData(const uint8_t* data, uint8_t lcss)
{
assert(data != nullptr);
@ -124,12 +111,7 @@ bool EmbeddedData::addData(const uint8_t* data, uint8_t lcss)
return false;
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/// <param name="n"></param>
/// <returns></returns>
/* Get LC data from the data store. */
uint8_t EmbeddedData::getData(uint8_t* data, uint8_t n) const
{
assert(data != nullptr);
@ -174,10 +156,7 @@ uint8_t EmbeddedData::getData(uint8_t* data, uint8_t n) const
}
}
/// <summary>
/// Sets link control data.
/// </summary>
/// <param name="lc"></param>
/* Sets link control data. */
void EmbeddedData::setLC(const lc::LC& lc)
{
lc.getData(m_data);
@ -188,10 +167,7 @@ void EmbeddedData::setLC(const lc::LC& lc)
encodeEmbeddedData();
}
/// <summary>
/// Gets link control data.
/// </summary>
/// <returns></returns>
/* Gets link control data. */
std::unique_ptr<lc::LC> EmbeddedData::getLC() const
{
if (!m_valid)
@ -203,11 +179,7 @@ std::unique_ptr<lc::LC> EmbeddedData::getLC() const
return std::make_unique<lc::LC>(m_data);
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
/* Get raw embedded data buffer. */
bool EmbeddedData::getRawData(uint8_t* data) const
{
assert(data != nullptr);
@ -228,9 +200,7 @@ bool EmbeddedData::getRawData(uint8_t* data) const
return true;
}
/// <summary>
/// Helper to reset data values to defaults.
/// </summary>
/* Helper to reset data values to defaults. */
void EmbeddedData::reset()
{
m_state = LCS_NONE;
@ -241,9 +211,7 @@ void EmbeddedData::reset()
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Unpack and error check an embedded LC.
/// </summary>
/* Unpack and error check an embedded LC. */
void EmbeddedData::decodeEmbeddedData()
{
// the data is unpacked downwards in columns
@ -308,9 +276,7 @@ void EmbeddedData::decodeEmbeddedData()
m_FLCO = (FLCO::E)(flco & 0x3FU);
}
/// <summary>
/// Pack and FEC for an embedded LC.
/// </summary>
/* Pack and FEC for an embedded LC. */
void EmbeddedData::encodeEmbeddedData()
{
uint32_t crc;

@ -1,17 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkap, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
* Copyright (C) 2024 Bryan Biedenkap, N2PLL
*
*/
* @file EmbeddedData.h
* @ingroup dmr
* @file EmbeddedData.cpp
* @ingroup dmr
*/
#if !defined(__DMR_DATA__EMBEDDED_DATA_H__)
#define __DMR_DATA__EMBEDDED_DATA_H__
@ -36,36 +38,68 @@ namespace dmr
// ---------------------------------------------------------------------------
// Class Declaration
// Represents a DMR embedded data.
// ---------------------------------------------------------------------------
/**
* @brief Represents a DMR embedded data.
* @ingroup dmr
*/
class HOST_SW_API EmbeddedData {
public:
/// <summary>Initializes a new instance of the EmbeddedData class.</summary>
/**
* @brief Initializes a new instance of the EmbeddedData class.
*/
EmbeddedData();
/// <summary>Finalizes a instance of the EmbeddedData class.</summary>
/**
* @brief Finalizes a instance of the EmbeddedData class.
*/
~EmbeddedData();
/// <summary>Add LC data (which may consist of 4 blocks) to the data store.</summary>
/**
* @brief Add LC data (which may consist of 4 blocks) to the data store.
* @param[in] data
* @param lcss
* @returns bool True, if LC data is decoded, otherwise false.
*/
bool addData(const uint8_t* data, uint8_t lcss);
/// <summary>Get LC data from the data store.</summary>
/**
* @brief Get LC data from the data store.
* @param[out] data
* @param n
* @returns uint8_t
*/
uint8_t getData(uint8_t* data, uint8_t n) const;
/// <summary>Sets link control data.</summary>
/**
* @brief Sets link control data.
* @param lc Instance of the LC class.
*/
void setLC(const lc::LC& lc);
/// <summary>Gets link control data.</summary>
/**
* @brief Gets link control data.
* @returns lc::LC* LC class.
*/
std::unique_ptr<lc::LC> getLC() const;
/// <summary>Get raw embedded data buffer.</summary>
/**
* @brief Get raw embedded data buffer.
* @param[in] data
*/
bool getRawData(uint8_t* data) const;
/// <summary>Helper to reset data values to defaults.</summary>
/**
* @brief Helper to reset data values to defaults.
*/
void reset();
public:
/// <summary>Flag indicating whether or not the embedded data is valid.</summary>
/**
* @brief Flag indicating whether or not the embedded data is valid.
*/
__READONLY_PROPERTY_PLAIN(bool, valid);
/// <summary>Full-link control opcode.</summary>
/**
* @brief Full-link control opcode.
*/
__READONLY_PROPERTY(defines::FLCO::E, FLCO, FLCO);
private:
@ -74,9 +108,13 @@ namespace dmr
bool* m_raw;
/// <summary>Unpack and error check an embedded LC.</summary>
/**
* @brief Unpack and error check an embedded LC.
*/
void decodeEmbeddedData();
/// <summary>Pack and FEC for an embedded LC.</summary>
/**
* @brief Pack and FEC for an embedded LC.
*/
void encodeEmbeddedData();
};
} // namespace data

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2019-2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2019-2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "edac/BPTC19696.h"
@ -37,18 +33,13 @@ SiteData CSBK::m_siteData = SiteData();
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a copy instance of the CSBK class.
/// </summary>
/// <param name="data"></param>
/* Initializes a copy instance of the CSBK class. */
CSBK::CSBK(const CSBK& data) : CSBK()
{
copy(data);
}
/// <summary>
/// Initializes a new instance of the CSBK class.
/// </summary>
/* Initializes a new instance of the CSBK class. */
CSBK::CSBK() :
m_colorCode(0U),
m_lastBlock(true),
@ -79,40 +70,26 @@ CSBK::CSBK() :
/* stub */
}
/// <summary>
/// Finalizes a instance of the CSBK class.
/// </summary>
/* Finalizes a instance of the CSBK class. */
CSBK::~CSBK()
{
if (m_raw != nullptr)
delete[] m_raw;
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK::toString()
{
return std::string("CSBKO, UNKNOWN (Unknown CSBK)");
}
/// <summary>
/// Returns a copy of the raw decoded CSBK bytes.
/// </summary>
/// <remarks>This will only return data for a *decoded* CSBK, not a created or copied CSBK.</remarks>
/// <returns></returns>
/* Returns a copy of the raw decoded CSBK bytes. */
uint8_t* CSBK::getDecodedRaw() const
{
return m_raw;
}
/// <summary>
/// Regenerate a DMR CSBK without decoding.
/// </summary>
/// <param name="data"></param>
/// <param name="dataType"></param>
/// <returns>True, if TSBK was decoded, otherwise false.</returns>
/* Regenerate a DMR CSBK without decoding. */
bool CSBK::regenerate(uint8_t* data, uint8_t dataType)
{
uint8_t csbk[DMR_CSBK_LENGTH_BYTES];
@ -199,11 +176,7 @@ bool CSBK::regenerate(uint8_t* data, uint8_t dataType)
// Protected Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper to convert payload bytes to a 64-bit long value.
/// </summary>
/// <param name="payload"></param>
/// <returns></returns>
/* Internal helper to convert payload bytes to a 64-bit long value. */
ulong64_t CSBK::toValue(const uint8_t* payload)
{
ulong64_t value = 0U;
@ -221,11 +194,7 @@ ulong64_t CSBK::toValue(const uint8_t* payload)
return value;
}
/// <summary>
/// Internal helper to convert a 64-bit long value to payload bytes.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
/* Internal helper to convert a 64-bit long value to payload bytes. */
UInt8Array CSBK::fromValue(const ulong64_t value)
{
UInt8Array payload = std::unique_ptr<uint8_t[]>(new uint8_t[DMR_CSBK_LENGTH_BYTES - 4U]);
@ -244,12 +213,7 @@ UInt8Array CSBK::fromValue(const ulong64_t value)
return payload;
}
/// <summary>
/// Internal helper to decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <param name="payload"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Internal helper to decode a control signalling block. */
bool CSBK::decode(const uint8_t* data, uint8_t* payload)
{
assert(data != nullptr);
@ -316,11 +280,7 @@ bool CSBK::decode(const uint8_t* data, uint8_t* payload)
return true;
}
/// <summary>
/// Internal helper to encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <param name="payload"></param>
/* Internal helper to encode a control signalling block. */
void CSBK::encode(uint8_t* data, const uint8_t* payload)
{
assert(data != nullptr);
@ -378,10 +338,7 @@ void CSBK::encode(uint8_t* data, const uint8_t* payload)
bptc.encode(csbk, data);
}
/// <summary>
/// Internal helper to copy the the class.
/// </summary>
/// <param name="data"></param>
/* Internal helper to copy the the class. */
void CSBK::copy(const CSBK& data)
{
m_colorCode = data.m_colorCode;

@ -12,6 +12,12 @@
* Copyright (C) 2019-2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* @file CSBK.h
* @ingroup dmr_lc
* @file CSBK.cpp
* @ingroup dmr_lc
*/
#if !defined(__DMR_LC__CSBK_H__)
#define __DMR_LC__CSBK_H__
@ -27,125 +33,232 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents DMR control signalling block data.
// ---------------------------------------------------------------------------
/**
* @brief Represents DMR control signalling block data.
* @ingroup dmr_lc
*/
class HOST_SW_API CSBK {
public:
/// <summary>Initializes a copy instance of the CSBK class.</summary>
/**
* @brief Initializes a copy instance of the CSBK class.
* @param data Instance of CSBK to copy.
*/
CSBK(const CSBK& data);
/// <summary>Initializes a new instance of the CSBK class.</summary>
/**
* @brief Initializes a new instance of the CSBK class.
*/
CSBK();
/// <summary>Finalizes a instance of the CSBK class.</summary>
/**
* @brief Finalizes a instance of the CSBK class.
*/
virtual ~CSBK();
/// <summary>Decodes a DMR CSBK.</summary>
/**
* @brief Decodes a DMR CSBK.
* @param[in] data Buffer containing a CSBK to decode.
*/
virtual bool decode(const uint8_t* data) = 0;
/// <summary>Encodes a DMR CSBK.</summary>
/**
* @brief Encodes a DMR CSBK.
* @param[out] data Buffer to encode a CSBK.
*/
virtual void encode(uint8_t* data) = 0;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
virtual std::string toString();
/// <summary>Returns a copy of the raw decoded CSBK bytes.</summary>
/// <remarks>This will only return data for a *decoded* CSBK, not a created or copied CSBK.</remarks>
/**
* @brief Returns a copy of the raw decoded CSBK bytes.
* This will only return data for a *decoded* CSBK, not a created or copied CSBK.
* @returns uint8_t* Raw decoded CSBK bytes.
*/
uint8_t* getDecodedRaw() const;
/// <summary>Regenerate a DMR CSBK without decoding.</summary>
/// <remarks>This is because the DMR architecture allows fall-thru of unsupported CSBKs.</remarks>
/**
* @brief Regenerate a DMR CSBK without decoding.
* This is because the DMR architecture allows fall-thru of unsupported CSBKs.
* @param data Buffer containing DMR CSBK to regenerate.
* @param dataType Data Type
* @returns bool True, if CSBK is regenerated, otherwise false.
*/
static bool regenerate(uint8_t* data, uint8_t dataType);
/// <summary>Gets the flag indicating verbose log output.</summary>
/**
* @brief Gets the flag indicating verbose log output.
* @returns bool True, if the CSBK is verbose logging, otherwise false.
*/
static bool getVerbose() { return m_verbose; }
/// <summary>Sets the flag indicating verbose log output.</summary>
/**
* @brief Sets the flag indicating verbose log output.
* @param verbose Flag indicating verbose log output.
*/
static void setVerbose(bool verbose) { m_verbose = verbose; }
/** Local Site data */
/// <summary>Gets the local site data.</summary>
/** @name Local Site data */
/**
* @brief Gets the local site data.
* @returns SiteData Currently set site data for the CSBK class.
*/
static SiteData getSiteData() { return m_siteData; }
/// <summary>Sets the local site data.</summary>
/**
* @brief Sets the local site data.
* @param siteData Site data to set for the CSBK class.
*/
static void setSiteData(SiteData siteData) { m_siteData = siteData; }
/** @} */
public:
/** Common Data */
/// <summary>DMR access color code.</summary>
/** @name Common Data */
/**
* @brief DMR access color code.
*/
__PROTECTED_PROPERTY(uint8_t, colorCode, ColorCode);
/// <summary>Flag indicating this is the last CSBK in a sequence of CSBKs.</summary>
/**
* @brief Flag indicating this is the last CSBK in a sequence of CSBKs.
*/
__PROTECTED_PROPERTY(bool, lastBlock, LastBlock);
/// <summary>Flag indicating whether the CSBK is a Cdef block.</summary>
/**
* @brief Flag indicating whether the CSBK is a Cdef block.
*/
__PROTECTED_PROPERTY(bool, Cdef, Cdef);
/// <summary>CSBK opcode.</summary>
/**
* @brief CSBK opcode.
*/
__PROTECTED_PROPERTY(uint8_t, CSBKO, CSBKO);
/// <summary>CSBK feature ID.</summayr>
/**
* @brief */
__PROTECTED_PROPERTY(uint8_t, FID, FID);
/// <summary>Flag indicating whether the CSBK is group or individual.</summary>
/**
* @brief Flag indicating whether the CSBK is group or individual.
*/
__PROTECTED_PROPERTY(bool, GI, GI);
/// <summary>Source ID.</summary>
/**
* @brief Source ID.
*/
__PROTECTED_PROPERTY(uint32_t, srcId, SrcId);
/// <summary>Destination ID.</summary>
/**
* @brief Destination ID.
*/
__PROTECTED_PROPERTY(uint32_t, dstId, DstId);
/// <summary></summary>
/**
* @brief
*/
__PROTECTED_READONLY_PROPERTY(bool, dataContent, DataContent);
/// <summary>Number of blocks to follow.</summary>
/**
* @brief Number of blocks to follow.
*/
__PROTECTED_PROPERTY(uint8_t, CBF, CBF);
/// <summary>Data type for this CSBK.</summary>
/**
* @brief Data type for this CSBK.
*/
__PROTECTED_PROPERTY(defines::DataType::E, dataType, DataType);
/** @} */
/** Common Service Options */
/// <summary>Flag indicating the emergency bits are set.</summary>
/** @name Common Service Options */
/**
* @brief Flag indicating the emergency bits are set.
*/
__PROTECTED_PROPERTY(bool, emergency, Emergency);
/// <summary>Flag indicating that privacy is enabled.</summary>
/**
* @brief Flag indicating that privacy is enabled.
*/
__PROTECTED_PROPERTY(bool, privacy, Privacy);
/// <summary>Flag indicating that supplementary data is required.</summary>
/**
* @brief Flag indicating that supplementary data is required.
*/
__PROTECTED_PROPERTY(bool, supplementData, SupplementData);
/// <summary>Priority level for the traffic.</summary>
/**
* @brief Priority level for the traffic.
*/
__PROTECTED_PROPERTY(uint8_t, priority, Priority);
/// <summary>Flag indicating a broadcast service.</summary>
/**
* @brief Flag indicating a broadcast service.
*/
__PROTECTED_PROPERTY(bool, broadcast, Broadcast);
/// <summary>Flag indicating a proxy.</summary>
/**
* @brief Flag indicating a proxy.
*/
__PROTECTED_PROPERTY(bool, proxy, Proxy);
/// <summary>Response information.</summary>
/**
* @brief Response information.
*/
__PROTECTED_PROPERTY(uint8_t, response, Response);
/// <summary>Reason type.</summary>
/**
* @brief Reason type.
*/
__PROTECTED_PROPERTY(uint8_t, reason, Reason);
/** @} */
/** Tier 3 */
/// <summary>Site offset timing.</summary>
/** @name Tier 3 */
/**
* @brief Site offset timing.
*/
__PROTECTED_PROPERTY(bool, siteOffsetTiming, SiteOffsetTiming);
/// <summary>Broadcast Logical Channel ID 1.</summary>
/**
* @brief Broadcast Logical Channel ID 1.
*/
__PROTECTED_PROPERTY(uint16_t, logicalCh1, LogicalCh1);
/// <summary>Broadcast Logical Channel ID 2.</summary>
/**
* @brief Broadcast Logical Channel ID 2.
*/
__PROTECTED_PROPERTY(uint16_t, logicalCh2, LogicalCh2);
/// <summary>Logical Channel Slot Number.</summary>
/**
* @brief Logical Channel Slot Number.
*/
__PROTECTED_PROPERTY(uint8_t, slotNo, SlotNo);
/** @} */
/** Local Site data */
/// <summary>Local Site Identity Entry.</summary>
/** @name Local Site data */
/**
* @brief Local Site Identity Entry.
*/
__PROTECTED_PROPERTY_PLAIN(::lookups::IdenTable, siteIdenEntry);
/** @} */
protected:
static bool m_verbose;
/** Local Site data */
// Local Site data
static SiteData m_siteData;
/// <summary>Internal helper to convert payload bytes to a 64-bit long value.</summary>
/**
* @brief Internal helper to convert payload bytes to a 64-bit long value.
* @param[in] payload Buffer containing payload to convert.
* @returns ulong64_t 64-bit packed value containing the buffer.
*/
static ulong64_t toValue(const uint8_t* payload);
/// <summary>Internal helper to convert a 64-bit long value to payload bytes.</summary>
/**
* @brief Internal helper to convert a 64-bit long value to payload bytes.
* @param[in] value 64-bit packed value.
* @returns UInt8Array Buffer containing the unpacked payload.
*/
static UInt8Array fromValue(const ulong64_t value);
/// <summary>Internal helper to decode a control signalling block.</summary>
/**
* @brief Internal helper to decode a control signalling block.
* @param[in] data Raw data.
* @param[out] payload CSBK payload buffer.
*/
bool decode(const uint8_t* data, uint8_t* payload);
/// <summary>Internal helper to encode a control signalling block.</summary>
/**
* @brief Internal helper to encode a control signalling block.
* @param[out] data Raw data.
* @param[in] payload CSBK payload buffer.
*/
void encode(uint8_t* data, const uint8_t* payload);
__PROTECTED_COPY(CSBK);

@ -1,18 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2012 Ian Wraith
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2012 Ian Wraith
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/lc/FullLC.h"
@ -31,26 +27,17 @@ using namespace dmr::lc;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initialize a new instance of the FullLC class.
/// </summary>
/* Initialize a new instance of the FullLC class. */
FullLC::FullLC() :
m_bptc()
{
/* stub */
}
/// <summary>
/// Finalizes a instance of the FullLC class.
/// </summary>
/* Finalizes a instance of the FullLC class. */
FullLC::~FullLC() = default;
/// <summary>
/// Decode DMR full-link control data.
/// </summary>
/// <param name="data"></param>
/// <param name="type"></param>
/// <returns></returns>
/* Decode DMR full-link control data. */
std::unique_ptr<LC> FullLC::decode(const uint8_t* data, DataType::E type)
{
assert(data != nullptr);
@ -84,12 +71,7 @@ std::unique_ptr<LC> FullLC::decode(const uint8_t* data, DataType::E type)
return std::make_unique<LC>(lcData);
}
/// <summary>
/// Encode DMR full-link control data.
/// </summary>
/// <param name="lc"></param>
/// <param name="data"></param>
/// <param name="type"></param>
/* Encode DMR full-link control data. */
void FullLC::encode(const LC& lc, uint8_t* data, DataType::E type)
{
assert(data != nullptr);
@ -123,12 +105,7 @@ void FullLC::encode(const LC& lc, uint8_t* data, DataType::E type)
m_bptc.encode(lcData, data);
}
/// <summary>
/// Decode DMR privacy control data.
/// </summary>
/// <param name="data"></param>
/// <param name="type"></param>
/// <returns></returns>
/* Decode DMR privacy control data. */
std::unique_ptr<PrivacyLC> FullLC::decodePI(const uint8_t* data)
{
assert(data != nullptr);
@ -154,12 +131,7 @@ std::unique_ptr<PrivacyLC> FullLC::decodePI(const uint8_t* data)
return std::make_unique<PrivacyLC>(lcData);
}
/// <summary>
/// Encode DMR privacy control data.
/// </summary>
/// <param name="lc"></param>
/// <param name="data"></param>
/// <param name="type"></param>
/* Encode DMR privacy control data. */
void FullLC::encodePI(const PrivacyLC& lc, uint8_t* data)
{
assert(data != nullptr);

@ -12,6 +12,12 @@
* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* @file FullLC.h
* @ingroup dmr_lc
* @file FullLC.cpp
* @ingroup dmr_lc
*/
#if !defined(__DMR_LC__FULL_LC_H__)
#define __DMR_LC__FULL_LC_H__
@ -27,24 +33,51 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents full DMR link control.
// ---------------------------------------------------------------------------
/**
* @brief Represents full DMR link control.
* @ingroup dmr_lc
*/
class HOST_SW_API FullLC {
public:
/// <summary>Initializes a new instance of the FullLC class.</summary>
/**
* @brief Initializes a new instance of the FullLC class.
*/
FullLC();
/// <summary>Finalizes a instance of the FullLC class.</summary>
/**
* @brief Finalizes a instance of the FullLC class.
*/
~FullLC();
/// <summary>Decode DMR full-link control data.</summary>
/**
* @brief Decode DMR full-link control data.
* @param[in] data Buffer containing full-link control data.
* @param type Data type.
* @returns LC* Instance of LC class.
*/
std::unique_ptr<LC> decode(const uint8_t* data, defines::DataType::E type);
/// <summary>Encode DMR full-link control data.</summary>
/**
* @brief Encode DMR full-link control data.
* @param[in] lc Instance of LC class.
* @param[out] data Buffer to encode full-link control data.
* @param type Data type.
*/
void encode(const LC& lc, uint8_t* data, defines::DataType::E type);
/// <summary>Decode DMR privacy control data.</summary>
/**
* @brief Decode DMR privacy control data.
* @param[in] data Buffer containing private control data.
* @param type Data type.
* @returns PrivacyLC* Instance of PrivacyLC class.
*/
std::unique_ptr<PrivacyLC> decodePI(const uint8_t* data);
/// <summary>Encode DMR privacy control data.</summary>
/**
* @brief Encode DMR privacy control data.
* @param[in] lc Instance of PrivacyLC class.
* @param[out] data Buffer to encode private control data.
* @param type Data type.
*/
void encodePI(const PrivacyLC& lc, uint8_t* data);
private:

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2020-2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2020-2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/lc/LC.h"
@ -27,12 +23,7 @@ using namespace dmr::lc;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the LC class.
/// </summary>
/// <param name="flco">Full-link Control Opcode.</param>
/// <param name="srcId">Source ID.</param>
/// <param name="dstId">Destination ID.</param>
/* Initializes a new instance of the LC class. */
LC::LC(FLCO::E flco, uint32_t srcId, uint32_t dstId) :
m_PF(false),
m_FLCO(flco),
@ -49,10 +40,7 @@ LC::LC(FLCO::E flco, uint32_t srcId, uint32_t dstId) :
/* stub */
}
/// <summary>
/// Initializes a new instance of the LC class.
/// </summary>
/// <param name="data"></param>
/* Initializes a new instance of the LC class. */
LC::LC(const uint8_t* data) :
m_PF(false),
m_FLCO(FLCO::GROUP),
@ -85,10 +73,7 @@ LC::LC(const uint8_t* data) :
m_srcId = data[6U] << 16 | data[7U] << 8 | data[8U]; // Source Address
}
/// <summary>
/// Initializes a new instance of the LC class.
/// </summary>
/// <param name="bits"></param>
/* Initializes a new instance of the LC class. */
LC::LC(const bool* bits) :
m_PF(false),
m_FLCO(FLCO::GROUP),
@ -135,9 +120,7 @@ LC::LC(const bool* bits) :
m_srcId = s1 << 16 | s2 << 8 | s3; // Source Address
m_dstId = d1 << 16 | d2 << 8 | d3; // Destination Address
}
/// <summary>
/// Initializes a new instance of the LC class.
/// </summary>
/* Initializes a new instance of the LC class. */
LC::LC() :
m_PF(false),
m_FLCO(FLCO::GROUP),
@ -154,15 +137,10 @@ LC::LC() :
/* stub */
}
/// <summary>
/// Finalizes a instance of the LC class.
/// </summary>
/* Finalizes a instance of the LC class. */
LC::~LC() = default;
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/* Gets LC data as bytes. */
void LC::getData(uint8_t* data) const
{
assert(data != nullptr);
@ -192,10 +170,7 @@ void LC::getData(uint8_t* data) const
data[8U] = m_srcId >> 0; // ..
}
/// <summary>
///
/// </summary>
/// <param name="bits"></param>
/* Gets LC data as bits. */
void LC::getData(bool* bits) const
{
assert(bits != nullptr);

@ -1,17 +1,23 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2020-2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2020-2024 Bryan Biedenkapp, N2PLL
*
*/
* @defgroup dmr_lc Link Control
* @brief Implementation for the data handling of ETSI TS-102 link control data.
* @ingroup dmr
*
* @file LC.h
* @ingroup dmr_lc
* @file LC.cpp
* @ingroup dmr_lc
*/
#if !defined(__DMR_LC__LC_H__)
#define __DMR_LC__LC_H__
@ -24,53 +30,100 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents DMR link control data.
// ---------------------------------------------------------------------------
/**
* @brief Represents DMR link control data.
* @ingroup dmr_lc
*/
class HOST_SW_API LC {
public:
/// <summary>Initializes a new instance of the LC class.</summary>
/**
* @brief Initializes a new instance of the LC class.
* @param flco Full-link Control Opcode.
* @param srcId Source ID.
* @param dstId Destination ID.
*/
LC(defines::FLCO::E flco, uint32_t srcId, uint32_t dstId);
/// <summary>Initializes a new instance of the LC class.</summary>
/**
* @brief Initializes a new instance of the LC class.
* @param data Buffer containing LC data.
*/
LC(const uint8_t* data);
/// <summary>Initializes a new instance of the LC class.</summary>
/**
* @brief Initializes a new instance of the LC class.
* @param bits Boolean bit buffer containing LC data.
*/
LC(const bool* bits);
/// <summary>Initializes a new instance of the LC class.</summary>
/**
* @brief Initializes a new instance of the LC class.
*/
LC();
/// <summary>Finalizes a instance of the LC class.</summary>
/**
* @brief Finalizes a instance of the LC class.
*/
~LC();
/// <summary>Gets LC data as bytes.</summary>
/**
* @brief Gets LC data as bytes.
* @param[out] data Buffer containing LC data.
*/
void getData(uint8_t* data) const;
/// <summary>Gets LC data as bits.</summary>
/**
* @brief Gets LC data as bits.
* @param[out] bits Boolean bit buffer containing LC data.
*/
void getData(bool* bits) const;
public:
/// <summary>Flag indicating whether link protection is enabled.</summary>
/** @name Common Data */
/**
* @brief Flag indicating whether link protection is enabled.
*/
__PROPERTY(bool, PF, PF);
/// <summary>Full-link control opcode.</summary>
/**
* @brief Full-link control opcode.
*/
__PROPERTY(defines::FLCO::E, FLCO, FLCO);
/// <summary>Feature ID.</summayr>
/**
* @brief Feature ID
*/
__PROPERTY(uint8_t, FID, FID);
/// <summary>Source ID.</summary>
/**
* @brief Source ID.
*/
__PROPERTY(uint32_t, srcId, SrcId);
/// <summary>Destination ID.</summary>
/**
* @brief Destination ID.
*/
__PROPERTY(uint32_t, dstId, DstId);
/** @} */
/** Service Options */
/// <summary>Flag indicating the emergency bits are set.</summary>
/** @name Service Options */
/**
* @brief Flag indicating the emergency bits are set.
*/
__PROPERTY(bool, emergency, Emergency);
/// <summary>Flag indicating that encryption is enabled.</summary>
/**
* @brief Flag indicating that encryption is enabled.
*/
__PROPERTY(bool, encrypted, Encrypted);
/// <summary>Flag indicating broadcast operation.</summary>
/**
* @brief Flag indicating broadcast operation.
*/
__PROPERTY(bool, broadcast, Broadcast);
/// <summary>Flag indicating OVCM operation.</summary>
/**
* @brief Flag indicating OVCM operation.
*/
__PROPERTY(bool, ovcm, OVCM);
/// <summary>Priority level for the traffic.</summary>
/**
* @brief Priority level for the traffic.
*/
__PROPERTY(uint8_t, priority, Priority);
/** @} */
private:
bool m_R;

@ -1,15 +1,15 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/lc/PrivacyLC.h"
@ -25,10 +25,7 @@ using namespace dmr::lc;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the PrivacyLC class.
/// </summary>
/// <param name="data"></param>
/* Initializes a new instance of the PrivacyLC class. */
PrivacyLC::PrivacyLC(const uint8_t* data) :
m_FID(FID_ETSI),
m_dstId(0U),
@ -54,10 +51,7 @@ PrivacyLC::PrivacyLC(const uint8_t* data) :
m_dstId = data[7U] << 16 | data[8U] << 8 | data[9U]; // Destination Address
}
/// <summary>
/// Initializes a new instance of the PrivacyLC class.
/// </summary>
/// <param name="bits"></param>
/* Initializes a new instance of the PrivacyLC class. */
PrivacyLC::PrivacyLC(const bool* bits) :
m_FID(FID_ETSI),
m_dstId(0U),
@ -100,9 +94,7 @@ PrivacyLC::PrivacyLC(const bool* bits) :
m_dstId = d1 << 16 | d2 << 8 | d3; // Destination Address
}
/// <summary>
/// Initializes a new instance of the PrivacyLC class.
/// </summary>
/* Initializes a new instance of the PrivacyLC class. */
PrivacyLC::PrivacyLC() :
m_FID(FID_ETSI),
m_dstId(0U),
@ -114,18 +106,13 @@ PrivacyLC::PrivacyLC() :
m_mi = new uint8_t[MI_LENGTH_BYTES];
}
/// <summary>
/// Finalizes a instance of the PrivacyLC class.
/// </summary>
/* Finalizes a instance of the PrivacyLC class. */
PrivacyLC::~PrivacyLC()
{
delete m_mi;
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/* Gets LC data as bytes. */
void PrivacyLC::getData(uint8_t* data) const
{
assert(data != nullptr);
@ -146,10 +133,7 @@ void PrivacyLC::getData(uint8_t* data) const
data[9U] = m_dstId >> 0; // ..
}
/// <summary>
///
/// </summary>
/// <param name="bits"></param>
/* Gets LC data as bits. */
void PrivacyLC::getData(bool* bits) const
{
assert(bits != nullptr);

@ -10,6 +10,12 @@
* Copyright (C) 2021 Bryan Biedenkapp, N2PLL
*
*/
/**
* @file PrivacyLC.h
* @ingroup dmr_lc
* @file PrivacyLC.cpp
* @ingroup dmr_lc
*/
#if !defined(__DMR_LC__PRIVACY_LC_H__)
#define __DMR_LC__PRIVACY_LC_H__
@ -21,44 +27,77 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents DMR privacy indicator link control data.
// ---------------------------------------------------------------------------
/**
* @brief Represents DMR privacy indicator link control data.
* @ingroup dmr_lc
*/
class HOST_SW_API PrivacyLC {
public:
/// <summary>Initializes a new instance of the PrivacyLC class.</summary>
/**
* @brief Initializes a new instance of the PrivacyLC class.
* @param data Buffer containing PrivacyLC data.
*/
PrivacyLC(const uint8_t* data);
/// <summary>Initializes a new instance of the PrivacyLC class.</summary>
/**
* @brief Initializes a new instance of the PrivacyLC class.
* @param bits Boolean bit buffer containing PrivacyLC data.
*/
PrivacyLC(const bool* bits);
/// <summary>Initializes a new instance of the PrivacyLC class.</summary>
/**
* @brief Initializes a new instance of the PrivacyLC class.
*/
PrivacyLC();
/// <summary>Finalizes a instance of the PrivacyLC class.</summary>
/**
* @brief Finalizes a instance of the PrivacyLC class.
*/
~PrivacyLC();
/// <summary>Gets LC data as bytes.</summary>
/**
* @brief Gets LC data as bytes.
* @param[out] data Buffer containing LC data.
*/
void getData(uint8_t* data) const;
/// <summary>Gets LC data as bits.</summary>
/**
* @brief Gets LC data as bits.
* @param[out] bits Boolean bit buffer containing LC data.
*/
void getData(bool* bits) const;
public:
/// <summary>Feature ID.</summayr>
/** @name Common Data */
/**
* @brief Feature ID
*/
__PROPERTY(uint8_t, FID, FID);
/// <summary>Destination ID.</summary>
/**
* @brief Destination ID.
*/
__PROPERTY(uint32_t, dstId, DstId);
/** @} */
/** Service Options */
/// <summary>Flag indicating a group/talkgroup operation.</summary>
/** @name Service Options */
/**
* @brief Flag indicating a group/talkgroup operation.
*/
__PROPERTY(bool, group, Group);
/** @} */
/** Encryption data */
/// <summary>Encryption algorithm ID.</summary>
/** @name Encryption data */
/**
* @brief Encryption algorithm ID.
*/
__PROPERTY(uint8_t, algId, AlgId);
/// <summary>Encryption key ID.</summary>
/**
* @brief Encryption key ID.
*/
__PROPERTY(uint32_t, kId, KId);
/** @} */
private:
/** Encryption data */
// Encryption data
uint8_t* m_mi;
};
} // namespace lc

@ -1,16 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
#include "Defines.h"
#include "dmr/lc/ShortLC.h"
#include "edac/Hamming.h"
@ -25,9 +21,7 @@ using namespace dmr::lc;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the ShortLC class.
/// </summary>
/* Initializes a new instance of the ShortLC class. */
ShortLC::ShortLC() :
m_rawData(nullptr),
m_deInterData(nullptr)
@ -36,21 +30,14 @@ ShortLC::ShortLC() :
m_deInterData = new bool[68U];
}
/// <summary>
/// Finalizes a instance of the ShortLC class.
/// </summary>
/* Finalizes a instance of the ShortLC class. */
ShortLC::~ShortLC()
{
delete[] m_rawData;
delete[] m_deInterData;
}
/// <summary>
/// Decode DMR short-link control data.
/// </summary>
/// <param name="in"></param>
/// <param name="out"></param>
/// <returns></returns>
/* Decode DMR short-link control data. */
bool ShortLC::decode(const uint8_t* in, uint8_t* out)
{
assert(in != nullptr);
@ -73,11 +60,7 @@ bool ShortLC::decode(const uint8_t* in, uint8_t* out)
return true;
}
/// <summary>
/// Encode DMR short-link control data.
/// </summary>
/// <param name="in"></param>
/// <param name="out"></param>
/* Encode DMR short-link control data. */
void ShortLC::encode(const uint8_t* in, uint8_t* out)
{
assert(in != nullptr);
@ -100,10 +83,7 @@ void ShortLC::encode(const uint8_t* in, uint8_t* out)
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/* */
void ShortLC::decodeExtractBinary(const uint8_t* in)
{
assert(in != nullptr);
@ -119,9 +99,7 @@ void ShortLC::decodeExtractBinary(const uint8_t* in)
Utils::byteToBitsBE(in[8U], m_rawData + 64U);
}
/// <summary>
///
/// </summary>
/* */
void ShortLC::decodeDeInterleave()
{
for (uint32_t i = 0U; i < 68U; i++)
@ -137,10 +115,7 @@ void ShortLC::decodeDeInterleave()
m_deInterData[67U] = m_rawData[67U];
}
/// <summary>
///
/// </summary>
/// <returns></returns>
/* */
bool ShortLC::decodeErrorCheck()
{
// run through each of the 3 rows containing data
@ -158,10 +133,7 @@ bool ShortLC::decodeErrorCheck()
return true;
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/* */
void ShortLC::decodeExtractData(uint8_t* data) const
{
assert(data != nullptr);
@ -188,10 +160,7 @@ void ShortLC::decodeExtractData(uint8_t* data) const
Utils::bitsToByteBE(bData + 32U, data[4U]);
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/* */
void ShortLC::encodeExtractData(const uint8_t* in) const
{
assert(in != nullptr);
@ -217,9 +186,7 @@ void ShortLC::encodeExtractData(const uint8_t* in) const
m_deInterData[a] = bData[pos];
}
/// <summary>
///
/// </summary>
/* */
void ShortLC::encodeErrorCheck()
{
// run through each of the 3 rows containing data
@ -232,9 +199,7 @@ void ShortLC::encodeErrorCheck()
m_deInterData[c + 51U] = m_deInterData[c + 0U] ^ m_deInterData[c + 17U] ^ m_deInterData[c + 34U];
}
/// <summary>
///
/// </summary>
/* */
void ShortLC::encodeInterleave()
{
for (uint32_t i = 0U; i < 72U; i++)
@ -251,10 +216,7 @@ void ShortLC::encodeInterleave()
m_rawData[67U] = m_deInterData[67U];
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/* */
void ShortLC::encodeExtractBinary(uint8_t* data)
{
assert(data != nullptr);

@ -1,16 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
* @file ShortLC.h
* @ingroup dmr_lc
* @file ShortLC.cpp
* @ingroup dmr_lc
*/
#if !defined(__DMR_LC__SHORT_LC_H__)
#define __DMR_LC__SHORT_LC_H__
@ -22,41 +24,76 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Represents short DMR link control.
// ---------------------------------------------------------------------------
/**
* @brief Represents short DMR link control.
* @ingroup dmr_lc
*/
class HOST_SW_API ShortLC {
public:
/// <summary>Initializes a new instance of the ShortLC class.</summary>
/**
* @brief Initializes a new instance of the ShortLC class.
*/
ShortLC();
/// <summary>Finalizes a instance of the ShortLC class.</summary>
/**
* @brief Finalizes a instance of the ShortLC class.
*/
~ShortLC();
/// <summary>Decode DMR short-link control data.</summary>
/**
* @brief Decode DMR short-link control data.
* @param[in] in Buffer containing encoded short-link control data.
* @param[out] out Buffer to copy raw short-link control data.
*/
bool decode(const uint8_t* in, uint8_t* out);
/// <summary>Encode DMR short-link control data.</summary>
/**
* @brief Encode DMR short-link control data.
* @param[in] in Buffer containing raw short-link control data.
* @param[out] out Buffer to copy encoded short-link control data.
*/
void encode(const uint8_t* in, uint8_t* out);
private:
bool* m_rawData;
bool* m_deInterData;
/// <summary></summary>
/**
* @brief
* @param[in] in
*/
void decodeExtractBinary(const uint8_t* in);
/// <summary></summary>
/**
* @brief
*/
void decodeDeInterleave();
/// <summary></summary>
/**
* @brief
*/
bool decodeErrorCheck();
/// <summary></summary>
/**
* @brief
* @param[out] data
*/
void decodeExtractData(uint8_t* data) const;
/// <summary></summary>
/**
* @brief
* @param[in] in
*/
void encodeExtractData(const uint8_t* in) const;
/// <summary></summary>
/**
* @brief
*/
void encodeErrorCheck();
/// <summary></summary>
/**
* @brief
*/
void encodeInterleave();
/// <summary></summary>
/**
* @brief
* @param[out] data
*/
void encodeExtractBinary(uint8_t* data);
};
} // namespace lc

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBKFactory.h"
#include "edac/BPTC19696.h"
@ -28,22 +25,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBKFactory class.
/// </summary>
/* Initializes a new instance of the CSBKFactory class. */
CSBKFactory::CSBKFactory() = default;
/// <summary>
/// Finalizes a instance of CSBKFactory class.
/// </summary>
/* Finalizes a instance of CSBKFactory class. */
CSBKFactory::~CSBKFactory() = default;
/// <summary>
/// Create an instance of a CSBK.
/// </summary>
/// <param name="data"></param>
/// <param name="dataType"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Create an instance of a CSBK. */
std::unique_ptr<CSBK> CSBKFactory::createCSBK(const uint8_t* data, DataType::E dataType)
{
assert(data != nullptr);
@ -136,12 +124,7 @@ std::unique_ptr<CSBK> CSBKFactory::createCSBK(const uint8_t* data, DataType::E d
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="csbk"></param>
/// <param name="data"></param>
/// <returns></returns>
/* Decode a CSBK. */
std::unique_ptr<CSBK> CSBKFactory::decode(CSBK* csbk, const uint8_t* data)
{
assert(csbk != nullptr);

@ -10,6 +10,16 @@
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* @defgroup dmr_csbk Control Signalling Block
* @brief Implementation for the data handling of the ETSI TS-102 control signalling block (CSBK).
* @ingroup dmr_lc
*
* @file CSBKFactory.h
* @ingroup dmr_csbk
* @file CSBKFactory.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC__CSBK_FACTORY_H__)
#define __DMR_LC__CSBK_FACTORY_H__
@ -45,21 +55,38 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Helper class to instantiate an instance of a CSBK.
// ---------------------------------------------------------------------------
/**
* @brief Helper class to instantiate an instance of a CSBK.
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBKFactory {
public:
/// <summary>Initializes a new instance of the CSBKFactory class.</summary>
/**
* @brief Initializes a new instance of the CSBKFactory class.
*/
CSBKFactory();
/// <summary>Finalizes a instance of the CSBKFactory class.</summary>
/**
* @brief Finalizes a instance of the CSBKFactory class.
*/
~CSBKFactory();
/// <summary>Create an instance of a CSBK.</summary>
/**
* @brief Create an instance of a CSBK.
* @param[in] data Buffer containing CSBK packet data to decode.
* @param dataType Data Type.
* @returns CSBK* Instance of a CSBK representing the decoded data.
*/
static std::unique_ptr<CSBK> createCSBK(const uint8_t* data, defines::DataType::E dataType);
private:
/// <summary></summary>
/**
* @brief Decode a CSBK.
* @param csbk Instance of a CSBK.
* @param[in] data Buffer containing CSBK packet data to decode.
* @returns CSBK* Instance of a CSBK representing the decoded data.
*/
static std::unique_ptr<CSBK> decode(CSBK* csbk, const uint8_t* data);
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_ACK_RSP.h"
@ -24,19 +21,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_ACK_RSP class.
/// </summary>
/* Initializes a new instance of the CSBK_ACK_RSP class. */
CSBK_ACK_RSP::CSBK_ACK_RSP() : CSBK()
{
m_CSBKO = CSBKO::ACK_RSP;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_ACK_RSP::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -58,10 +49,7 @@ bool CSBK_ACK_RSP::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_ACK_RSP::encode(uint8_t* data)
{
assert(data != nullptr);
@ -83,10 +71,7 @@ void CSBK_ACK_RSP::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_ACK_RSP::toString()
{
return std::string("CSBKO, ACK_RSP (Acknowledge Response)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_ACK_RSP.h
* @ingroup dmr_csbk
* @file CSBK_ACK_RSP.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_ACK_RSP_H__)
#define __DMR_LC_CSBK__CSBK_ACK_RSP_H__
@ -24,20 +27,34 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements ACK RSP - Acknowledge Response
// ---------------------------------------------------------------------------
/**
* @brief Implements ACK RSP - Acknowledge Response
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_ACK_RSP : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_ACK_RSP class.</summary>
/**
* @brief Initializes a new instance of the CSBK_ACK_RSP class.
*/
CSBK_ACK_RSP();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_ALOHA.h"
@ -24,9 +21,7 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_ALOHA class.
/// </summary>
/* Initializes a new instance of the CSBK_ALOHA class. */
CSBK_ALOHA::CSBK_ALOHA() : CSBK(),
m_siteTSSync(false),
m_alohaMask(0U),
@ -36,11 +31,7 @@ CSBK_ALOHA::CSBK_ALOHA() : CSBK(),
m_CSBKO = CSBKO::ALOHA;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_ALOHA::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -50,10 +41,7 @@ bool CSBK_ALOHA::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_ALOHA::encode(uint8_t* data)
{
assert(data != nullptr);
@ -77,10 +65,7 @@ void CSBK_ALOHA::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_ALOHA::toString()
{
return std::string("CSBKO, ALOHA (Aloha PDU)");
@ -90,10 +75,7 @@ std::string CSBK_ALOHA::toString()
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper to copy the the class.
/// </summary>
/// <param name="data"></param>
/* Internal helper to copy the the class. */
void CSBK_ALOHA::copy(const CSBK_ALOHA& data)
{
CSBK::copy(data);

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_ALOHA.h
* @ingroup dmr_csbk
* @file CSBK_ALOHA.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_ALOHA_H__)
#define __DMR_LC_CSBK__CSBK_ALOHA_H__
@ -24,31 +27,53 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements ALOHA - Aloha PDUs for the random access protocol
// ---------------------------------------------------------------------------
/**
* @brief Implements ALOHA - Aloha PDUs for the random access protocol
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_ALOHA : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_ALOHA class.</summary>
/**
* @brief Initializes a new instance of the CSBK_ALOHA class.
*/
CSBK_ALOHA();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
public:
/// <summary>Aloha Site Time Slot Synchronization.</summary>
/**
* @brief Aloha Site Time Slot Synchronization.
*/
__PROPERTY(bool, siteTSSync, SiteTSSync);
/// <summary>Aloha MS mask.</summary>
/**
* @brief Aloha MS mask.
*/
__PROPERTY(uint8_t, alohaMask, AlohaMask);
/// <summary>Backoff Number.</summary>
/**
* @brief Backoff Number.
*/
__PROPERTY(uint8_t, backoffNo, BackoffNo);
/// <summary>Random Access Wait Delay.</summary>
/**
* @brief Random Access Wait Delay.
*/
__PROPERTY(uint8_t, nRandWait, NRandWait);
__COPY(CSBK_ALOHA);

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_BROADCAST.h"
@ -24,9 +21,7 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_BROADCAST class.
/// </summary>
/* Initializes a new instance of the CSBK_BROADCAST class. */
CSBK_BROADCAST::CSBK_BROADCAST() : CSBK(),
m_anncType(BroadcastAnncType::SITE_PARMS),
m_hibernating(false),
@ -39,11 +34,7 @@ CSBK_BROADCAST::CSBK_BROADCAST() : CSBK(),
m_CSBKO = CSBKO::BROADCAST;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_BROADCAST::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -80,10 +71,7 @@ bool CSBK_BROADCAST::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_BROADCAST::encode(uint8_t* data)
{
assert(data != nullptr);
@ -168,10 +156,7 @@ void CSBK_BROADCAST::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_BROADCAST::toString()
{
switch (m_anncType) {
@ -186,10 +171,7 @@ std::string CSBK_BROADCAST::toString()
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper to copy the the class.
/// </summary>
/// <param name="data"></param>
/* Internal helper to copy the the class. */
void CSBK_BROADCAST::copy(const CSBK_BROADCAST& data)
{
CSBK::copy(data);

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_BROADCAST.h
* @ingroup dmr_csbk
* @file CSBK_BROADCAST.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_BROADCAST_H__)
#define __DMR_LC_CSBK__CSBK_BROADCAST_H__
@ -24,39 +27,67 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements BCAST - Announcement PDUs
// ---------------------------------------------------------------------------
/**
* @brief Implements BCAST - Announcement PDUs
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_BROADCAST : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_BROADCAST class.</summary>
/**
* @brief Initializes a new instance of the CSBK_BROADCAST class.
*/
CSBK_BROADCAST();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
public:
/// <summary>Broadcast Announcment Type.</summary>
/**
* @brief Broadcast Announcment Type.
*/
__PROPERTY(uint8_t, anncType, AnncType);
/// <summary>Broadcast Hibernation Flag.</summary>
/**
* @brief Broadcast Hibernation Flag.
*/
__PROPERTY(bool, hibernating, Hibernating);
/// <summary>Broadcast Announce/Withdraw Channel 1 Flag.</summary>
/**
* @brief Broadcast Announce/Withdraw Channel 1 Flag.
*/
__PROPERTY(bool, annWdCh1, AnnWdCh1);
/// <summary>Broadcast Announce/Withdraw Channel 2 Flag.</summary>
/**
* @brief Broadcast Announce/Withdraw Channel 2 Flag.
*/
__PROPERTY(bool, annWdCh2, AnnWdCh2);
/// <summary>Require Registration.</summary>
/**
* @brief Require Registration.
*/
__PROPERTY(bool, requireReg, RequireReg);
/// <summary>System Identity.</summary>
/**
* @brief System Identity.
*/
__PROPERTY(uint32_t, systemId, SystemId);
/// <summary>Backoff Number.</summary>
/**
* @brief Backoff Number.
*/
__PROPERTY(uint8_t, backoffNo, BackoffNo);
__COPY(CSBK_BROADCAST);

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_BSDWNACT.h"
@ -24,20 +21,14 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_BSDWNACT class.
/// </summary>
/* Initializes a new instance of the CSBK_BSDWNACT class. */
CSBK_BSDWNACT::CSBK_BSDWNACT() : CSBK(),
m_bsId(0U)
{
m_CSBKO = CSBKO::BSDWNACT;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_BSDWNACT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -57,10 +48,7 @@ bool CSBK_BSDWNACT::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_BSDWNACT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -68,10 +56,7 @@ void CSBK_BSDWNACT::encode(uint8_t* data)
/* stub */
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_BSDWNACT::toString()
{
return std::string("CSBKO, BSDWNACT (BS Outbound Activation)");
@ -81,10 +66,7 @@ std::string CSBK_BSDWNACT::toString()
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper to copy the the class.
/// </summary>
/// <param name="data"></param>
/* Internal helper to copy the the class. */
void CSBK_BSDWNACT::copy(const CSBK_BSDWNACT& data)
{
CSBK::copy(data);

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_BSDWNACT.h
* @ingroup dmr_csbk
* @file CSBK_BSDWNACT.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_BSDWNACT_H__)
#define __DMR_LC_CSBK__CSBK_BSDWNACT_H__
@ -24,24 +27,40 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements BS DWN ACT - BS Outbound Activation
// ---------------------------------------------------------------------------
/**
* @brief Implements BS DWN ACT - BS Outbound Activation
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_BSDWNACT : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_BSDWNACT class.</summary>
/**
* @brief Initializes a new instance of the CSBK_BSDWNACT class.
*/
CSBK_BSDWNACT();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
public:
/// <summary>Base Station ID.</summary>
/**
* @brief Base Station ID.
*/
__READONLY_PROPERTY(uint32_t, bsId, BSId);
__COPY(CSBK_BSDWNACT);

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_CALL_ALRT.h"
@ -24,20 +21,14 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_CALL_ALRT class.
/// </summary>
/* Initializes a new instance of the CSBK_CALL_ALRT class. */
CSBK_CALL_ALRT::CSBK_CALL_ALRT() : CSBK()
{
m_CSBKO = CSBKO::RAND;
m_FID = FID_DMRA;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_CALL_ALRT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -58,10 +49,7 @@ bool CSBK_CALL_ALRT::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_CALL_ALRT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -76,10 +64,7 @@ void CSBK_CALL_ALRT::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_CALL_ALRT::toString()
{
return std::string("CSBKO, RAND (Call Alert)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_CALL_ALRT.h
* @ingroup dmr_csbk
* @file CSBK_CALL_ALRT.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_CALL_ALRT_H__)
#define __DMR_LC_CSBK__CSBK_CALL_ALRT_H__
@ -24,20 +27,34 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements CALL ALRT - Call Alert
// ---------------------------------------------------------------------------
/**
* @brief Implements CALL ALRT - Call Alert
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_CALL_ALRT : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_CALL_ALRT class.</summary>
/**
* @brief Initializes a new instance of the CSBK_CALL_ALRT class.
*/
CSBK_CALL_ALRT();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_EXT_FNCT.h"
@ -24,9 +21,7 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_EXT_FNCT class.
/// </summary>
/* Initializes a new instance of the CSBK_EXT_FNCT class. */
CSBK_EXT_FNCT::CSBK_EXT_FNCT() : CSBK(),
m_extendedFunction(ExtendedFunctions::CHECK)
{
@ -34,11 +29,7 @@ CSBK_EXT_FNCT::CSBK_EXT_FNCT() : CSBK(),
m_FID = FID_DMRA;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_EXT_FNCT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -60,10 +51,7 @@ bool CSBK_EXT_FNCT::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_EXT_FNCT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -81,10 +69,7 @@ void CSBK_EXT_FNCT::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_EXT_FNCT::toString()
{
return std::string("CSBKO, EXT_FNCT (Extended Function)");
@ -94,10 +79,7 @@ std::string CSBK_EXT_FNCT::toString()
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper to copy the the class.
/// </summary>
/// <param name="data"></param>
/* Internal helper to copy the the class. */
void CSBK_EXT_FNCT::copy(const CSBK_EXT_FNCT& data)
{
CSBK::copy(data);

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_EXT_FNCT.h
* @ingroup dmr_csbk
* @file CSBK_EXT_FNCT.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_EXT_FNCT_H__)
#define __DMR_LC_CSBK__CSBK_EXT_FNCT_H__
@ -24,24 +27,40 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements EXT FNCT - Extended Function
// ---------------------------------------------------------------------------
/**
* @brief Implements EXT FNCT - Extended Function
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_EXT_FNCT : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_EXT_FNCT class.</summary>
/**
* @brief Initializes a new instance of the CSBK_EXT_FNCT class.
*/
CSBK_EXT_FNCT();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
public:
/// <summary>Extended function opcode.</summary>
/**
* @brief Extended function opcode.
*/
__PROPERTY(uint8_t, extendedFunction, ExtendedFunction);
__COPY(CSBK_EXT_FNCT);

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_MAINT.h"
@ -24,20 +21,14 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_MAINT class.
/// </summary>
/* Initializes a new instance of the CSBK_MAINT class. */
CSBK_MAINT::CSBK_MAINT() : CSBK(),
m_maintKind(0U)
{
m_CSBKO = CSBKO::MAINT;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_MAINT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -58,10 +49,7 @@ bool CSBK_MAINT::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_MAINT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -76,10 +64,7 @@ void CSBK_MAINT::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_MAINT::toString()
{
return std::string("CSBKO, MAINT (Call Maintainence)");
@ -89,10 +74,7 @@ std::string CSBK_MAINT::toString()
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper to copy the the class.
/// </summary>
/// <param name="data"></param>
/* Internal helper to copy the the class. */
void CSBK_MAINT::copy(const CSBK_MAINT& data)
{
CSBK::copy(data);

@ -10,6 +10,12 @@
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/**
* @file CSBK_MAINT.h
* @ingroup dmr_csbk
* @file CSBK_MAINT.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_MAINT_H__)
#define __DMR_LC_CSBK__CSBK_MAINT_H__
@ -24,24 +30,40 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements MAINT - Call Maintainence
// ---------------------------------------------------------------------------
/**
* @brief Implements MAINT - Call Maintainence
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_MAINT : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_MAINT class.</summary>
/**
* @brief Initializes a new instance of the CSBK_MAINT class.
*/
CSBK_MAINT();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
public:
/// <summary>Maintainence Kind.</summary>
/**
* @brief Maintainence Kind.
*/
__PROPERTY(uint8_t, maintKind, MaintKind);
__COPY(CSBK_MAINT);

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_NACK_RSP.h"
@ -24,20 +21,14 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_NACK_RSP class.
/// </summary>
/* Initializes a new instance of the CSBK_NACK_RSP class. */
CSBK_NACK_RSP::CSBK_NACK_RSP() : CSBK(),
m_serviceKind(0U)
{
m_CSBKO = CSBKO::NACK_RSP;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_NACK_RSP::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -60,10 +51,7 @@ bool CSBK_NACK_RSP::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_NACK_RSP::encode(uint8_t* data)
{
assert(data != nullptr);
@ -81,10 +69,7 @@ void CSBK_NACK_RSP::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_NACK_RSP::toString()
{
return std::string("CSBKO, NACK_RSP (Negative Acknowledgement Response)");
@ -94,10 +79,7 @@ std::string CSBK_NACK_RSP::toString()
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper to copy the the class.
/// </summary>
/// <param name="data"></param>
/* Internal helper to copy the the class. */
void CSBK_NACK_RSP::copy(const CSBK_NACK_RSP& data)
{
CSBK::copy(data);

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_NACK_RSP.h
* @ingroup dmr_csbk
* @file CSBK_NACK_RSP.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_NACK_RSP_H__)
#define __DMR_LC_CSBK__CSBK_NACK_RSP_H__
@ -24,24 +27,40 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements NACK RSP - Negative Acknowledgement Response
// ---------------------------------------------------------------------------
/**
* @brief Implements NACK RSP - Negative Acknowledgement Response
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_NACK_RSP : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_NACK_RSP class.</summary>
/**
* @brief Initializes a new instance of the CSBK_NACK_RSP class.
*/
CSBK_NACK_RSP();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
public:
/// <summary>Service Kind.</summary>
/**
* @brief Service Kind.
*/
__PROPERTY(uint8_t, serviceKind, ServiceKind);
__COPY(CSBK_NACK_RSP);

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_PD_GRANT.h"
@ -24,19 +21,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_PD_GRANT class.
/// </summary>
/* Initializes a new instance of the CSBK_PD_GRANT class. */
CSBK_PD_GRANT::CSBK_PD_GRANT() : CSBK()
{
m_CSBKO = CSBKO::PD_GRANT;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_PD_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -46,10 +37,7 @@ bool CSBK_PD_GRANT::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_PD_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -68,10 +56,7 @@ void CSBK_PD_GRANT::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_PD_GRANT::toString()
{
return std::string("CSBKO, PD_GRANT (Private Data Channel Grant)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_PD_GRANT.h
* @ingroup dmr_csbk
* @file CSBK_PD_GRANT.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_PD_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_PD_GRANT_H__
@ -24,20 +27,34 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements PD_GRANT - Private Data Channel Grant
// ---------------------------------------------------------------------------
/**
* @brief Implements PD_GRANT - Private Data Channel Grant
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_PD_GRANT : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_PD_GRANT class.</summary>
/**
* @brief Initializes a new instance of the CSBK_PD_GRANT class.
*/
CSBK_PD_GRANT();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_PRECCSBK.h"
@ -24,19 +21,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_PRECCSBK class.
/// </summary>
/* Initializes a new instance of the CSBK_PRECCSBK class. */
CSBK_PRECCSBK::CSBK_PRECCSBK() : CSBK()
{
m_CSBKO = CSBKO::PRECCSBK;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_PRECCSBK::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -59,10 +50,7 @@ bool CSBK_PRECCSBK::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_PRECCSBK::encode(uint8_t* data)
{
assert(data != nullptr);
@ -70,10 +58,7 @@ void CSBK_PRECCSBK::encode(uint8_t* data)
/* stub */
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_PRECCSBK::toString()
{
return std::string("CSBKO, PRECCSBK (Preamble CSBK)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_PRECCSBK.h
* @ingroup dmr_csbk
* @file CSBK_PRECCSBK.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_PRECCSBK_H__)
#define __DMR_LC_CSBK__CSBK_PRECCSBK_H__
@ -24,20 +27,35 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements PRE CSBK - Preamble CSBK
//
// ---------------------------------------------------------------------------
/**
* @brief Implements PRE CSBK - Preamble CSBK
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_PRECCSBK : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_PRECCSBK class.</summary>
/**
* @brief Initializes a new instance of the CSBK_PRECCSBK class.
*/
CSBK_PRECCSBK();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_PV_GRANT.h"
@ -24,19 +21,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_PV_GRANT class.
/// </summary>
/* Initializes a new instance of the CSBK_PV_GRANT class. */
CSBK_PV_GRANT::CSBK_PV_GRANT() : CSBK()
{
m_CSBKO = CSBKO::PV_GRANT;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_PV_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -46,10 +37,7 @@ bool CSBK_PV_GRANT::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_PV_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -68,10 +56,7 @@ void CSBK_PV_GRANT::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_PV_GRANT::toString()
{
return std::string("CSBKO, PV_GRANT (Private Voice Channel Grant)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_PV_GRANT.h
* @ingroup dmr_csbk
* @file CSBK_PV_GRANT.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_PV_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_PV_GRANT_H__
@ -24,20 +27,34 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements PV_GRANT - Private Voice Channel Grant
// ---------------------------------------------------------------------------
/**
* @brief Implements PV_GRANT - Private Voice Channel Grant
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_PV_GRANT : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_PV_GRANT class.</summary>
/**
* @brief Initializes a new instance of the CSBK_PV_GRANT class.
*/
CSBK_PV_GRANT();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_P_CLEAR.h"
@ -24,19 +21,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_P_CLEAR class.
/// </summary>
/* Initializes a new instance of the CSBK_P_CLEAR class. */
CSBK_P_CLEAR::CSBK_P_CLEAR() : CSBK()
{
m_CSBKO = CSBKO::P_CLEAR;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_P_CLEAR::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -46,10 +37,7 @@ bool CSBK_P_CLEAR::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_P_CLEAR::encode(uint8_t* data)
{
assert(data != nullptr);
@ -67,10 +55,7 @@ void CSBK_P_CLEAR::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_P_CLEAR::toString()
{
return std::string("CSBKO, P_CLEAR (Payload Channel Clear)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_P_CLEAR.h
* @ingroup dmr_csbk
* @file CSBK_P_CLEAR.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_P_CLEAR_H__)
#define __DMR_LC_CSBK__CSBK_P_CLEAR_H__
@ -24,20 +27,34 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements P_CLEAR - Payload Channel Clear
// ---------------------------------------------------------------------------
/**
* @brief Implements P_CLEAR - Payload Channel Clear
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_P_CLEAR : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_P_CLEAR class.</summary>
/**
* @brief Initializes a new instance of the CSBK_P_CLEAR class.
*/
CSBK_P_CLEAR();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_P_GRANT.h"
@ -24,19 +21,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_P_GRANT class.
/// </summary>
/* Initializes a new instance of the CSBK_P_GRANT class. */
CSBK_P_GRANT::CSBK_P_GRANT() : CSBK()
{
m_CSBKO = CSBKO::TV_GRANT;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_P_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -46,10 +37,7 @@ bool CSBK_P_GRANT::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_P_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -68,10 +56,7 @@ void CSBK_P_GRANT::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_P_GRANT::toString()
{
return std::string("CSBKO, P_GRANT (Payload Grant)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_P_GRANT.h
* @ingroup dmr_csbk
* @file CSBK_P_GRANT.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_P_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_P_GRANT_H__
@ -24,20 +27,34 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements P_GRANT - Payload Channel Talkgroup Voice Channel Grant
// ---------------------------------------------------------------------------
/**
* @brief Implements P_GRANT - Payload Channel Talkgroup Voice Channel Grant
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_P_GRANT : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_P_GRANT class.</summary>
/**
* @brief Initializes a new instance of the CSBK_P_GRANT class.
*/
CSBK_P_GRANT();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_RAND.h"
@ -24,9 +21,7 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_RAND class.
/// </summary>
/* Initializes a new instance of the CSBK_RAND class. */
CSBK_RAND::CSBK_RAND() : CSBK(),
m_serviceOptions(0U),
m_serviceExtra(0U),
@ -35,11 +30,7 @@ CSBK_RAND::CSBK_RAND() : CSBK(),
m_CSBKO = CSBKO::RAND;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_RAND::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -63,10 +54,7 @@ bool CSBK_RAND::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_RAND::encode(uint8_t* data)
{
assert(data != nullptr);
@ -84,10 +72,7 @@ void CSBK_RAND::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_RAND::toString()
{
switch (m_serviceKind) {
@ -112,10 +97,7 @@ std::string CSBK_RAND::toString()
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper to copy the the class.
/// </summary>
/// <param name="data"></param>
/* Internal helper to copy the the class. */
void CSBK_RAND::copy(const CSBK_RAND& data)
{
CSBK::copy(data);

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_RAND.h
* @ingroup dmr_csbk
* @file CSBK_RAND.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_RAND_H__)
#define __DMR_LC_CSBK__CSBK_RAND_H__
@ -24,28 +27,48 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements RAND - Random Access
// ---------------------------------------------------------------------------
/**
* @brief Implements RAND - Random Access
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_RAND : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_RAND class.</summary>
/**
* @brief Initializes a new instance of the CSBK_RAND class.
*/
CSBK_RAND();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a DMR CSBK.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a DMR CSBK.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
public:
/// <summary>Service Options.</summary>
/**
* @brief Service Options.
*/
__PROPERTY(uint8_t, serviceOptions, ServiceOptions);
/// <summary>Service Extra Options.</summary>
/**
* @brief Service Extra Options.
*/
__PROPERTY(uint8_t, serviceExtra, ServiceExtra);
/// <summary>Service Kind.</summary>
/**
* @brief Service Kind.
*/
__PROPERTY(uint8_t, serviceKind, ServiceKind);
__COPY(CSBK_RAND);

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_RAW.h"
@ -24,18 +21,14 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_RAW class.
/// </summary>
/* Initializes a new instance of the CSBK_RAW class. */
CSBK_RAW::CSBK_RAW() : CSBK(),
m_csbk(nullptr)
{
m_CSBKO = CSBKO::RAND;
}
/// <summary>
/// Finalizes a new instance of the CSBK_RAW class.
/// </summary>
/* Finalizes a new instance of the CSBK_RAW class. */
CSBK_RAW::~CSBK_RAW()
{
if (m_csbk != nullptr) {
@ -43,11 +36,7 @@ CSBK_RAW::~CSBK_RAW()
}
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_RAW::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -57,10 +46,7 @@ bool CSBK_RAW::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_RAW::encode(uint8_t* data)
{
assert(data != nullptr);
@ -71,10 +57,7 @@ void CSBK_RAW::encode(uint8_t* data)
CSBK::encode(data, m_csbk);
}
/// <summary>
/// Sets the CSBK to encode.
/// </summary>
/// <param name="csbk"></param>
/* Sets the CSBK to encode. */
void CSBK_RAW::setCSBK(const uint8_t* csbk)
{
assert(csbk != nullptr);

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_RAW.h
* @ingroup dmr_csbk
* @file CSBK_RAW.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_RAW_H__)
#define __DMR_LC_CSBK__CSBK_RAW_H__
@ -24,22 +27,38 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements a mechanism to generate raw CSBK data from bytes.
// ---------------------------------------------------------------------------
/**
* @brief Implements a mechanism to generate raw CSBK data from bytes.
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_RAW : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_RAW class.</summary>
/**
* @brief Initializes a new instance of the CSBK_RAW class.
*/
CSBK_RAW();
/// <summary>Finalizes a instance of the CSBK_RAW class.</summary>
/**
* @brief Finalizes a instance of the CSBK_RAW class.
*/
~CSBK_RAW();
/// <summary>Decode a trunking signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a trunking signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Sets the CSBK to encode.</summary>
/**
* @brief Sets the CSBK to encode.
* @param[in] csbk Buffer containing CSBK to encode.
*/
void setCSBK(const uint8_t* csbk);
private:

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_TD_GRANT.h"
@ -24,19 +21,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_TD_GRANT class.
/// </summary>
/* Initializes a new instance of the CSBK_TD_GRANT class. */
CSBK_TD_GRANT::CSBK_TD_GRANT() : CSBK()
{
m_CSBKO = CSBKO::TD_GRANT;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_TD_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -46,10 +37,7 @@ bool CSBK_TD_GRANT::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_TD_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -68,10 +56,7 @@ void CSBK_TD_GRANT::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_TD_GRANT::toString()
{
return std::string("CSBKO, TD_GRANT (Talkgroup Data Channel Grant)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_TD_GRANT.h
* @ingroup dmr_csbk
* @file CSBK_TD_GRANT.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_TD_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_TD_GRANT_H__
@ -24,20 +27,34 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements TD_GRANT - Talkgroup Data Channel Grant
// ---------------------------------------------------------------------------
/**
* @brief Implements TD_GRANT - Talkgroup Data Channel Grant
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_TD_GRANT : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_TD_GRANT class.</summary>
/**
* @brief Initializes a new instance of the CSBK_TD_GRANT class.
*/
CSBK_TD_GRANT();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_TV_GRANT.h"
@ -24,20 +21,14 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_TV_GRANT class.
/// </summary>
/* Initializes a new instance of the CSBK_TV_GRANT class. */
CSBK_TV_GRANT::CSBK_TV_GRANT() : CSBK(),
m_lateEntry(false)
{
m_CSBKO = CSBKO::TV_GRANT;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_TV_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -47,10 +38,7 @@ bool CSBK_TV_GRANT::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_TV_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -69,10 +57,7 @@ void CSBK_TV_GRANT::encode(uint8_t* data)
CSBK::encode(data, csbk.get());
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_TV_GRANT::toString()
{
return std::string("CSBKO, TV_GRANT (Talkgroup Voice Channel Grant)");
@ -82,10 +67,7 @@ std::string CSBK_TV_GRANT::toString()
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Internal helper to copy the the class.
/// </summary>
/// <param name="data"></param>
/* Internal helper to copy the the class. */
void CSBK_TV_GRANT::copy(const CSBK_TV_GRANT& data)
{
CSBK::copy(data);

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_TV_GRANT.h
* @ingroup dmr_csbk
* @file CSBK_TV_GRANT.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_TV_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_TV_GRANT_H__
@ -24,24 +27,40 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements TV_GRANT - Talkgroup Voice Channel Grant
// ---------------------------------------------------------------------------
/**
* @brief Implements TV_GRANT - Talkgroup Voice Channel Grant
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_TV_GRANT : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_TV_GRANT class.</summary>
/**
* @brief Initializes a new instance of the CSBK_TV_GRANT class.
*/
CSBK_TV_GRANT();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
public:
/// <summary>Flag indicating whether the grant is a late entry.</summary>
/**
* @brief Flag indicating whether the grant is a late entry.
*/
__PROPERTY(bool, lateEntry, LateEntry);
__COPY(CSBK_TV_GRANT);

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_UU_ANS_RSP.h"
@ -24,19 +21,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_UU_ANS_RSP class.
/// </summary>
/* Initializes a new instance of the CSBK_UU_ANS_RSP class. */
CSBK_UU_ANS_RSP::CSBK_UU_ANS_RSP() : CSBK()
{
m_CSBKO = CSBKO::UU_ANS_RSP;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_UU_ANS_RSP::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -56,10 +47,7 @@ bool CSBK_UU_ANS_RSP::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_UU_ANS_RSP::encode(uint8_t* data)
{
assert(data != nullptr);
@ -67,10 +55,7 @@ void CSBK_UU_ANS_RSP::encode(uint8_t* data)
/* stub */
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_UU_ANS_RSP::toString()
{
return std::string("CSBKO, UU_ANS_RSP (Unit-to-Unit Answer Response)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_UU_ANS_RSP.h
* @ingroup dmr_csbk
* @file CSBK_UU_ANS_RSP.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_UU_ANS_RSP_H__)
#define __DMR_LC_CSBK__CSBK_UU_ANS_RSP_H__
@ -24,20 +27,34 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements UU ANS RSP - Unit to Unit Answer Response
// ---------------------------------------------------------------------------
/**
* @brief Implements UU ANS RSP - Unit to Unit Answer Response
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_UU_ANS_RSP : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_UU_ANS_RSP class.</summary>
/**
* @brief Initializes a new instance of the CSBK_UU_ANS_RSP class.
*/
CSBK_UU_ANS_RSP();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "dmr/lc/csbk/CSBK_UU_V_REQ.h"
@ -24,19 +21,13 @@ using namespace dmr::lc::csbk;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the CSBK_UU_V_REQ class.
/// </summary>
/* Initializes a new instance of the CSBK_UU_V_REQ class. */
CSBK_UU_V_REQ::CSBK_UU_V_REQ() : CSBK()
{
m_CSBKO = CSBKO::UU_V_REQ;
}
/// <summary>
/// Decode a control signalling block.
/// </summary>
/// <param name="data"></param>
/// <returns>True, if CSBK was decoded, otherwise false.</returns>
/* Decode a control signalling block. */
bool CSBK_UU_V_REQ::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -56,10 +47,7 @@ bool CSBK_UU_V_REQ::decode(const uint8_t* data)
return true;
}
/// <summary>
/// Encode a control signalling block.
/// </summary>
/// <param name="data"></param>
/* Encode a control signalling block. */
void CSBK_UU_V_REQ::encode(uint8_t* data)
{
assert(data != nullptr);
@ -67,10 +55,7 @@ void CSBK_UU_V_REQ::encode(uint8_t* data)
/* stub */
}
/// <summary>
/// Returns a string that represents the current CSBK.
/// </summary>
/// <returns></returns>
/* Returns a string that represents the current CSBK. */
std::string CSBK_UU_V_REQ::toString()
{
return std::string("CSBKO, UU_V_REQ (Unit-to-Unit Voice Channel Request)");

@ -1,15 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2022 Bryan Biedenkapp, N2PLL
*
*/
* @file CSBK_UU_V_REQ.h
* @ingroup dmr_csbk
* @file CSBK_UU_V_REQ.cpp
* @ingroup dmr_csbk
*/
#if !defined(__DMR_LC_CSBK__CSBK_UU_V_REQ_H__)
#define __DMR_LC_CSBK__CSBK_UU_V_REQ_H__
@ -24,20 +27,34 @@ namespace dmr
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements UU VCH REQ - Unit-to-Unit Voice Channel Request
// ---------------------------------------------------------------------------
/**
* @brief Implements UU VCH REQ - Unit-to-Unit Voice Channel Request
* @ingroup dmr_csbk
*/
class HOST_SW_API CSBK_UU_V_REQ : public CSBK {
public:
/// <summary>Initializes a new instance of the CSBK_UU_V_REQ class.</summary>
/**
* @brief Initializes a new instance of the CSBK_UU_V_REQ class.
*/
CSBK_UU_V_REQ();
/// <summary>Decode a control signalling block.</summary>
/**
* @brief Decodes a control signalling block.
* @param[in] data Buffer containing a CSBK to decode.
*/
bool decode(const uint8_t* data) override;
/// <summary>Encode a control signalling block.</summary>
/**
* @brief Encodes a control signalling block.
* @param[out] data Buffer to encode a CSBK.
*/
void encode(uint8_t* data) override;
/// <summary>Returns a string that represents the current CSBK.</summary>
/**
* @brief Returns a string that represents the current CSBK.
* @returns std::string String representation of the CSBK.
*/
std::string toString() override;
};
} // namespace csbk

@ -1,18 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2010,2014,2016,2021 Jonathan Naylor, G4KLX
* Copyright (C) 2016 Mathias Weyland, HB9FRV
* Copyright (C) 2018-2022 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2010,2014,2016,2021 Jonathan Naylor, G4KLX
* Copyright (C) 2016 Mathias Weyland, HB9FRV
* Copyright (C) 2018-2022 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "edac/AMBEFEC.h"
#include "edac/Golay24128.h"
@ -29,21 +25,13 @@ using namespace edac;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the AMBEFEC class.
/// </summary>
/* Initializes a new instance of the AMBEFEC class. */
AMBEFEC::AMBEFEC() = default;
/// <summary>
/// Finalizes a instance of the AMBEFEC class.
/// </summary>
/* Finalizes a instance of the AMBEFEC class. */
AMBEFEC::~AMBEFEC() = default;
/// <summary>
/// Regenerates the DMR AMBE FEC for the input bytes.
/// </summary>
/// <param name="bytes"></param>
/// <returns>Count of errors.</returns>
/* Regenerates the DMR AMBE FEC for the input bytes. */
uint32_t AMBEFEC::regenerateDMR(uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -146,11 +134,7 @@ uint32_t AMBEFEC::regenerateDMR(uint8_t* bytes) const
return errors;
}
/// <summary>
/// Returns the number of errors on the DMR BER input bytes.
/// </summary>
/// <param name="bytes"></param>
/// <returns>Count of errors.</returns>
/* Returns the number of errors on the DMR BER input bytes. */
uint32_t AMBEFEC::measureDMRBER(const uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -214,11 +198,7 @@ uint32_t AMBEFEC::measureDMRBER(const uint8_t* bytes) const
return errors;
}
/// <summary>
/// Regenerates the P25 IMBE FEC for the input bytes.
/// </summary>
/// <param name="bytes"></param>
/// <returns>Count of errors.</returns>
/* Regenerates the P25 IMBE FEC for the input bytes. */
uint32_t AMBEFEC::regenerateIMBE(uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -353,11 +333,7 @@ uint32_t AMBEFEC::regenerateIMBE(uint8_t* bytes) const
return errors;
}
/// <summary>
/// Returns the number of errors on the P25 BER input bytes.
/// </summary>
/// <param name="bytes"></param>
/// <returns>Count of errors.</returns>
/* Returns the number of errors on the P25 BER input bytes. */
uint32_t AMBEFEC::measureP25BER(const uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -486,11 +462,7 @@ uint32_t AMBEFEC::measureP25BER(const uint8_t* bytes) const
return errors;
}
/// <summary>
/// Regenerates the NXDN AMBE FEC for the input bytes.
/// </summary>
/// <param name="bytes"></param>
/// <returns>Count of errors.</returns>
/* Regenerates the NXDN AMBE FEC for the input bytes. */
uint32_t AMBEFEC::regenerateNXDN(uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -542,11 +514,7 @@ uint32_t AMBEFEC::regenerateNXDN(uint8_t* bytes) const
return errors;
}
/// <summary>
/// Returns the number of errors on the NXDN BER input bytes.
/// </summary>
/// <param name="bytes"></param>
/// <returns>Count of errors.</returns>
/* Returns the number of errors on the NXDN BER input bytes. */
uint32_t AMBEFEC::measureNXDNBER(uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -583,13 +551,7 @@ uint32_t AMBEFEC::measureNXDNBER(uint8_t* bytes) const
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="c"></param>
/// <returns></returns>
/* */
uint32_t AMBEFEC::regenerate(uint32_t& a, uint32_t& b, uint32_t& c) const
{
uint32_t old_a = a;

@ -1,17 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2010,2014,2016,2021 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2010,2014,2016,2021 Jonathan Naylor, G4KLX
* Copyright (C) 2018-2022 Bryan Biedenkapp, N2PLL
*
*/
* @file AMBEFEC.h
* @ingroup edac
* @file AMBEFEC.cpp
* @ingroup edac
*/
#if !defined(__AMBE_FEC_H__)
#define __AMBE_FEC_H__
@ -455,34 +457,71 @@ namespace edac
// ---------------------------------------------------------------------------
// Class Declaration
// Implements routines to regenerate AMBE/IMBE data using forward error
// correction.
// ---------------------------------------------------------------------------
/**
* @brief Implements routines to regenerate AMBE/IMBE data using forward error
* correction.
* @ingroup edac
*/
class HOST_SW_API AMBEFEC {
public:
/// <summary>Initializes a new instance of the AMBEFEC class.</summary>
/**
* @brief Initializes a new instance of the AMBEFEC class.
*/
AMBEFEC();
/// <summary>Finalizes a instance of the AMBEFEC class.</summary>
/**
* @brief Finalizes a instance of the AMBEFEC class.
*/
~AMBEFEC();
/// <summary>Regenerates the DMR AMBE FEC for the input bytes.</summary>
/**
* @brief Regenerates the DMR AMBE FEC for the input bytes.
* @param bytes AMBE bytes.
* @returns uint32_t Count of errors.
*/
uint32_t regenerateDMR(uint8_t* bytes) const;
/// <summary>Returns the number of errors on the DMR BER input bytes.</summary>
/**
* @brief Returns the number of errors on the DMR BER input bytes.
* @param[in] bytes AMBE bytes.
* @returns uint32_t Count of errors.
*/
uint32_t measureDMRBER(const uint8_t* bytes) const;
/// <summary>Regenerates the P25 IMBE FEC for the input bytes.</summary>
/**
* @brief Regenerates the P25 IMBE FEC for the input bytes.
* @param bytes IMBE bytes.
* @returns Count of errors.
*/
uint32_t regenerateIMBE(uint8_t* bytes) const;
/// <summary>Returns the number of errors on the P25 BER input bytes.</summary>
/**
* @brief Returns the number of errors on the P25 BER input bytes.
* @param[in] bytes AMBE bytes.
* @returns uint32_t Count of errors.
*/
uint32_t measureP25BER(const uint8_t* bytes) const;
/// <summary>Regenerates the NXDN AMBE FEC for the input bytes.</summary>
/**
* @brief Regenerates the NXDN AMBE FEC for the input bytes.
* @param bytes AMBE bytes.
* @returns uint32_t Count of errors.
*/
uint32_t regenerateNXDN(uint8_t* bytes) const;
/// <summary>Returns the number of errors on the NXDN BER input bytes.</summary>
/**
* @brief Returns the number of errors on the NXDN BER input bytes.
* @param[in] bytes AMBE bytes.
* @returns uint32_t Count of errors.
*/
uint32_t measureNXDNBER(uint8_t* bytes) const;
private:
/// <summary></summary>
/**
* @brief
* @param a
* @param b
* @param c
* @returns uint32_t Count of errors.
*/
uint32_t regenerate(uint32_t& a, uint32_t& b, uint32_t& c) const;
};
} // namespace edac

@ -1,14 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*/
/*
* File: bch3.c
* Title: Encoder/decoder for binary BCH codes in C (Version 3.1)
@ -103,20 +99,13 @@ const int g[] = {
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the BCH class.
/// </summary>
/* Initializes a new instance of the BCH class. */
BCH::BCH() = default;
/// <summary>
/// Finalizes a instance of the BCH class.
/// </summary>
/* Finalizes a instance of the BCH class. */
BCH::~BCH() = default;
/// <summary>
/// Encodes input data with BCH.
/// </summary>
/// <param name="nid">P25 NID data to encode with BCH.</param>
/* Encodes input data with BCH. */
void BCH::encode(uint8_t* nid)
{
assert(nid != nullptr);
@ -138,16 +127,8 @@ void BCH::encode(uint8_t* nid)
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <remarks>
/// Compute redundancy bb[], the coefficients of b(x). The redundancy
/// polynomial b(x) is the remainder after dividing x^(length-k)*data(x)
/// by the generator polynomial g(x).
/// </remarks>
/// <param name="data"></param>
/// <param name="bb"></param>
/* Compute redundancy bb[], the coefficients of b(x). The redundancy polynomial b(x) is the
remainder after dividing x^(length-k)*data(x) by the generator polynomial g(x). */
void BCH::encode(const int* data, int* bb)
{
for (int i = 0; i < length - k; i++)

@ -1,16 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2016 Jonathan Naylor, G4KLX
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2016 Jonathan Naylor, G4KLX
*
*/
* @file BCH.h
* @ingroup edac
* @file BCH.cpp
* @ingroup edac
*/
#if !defined(__BCH_H__)
#define __BCH_H__
@ -20,22 +22,37 @@ namespace edac
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements Bose/Chaudhuri/Hocquenghem codes for protecting P25 NID
// data.
// ---------------------------------------------------------------------------
/**
* @brief Implements Bose/Chaudhuri/Hocquenghem codes for protecting P25 NID
* data.
* @ingroup edac
*/
class HOST_SW_API BCH {
public:
/// <summary>Initializes a new instance of the BCH class.</summary>
/**
* @brief Initializes a new instance of the BCH class.
*/
BCH();
/// <summary>Finalizes a instance of the BCH class.</summary>
/**
* @brief Finalizes a instance of the BCH class.
*/
~BCH();
/// <summary>Encodes input data with BCH.</summary>
/**
* @brief Encodes input data with BCH.
* @param data Data to encode with BCH.
*/
void encode(uint8_t* data);
private:
/// <summary></summary>
/**
* @brief Compute redundancy bb[], the coefficients of b(x). The redundancy polynomial b(x) is the
* remainder after dividing x^(length-k)*data(x) by the generator polynomial g(x).
* @param data
* @param bb
*/
void encode(const int* data, int* bb);
};
} // namespace edac

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2012 Ian Wraith
* Copyright (C) 2015 Jonathan Naylor, G4KLX
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2012 Ian Wraith
* Copyright (C) 2015 Jonathan Naylor, G4KLX
*
*/
#include "Defines.h"
#include "edac/BPTC19696.h"
#include "edac/Hamming.h"
@ -25,9 +21,7 @@ using namespace edac;
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the BPTC19696 class.
/// </summary>
/* Initializes a new instance of the BPTC19696 class. */
BPTC19696::BPTC19696() :
m_rawData(nullptr),
m_deInterData(nullptr)
@ -36,20 +30,14 @@ BPTC19696::BPTC19696() :
m_deInterData = new bool[196];
}
/// <summary>
/// Finalizes a instance of the BPTC19696 class.
/// </summary>
/* Finalizes a instance of the BPTC19696 class. */
BPTC19696::~BPTC19696()
{
delete[] m_rawData;
delete[] m_deInterData;
}
/// <summary>
/// Decode BPTC (196,96) FEC.
/// </summary>
/// <param name="in">Input data to decode.</param>
/// <param name="out">Decoded data.</param>
/* Decode BPTC (196,96) FEC. */
void BPTC19696::decode(const uint8_t* in, uint8_t* out)
{
assert(in != nullptr);
@ -68,11 +56,7 @@ void BPTC19696::decode(const uint8_t* in, uint8_t* out)
decodeExtractData(out);
}
/// <summary>
/// Encode BPTC (196,96) FEC.
/// </summary>
/// <param name="in">Input data to encode.</param>
/// <param name="out">Encoded data.</param>
/* Encode BPTC (196,96) FEC. */
void BPTC19696::encode(const uint8_t* in, uint8_t* out)
{
assert(in != nullptr);
@ -95,10 +79,7 @@ void BPTC19696::encode(const uint8_t* in, uint8_t* out)
// Private Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/* */
void BPTC19696::decodeExtractBinary(const uint8_t* in)
{
// first block
@ -137,9 +118,7 @@ void BPTC19696::decodeExtractBinary(const uint8_t* in)
Utils::byteToBitsBE(in[32U], m_rawData + 188U);
}
/// <summary>
///
/// </summary>
/* */
void BPTC19696::decodeDeInterleave()
{
for (uint32_t i = 0U; i < 196U; i++)
@ -154,9 +133,7 @@ void BPTC19696::decodeDeInterleave()
}
}
/// <summary>
///
/// </summary>
/* */
void BPTC19696::decodeErrorCheck()
{
bool fixing;
@ -195,10 +172,7 @@ void BPTC19696::decodeErrorCheck()
} while (fixing && count < 5U);
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/* */
void BPTC19696::decodeExtractData(uint8_t* data) const
{
bool bData[96U];
@ -244,10 +218,7 @@ void BPTC19696::decodeExtractData(uint8_t* data) const
Utils::bitsToByteBE(bData + 88U, data[11U]);
}
/// <summary>
///
/// </summary>
/// <param name="in"></param>
/* */
void BPTC19696::encodeExtractData(const uint8_t* in) const
{
bool bData[96U];
@ -296,9 +267,7 @@ void BPTC19696::encodeExtractData(const uint8_t* in) const
m_deInterData[a] = bData[pos];
}
/// <summary>
///
/// </summary>
/* */
void BPTC19696::encodeErrorCheck()
{
// run through each of the 9 rows containing data
@ -326,9 +295,7 @@ void BPTC19696::encodeErrorCheck()
}
}
/// <summary>
///
/// </summary>
/* */
void BPTC19696::encodeInterleave()
{
for (uint32_t i = 0U; i < 196U; i++)
@ -343,10 +310,7 @@ void BPTC19696::encodeInterleave()
}
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/* */
void BPTC19696::encodeExtractBinary(uint8_t* data)
{
// first block

@ -1,16 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015 Jonathan Naylor, G4KLX
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015 Jonathan Naylor, G4KLX
*
*/
* @file BPTC19696.h
* @ingroup edac
* @file BPTC19696.cpp
* @ingroup edac
*/
#if !defined(__BPTC19696_H__)
#define __BPTC19696_H__
@ -20,41 +22,75 @@ namespace edac
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements Block Product Turbo Code (196,96) FEC.
// ---------------------------------------------------------------------------
/**
* @brief Implements Block Product Turbo Code (196,96) FEC.
* @ingroup edac
*/
class HOST_SW_API BPTC19696 {
public:
/// <summary>Initializes a new instance of the BPTC19696 class.</summary>
/**
* @brief Initializes a new instance of the BPTC19696 class.
*/
BPTC19696();
/// <summary>Finalizes a instance of the BPTC19696 class.</summary>
/**
* @brief Finalizes a instance of the BPTC19696 class.
*/
~BPTC19696();
/// <summary>Decode BPTC (196,96) FEC.</summary>
/**
* @brief Decode BPTC (196,96) FEC.
* @param[in] in Input data to decode.
* @param[out] out Decoded data.
*/
void decode(const uint8_t* in, uint8_t* out);
/// <summary>Encode BPTC (196,96) FEC.</summary>
/**
* @brief Encode BPTC (196,96) FEC.
* @param[in] in Input data to encode.
* @param[out] out Encoded data.
*/
void encode(const uint8_t* in, uint8_t* out);
private:
bool* m_rawData;
bool* m_deInterData;
/// <summary></summary>
/**
* @brief
* @param in
*/
void decodeExtractBinary(const uint8_t* in);
/// <summary></summary>
/**
* @brief
*/
void decodeErrorCheck();
/// <summary></summary>
/**
* @brief
*/
void decodeDeInterleave();
/// <summary></summary>
/**
* @brief
* @param data
*/
void decodeExtractData(uint8_t* data) const;
/// <summary></summary>
/**
* @brief
*/
void encodeExtractData(const uint8_t* in) const;
/// <summary></summary>
/**
* @brief
*/
void encodeInterleave();
/// <summary></summary>
/**
* @brief
*/
void encodeErrorCheck();
/// <summary></summary>
/**
* @brief
* @param data
*/
void encodeExtractBinary(uint8_t* data);
};
} // namespace edac

@ -1,17 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018,2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018,2022,2024 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "edac/CRC.h"
#include "Log.h"
@ -155,12 +151,7 @@ const uint32_t CRC32_TABLE[] = {
// Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Check 5-bit CRC.
/// </summary>
/// <param name="in">Boolean bit array.</param>
/// <param name="tcrc">Computed CRC to check.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
/* Check 5-bit CRC. */
bool CRC::checkFiveBit(bool* in, uint32_t tcrc)
{
assert(in != nullptr);
@ -171,11 +162,7 @@ bool CRC::checkFiveBit(bool* in, uint32_t tcrc)
return crc == tcrc;
}
/// <summary>
/// Encode 5-bit CRC.
/// </summary>
/// <param name="in">Boolean bit array.</param>
/// <param name="tcrc">Computed CRC.</param>
/* Encode 5-bit CRC. */
void CRC::encodeFiveBit(const bool* in, uint32_t& tcrc)
{
assert(in != nullptr);
@ -192,13 +179,7 @@ void CRC::encodeFiveBit(const bool* in, uint32_t& tcrc)
tcrc = total;
}
/// <summary>
/// Check 16-bit CRC CCITT-162.
/// </summary>
/// <remarks>This uses polynomial 0x1021.</remarks>
/// <param name="in">Input byte array.</param>
/// <param name="length">Length of byte array.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
/* Check 16-bit CRC CCITT-162. */
bool CRC::checkCCITT162(const uint8_t *in, uint32_t length)
{
assert(in != nullptr);
@ -224,12 +205,7 @@ bool CRC::checkCCITT162(const uint8_t *in, uint32_t length)
return crc8[0U] == in[length - 1U] && crc8[1U] == in[length - 2U];
}
/// <summary>
/// Encode 16-bit CRC CCITT-162.
/// </summary>
/// <remarks>This uses polynomial 0x1021.</remarks>
/// <param name="in">Input byte array.</param>
/// <param name="length">Length of byte array.</param>
/* Encode 16-bit CRC CCITT-162. */
void CRC::addCCITT162(uint8_t* in, uint32_t length)
{
assert(in != nullptr);
@ -255,13 +231,7 @@ void CRC::addCCITT162(uint8_t* in, uint32_t length)
in[length - 2U] = crc8[1U];
}
/// <summary>
/// Check 16-bit CRC CCITT-161.
/// </summary>
/// <remarks>This uses polynomial 0x1189.</remarks>
/// <param name="in">Input byte array.</param>
/// <param name="length">Length of byte array.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
/* Check 16-bit CRC CCITT-161. */
bool CRC::checkCCITT161(const uint8_t *in, uint32_t length)
{
assert(in != nullptr);
@ -287,12 +257,7 @@ bool CRC::checkCCITT161(const uint8_t *in, uint32_t length)
return crc8[0U] == in[length - 2U] && crc8[1U] == in[length - 1U];
}
/// <summary>
/// Encode 16-bit CRC CCITT-161.
/// </summary>
/// <remarks>This uses polynomial 0x1189.</remarks>
/// <param name="in">Input byte array.</param>
/// <param name="length">Length of byte array.</param>
/* Encode 16-bit CRC CCITT-161. */
void CRC::addCCITT161(uint8_t* in, uint32_t length)
{
assert(in != nullptr);
@ -318,12 +283,7 @@ void CRC::addCCITT161(uint8_t* in, uint32_t length)
in[length - 1U] = crc8[1U];
}
/// <summary>
/// Check 32-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="length">Length of byte array.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
/* Check 32-bit CRC. */
bool CRC::checkCRC32(const uint8_t *in, uint32_t length)
{
assert(in != nullptr);
@ -353,11 +313,7 @@ bool CRC::checkCRC32(const uint8_t *in, uint32_t length)
return crc8[0U] == in[length - 1U] && crc8[1U] == in[length - 2U] && crc8[2U] == in[length - 3U] && crc8[3U] == in[length - 4U];
}
/// <summary>
/// Encode 32-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="length">Length of byte array.</param>
/* Encode 32-bit CRC. */
void CRC::addCRC32(uint8_t* in, uint32_t length)
{
assert(in != nullptr);
@ -389,12 +345,7 @@ void CRC::addCRC32(uint8_t* in, uint32_t length)
in[length - 4U] = crc8[3U];
}
/// <summary>
/// Generate 8-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="length">Length of byte array.</param>
/// <returns>Calculated 8-bit CRC value.</returns>
/* Generate 8-bit CRC. */
uint8_t CRC::crc8(const uint8_t *in, uint32_t length)
{
assert(in != nullptr);
@ -411,12 +362,7 @@ uint8_t CRC::crc8(const uint8_t *in, uint32_t length)
return crc;
}
/// <summary>
/// Check 6-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
/* Check 6-bit CRC. */
bool CRC::checkCRC6(const uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -439,12 +385,7 @@ bool CRC::checkCRC6(const uint8_t* in, uint32_t bitLength)
return crc == temp[0U];
}
/// <summary>
/// Encode 6-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>6-bit CRC.</returns>
/* Encode 6-bit CRC. */
uint8_t CRC::addCRC6(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -464,12 +405,7 @@ uint8_t CRC::addCRC6(uint8_t* in, uint32_t bitLength)
return crc[0U];
}
/// <summary>
/// Check 12-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
/* Check 12-bit CRC. */
bool CRC::checkCRC12(const uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -496,12 +432,7 @@ bool CRC::checkCRC12(const uint8_t* in, uint32_t bitLength)
return temp1[0U] == temp2[0U] && temp1[1U] == temp2[1U];
}
/// <summary>
/// Encode 12-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>12-bit CRC.</returns>
/* Encode 12-bit CRC. */
uint16_t CRC::addCRC12(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -524,12 +455,7 @@ uint16_t CRC::addCRC12(uint8_t* in, uint32_t bitLength)
return crc;
}
/// <summary>
/// Check 15-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
/* Check 15-bit CRC. */
bool CRC::checkCRC15(const uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -556,12 +482,7 @@ bool CRC::checkCRC15(const uint8_t* in, uint32_t bitLength)
return temp1[0U] == temp2[0U] && temp1[1U] == temp2[1U];
}
/// <summary>
/// Encode 15-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>15-bit CRC.</returns>
/* Encode 15-bit CRC. */
uint16_t CRC::addCRC15(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -584,12 +505,7 @@ uint16_t CRC::addCRC15(uint8_t* in, uint32_t bitLength)
return crc;
}
/// <summary>
/// Check 16-bit CRC CCITT-162 w/ initial generator of 1.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns>True, if CRC is valid, otherwise false.</returns>
/* Check 16-bit CRC CCITT-162 w/ initial generator of 1. */
bool CRC::checkCRC16(const uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -616,13 +532,7 @@ bool CRC::checkCRC16(const uint8_t* in, uint32_t bitLength)
return temp1[0U] == temp2[0U] && temp1[1U] == temp2[1U];
}
/// <summary>
/// Encode 16-bit CRC CCITT-162 w/ initial generator of 1.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <param name="offset">Offset in bits to write CRC.</param>
/// <returns>16-bit CRC.</returns>
/* Encode 16-bit CRC CCITT-162 w/ initial generator of 1. */
uint16_t CRC::addCRC16(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -645,12 +555,7 @@ uint16_t CRC::addCRC16(uint8_t* in, uint32_t bitLength)
return crc;
}
/// <summary>
/// Generate 9-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns></returns>
/* Generate 9-bit CRC. */
uint16_t CRC::createCRC9(const uint8_t* in, uint32_t bitLength)
{
uint16_t crc = 0U;
@ -669,12 +574,7 @@ uint16_t CRC::createCRC9(const uint8_t* in, uint32_t bitLength)
return crc & 0x1FFU;
}
/// <summary>
/// Generate 16-bit CRC.
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns></returns>
/* Generate 16-bit CRC. */
uint16_t CRC::createCRC16(const uint8_t* in, uint32_t bitLength)
{
uint16_t crc = 0xFFFFU;
@ -696,12 +596,7 @@ uint16_t CRC::createCRC16(const uint8_t* in, uint32_t bitLength)
// Private Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns></returns>
/* Generate 6-bit CRC. */
uint8_t CRC::createCRC6(const uint8_t* in, uint32_t bitLength)
{
uint8_t crc = 0x3FU;
@ -719,12 +614,7 @@ uint8_t CRC::createCRC6(const uint8_t* in, uint32_t bitLength)
return crc & 0x3FU;
}
/// <summary>
///
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns></returns>
/* Generate 12-bit CRC. */
uint16_t CRC::createCRC12(const uint8_t* in, uint32_t bitLength)
{
uint16_t crc = 0x0FFFU;
@ -742,12 +632,7 @@ uint16_t CRC::createCRC12(const uint8_t* in, uint32_t bitLength)
return crc & 0x0FFFU;
}
/// <summary>
///
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
/// <returns></returns>
/* Generate 15-bit CRC. */
uint16_t CRC::createCRC15(const uint8_t* in, uint32_t bitLength)
{
uint16_t crc = 0x7FFFU;

@ -1,17 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018,2022,2024 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2018,2022,2024 Bryan Biedenkapp, N2PLL
*
*/
* @file CRC.h
* @ingroup edac
* @file CRC.cpp
* @ingroup edac
*/
#if !defined(__CRC_H__)
#define __CRC_H__
@ -21,65 +23,187 @@ namespace edac
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements various Cyclic Redundancy Check routines.
// ---------------------------------------------------------------------------
/**
* @brief Implements various Cyclic Redundancy Check routines.
* @ingroup edac
*/
class HOST_SW_API CRC {
public:
/// <summary>Check 5-bit CRC.</summary>
/**
* @brief Check 5-bit CRC.
* @param in Boolean bit array.
* @param tcrc Computed CRC to check.
* @returns bool True, if CRC is valid, otherwise false.
*/
static bool checkFiveBit(bool* in, uint32_t tcrc);
/// <summary>Encode 5-bit CRC.</summary>
/**
* @brief Encode 5-bit CRC.
* @param in Boolean bit array.
* @param tcrc Computed CRC.
*/
static void encodeFiveBit(const bool* in, uint32_t& tcrc);
/// <summary>Check 16-bit CRC CCITT-162.</summary>
/**
* @brief Check 16-bit CRC CCITT-162.
*
* This uses polynomial 0x1021.
*
* @param[in] in Input byte array.
* @param length Length of byte array.
* @returns bool True, if CRC is valid, otherwise false.
*/
static bool checkCCITT162(const uint8_t* in, uint32_t length);
/// <summary>Encode 16-bit CRC CCITT-162.</summary>
/**
* @brief Encode 16-bit CRC CCITT-162.
*
* This uses polynomial 0x1021.
*
* @param[out] in Input byte array.
* @param length Length of byte array.
*/
static void addCCITT162(uint8_t* in, uint32_t length);
/// <summary>Check 16-bit CRC CCITT-161.</summary>
/**
* @brief Check 16-bit CRC CCITT-161.
*
* This uses polynomial 0x1189.
*
* @param[in] in Input byte array.
* @param length Length of byte array.
* @returns bool True, if CRC is valid, otherwise false.
*/
static bool checkCCITT161(const uint8_t* in, uint32_t length);
/// <summary>Encode 16-bit CRC CCITT-161.</summary>
/**
* @brief Encode 16-bit CRC CCITT-161.
*
* This uses polynomial 0x1189.
*
* @param[out] in Input byte array.
* @param length Length of byte array.
*/
static void addCCITT161(uint8_t* in, uint32_t length);
/// <summary>Check 32-bit CRC.</summary>
/**
* @brief Check 32-bit CRC.
* @param[in] in Input byte array.
* @param length Length of byte array.
* @returns bool True, if CRC is valid, otherwise false.
*/
static bool checkCRC32(const uint8_t* in, uint32_t length);
/// <summary>Encode 32-bit CRC.</summary>
/**
* @brief Encode 32-bit CRC.
* @param[out] in Input byte array.
* @param length Length of byte array.
*/
static void addCRC32(uint8_t* in, uint32_t length);
/// <summary>Generate 8-bit CRC.</summary>
/**
* @brief Generate 8-bit CRC.
* @param[in] in Input byte array.
* @param length Length of byte array.
* @returns uint8_t Calculated 8-bit CRC value.
*/
static uint8_t crc8(const uint8_t* in, uint32_t length);
/// <summary>Check 6-bit CRC.</summary>
/**
* @brief Check 6-bit CRC.
* @param[in] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns bool True, if CRC is valid, otherwise false.
*/
static bool checkCRC6(const uint8_t* in, uint32_t bitLength);
/// <summary>Encode 6-bit CRC.</summary>
/**
* @brief Encode 6-bit CRC.
* @param[out] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns uint8_t 6-bit CRC.
*/
static uint8_t addCRC6(uint8_t* in, uint32_t bitLength);
/// <summary>Check 12-bit CRC.</summary>
/**
* @brief Check 12-bit CRC.
* @param[out] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns bool True, if CRC is valid, otherwise false.
*/
static bool checkCRC12(const uint8_t* in, uint32_t bitLength);
/// <summary>Encode 12-bit CRC.</summary>
/**
* @brief Encode 12-bit CRC.
* @param[out] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns uint16_t 12-bit CRC.
*/
static uint16_t addCRC12(uint8_t* in, uint32_t bitLength);
/// <summary>Check 15-bit CRC.</summary>
/**
* @brief Check 15-bit CRC.
* @param[in] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns bool True, if CRC is valid, otherwise false.
*/
static bool checkCRC15(const uint8_t* in, uint32_t bitLength);
/// <summary>Encode 15-bit CRC.</summary>
/**
* @brief Encode 15-bit CRC.
* @param[out] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns uint16_t 15-bit CRC.
*/
static uint16_t addCRC15(uint8_t* in, uint32_t bitLength);
/// <summary>Check 16-bit CRC CCITT-162 w/ initial generator of 1.</summary>
/**
* @brief Check 16-bit CRC CCITT-162 w/ initial generator of 1.
* @param[in] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns bool True, if CRC is valid, otherwise false.
*/
static bool checkCRC16(const uint8_t* in, uint32_t bitLength);
/// <summary>Encode 16-bit CRC CCITT-162 w/ initial generator of 1.</summary>
/**
* @brief Encode 16-bit CRC CCITT-162 w/ initial generator of 1.
* @param[out] in Input byte array.
* @param bitLength Length of byte array in bits.
* @param offset Offset in bits to write CRC.
* @returns uint16_t 16-bit CRC.
*/
static uint16_t addCRC16(uint8_t* in, uint32_t bitLength);
/// <summary>Generate 9-bit CRC.</summary>
/**
* @brief Generate 9-bit CRC.
* @param[in] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns uint16_t 9-bit CRC.
*/
static uint16_t createCRC9(const uint8_t* in, uint32_t bitLength);
/// <summary>Generate 16-bit CRC.</summary>
/**
* @brief Generate 16-bit CRC.
* @param[in] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns uint16_t 16-bit CRC.
*/
static uint16_t createCRC16(const uint8_t* in, uint32_t bitLength);
private:
/// <summary></summary>
/**
* @brief Generate 6-bit CRC.
* @param[in] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns uint8_t 6-bit CRC.
*/
static uint8_t createCRC6(const uint8_t* in, uint32_t bitLength);
/// <summary></summary>
/**
* @brief Generate 12-bit CRC.
* @param[in] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns uint16_t 12-bit CRC.
*/
static uint16_t createCRC12(const uint8_t* in, uint32_t bitLength);
/// <summary></summary>
/**
* @brief Generate 15-bit CRC.
* @param[in] in Input byte array.
* @param bitLength Length of byte array in bits.
* @returns uint16_t 15-bit CRC.
*/
static uint16_t createCRC15(const uint8_t* in, uint32_t bitLength);
};
} // namespace edac

@ -1,16 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
#include "Defines.h"
#include "edac/Golay2087.h"
@ -216,11 +212,7 @@ const uint32_t DECODING_TABLE_1987[] = {
// Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Decode Golay (20,8,7) FEC.
/// </summary>
/// <param name="data">Golay FEC encoded data byte array</param>
/// <returns></returns>
/* Decode Golay (20,8,7) FEC. */
uint8_t Golay2087::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -235,10 +227,7 @@ uint8_t Golay2087::decode(const uint8_t* data)
return code >> 11;
}
/// <summary>
/// Encode Golay (20,8,7) FEC.
/// </summary>
/// <param name="data">Data to encode with Golay FEC.</param>
/* Encode Golay (20,8,7) FEC. */
void Golay2087::encode(uint8_t* data)
{
assert(data != nullptr);
@ -255,20 +244,11 @@ void Golay2087::encode(uint8_t* data)
// Private Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <remarks>
/// Compute the syndrome corresponding to the given pattern, i.e., the
/// remainder after dividing the pattern (when considering it as the vector
/// representation of a polynomial) by the generator polynomial, GENPOL.
/// In the program this pattern has several meanings: (1) pattern = information
/// bits, when constructing the encoding table; (2) pattern = error pattern,
/// when constructing the decoding table; and (3) pattern = received vector, to
/// obtain its syndrome in decoding.
/// </remarks>
/// <param name="pattern"></param>
/// <returns></returns>
/* Compute the syndrome corresponding to the given pattern, i.e., the remainder after dividing the
pattern (when considering it as the vector representation of a polynomial) by the generator
polynomial, GENPOL. In the program this pattern has several meanings: (1) pattern = information bits,
when constructing the encoding table; (2) pattern = error pattern, when constructing the decoding
table; and (3) pattern = received vector, to obtain its syndrome in decoding. */
uint32_t Golay2087::getSyndrome1987(uint32_t pattern)
{
uint32_t aux = X18;

@ -1,16 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015 Jonathan Naylor, G4KLX
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015 Jonathan Naylor, G4KLX
*
*/
* @file Golay2087.h
* @ingroup edac
* @file Golay2087.cpp
* @ingroup edac
*/
#if !defined(__GOLAY2087_H__)
#define __GOLAY2087_H__
@ -20,18 +22,36 @@ namespace edac
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements Golay (20,8,7) forward error correction.
// ---------------------------------------------------------------------------
/**
* @brief Implements Golay (20,8,7) forward error correction.
* @ingroup edac
*/
class HOST_SW_API Golay2087 {
public:
/// <summary>Decode Golay (20,8,7) FEC.</summary>
/**
* @brief Decode Golay (20,8,7) FEC.
* @param bytes Golay FEC encoded data byte array.
* @returns uint8_t
*/
static uint8_t decode(const uint8_t* data);
/// <summary>Encode Golay (20,8,7) FEC.</summary>
/**
* @brief Encode Golay (20,8,7) FEC.
* @param data Data to encode with Golay FEC.
*/
static void encode(uint8_t* data);
private:
/// <summary></summary>
/**
* @brief Compute the syndrome corresponding to the given pattern, i.e., the
* remainder after dividing the pattern (when considering it as the vector
* representation of a polynomial) by the generator polynomial, GENPOL.
* In the program this pattern has several meanings: (1) pattern = information
* bits, when constructing the encoding table; (2) pattern = error pattern,
* when constructing the decoding table; and (3) pattern = received vector, to
* obtain its syndrome in decoding.
*/
static uint32_t getSyndrome1987(uint32_t pattern);
};
} // namespace edac

@ -1,18 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2002 by Robert H. Morelos-Zaragoza., All rights reserved.
* Copyright (C) 2010,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2017 Bryan Biedenkapp, N2PLL
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2002 by Robert H. Morelos-Zaragoza., All rights reserved.
* Copyright (C) 2010,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2017 Bryan Biedenkapp, N2PLL
*
*/
#include "Defines.h"
#include "edac/Golay24128.h"
#include "Utils.h"
@ -1065,11 +1061,7 @@ static const uint32_t DECODING_TABLE_23127[] = {
// Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Decode Golay (23,12,7) FEC.
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
/* Decode Golay (23,12,7) FEC. */
uint32_t Golay24128::decode23127(uint32_t code)
{
uint32_t syndrome = getSyndrome23127(code);
@ -1080,12 +1072,7 @@ uint32_t Golay24128::decode23127(uint32_t code)
return code >> 11;
}
/// <summary>
/// Decode Golay (24,12,8) FEC.
/// </summary>
/// <param name="code"></param>
/// <param name="out"></param>
/// <returns></returns>
/* Decode Golay (24,12,8) FEC. */
bool Golay24128::decode24128(uint32_t code, uint32_t& out)
{
uint32_t syndrome = getSyndrome23127(code >> 1);
@ -1099,12 +1086,7 @@ bool Golay24128::decode24128(uint32_t code, uint32_t& out)
return valid;
}
/// <summary>
/// Decode Golay (24,12,8) FEC.
/// </summary>
/// <param name="bytes">Golay FEC encoded data byte array</param>
/// <param name="out"></param>
/// <returns></returns>
/* Decode Golay (24,12,8) FEC. */
bool Golay24128::decode24128(uint8_t* bytes, uint32_t& out)
{
assert(bytes != nullptr);
@ -1113,13 +1095,7 @@ bool Golay24128::decode24128(uint8_t* bytes, uint32_t& out)
return decode24128(code, out);
}
/// <summary>
/// Decode Golay (24,12,8) FEC.
/// </summary>
/// <param name="data">Data decoded with Golay FEC.</param>
/// <param name="raw">Raw data to decode.</param>
/// <param name="msglen">Length of data to decode.</param>
/// <returns></returns>
/* Decode Golay (24,12,8) FEC. */
void Golay24128::decode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen)
{
uint32_t i = 0; // decoded byte counter
@ -1176,32 +1152,19 @@ void Golay24128::decode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen)
}
}
/// <summary>
/// Encode Golay (23,12,7) FEC.
/// </summary>
/// <param name="data">Data to encode with Golay FEC.</param>
/// <returns></returns>
/* Encode Golay (23,12,7) FEC. */
uint32_t Golay24128::encode23127(uint32_t data)
{
return ENCODING_TABLE_23127[data];
}
/// <summary>
/// Encode Golay (24,12,8) FEC.
/// </summary>
/// <param name="data">Data to encode with Golay FEC.</param>
/// <returns></returns>
/* Encode Golay (24,12,8) FEC. */
uint32_t Golay24128::encode24128(uint32_t data)
{
return ENCODING_TABLE_24128[data];
}
/// <summary>
/// Encode Golay (24,12,8) FEC.
/// </summary>
/// <param name="data">Data encoded with Golay FEC.</param>
/// <param name="raw">Raw data to encode.</param>
/// <param name="msglen">Length of data to encode.</param>
/* Encode Golay (24,12,8) FEC. */
void Golay24128::encode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen)
{
uint32_t j = 0;
@ -1263,20 +1226,11 @@ void Golay24128::encode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen)
// Private Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <remarks>
/// Compute the syndrome corresponding to the given pattern, i.e., the
/// remainder after dividing the pattern (when considering it as the vector
/// representation of a polynomial) by the generator polynomial, GENPOL.
/// In the program this pattern has several meanings: (1) pattern = information
/// bits, when constructing the encoding table; (2) pattern = error pattern,
/// when constructing the decoding table; and (3) pattern = received vector, to
/// obtain its syndrome in decoding.
/// </remarks>
/// <param name="pattern"></param>
/// <returns></returns>
/* Compute the syndrome corresponding to the given pattern, i.e., the remainder after dividing the
pattern (when considering it as the vector representation of a polynomial) by the generator
polynomial, GENPOL. In the program this pattern has several meanings: (1) pattern = information bits,
when constructing the encoding table; (2) pattern = error pattern, when constructing the decoding
table; and (3) pattern = received vector, to obtain its syndrome in decoding. */
uint32_t Golay24128::getSyndrome23127(uint32_t pattern)
{
uint32_t aux = X22;

@ -1,17 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2010,2016,2021 Jonathan Naylor, G4KLX
* Copyright (C) 2017,2022 Bryan Biedenkapp, N2PLL
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2010,2016,2021 Jonathan Naylor, G4KLX
* Copyright (C) 2017,2022 Bryan Biedenkapp, N2PLL
*
*/
* @file Golay24128.h
* @ingroup edac
* @file Golay24128.cpp
* @ingroup edac
*/
#if !defined(__GOLAY24128_H__)
#define __GOLAY24128_H__
@ -21,30 +23,73 @@ namespace edac
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements Golay (23,12,7) and Golay (24,12,8) forward error
// correction.
// ---------------------------------------------------------------------------
/**
* @brief Implements Golay (23,12,7) and Golay (24,12,8) forward error
* correction.
* @ingroup edac
*/
class HOST_SW_API Golay24128 {
public:
/// <summary>Decode Golay (23,12,7) FEC.</summary>
/**
* @brief Decode Golay (23,12,7) FEC.
* @param code
* @returns uint8_t Number of errors detected.
*/
static uint32_t decode23127(uint32_t code);
/// <summary>Decode Golay (24,12,8) FEC.</summary>
/**
* @brief Decode Golay (24,12,8) FEC.
* @param code
* @param out
* @returns bool
*/
static bool decode24128(uint32_t code, uint32_t& out);
/// <summary>Decode Golay (24,12,8) FEC.</summary>
/**
* @brief Decode Golay (24,12,8) FEC.
* @param bytes Golay FEC encoded data byte array.
* @param out
* @returns bool
*/
static bool decode24128(uint8_t* bytes, uint32_t& out);
/// <summary>Decode Golay (24,12,8) FEC.</summary>
/**
* @brief Decode Golay (24,12,8) FEC.
* @param data Data decoded with Golay FEC.
* @param raw Raw data to decode.
* @param msglen Length of data to decode.
*/
static void decode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen);
/// <summary>Encode Golay (23,12,7) FEC.</summary>
/**
* @brief Encode Golay (23,12,7) FEC.
* @param data Data to encode with Golay FEC.
* @returns uint32_t
*/
static uint32_t encode23127(uint32_t data);
/// <summary>Encode Golay (24,12,8) FEC.</summary>
/**
* @brief Encode Golay (24,12,8) FEC.
* @param data Data to encode with Golay FEC.
* @returns uint32_t
*/
static uint32_t encode24128(uint32_t data);
/// <summary>Encode Golay (24,12,8) FEC.</summary>
/**
* @brief Encode Golay (24,12,8) FEC.
* @param data Data encoded with Golay FEC.
* @param raw Raw data to encode.
* @param msglen Length of data to encode.
*/
static void encode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen);
private:
/// <summary></summary>
/**
* @brief Compute the syndrome corresponding to the given pattern, i.e., the
* remainder after dividing the pattern (when considering it as the vector
* representation of a polynomial) by the generator polynomial, GENPOL.
* In the program this pattern has several meanings: (1) pattern = information
* bits, when constructing the encoding table; (2) pattern = error pattern,
* when constructing the decoding table; and (3) pattern = received vector, to
* obtain its syndrome in decoding.
*/
static uint32_t getSyndrome23127(uint32_t pattern);
};
} // namespace edac

@ -1,16 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
#include "edac/Hamming.h"
using namespace edac;
@ -21,11 +17,7 @@ using namespace edac;
// Static Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Decode Hamming (15,11,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/// <returns>True, if bit errors are detected, otherwise false.</returns>
/* Decode Hamming (15,11,3). */
bool Hamming::decode15113_1(bool* d)
{
assert(d != nullptr);
@ -67,10 +59,7 @@ bool Hamming::decode15113_1(bool* d)
}
}
/// <summary>
/// Encode Hamming (15,11,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/* Encode Hamming (15,11,3). */
void Hamming::encode15113_1(bool* d)
{
assert(d != nullptr);
@ -82,11 +71,7 @@ void Hamming::encode15113_1(bool* d)
d[14] = d[0] ^ d[2] ^ d[4] ^ d[6] ^ d[7] ^ d[9] ^ d[10];
}
/// <summary>
/// Decode Hamming (15,11,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/// <returns>True, if bit errors are detected, otherwise false.</returns>
/* Decode Hamming (15,11,3). */
bool Hamming::decode15113_2(bool* d)
{
assert(d != nullptr);
@ -128,10 +113,7 @@ bool Hamming::decode15113_2(bool* d)
}
}
/// <summary>
/// Encode Hamming (15,11,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/* Encode Hamming (15,11,3). */
void Hamming::encode15113_2(bool* d)
{
assert(d != nullptr);
@ -143,11 +125,7 @@ void Hamming::encode15113_2(bool* d)
d[14] = d[0] ^ d[1] ^ d[2] ^ d[4] ^ d[6] ^ d[7] ^ d[10];
}
/// <summary>
/// Decode Hamming (13,9,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/// <returns>True, if bit errors are detected, otherwise false.</returns>
/* Decode Hamming (13,9,3). */
bool Hamming::decode1393(bool* d)
{
assert(d != nullptr);
@ -187,10 +165,7 @@ bool Hamming::decode1393(bool* d)
}
}
/// <summary>
/// Encode Hamming (13,9,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/* Encode Hamming (13,9,3). */
void Hamming::encode1393(bool* d)
{
assert(d != nullptr);
@ -202,11 +177,7 @@ void Hamming::encode1393(bool* d)
d[12] = d[0] ^ d[2] ^ d[4] ^ d[5] ^ d[8];
}
/// <summary>
/// Decode Hamming (10,6,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/// <returns>True, if bit errors are detected, otherwise false.</returns>
/* Decode Hamming (10,6,3). */
bool Hamming::decode1063(bool* d)
{
assert(d != nullptr);
@ -243,10 +214,7 @@ bool Hamming::decode1063(bool* d)
}
}
/// <summary>
/// Encode Hamming (10,6,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/* Encode Hamming (10,6,3). */
void Hamming::encode1063(bool* d)
{
assert(d != nullptr);
@ -258,11 +226,7 @@ void Hamming::encode1063(bool* d)
d[9] = d[1] ^ d[2] ^ d[3] ^ d[4];
}
/// <summary>
/// Decode Hamming (16,11,4).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/// <returns>True, if bit errors are detected or no bit errors, otherwise false if unrecoverable errors are detected.</returns>
/* Decode Hamming (16,11,4). */
bool Hamming::decode16114(bool* d)
{
assert(d != nullptr);
@ -311,10 +275,7 @@ bool Hamming::decode16114(bool* d)
}
}
/// <summary>
/// Encode Hamming (10,6,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/* Encode Hamming (10,6,3). */
void Hamming::encode16114(bool* d)
{
assert(d != nullptr);
@ -326,11 +287,7 @@ void Hamming::encode16114(bool* d)
d[15] = d[0] ^ d[2] ^ d[5] ^ d[6] ^ d[8] ^ d[9] ^ d[10];
}
/// <summary>
/// Decode Hamming (17,12,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/// <returns>True, if bit errors are detected or no bit errors, otherwise false if unrecoverable errors are detected.</returns>
/* Decode Hamming (17,12,3). */
bool Hamming::decode17123(bool* d)
{
assert(d != nullptr);
@ -380,10 +337,7 @@ bool Hamming::decode17123(bool* d)
}
}
/// <summary>
/// Encode Hamming (17,12,3).
/// </summary>
/// <param name="d">Boolean bit array.</param>
/* Encode Hamming (17,12,3). */
void Hamming::encode17123(bool* d)
{
assert(d != nullptr);

@ -1,16 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
/**
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Common Library
* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost)
* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0)
*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
*
*/
* @file Hamming.h
* @ingroup edac
* @file Hamming.cpp
* @ingroup edac
*/
#if !defined(__HAMMING_H__)
#define __HAMMING_H__
@ -20,40 +22,85 @@ namespace edac
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements Hamming (15,11,3), (13,9,3), (10,6,3), (16,11,4) and
// (17, 12, 3) forward error correction.
// ---------------------------------------------------------------------------
/**
* @brief Implements Hamming (15,11,3), (13,9,3), (10,6,3), (16,11,4) and
* (17, 12, 3) forward error correction.
* @ingroup edac
*/
class HOST_SW_API Hamming {
public:
/// <summary>Decode Hamming (15,11,3).</summary>
/**
* @brief Decode Hamming (15,11,3).
* @param d Boolean bit array.
* @returns bool True, if bit errors are detected, otherwise false.
*/
static bool decode15113_1(bool* d);
/// <summary>Encode Hamming (15,11,3).</summary>
/**
* @brief Encode Hamming (15,11,3).
* @param d Boolean bit array.
*/
static void encode15113_1(bool* d);
/// <summary>Decode Hamming (15,11,3).</summary>
/**
* @brief Decode Hamming (15,11,3).
* @param d Boolean bit array.
* @returns bool True, if bit errors are detected, otherwise false.
*/
static bool decode15113_2(bool* d);
/// <summary>Encode Hamming (15,11,3).</summary>
/**
* @brief Encode Hamming (15,11,3).
* @param d Boolean bit array.
*/
static void encode15113_2(bool* d);
/// <summary>Decode Hamming (13,9,3).</summary>
/**
* @brief Decode Hamming (13,9,3).
* @param d Boolean bit array.
* @returns bool True, if bit errors are detected, otherwise false.
*/
static bool decode1393(bool* d);
/// <summary>Encode Hamming (13,9,3).</summary>
/**
* @brief Encode Hamming (13,9,3).
* @param d Boolean bit array.
*/
static void encode1393(bool* d);
/// <summary>Decode Hamming (10,6,3).</summary>
/**
* @brief Decode Hamming (10,6,3).
* @param d Boolean bit array.
* @returns bool True, if bit errors are detected, otherwise false.
*/
static bool decode1063(bool* d);
/// <summary>Encode Hamming (10,6,3).</summary>
/**
* @brief Encode Hamming (10,6,3).
* @param d Boolean bit array.
*/
static void encode1063(bool* d);
/// <summary>Decode Hamming (16,11,4).</summary>
/**
* @brief Decode Hamming (16,11,4).
* @param d Boolean bit array.
* @returns bool True, if bit errors are detected, otherwise false.
*/
static bool decode16114(bool* d);
/// <summary>Encode Hamming (16,11,4).</summary>
/**
* @brief Encode Hamming (16,11,4).
* @param d Boolean bit array.
*/
static void encode16114(bool* d);
/// <summary>Decode Hamming (17,12,3).</summary>
/**
* @brief Decode Hamming (17,12,3).
* @param d Boolean bit array.
* @returns bool True, if bit errors are detected, otherwise false.
*/
static bool decode17123(bool* d);
/// <summary>Encode Hamming (17,12,3).</summary>
/**
* @brief Encode Hamming (17,12,3).
* @param d Boolean bit array.
*/
static void encode17123(bool* d);
};
} // namespace edac

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.