From 893952f0241a8ce963508e7aaf003767f64fb2a1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 3 Jul 2023 16:21:35 +0100 Subject: [PATCH] Make all of the rest of the code base be conditionally compiled. --- AMBEFEC.cpp | 2 +- AMBEFEC.h | 2 +- BCH.cpp | 5 + BCH.h | 9 +- BPTC19696.cpp | 9 +- BPTC19696.h | 9 +- CRC.cpp | 19 +- CRC.h | 12 +- Conf.cpp | 4 + Conf.h | 4 + DMRAccessControl.cpp | 7 +- DMRAccessControl.h | 9 +- DMRCSBK.cpp | 7 +- DMRCSBK.h | 8 +- DMRControl.cpp | 6 +- DMRControl.h | 7 + DMRData.cpp | 8 +- DMRData.h | 8 +- DMRDataHeader.cpp | 7 +- DMRDataHeader.h | 8 +- DMREMB.cpp | 8 +- DMREMB.h | 9 +- DMREmbeddedData.cpp | 8 +- DMREmbeddedData.h | 8 +- DMRFullLC.cpp | 10 +- DMRFullLC.h | 8 +- DMRLC.cpp | 8 +- DMRLC.h | 7 +- DMRLookup.cpp | 7 +- DMRLookup.h | 8 +- DMRNetwork.cpp | 6 +- DMRNetwork.h | 5 + DMRShortLC.cpp | 8 +- DMRShortLC.h | 9 +- DMRSlot.cpp | 95 +--------- DMRSlot.h | 10 +- DMRSlotType.cpp | 8 +- DMRSlotType.h | 9 +- DMRTA.cpp | 4 + DMRTA.h | 7 + DMRTrellis.cpp | 7 +- DMRTrellis.h | 9 +- Golay2087.cpp | 7 +- Golay2087.h | 9 +- IIRDirectForm1Filter.cpp | 9 +- IIRDirectForm1Filter.h | 10 +- MMDVMHost.cpp | 2 + Makefile | 2 +- Modem.cpp | 4 + NXDNAudio.cpp | 7 +- NXDNAudio.h | 9 +- NXDNCRC.cpp | 7 +- NXDNCRC.h | 9 +- NXDNControl.cpp | 76 +------- NXDNControl.h | 10 +- NXDNConvolution.cpp | 7 +- NXDNConvolution.h | 8 +- NXDNFACCH1.cpp | 8 +- NXDNFACCH1.h | 9 +- NXDNIcomNetwork.cpp | 8 +- NXDNIcomNetwork.h | 8 +- NXDNKenwoodNetwork.cpp | 7 +- NXDNKenwoodNetwork.h | 8 +- NXDNLICH.cpp | 7 +- NXDNLICH.h | 9 +- NXDNLayer3.cpp | 7 +- NXDNLayer3.h | 9 +- NXDNLookup.cpp | 7 +- NXDNLookup.h | 8 +- NXDNNetwork.cpp | 7 +- NXDNNetwork.h | 8 +- NXDNSACCH.cpp | 8 +- NXDNSACCH.h | 9 +- NXDNUDCH.cpp | 8 +- NXDNUDCH.h | 9 +- P25Audio.cpp | 7 +- P25Audio.h | 8 +- P25Control.cpp | 76 +------- P25Control.h | 10 +- P25Data.cpp | 7 +- P25Data.h | 8 +- P25LowSpeedData.cpp | 7 +- P25LowSpeedData.h | 9 +- P25NID.cpp | 7 +- P25NID.h | 9 +- P25Network.cpp | 8 +- P25Network.h | 8 +- P25Trellis.cpp | 7 +- P25Trellis.h | 9 +- P25Utils.cpp | 7 +- P25Utils.h | 9 +- PseudoTTYController.cpp | 10 +- PseudoTTYController.h | 9 +- QR1676.cpp | 7 +- QR1676.h | 9 +- RS129.cpp | 6 +- RS129.h | 9 +- RS241213.cpp | 7 +- RS241213.h | 9 +- SHA256.cpp | 373 --------------------------------------- SHA256.h | 73 -------- UserDB.cpp | 6 + UserDB.h | 7 + UserDBentry.cpp | 7 + UserDBentry.h | 8 + YSFControl.cpp | 102 +---------- YSFControl.h | 10 +- YSFConvolution.cpp | 7 +- YSFConvolution.h | 8 +- YSFFICH.cpp | 7 +- YSFFICH.h | 9 +- YSFNetwork.cpp | 8 +- YSFNetwork.h | 8 +- YSFPayload.cpp | 7 +- YSFPayload.h | 8 +- 115 files changed, 735 insertions(+), 903 deletions(-) delete mode 100644 SHA256.cpp delete mode 100644 SHA256.h diff --git a/AMBEFEC.cpp b/AMBEFEC.cpp index 96ac73f..2b1e433 100644 --- a/AMBEFEC.cpp +++ b/AMBEFEC.cpp @@ -615,7 +615,7 @@ unsigned int CAMBEFEC::regenerateDStar(unsigned char* bytes) const } #endif -#if defined(USE_YSF) +#if defined(USE_YSF) || defined(USE_NXDN) unsigned int CAMBEFEC::regenerateYSFDN(unsigned char* bytes) const { assert(bytes != NULL); diff --git a/AMBEFEC.h b/AMBEFEC.h index a013076..960e5ac 100644 --- a/AMBEFEC.h +++ b/AMBEFEC.h @@ -34,7 +34,7 @@ public: unsigned int regenerateDStar(unsigned char* bytes) const; #endif -#if defined(USE_YSF) +#if defined(USE_YSF) || defined(USE_NXDN) unsigned int regenerateYSFDN(unsigned char* bytes) const; #endif diff --git a/BCH.cpp b/BCH.cpp index fa02351..f8d2360 100644 --- a/BCH.cpp +++ b/BCH.cpp @@ -71,6 +71,8 @@ #include "BCH.h" +#if defined(USE_P25) + #include #include #include @@ -137,3 +139,6 @@ void CBCH::encode(unsigned char* nid) WRITE_BIT(nid, i + 16U, b); } } + +#endif + diff --git a/BCH.h b/BCH.h index fa1265d..1791f1f 100644 --- a/BCH.h +++ b/BCH.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(BCH_H) #define BCH_H +#include "Defines.h" + +#if defined(USE_P25) + class CBCH { public: CBCH(); @@ -31,3 +35,6 @@ private: }; #endif + +#endif + diff --git a/BPTC19696.cpp b/BPTC19696.cpp index 289005a..aa18fe9 100644 --- a/BPTC19696.cpp +++ b/BPTC19696.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2012 by Ian Wraith - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2012 by Ian Wraith + * Copyright (C) 2015,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ #include "BPTC19696.h" +#if defined(USE_DMR) + #include "Hamming.h" #include "Utils.h" @@ -345,3 +347,6 @@ void CBPTC19696::encodeExtractBinary(unsigned char* data) CUtils::bitsToByteBE(m_rawData + 180U, data[31U]); CUtils::bitsToByteBE(m_rawData + 188U, data[32U]); } + +#endif + diff --git a/BPTC19696.h b/BPTC19696.h index 0a40a78..cc86b5b 100644 --- a/BPTC19696.h +++ b/BPTC19696.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(BPTC19696_H) #define BPTC19696_H +#include "Defines.h" + +#if defined(USE_DMR) + class CBPTC19696 { public: @@ -45,3 +49,6 @@ private: }; #endif + +#endif + diff --git a/CRC.cpp b/CRC.cpp index fbb5db0..37a7b95 100644 --- a/CRC.cpp +++ b/CRC.cpp @@ -26,6 +26,7 @@ #include #include +#if defined(USE_DMR) const uint8_t CRC8_TABLE[] = { 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, @@ -48,7 +49,8 @@ const uint8_t CRC8_TABLE[] = { 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83, 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, - 0xFA, 0xFD, 0xF4, 0xF3, 0x01 }; + 0xFA, 0xFD, 0xF4, 0xF3, 0x01}; +#endif #if defined(USE_DSTAR) const uint16_t CCITT16_TABLE1[] = { @@ -83,9 +85,10 @@ const uint16_t CCITT16_TABLE1[] = { 0xe70eU, 0xf687U, 0xc41cU, 0xd595U, 0xa12aU, 0xb0a3U, 0x8238U, 0x93b1U, 0x6b46U, 0x7acfU, 0x4854U, 0x59ddU, 0x2d62U, 0x3cebU, 0x0e70U, 0x1ff9U, 0xf78fU, 0xe606U, 0xd49dU, 0xc514U, 0xb1abU, 0xa022U, 0x92b9U, 0x8330U, - 0x7bc7U, 0x6a4eU, 0x58d5U, 0x495cU, 0x3de3U, 0x2c6aU, 0x1ef1U, 0x0f78U }; + 0x7bc7U, 0x6a4eU, 0x58d5U, 0x495cU, 0x3de3U, 0x2c6aU, 0x1ef1U, 0x0f78U}; #endif +#if defined(USE_DMR) || defined(USE_YSF) || defined(USE_P25) const uint16_t CCITT16_TABLE2[] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, @@ -118,9 +121,10 @@ const uint16_t CCITT16_TABLE2[] = { 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, - 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 }; - + 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0}; +#endif +#if defined(USE_DMR) bool CCRC::checkFiveBit(bool* in, unsigned int tcrc) { assert(in != NULL); @@ -146,7 +150,9 @@ void CCRC::encodeFiveBit(const bool* in, unsigned int& tcrc) tcrc = total; } +#endif +#if defined(USE_DMR) || defined(USE_YSF) || defined(USE_P25) void CCRC::addCCITT162(unsigned char *in, unsigned int length) { assert(in != NULL); @@ -187,6 +193,7 @@ bool CCRC::checkCCITT162(const unsigned char *in, unsigned int length) return crc8[0U] == in[length - 1U] && crc8[1U] == in[length - 2U]; } +#endif #if defined(USE_DSTAR) void CCRC::addCCITT161(unsigned char *in, unsigned int length) @@ -231,6 +238,7 @@ bool CCRC::checkCCITT161(const unsigned char *in, unsigned int length) } #endif +#if defined(USE_DMR) unsigned char CCRC::crc8(const unsigned char *in, unsigned int length) { assert(in != NULL); @@ -242,3 +250,6 @@ unsigned char CCRC::crc8(const unsigned char *in, unsigned int length) return crc; } + +#endif + diff --git a/CRC.h b/CRC.h index 140dfc3..ac6b419 100644 --- a/CRC.h +++ b/CRC.h @@ -24,20 +24,30 @@ class CCRC { public: +#if defined(USE_DMR) static bool checkFiveBit(bool* in, unsigned int tcrc); static void encodeFiveBit(const bool* in, unsigned int& tcrc); +#endif #if defined(USE_DSTAR) static void addCCITT161(unsigned char* in, unsigned int length); #endif + +#if defined(USE_DMR) || defined(USE_YSF) || defined(USE_P25) static void addCCITT162(unsigned char* in, unsigned int length); +#endif #if defined(USE_DSTAR) static bool checkCCITT161(const unsigned char* in, unsigned int length); #endif - static bool checkCCITT162(const unsigned char* in, unsigned int length); +#if defined(USE_DMR) || defined(USE_YSF) || defined(USE_P25) + static bool checkCCITT162(const unsigned char* in, unsigned int length); +#endif + +#if defined(USE_DMR) static unsigned char crc8(const unsigned char* in, unsigned int length); +#endif }; #endif diff --git a/Conf.cpp b/Conf.cpp index 53e9785..6ed95bc 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -192,7 +192,9 @@ m_dmrEnabled(false), m_dmrBeacons(DMR_BEACONS_OFF), m_dmrBeaconInterval(60U), m_dmrBeaconDuration(3U), +#endif m_dmrId(0U), +#if defined(USE_DMR) m_dmrColorCode(2U), m_dmrSelfOnly(false), m_dmrEmbeddedLCOnly(false), @@ -219,7 +221,9 @@ m_fusionTXHang(4U), m_fusionModeHang(10U), #if defined(USE_P25) m_p25Enabled(false), +#endif m_p25Id(0U), +#if defined(USE_P25) m_p25NAC(0x293U), m_p25SelfOnly(false), m_p25OverrideUID(false), diff --git a/Conf.h b/Conf.h index 23ddccb..6488cf9 100644 --- a/Conf.h +++ b/Conf.h @@ -488,7 +488,9 @@ private: DMR_BEACONS m_dmrBeacons; unsigned int m_dmrBeaconInterval; unsigned int m_dmrBeaconDuration; +#endif unsigned int m_dmrId; +#if defined(USE_DMR) unsigned int m_dmrColorCode; bool m_dmrSelfOnly; bool m_dmrEmbeddedLCOnly; @@ -517,7 +519,9 @@ private: #if defined(USE_P25) bool m_p25Enabled; +#endif unsigned int m_p25Id; +#if defined(USE_P25) unsigned int m_p25NAC; bool m_p25SelfOnly; bool m_p25OverrideUID; diff --git a/DMRAccessControl.cpp b/DMRAccessControl.cpp index 75ec36c..29a2935 100644 --- a/DMRAccessControl.cpp +++ b/DMRAccessControl.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 by Simon Rune G7RZU - * Copyright (C) 2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ #include "DMRAccessControl.h" #include "Log.h" +#if defined(USE_DMR) + #include #include #include @@ -97,3 +99,6 @@ bool CDMRAccessControl::validateTGId(unsigned int slotNo, bool group, unsigned i return std::find(m_slot2TGWhiteList.begin(), m_slot2TGWhiteList.end(), id) != m_slot2TGWhiteList.end(); } } + +#endif + diff --git a/DMRAccessControl.h b/DMRAccessControl.h index 7d4aec1..480560b 100644 --- a/DMRAccessControl.h +++ b/DMRAccessControl.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 by Simon Rune G7RZU - * Copyright (C) 2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,10 @@ #if !defined(DMRAccessControl_H) #define DMRAccessControl_H +#include "Defines.h" + +#if defined(USE_DMR) + #include class CDMRAccessControl { @@ -42,3 +46,6 @@ private: }; #endif + +#endif + diff --git a/DMRCSBK.cpp b/DMRCSBK.cpp index ad02b0b..16c0420 100644 --- a/DMRCSBK.cpp +++ b/DMRCSBK.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2020,2021,2022 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2020,2021,2022,2023 by Jonathan Naylor G4KLX * Copyright (C) 2019 by Patrick Maier DK5MP * * This program is free software; you can redistribute it and/or modify @@ -22,6 +22,8 @@ #include "Utils.h" #include "CRC.h" +#if defined(USE_DMR) + #include #include @@ -246,3 +248,6 @@ void CDMRCSBK::setCBF(unsigned char cbf) { m_CBF = m_data[3U] = cbf; } + +#endif + diff --git a/DMRCSBK.h b/DMRCSBK.h index 52f16d2..be9e6ef 100644 --- a/DMRCSBK.h +++ b/DMRCSBK.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2020,2021,2022 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2020,2021,2022,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,9 @@ #define DMRCSBK_H #include "DMRDefines.h" +#include "Defines.h" + +#if defined(USE_DMR) enum CSBKO { CSBKO_NONE = 0x00, @@ -81,3 +84,6 @@ private: }; #endif + +#endif + diff --git a/DMRControl.cpp b/DMRControl.cpp index f828d9f..2431131 100644 --- a/DMRControl.cpp +++ b/DMRControl.cpp @@ -13,10 +13,11 @@ #include "DMRControl.h" #include "DMRAccessControl.h" -#include "Defines.h" #include "DMRCSBK.h" #include "Log.h" +#if defined(USE_DMR) + #include #include #include @@ -135,3 +136,6 @@ void CDMRControl::enable(bool enabled) m_slot1.enable(enabled); m_slot2.enable(enabled); } + +#endif + diff --git a/DMRControl.h b/DMRControl.h index c3c3b90..8a8b274 100644 --- a/DMRControl.h +++ b/DMRControl.h @@ -26,6 +26,10 @@ #include "DMRData.h" #include "Modem.h" +#include "Defines.h" + +#if defined(USE_DMR) + #include class CDMRControl { @@ -57,3 +61,6 @@ private: }; #endif + +#endif + diff --git a/DMRData.cpp b/DMRData.cpp index 25dea58..a3566fa 100644 --- a/DMRData.cpp +++ b/DMRData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2015,2016,2017,2023 Jonathan Naylor, G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,11 +16,12 @@ #include "Utils.h" #include "Log.h" +#if defined(USE_DMR) + #include #include #include - CDMRData::CDMRData(const CDMRData& data) : m_slotNo(data.m_slotNo), m_data(NULL), @@ -183,3 +184,6 @@ void CDMRData::setData(const unsigned char* buffer) ::memcpy(m_data, buffer, DMR_FRAME_LENGTH_BYTES); } + +#endif + diff --git a/DMRData.h b/DMRData.h index c5dc4fc..15f7c25 100644 --- a/DMRData.h +++ b/DMRData.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor, G4KLX + * Copyright (C) 2015,2016,2017,2023 by Jonathan Naylor, G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,6 +15,9 @@ #define DMRData_H #include "DMRDefines.h" +#include "Defines.h" + +#if defined(USE_DMR) class CDMRData { public: @@ -68,3 +71,6 @@ private: }; #endif + +#endif + diff --git a/DMRDataHeader.cpp b/DMRDataHeader.cpp index 4a819f6..4cb251d 100644 --- a/DMRDataHeader.cpp +++ b/DMRDataHeader.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2012 by Ian Wraith - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,8 @@ #include "CRC.h" #include "Log.h" +#if defined(USE_DMR) + #include #include #include @@ -173,3 +175,6 @@ CDMRDataHeader& CDMRDataHeader::operator=(const CDMRDataHeader& header) return *this; } + +#endif + diff --git a/DMRDataHeader.h b/DMRDataHeader.h index 97c6036..ae273b5 100644 --- a/DMRDataHeader.h +++ b/DMRDataHeader.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #ifndef DMRDataHeader_H #define DMRDataHeader_H +#include "Defines.h" + +#if defined(USE_DMR) + class CDMRDataHeader { public: @@ -52,3 +56,5 @@ private: #endif +#endif + diff --git a/DMREMB.cpp b/DMREMB.cpp index 7b62cba..f3876c4 100644 --- a/DMREMB.cpp +++ b/DMREMB.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +17,10 @@ */ #include "DMREMB.h" - #include "QR1676.h" +#if defined(USE_DMR) + #include #include @@ -98,3 +99,6 @@ void CDMREMB::setLCSS(unsigned char lcss) { m_LCSS = lcss; } + +#endif + diff --git a/DMREMB.h b/DMREMB.h index 517be1e..5ba2f88 100644 --- a/DMREMB.h +++ b/DMREMB.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(DMREMB_H) #define DMREMB_H +#include "Defines.h" + +#if defined(USE_DMR) + class CDMREMB { public: @@ -44,3 +48,6 @@ private: }; #endif + +#endif + diff --git a/DMREmbeddedData.cpp b/DMREmbeddedData.cpp index a5a3e42..bddba92 100644 --- a/DMREmbeddedData.cpp +++ b/DMREmbeddedData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,11 +17,12 @@ */ #include "DMREmbeddedData.h" - #include "Hamming.h" #include "Utils.h" #include "CRC.h" +#if defined(USE_DMR) + #include #include #include @@ -320,3 +321,6 @@ bool CDMREmbeddedData::getRawData(unsigned char* data) const return true; } + +#endif + diff --git a/DMREmbeddedData.h b/DMREmbeddedData.h index 7222dcd..2cdbbdd 100644 --- a/DMREmbeddedData.h +++ b/DMREmbeddedData.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,8 +20,11 @@ #define DMREmbeddedData_H #include "DMRDefines.h" +#include "Defines.h" #include "DMRLC.h" +#if defined(USE_DMR) + enum LC_STATE { LCS_NONE, LCS_FIRST, @@ -61,3 +64,6 @@ private: }; #endif + +#endif + diff --git a/DMRFullLC.cpp b/DMRFullLC.cpp index dbcd6cc..b5684b2 100644 --- a/DMRFullLC.cpp +++ b/DMRFullLC.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2012 by Ian Wraith - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2012 by Ian Wraith + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,12 +18,13 @@ */ #include "DMRFullLC.h" - #include "DMRDefines.h" #include "RS129.h" #include "Utils.h" #include "Log.h" +#if defined(USE_DMR) + #include #include @@ -97,3 +98,6 @@ void CDMRFullLC::encode(const CDMRLC& lc, unsigned char* data, unsigned char typ m_bptc.encode(lcData, data); } + +#endif + diff --git a/DMRFullLC.h b/DMRFullLC.h index d3294ef..006b56c 100644 --- a/DMRFullLC.h +++ b/DMRFullLC.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,8 +21,10 @@ #include "DMRLC.h" #include "DMRSlotType.h" - #include "BPTC19696.h" +#include "Defines.h" + +#if defined(USE_DMR) class CDMRFullLC { @@ -40,3 +42,5 @@ private: #endif +#endif + diff --git a/DMRLC.cpp b/DMRLC.cpp index 6433647..131d0b9 100644 --- a/DMRLC.cpp +++ b/DMRLC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2019,2021,2022 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2019,2021,2022,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +17,10 @@ */ #include "DMRLC.h" - #include "Utils.h" +#if defined(USE_DMR) + #include #include @@ -216,3 +217,6 @@ void CDMRLC::setDstId(unsigned int id) { m_dstId = id; } + +#endif + diff --git a/DMRLC.h b/DMRLC.h index 22e133e..760b179 100644 --- a/DMRLC.h +++ b/DMRLC.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2019,2021,2022 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2019,2021,2022,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,9 @@ #define DMRLC_H #include "DMRDefines.h" +#include "Defines.h" + +#if defined(USE_DMR) class CDMRLC { @@ -63,3 +66,5 @@ private: #endif +#endif + diff --git a/DMRLookup.cpp b/DMRLookup.cpp index 413a950..35c06e2 100644 --- a/DMRLookup.cpp +++ b/DMRLookup.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,8 @@ #include "Timer.h" #include "Log.h" +#if defined(USE_DMR) || defined(USE_P25) + #include #include #include @@ -134,3 +136,6 @@ bool CDMRLookup::exists(unsigned int id) { return m_table.lookup(id, NULL); } + +#endif + diff --git a/DMRLookup.h b/DMRLookup.h index 2a9de72..41301bc 100644 --- a/DMRLookup.h +++ b/DMRLookup.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017,2021 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,9 @@ #include "Thread.h" #include "UserDB.h" +#include "Defines.h" + +#if defined(USE_DMR) || defined(USE_P25) #include @@ -51,3 +54,6 @@ private: }; #endif + +#endif + diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 8846147..80b814a 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -17,10 +17,11 @@ */ #include "DMRNetwork.h" - #include "Utils.h" #include "Log.h" +#if defined(USE_DMR) + #include #include #include @@ -444,3 +445,6 @@ bool CDMRNetwork::write(const unsigned char* data, unsigned int length) return true; } + +#endif + diff --git a/DMRNetwork.h b/DMRNetwork.h index dfca5da..2d90953 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -25,6 +25,8 @@ #include "DMRData.h" #include "Defines.h" +#if defined(USE_DMR) + #include #include #include @@ -89,3 +91,6 @@ private: }; #endif + +#endif + diff --git a/DMRShortLC.cpp b/DMRShortLC.cpp index 9341db7..90ac2b9 100644 --- a/DMRShortLC.cpp +++ b/DMRShortLC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,10 +17,11 @@ */ #include "DMRShortLC.h" - #include "Hamming.h" #include "Utils.h" +#if defined(USE_DMR) + #include #include #include @@ -226,3 +227,6 @@ void CDMRShortLC::encodeExtractBinary(unsigned char* data) CUtils::bitsToByteBE(m_rawData + 56U, data[7U]); CUtils::bitsToByteBE(m_rawData + 64U, data[8U]); } + +#endif + diff --git a/DMRShortLC.h b/DMRShortLC.h index af21589..5dc38da 100644 --- a/DMRShortLC.h +++ b/DMRShortLC.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(DMRSHORTLC_H) #define DMRSHORTLC_H +#include "Defines.h" + +#if defined(USE_DMR) + class CDMRShortLC { public: @@ -45,3 +49,6 @@ private: }; #endif + +#endif + diff --git a/DMRSlot.cpp b/DMRSlot.cpp index e8462f1..714df51 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -26,6 +26,8 @@ #include "CRC.h" #include "Log.h" +#if defined(USE_DMR) + #include #include #include @@ -71,8 +73,6 @@ const unsigned int NO_PREAMBLE_CSBK = 15U; const unsigned int RSSI_COUNT = 4U; // 4 * 360ms = 1440ms const unsigned int BER_COUNT = 24U * 141U; // 24 * 60ms = 1440ms -// #define DUMP_DMR - CDMRSlot::CDMRSlot(unsigned int slotNo, unsigned int timeout) : m_slotNo(slotNo), m_queue(5000U, "DMR Slot"), @@ -123,8 +123,7 @@ m_rssiAccum(0U), m_rssiCount(0U), m_bitErrsAccum(0U), m_bitsCount(0U), -m_enabled(true), -m_fp(NULL) +m_enabled(true) { m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U]; @@ -1097,10 +1096,6 @@ void CDMRSlot::writeEndNet(bool writeEnd) delete m_netLC; m_netLC = NULL; - -#if defined(DUMP_DMR) - closeFile(); -#endif } void CDMRSlot::writeNetwork(const CDMRData& dmrData) @@ -1203,11 +1198,6 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) class CUserDBentry cn; m_lookup->findWithName(srcId, &cn); -#if defined(DUMP_DMR) - openFile(); - writeFile(data); -#endif - LogMessage("DMR Slot %u, received network voice header from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str()); writeJSONNet("start", srcId, src, flco == FLCO_GROUP, dstId); } else if (dataType == DT_VOICE_PI_HEADER) { @@ -1261,9 +1251,6 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) writeQueueRF(start); } -#if defined(DUMP_DMR) - openFile(); -#endif m_netFrames = 0U; m_netLost = 0U; m_netBits = 1U; @@ -1300,10 +1287,6 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) data[1U] = 0x00U; writeQueueNet(data); - -#if defined(DUMP_DMR) - writeFile(data); -#endif } else if (dataType == DT_TERMINATOR_WITH_LC) { if (m_netState != RS_NET_AUDIO) return; @@ -1334,10 +1317,6 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) } } -#if defined(DUMP_DMR) - writeFile(data); - closeFile(); -#endif unsigned int srcId = m_netLC->getSrcId(); unsigned int dstId = m_netLC->getDstId(); std::string src = m_lookup->find(srcId); @@ -1458,9 +1437,6 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) writeQueueRF(start); } -#if defined(DUMP_DMR) - openFile(); -#endif m_netFrames = 0U; m_netLost = 0U; m_netBits = 1U; @@ -1520,10 +1496,6 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // Save details in case we need to infill data m_netN = dmrData.getN(); - -#if defined(DUMP_DMR) - writeFile(data); -#endif } } else if (dataType == DT_VOICE) { if (m_netState != RS_NET_AUDIO) @@ -1675,10 +1647,6 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // Save details in case we need to infill data m_netN = dmrData.getN(); - -#if defined(DUMP_DMR) - writeFile(data); -#endif } else if (dataType == DT_CSBK) { CDMRCSBK csbk; bool valid = csbk.put(data + 2U); @@ -1739,12 +1707,6 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) } else writeQueueNet(data); -#if defined(DUMP_DMR) - openFile(); - writeFile(data); - closeFile(); -#endif - std::string src = m_lookup->find(srcId); std::string dst = m_lookup->find(dstId); @@ -1823,9 +1785,6 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) data[0U] = m_netFrames == 0U ? TAG_EOT : TAG_DATA; data[1U] = 0x00U; -#if defined(DUMP_DMR) - writeFile(data); -#endif writeQueueNet(data); if (m_netFrames == 0U) { @@ -1919,16 +1878,10 @@ void CDMRSlot::clock() LogMessage("DMR Slot %u, network watchdog has expired, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); writeJSONNet("lost", float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); writeEndNet(true); -#if defined(DUMP_DMR) - closeFile(); -#endif } else { LogMessage("DMR Slot %u, network watchdog has expired", m_slotNo); writeJSONNet("lost"); writeEndNet(); -#if defined(DUMP_DMR) - closeFile(); -#endif } } } @@ -2147,46 +2100,6 @@ void CDMRSlot::setShortLC(unsigned int slotNo, unsigned int id, FLCO flco, ACTIV m_modem->writeDMRShortLC(sLC); } -bool CDMRSlot::openFile() -{ - if (m_fp != NULL) - return true; - - time_t t; - ::time(&t); - - struct tm* tm = ::localtime(&t); - - char name[100U]; - ::sprintf(name, "DMR_%u_%04d%02d%02d_%02d%02d%02d.ambe", m_slotNo, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); - - m_fp = ::fopen(name, "wb"); - if (m_fp == NULL) - return false; - - ::fwrite("DMR", 1U, 3U, m_fp); - - return true; -} - -bool CDMRSlot::writeFile(const unsigned char* data) -{ - if (m_fp == NULL) - return false; - - ::fwrite(data, 1U, DMR_FRAME_LENGTH_BYTES + 2U, m_fp); - - return true; -} - -void CDMRSlot::closeFile() -{ - if (m_fp != NULL) { - ::fclose(m_fp); - m_fp = NULL; - } -} - bool CDMRSlot::insertSilence(const unsigned char* data, unsigned char seqNo) { assert(data != NULL); @@ -2547,3 +2460,5 @@ void CDMRSlot::writeJSON(nlohmann::json& json, const char* source, const char* a json["source_info"] = srcInfo; } +#endif + diff --git a/DMRSlot.h b/DMRSlot.h index 592dad9..a2f426b 100644 --- a/DMRSlot.h +++ b/DMRSlot.h @@ -34,6 +34,8 @@ #include "Modem.h" #include "DMRLC.h" +#if defined(USE_DMR) + #include #include @@ -116,7 +118,6 @@ private: unsigned int m_bitErrsAccum; unsigned int m_bitsCount; bool m_enabled; - FILE* m_fp; static unsigned int m_colorCode; @@ -154,10 +155,6 @@ private: void writeEndRF(bool writeEnd = false); void writeEndNet(bool writeEnd = false); - bool openFile(); - bool writeFile(const unsigned char* data); - void closeFile(); - bool insertSilence(const unsigned char* data, unsigned char seqNo); void insertSilence(unsigned int count); @@ -185,3 +182,6 @@ private: }; #endif + +#endif + diff --git a/DMRSlotType.cpp b/DMRSlotType.cpp index d855303..24fdaaf 100644 --- a/DMRSlotType.cpp +++ b/DMRSlotType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +17,10 @@ */ #include "DMRSlotType.h" - #include "Golay2087.h" +#if defined(USE_DMR) + #include #include @@ -90,3 +91,6 @@ void CDMRSlotType::setDataType(unsigned char type) { m_dataType = type; } + +#endif + diff --git a/DMRSlotType.h b/DMRSlotType.h index e76821f..bce1173 100644 --- a/DMRSlotType.h +++ b/DMRSlotType.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(DMRSLOTTYPE_H) #define DMRSLOTTYPE_H +#include "Defines.h" + +#if defined(USE_DMR) + class CDMRSlotType { public: @@ -40,3 +44,6 @@ private: }; #endif + +#endif + diff --git a/DMRTA.cpp b/DMRTA.cpp index 055116e..3854d45 100644 --- a/DMRTA.cpp +++ b/DMRTA.cpp @@ -15,6 +15,8 @@ #include "DMRTA.h" #include "Log.h" +#if defined(USE_DMR) + #include #include @@ -134,3 +136,5 @@ bool CDMRTA::decodeTA() return taLen >= taSize; } +#endif + diff --git a/DMRTA.h b/DMRTA.h index ccf48d9..175388e 100644 --- a/DMRTA.h +++ b/DMRTA.h @@ -15,6 +15,10 @@ #ifndef DMRTA_H #define DMRTA_H +#include "Defines.h" + +#if defined(USE_DMR) + class CDMRTA { public: CDMRTA(unsigned int slotNo); @@ -36,3 +40,6 @@ private: }; #endif + +#endif + diff --git a/DMRTrellis.cpp b/DMRTrellis.cpp index f0a73cb..956e396 100644 --- a/DMRTrellis.cpp +++ b/DMRTrellis.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor, G4KLX +* Copyright (C) 2016,2023 by Jonathan Naylor, G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,6 +15,8 @@ #include "DMRDefines.h" #include "Log.h" +#if defined(USE_DMR) + #include #include @@ -372,3 +374,6 @@ unsigned int CDMRTrellis::checkCode(const unsigned char* points, unsigned char* return 999U; } + +#endif + diff --git a/DMRTrellis.h b/DMRTrellis.h index 55ed0c0..7d4acfc 100644 --- a/DMRTrellis.h +++ b/DMRTrellis.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor, G4KLX +* Copyright (C) 2016,2023 by Jonathan Naylor, G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,6 +14,10 @@ #ifndef DMRTrellis_H #define DMRTrellis_H +#include "Defines.h" + +#if defined(USE_DMR) + class CDMRTrellis { public: CDMRTrellis(); @@ -34,3 +38,6 @@ private: }; #endif + +#endif + diff --git a/Golay2087.cpp b/Golay2087.cpp index 61942d8..4be5771 100644 --- a/Golay2087.cpp +++ b/Golay2087.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ #include "Golay2087.h" +#if defined(USE_DMR) + #include #include @@ -260,3 +262,6 @@ void CGolay2087::encode(unsigned char* data) data[1U] = cksum & 0xFFU; data[2U] = cksum >> 8; } + +#endif + diff --git a/Golay2087.h b/Golay2087.h index d54daed..c8ce210 100644 --- a/Golay2087.h +++ b/Golay2087.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #ifndef Golay2087_H #define Golay2087_H +#include "Defines.h" + +#if defined(USE_DMR) + class CGolay2087 { public: static void encode(unsigned char* data); @@ -30,3 +34,6 @@ private: }; #endif + +#endif + diff --git a/IIRDirectForm1Filter.cpp b/IIRDirectForm1Filter.cpp index 946acdd..871b6ce 100644 --- a/IIRDirectForm1Filter.cpp +++ b/IIRDirectForm1Filter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2020,2023 by Jonathan Naylor G4KLX * Copyright (C) 2020 by Geoffrey Merck - F4FXL KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -18,7 +18,9 @@ */ #include "IIRDirectForm1Filter.h" -#include "math.h" +#include + +#if defined(USE_FM) CIIRDirectForm1Filter::CIIRDirectForm1Filter(float b0, float b1, float b2, float , float a1, float a2, float addtionalGaindB) : m_x2(0.0F), @@ -58,3 +60,6 @@ void CIIRDirectForm1Filter::reset() m_y1 = 0.0f; m_y2 = 0.0f; } + +#endif + diff --git a/IIRDirectForm1Filter.h b/IIRDirectForm1Filter.h index f575f7f..79ec76a 100644 --- a/IIRDirectForm1Filter.h +++ b/IIRDirectForm1Filter.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2020,2023 by Jonathan Naylor G4KLX * Copyright (C) 2020 by Geoffrey Merck - F4FXL KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -20,6 +20,10 @@ #if !defined(IIRDIRECTFORM1FILTER_H) #define IIRDIRECTFORM1FILTER_H +#include "Defines.h" + +#if defined(USE_FM) + class CIIRDirectForm1Filter { public: @@ -46,5 +50,7 @@ private: float m_additionalGainLin; }; +#endif + +#endif -#endif \ No newline at end of file diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index be688bb..d04765b 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1650,6 +1650,8 @@ bool CMMDVMHost::createModem() unsigned int txDelay = m_conf.getModemTXDelay(); #if defined(USE_DMR) unsigned int dmrDelay = m_conf.getModemDMRDelay(); +#else + unsigned int dmrDelay = 0U; #endif float rxLevel = m_conf.getModemRXLevel(); float cwIdTXLevel = m_conf.getModemCWIdTXLevel(); diff --git a/Makefile b/Makefile index f54ca77..5be4659 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ OBJECTS = \ MQTTConnection.o Modem.o ModemPort.o Mutex.o NullController.o NXDNAudio.o NXDNControl.o \ NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o \ NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o \ - POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o Thread.o \ + POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o Thread.o \ Timer.o UARTController.o UDPController.o UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o all: MMDVMHost diff --git a/Modem.cpp b/Modem.cpp index 1f4ea9a..c57d354 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -2441,8 +2441,10 @@ bool CModem::setConfig1() buffer[3U] |= 0x02U; if (m_pttInvert) buffer[3U] |= 0x04U; +#if defined(USE_YSF) if (m_ysfLoDev) buffer[3U] |= 0x08U; +#endif if (m_debug) buffer[3U] |= 0x10U; if (m_useCOSAsLockout) @@ -2612,8 +2614,10 @@ bool CModem::setConfig2() buffer[3U] |= 0x02U; if (m_pttInvert) buffer[3U] |= 0x04U; +#if defined(USE_YSF) if (m_ysfLoDev) buffer[3U] |= 0x08U; +#endif if (m_debug) buffer[3U] |= 0x10U; if (m_useCOSAsLockout) diff --git a/NXDNAudio.cpp b/NXDNAudio.cpp index a56316c..9a796cb 100644 --- a/NXDNAudio.cpp +++ b/NXDNAudio.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ #include "NXDNAudio.h" #include "Golay24128.h" +#if defined(USE_NXDN) + #include #include #include @@ -575,3 +577,6 @@ void CNXDNAudio::encode(const unsigned char* in, unsigned char* out, unsigned in WRITE_BIT(out, cPos, cOrig & MASK); } } + +#endif + diff --git a/NXDNAudio.h b/NXDNAudio.h index fd778c7..2f8df81 100644 --- a/NXDNAudio.h +++ b/NXDNAudio.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(NXDNAudio_H) #define NXDNAudio_H +#include "Defines.h" + +#if defined(USE_NXDN) + class CNXDNAudio { public: CNXDNAudio(); @@ -35,3 +39,6 @@ private: }; #endif + +#endif + diff --git a/NXDNCRC.cpp b/NXDNCRC.cpp index 60278ae..dff2e7f 100644 --- a/NXDNCRC.cpp +++ b/NXDNCRC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 by Jonathan Naylor G4KLX + * Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ #include "NXDNCRC.h" +#if defined(USE_NXDN) + #include #include @@ -183,3 +185,6 @@ uint16_t CNXDNCRC::createCRC15(const unsigned char* in, unsigned int length) return crc & 0x7FFFU; } + +#endif + diff --git a/NXDNCRC.h b/NXDNCRC.h index 12e2e40..c42fd48 100644 --- a/NXDNCRC.h +++ b/NXDNCRC.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 by Jonathan Naylor G4KLX + * Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(NXDNCRC_H) #define NXDNCRC_H +#include "Defines.h" + +#if defined(USE_NXDN) + #include class CNXDNCRC @@ -40,3 +44,6 @@ private: }; #endif + +#endif + diff --git a/NXDNControl.cpp b/NXDNControl.cpp index fc66659..cf2b9b5 100644 --- a/NXDNControl.cpp +++ b/NXDNControl.cpp @@ -21,6 +21,8 @@ #include "Sync.h" #include "Log.h" +#if defined(USE_NXDN) + #include #include #include @@ -32,8 +34,6 @@ const unsigned char SCRAMBLER[] = { 0x28U, 0x28U, 0x00U, 0x0AU, 0x02U, 0x82U, 0x20U, 0x28U, 0x82U, 0x2AU, 0xAAU, 0x20U, 0x22U, 0x80U, 0xA8U, 0x8AU, 0x08U, 0xA0U, 0xAAU, 0x02U }; -// #define DUMP_NXDN - const unsigned int RSSI_COUNT = 28U; // 28 * 40ms = 1120ms const unsigned int BER_COUNT = 28U; // 28 * 40ms = 1120ms @@ -77,8 +77,7 @@ m_rssiAccum(0U), m_rssiCount(0U), m_bitsCount(0U), m_bitErrsAccum(0U), -m_enabled(true), -m_fp(NULL) +m_enabled(true) { assert(lookup != NULL); assert(rssiMapper != NULL); @@ -268,9 +267,6 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne writeNetwork(netData, data[0U] == TAG_EOT ? NNMT_VOICE_TRAILER : NNMT_VOICE_HEADER); -#if defined(DUMP_NXDN) - writeFile(data + 2U); -#endif if (m_duplex) writeQueueRF(data); @@ -309,9 +305,6 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne m_bitErrsAccum = 0U; m_bitsCount = 0U; -#if defined(DUMP_NXDN) - openFile(); -#endif unsigned short dstId = m_rfLayer3.getDestinationGroupId(); bool grp = m_rfLayer3.getIsGroup(); unsigned short srcId = m_rfLayer3.getSourceUnitId(); @@ -424,9 +417,6 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne m_bitErrsAccum = 0U; m_bitsCount = 0U; -#if defined(DUMP_NXDN) - openFile(); -#endif std::string source = m_lookup->find(srcId); LogMessage("NXDN, received RF late entry from %s to %s%u", source.c_str(), grp ? "TG " : "", dstId); writeJSONRF("late_entry", srcId, source, grp, dstId); @@ -475,9 +465,6 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne writeNetwork(netData, NNMT_VOICE_HEADER); -#if defined(DUMP_NXDN) - writeFile(start + 2U); -#endif if (m_duplex) writeQueueRF(start); } @@ -581,10 +568,6 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne writeNetwork(netData, NNMT_VOICE_BODY); -#if defined(DUMP_NXDN) - writeFile(data + 2U); -#endif - if (m_duplex) writeQueueRF(data); @@ -646,10 +629,6 @@ bool CNXDNControl::processData(unsigned char option, unsigned char *data) m_rfFrames = 0U; m_rfState = RS_RF_DATA; - -#if defined(DUMP_NXDN) - openFile(); -#endif } if (m_rfState != RS_RF_DATA) @@ -701,10 +680,6 @@ bool CNXDNControl::processData(unsigned char option, unsigned char *data) m_rfFrames++; -#if defined(DUMP_NXDN) - writeFile(data + 2U); -#endif - if (data[0U] == TAG_EOT) { unsigned short dstId = m_rfLayer3.getDestinationGroupId(); bool grp = m_rfLayer3.getIsGroup(); @@ -748,9 +723,6 @@ void CNXDNControl::writeEndRF() m_network->reset(); } -#if defined(DUMP_NXDN) - closeFile(); -#endif } void CNXDNControl::writeEndNet() @@ -1104,46 +1076,6 @@ void CNXDNControl::scrambler(unsigned char* data) const data[i] ^= SCRAMBLER[i]; } -bool CNXDNControl::openFile() -{ - if (m_fp != NULL) - return true; - - time_t t; - ::time(&t); - - struct tm* tm = ::localtime(&t); - - char name[100U]; - ::sprintf(name, "NXDN_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); - - m_fp = ::fopen(name, "wb"); - if (m_fp == NULL) - return false; - - ::fwrite("NXDN", 1U, 4U, m_fp); - - return true; -} - -bool CNXDNControl::writeFile(const unsigned char* data) -{ - if (m_fp == NULL) - return false; - - ::fwrite(data, 1U, NXDN_FRAME_LENGTH_BYTES, m_fp); - - return true; -} - -void CNXDNControl::closeFile() -{ - if (m_fp != NULL) { - ::fclose(m_fp); - m_fp = NULL; - } -} - bool CNXDNControl::isBusy() const { return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; @@ -1334,3 +1266,5 @@ void CNXDNControl::writeJSON(nlohmann::json& json, const char* source, const cha json["source_info"] = srcInfo; } +#endif + diff --git a/NXDNControl.h b/NXDNControl.h index a87a84c..68683ca 100644 --- a/NXDNControl.h +++ b/NXDNControl.h @@ -31,6 +31,8 @@ #include "Timer.h" #include "Modem.h" +#if defined(USE_NXDN) + #include #include @@ -86,7 +88,6 @@ private: unsigned int m_bitsCount; unsigned int m_bitErrsAccum; bool m_enabled; - FILE* m_fp; bool processVoice(unsigned char usc, unsigned char option, unsigned char *data); bool processData(unsigned char option, unsigned char *data); @@ -101,10 +102,6 @@ private: void writeEndRF(); void writeEndNet(); - bool openFile(); - bool writeFile(const unsigned char* data); - void closeFile(); - void writeJSONRSSI(); void writeJSONBER(unsigned int bits, unsigned int errs); @@ -122,3 +119,6 @@ private: }; #endif + +#endif + diff --git a/NXDNConvolution.cpp b/NXDNConvolution.cpp index 875752e..8bf33e2 100644 --- a/NXDNConvolution.cpp +++ b/NXDNConvolution.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016,2018,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2016,2018,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ #include "NXDNConvolution.h" +#if defined(USE_NXDN) + #include #include #include @@ -149,3 +151,6 @@ void CNXDNConvolution::encode(const unsigned char* in, unsigned char* out, unsig k++; } } + +#endif + diff --git a/NXDNConvolution.h b/NXDNConvolution.h index 805bc25..a9aa8f7 100644 --- a/NXDNConvolution.h +++ b/NXDNConvolution.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2018,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2018,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(NXDNConvolution_H) #define NXDNConvolution_H +#include "Defines.h" + +#if defined(USE_NXDN) + #include class CNXDNConvolution { @@ -44,3 +48,5 @@ private: #endif +#endif + diff --git a/NXDNFACCH1.cpp b/NXDNFACCH1.cpp index e8e04bc..53124ab 100644 --- a/NXDNFACCH1.cpp +++ b/NXDNFACCH1.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,11 +17,12 @@ */ #include "NXDNFACCH1.h" - #include "NXDNConvolution.h" #include "NXDNDefines.h" #include "NXDNCRC.h" +#if defined(USE_NXDN) + #include #include #include @@ -186,3 +187,6 @@ CNXDNFACCH1& CNXDNFACCH1::operator=(const CNXDNFACCH1& facch1) return *this; } + +#endif + diff --git a/NXDNFACCH1.h b/NXDNFACCH1.h index db56ec1..3d1b8fe 100644 --- a/NXDNFACCH1.h +++ b/NXDNFACCH1.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(NXDNFACCH1_H) #define NXDNFACCH1_H +#include "Defines.h" + +#if defined(USE_NXDN) + class CNXDNFACCH1 { public: CNXDNFACCH1(const CNXDNFACCH1& facch); @@ -42,3 +46,6 @@ private: }; #endif + +#endif + diff --git a/NXDNIcomNetwork.cpp b/NXDNIcomNetwork.cpp index adc4ec6..09f6341 100644 --- a/NXDNIcomNetwork.cpp +++ b/NXDNIcomNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2018-2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2018-2020,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,10 +18,11 @@ #include "NXDNIcomNetwork.h" #include "NXDNDefines.h" -#include "Defines.h" #include "Utils.h" #include "Log.h" +#if defined(USE_NXDN) + #include #include #include @@ -174,3 +175,6 @@ void CNXDNIcomNetwork::enable(bool enabled) m_enabled = enabled; } + +#endif + diff --git a/NXDNIcomNetwork.h b/NXDNIcomNetwork.h index f417574..2eb4ff6 100644 --- a/NXDNIcomNetwork.h +++ b/NXDNIcomNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2018,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2018,2020,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,9 @@ #include "RingBuffer.h" #include "UDPSocket.h" #include "Timer.h" +#include "Defines.h" + +#if defined(USE_NXDN) #include #include @@ -59,3 +62,6 @@ private: }; #endif + +#endif + diff --git a/NXDNKenwoodNetwork.cpp b/NXDNKenwoodNetwork.cpp index 1b7432b..223b96a 100644 --- a/NXDNKenwoodNetwork.cpp +++ b/NXDNKenwoodNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2018,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2018,2020,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,8 @@ #include "Utils.h" #include "Log.h" +#if defined(USE_NXDN) + #include #include #include @@ -1185,3 +1187,6 @@ void CNXDNKenwoodNetwork::enable(bool enabled) m_enabled = enabled; } + +#endif + diff --git a/NXDNKenwoodNetwork.h b/NXDNKenwoodNetwork.h index 216176e..83ae69f 100644 --- a/NXDNKenwoodNetwork.h +++ b/NXDNKenwoodNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2018,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2018,2020,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,9 @@ #include "NXDNNetwork.h" #include "UDPSocket.h" #include "Timer.h" +#include "Defines.h" + +#if defined(USE_NXDN) #include #include @@ -100,3 +103,6 @@ private: }; #endif + +#endif + diff --git a/NXDNLICH.cpp b/NXDNLICH.cpp index a456103..3f82927 100644 --- a/NXDNLICH.cpp +++ b/NXDNLICH.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 by Jonathan Naylor G4KLX + * Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ #include "NXDNDefines.h" #include "NXDNLICH.h" +#if defined(USE_NXDN) + #include #include #include @@ -160,3 +162,6 @@ bool CNXDNLICH::getParity() const return false; } } + +#endif + diff --git a/NXDNLICH.h b/NXDNLICH.h index c3fe821..c58c71f 100644 --- a/NXDNLICH.h +++ b/NXDNLICH.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 by Jonathan Naylor G4KLX + * Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(NXDNLICH_H) #define NXDNLICH_H +#include "Defines.h" + +#if defined(USE_NXDN) + class CNXDNLICH { public: CNXDNLICH(const CNXDNLICH& lich); @@ -50,3 +54,6 @@ private: }; #endif + +#endif + diff --git a/NXDNLayer3.cpp b/NXDNLayer3.cpp index e6e731a..de5c5b3 100644 --- a/NXDNLayer3.cpp +++ b/NXDNLayer3.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ #include "NXDNDefines.h" #include "NXDNLayer3.h" +#if defined(USE_NXDN) + #include #include #include @@ -115,3 +117,6 @@ CNXDNLayer3& CNXDNLayer3::operator=(const CNXDNLayer3& layer3) return *this; } + +#endif + diff --git a/NXDNLayer3.h b/NXDNLayer3.h index a152452..befd233 100644 --- a/NXDNLayer3.h +++ b/NXDNLayer3.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(NXDNLayer3_H) #define NXDNLayer3_H +#include "Defines.h" + +#if defined(USE_NXDN) + class CNXDNLayer3 { public: CNXDNLayer3(const CNXDNLayer3& layer3); @@ -47,3 +51,6 @@ private: }; #endif + +#endif + diff --git a/NXDNLookup.cpp b/NXDNLookup.cpp index fb1299b..b4aef1c 100644 --- a/NXDNLookup.cpp +++ b/NXDNLookup.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017,2018,2021 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,8 @@ #include "Timer.h" #include "Log.h" +#if defined(USE_NXDN) + #include #include #include @@ -134,3 +136,6 @@ bool CNXDNLookup::exists(unsigned int id) { return m_table.lookup(id, NULL); } + +#endif + diff --git a/NXDNLookup.h b/NXDNLookup.h index c49e114..d7b0011 100644 --- a/NXDNLookup.h +++ b/NXDNLookup.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,9 @@ #include "Thread.h" #include "UserDB.h" +#include "Defines.h" + +#if defined(USE_NXDN) #include @@ -51,3 +54,6 @@ private: }; #endif + +#endif + diff --git a/NXDNNetwork.cpp b/NXDNNetwork.cpp index 0f55011..73d52ff 100644 --- a/NXDNNetwork.cpp +++ b/NXDNNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 by Jonathan Naylor G4KLX + * Copyright (C) 2020,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,11 @@ #include "NXDNNetwork.h" +#if defined(USE_NXDN) + INXDNNetwork::~INXDNNetwork() { } + +#endif + diff --git a/NXDNNetwork.h b/NXDNNetwork.h index 107e02f..d6e8869 100644 --- a/NXDNNetwork.h +++ b/NXDNNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 by Jonathan Naylor G4KLX + * Copyright (C) 2020,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,9 @@ #define NXDNNetwork_H #include "NXDNDefines.h" +#include "Defines.h" + +#if defined(USE_NXDN) #include @@ -56,3 +59,6 @@ private: }; #endif + +#endif + diff --git a/NXDNSACCH.cpp b/NXDNSACCH.cpp index 69795c3..df887fa 100644 --- a/NXDNSACCH.cpp +++ b/NXDNSACCH.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,11 +17,12 @@ */ #include "NXDNSACCH.h" - #include "NXDNConvolution.h" #include "NXDNDefines.h" #include "NXDNCRC.h" +#if defined(USE_NXDN) + #include #include #include @@ -212,3 +213,6 @@ CNXDNSACCH& CNXDNSACCH::operator=(const CNXDNSACCH& sacch) return *this; } + +#endif + diff --git a/NXDNSACCH.h b/NXDNSACCH.h index 8d6f44a..3103fc0 100644 --- a/NXDNSACCH.h +++ b/NXDNSACCH.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(NXDNSACCH_H) #define NXDNSACCH_H +#include "Defines.h" + +#if defined(USE_NXDN) + class CNXDNSACCH { public: CNXDNSACCH(const CNXDNSACCH& sacch); @@ -48,3 +52,6 @@ private: }; #endif + +#endif + diff --git a/NXDNUDCH.cpp b/NXDNUDCH.cpp index bdba864..4d34083 100644 --- a/NXDNUDCH.cpp +++ b/NXDNUDCH.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,11 +17,12 @@ */ #include "NXDNUDCH.h" - #include "NXDNConvolution.h" #include "NXDNDefines.h" #include "NXDNCRC.h" +#if defined(USE_NXDN) + #include #include #include @@ -215,3 +216,6 @@ CNXDNUDCH& CNXDNUDCH::operator=(const CNXDNUDCH& udch) return *this; } + +#endif + diff --git a/NXDNUDCH.h b/NXDNUDCH.h index 0db3bf6..4a5b4a7 100644 --- a/NXDNUDCH.h +++ b/NXDNUDCH.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(NXDNUDCH_H) #define NXDNUDCH_H +#include "Defines.h" + +#if defined(USE_NXDN) + class CNXDNUDCH { public: CNXDNUDCH(const CNXDNUDCH& udch); @@ -46,3 +50,6 @@ private: }; #endif + +#endif + diff --git a/P25Audio.cpp b/P25Audio.cpp index 80bf492..5f2f9b2 100644 --- a/P25Audio.cpp +++ b/P25Audio.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,8 @@ #include "Golay24128.h" #include "Hamming.h" +#if defined(USE_P25) + #include #include @@ -337,3 +339,6 @@ void CP25Audio::encode(unsigned char* data, const unsigned char* imbe, unsigned return; } } + +#endif + diff --git a/P25Audio.h b/P25Audio.h index 7d77c5b..83e5dc2 100644 --- a/P25Audio.h +++ b/P25Audio.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,9 @@ #define P25Audio_H #include "AMBEFEC.h" +#include "Defines.h" + +#if defined(USE_P25) class CP25Audio { public: @@ -37,3 +40,6 @@ private: }; #endif + +#endif + diff --git a/P25Control.cpp b/P25Control.cpp index 40a5fc6..7fb9351 100644 --- a/P25Control.cpp +++ b/P25Control.cpp @@ -26,6 +26,8 @@ #include "CRC.h" #include "Log.h" +#if defined(USE_P25) + #include #include #include @@ -34,8 +36,6 @@ const unsigned int RSSI_COUNT = 7U; // 7 * 180ms = 1260ms const unsigned int BER_COUNT = 7U * 1233U; // 7 * 180ms = 1260ms -// #define DUMP_P25 - const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U}; #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]) @@ -86,8 +86,7 @@ m_rssiAccum(0U), m_rssiCount(0U), m_bitsCount(0U), m_bitErrsAccum(0U), -m_enabled(true), -m_fp(NULL) +m_enabled(true) { assert(lookup != NULL); assert(rssiMapper != NULL); @@ -145,9 +144,7 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len) m_rfState = RS_RF_LISTENING; m_rfTimeout.stop(); m_rfData.reset(); -#if defined(DUMP_P25) - closeFile(); -#endif + return false; } @@ -155,9 +152,7 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len) m_rfState = RS_RF_LISTENING; m_rfPDUCount = 0U; m_rfPDUBits = 0U; -#if defined(DUMP_P25) - closeFile(); -#endif + return false; } @@ -310,10 +305,6 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len) // Add busy bits addBusyBits(data + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true); -#if defined(DUMP_P25) - writeFile(data + 2U, len - 2U); -#endif - ::memcpy(m_rfLDU, data + 2U, P25_LDU_FRAME_LENGTH_BYTES); if (m_duplex) { @@ -358,10 +349,6 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len) // Add busy bits addBusyBits(data + 2U, P25_LDU_FRAME_LENGTH_BITS, false, true); -#if defined(DUMP_P25) - writeFile(data + 2U, len - 2U); -#endif - ::memcpy(m_rfLDU, data + 2U, P25_LDU_FRAME_LENGTH_BYTES); if (m_duplex) { @@ -487,10 +474,6 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len) writeJSONRF("end", float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits)); } -#if defined(DUMP_P25) - closeFile(); -#endif - writeNetwork(data + 2U, P25_DUID_TERM, true); if (m_duplex) { @@ -950,11 +933,6 @@ void CP25Control::createRFHeader() m_lastDUID = P25_DUID_HEADER; ::memset(m_rfLDU, 0x00U, P25_LDU_FRAME_LENGTH_BYTES); -#if defined(DUMP_P25) - openFile(); - writeFile(buffer + 2U, buffer - 2U); -#endif - if (m_duplex) { buffer[0U] = TAG_HEADER; buffer[1U] = 0x00U; @@ -1151,48 +1129,6 @@ void CP25Control::createNetTerminator() m_netState = RS_NET_IDLE; } -bool CP25Control::openFile() -{ - if (m_fp != NULL) - return true; - - time_t t; - ::time(&t); - - struct tm* tm = ::localtime(&t); - - char name[100U]; - ::sprintf(name, "P25_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); - - m_fp = ::fopen(name, "wb"); - if (m_fp == NULL) - return false; - - ::fwrite("P25", 1U, 3U, m_fp); - - return true; -} - -bool CP25Control::writeFile(const unsigned char* data, unsigned char length) -{ - if (m_fp == NULL) - return false; - - ::fwrite(&length, 1U, 1U, m_fp); - - ::fwrite(data, 1U, length, m_fp); - - return true; -} - -void CP25Control::closeFile() -{ - if (m_fp != NULL) { - ::fclose(m_fp); - m_fp = NULL; - } -} - bool CP25Control::isBusy() const { return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; @@ -1350,3 +1286,5 @@ void CP25Control::writeJSON(nlohmann::json& json, const char* source, const char json["source_info"] = srcInfo; } +#endif + diff --git a/P25Control.h b/P25Control.h index db185e4..72b101b 100644 --- a/P25Control.h +++ b/P25Control.h @@ -32,6 +32,8 @@ #include "Modem.h" #include "Timer.h" +#if defined(USE_P25) + #include #include @@ -97,7 +99,6 @@ private: unsigned int m_bitsCount; unsigned int m_bitErrsAccum; bool m_enabled; - FILE* m_fp; void writeQueueRF(const unsigned char* data, unsigned int length); void writeQueueNet(const unsigned char* data, unsigned int length); @@ -119,10 +120,6 @@ private: void createNetLDU2(); void createNetTerminator(); - bool openFile(); - bool writeFile(const unsigned char* data, unsigned char length); - void closeFile(); - void writeJSONRSSI(); void writeJSONBER(); @@ -138,3 +135,6 @@ private: }; #endif + +#endif + diff --git a/P25Data.cpp b/P25Data.cpp index 618fdc2..6b8a596 100644 --- a/P25Data.cpp +++ b/P25Data.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2023 by Jonathan Naylor G4KLX * Copyright (C) 2018 by Bryan Biedenkapp * * This program is free software; you can redistribute it and/or modify @@ -25,6 +25,8 @@ #include "Utils.h" #include "Log.h" +#if defined(USE_P25) + #include #include #include @@ -467,3 +469,6 @@ void CP25Data::encodeLDUHamming(unsigned char* data, const unsigned char* raw) } } } + +#endif + diff --git a/P25Data.h b/P25Data.h index 1b9eec9..8ce389f 100644 --- a/P25Data.h +++ b/P25Data.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2023 by Jonathan Naylor G4KLX * Copyright (C) 2018 by Bryan Biedenkapp * * This program is free software; you can redistribute it and/or modify @@ -22,6 +22,9 @@ #include "RS241213.h" #include "P25Trellis.h" +#include "Defines.h" + +#if defined(USE_P25) class CP25Data { public: @@ -85,3 +88,6 @@ private: }; #endif + +#endif + diff --git a/P25LowSpeedData.cpp b/P25LowSpeedData.cpp index 8b05368..84a83eb 100644 --- a/P25LowSpeedData.cpp +++ b/P25LowSpeedData.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ #include "P25LowSpeedData.h" #include "P25Utils.h" +#if defined(USE_P25) + #include #include @@ -128,3 +130,6 @@ unsigned char CP25LowSpeedData::encode(unsigned char in) const { return CCS_PARITY[in]; } + +#endif + diff --git a/P25LowSpeedData.h b/P25LowSpeedData.h index 41ba306..5634879 100644 --- a/P25LowSpeedData.h +++ b/P25LowSpeedData.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(P25LowSpeedData_H) #define P25LowSpeedData_H +#include "Defines.h" + +#if defined(USE_P25) + class CP25LowSpeedData { public: CP25LowSpeedData(); @@ -42,3 +46,6 @@ private: }; #endif + +#endif + diff --git a/P25NID.cpp b/P25NID.cpp index 5e057c5..e0afab0 100644 --- a/P25NID.cpp +++ b/P25NID.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2018,2023 by Jonathan Naylor G4KLX * Copyright (C) 2018 by Bryan Biedenkapp * * This program is free software; you can redistribute it and/or modify @@ -22,6 +22,8 @@ #include "P25Utils.h" #include "BCH.h" +#if defined(USE_P25) + #include #include @@ -187,3 +189,6 @@ unsigned char CP25NID::getDUID() const { return m_duid; } + +#endif + diff --git a/P25NID.h b/P25NID.h index fe7ee74..88510bc 100644 --- a/P25NID.h +++ b/P25NID.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2018,2023 by Jonathan Naylor G4KLX * Copyright (C) 2018 by Bryan Biedenkapp * * This program is free software; you can redistribute it and/or modify @@ -20,6 +20,10 @@ #if !defined(P25NID_H) #define P25NID_H +#include "Defines.h" + +#if defined(USE_P25) + class CP25NID { public: CP25NID(unsigned int nac); @@ -43,3 +47,6 @@ private: }; #endif + +#endif + diff --git a/P25Network.cpp b/P25Network.cpp index b63b522..2f167ec 100644 --- a/P25Network.cpp +++ b/P25Network.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2019,2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2019,2020,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,10 +18,11 @@ #include "P25Network.h" #include "P25Defines.h" -#include "Defines.h" #include "Utils.h" #include "Log.h" +#if defined(USE_P25) + #include #include #include @@ -443,3 +444,6 @@ void CP25Network::enable(bool enabled) m_enabled = enabled; } + +#endif + diff --git a/P25Network.h b/P25Network.h index 7023c94..c2c2e63 100644 --- a/P25Network.h +++ b/P25Network.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2020,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,9 @@ #include "UDPSocket.h" #include "P25Audio.h" #include "P25Data.h" +#include "Defines.h" + +#if defined(USE_P25) #include #include @@ -60,3 +63,6 @@ private: }; #endif + +#endif + diff --git a/P25Trellis.cpp b/P25Trellis.cpp index 5bdb651..40ff73a 100644 --- a/P25Trellis.cpp +++ b/P25Trellis.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2018 by Jonathan Naylor, G4KLX +* Copyright (C) 2016,2018,2023 by Jonathan Naylor, G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,6 +14,8 @@ #include "P25Trellis.h" #include "Log.h" +#if defined(USE_P25) + #include #include @@ -523,3 +525,6 @@ unsigned int CP25Trellis::checkCode12(const unsigned char* points, unsigned char return 999U; } + +#endif + diff --git a/P25Trellis.h b/P25Trellis.h index 47e7c1d..d5c89a8 100644 --- a/P25Trellis.h +++ b/P25Trellis.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2018 by Jonathan Naylor, G4KLX +* Copyright (C) 2016,2018,2023 by Jonathan Naylor, G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,6 +14,10 @@ #ifndef P25Trellis_H #define P25Trellis_H +#include "Defines.h" + +#if defined(USE_P25) + class CP25Trellis { public: CP25Trellis(); @@ -41,3 +45,6 @@ private: }; #endif + +#endif + diff --git a/P25Utils.cpp b/P25Utils.cpp index 70f5c29..cd4aecd 100644 --- a/P25Utils.cpp +++ b/P25Utils.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ #include "P25Utils.h" #include "P25Defines.h" +#if defined(USE_P25) + #include #include @@ -130,3 +132,6 @@ unsigned int CP25Utils::compare(const unsigned char* data1, const unsigned char* return errs; } + +#endif + diff --git a/P25Utils.h b/P25Utils.h index 75960e5..0062356 100644 --- a/P25Utils.h +++ b/P25Utils.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2018,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(P25Utils_H) #define P25Utils_H +#include "Defines.h" + +#if defined(USE_P25) + class CP25Utils { public: static unsigned int encode(const unsigned char* in, unsigned char* out, unsigned int start, unsigned int stop); @@ -32,3 +36,6 @@ private: }; #endif + +#endif + diff --git a/PseudoTTYController.cpp b/PseudoTTYController.cpp index 97062eb..207af38 100644 --- a/PseudoTTYController.cpp +++ b/PseudoTTYController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2020,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,9 +16,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "PseudoTTYController.h" + +#if defined(USE_AX25) + #if !defined(_WIN32) && !defined(_WIN64) -#include "PseudoTTYController.h" #include "Log.h" #include @@ -86,3 +89,6 @@ void CPseudoTTYController::close() } #endif + +#endif + diff --git a/PseudoTTYController.h b/PseudoTTYController.h index 228f153..c46a31e 100644 --- a/PseudoTTYController.h +++ b/PseudoTTYController.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2020,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #ifndef PseudoTTYController_H #define PseudoTTYController_H +#include "Defines.h" + +#if defined(USE_AX25) + #if !defined(_WIN32) && !defined(_WIN64) #include @@ -41,3 +45,6 @@ protected: #endif #endif + +#endif + diff --git a/QR1676.cpp b/QR1676.cpp index 1548fc5..42ec9f4 100644 --- a/QR1676.cpp +++ b/QR1676.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ #include "QR1676.h" #include "Log.h" +#if defined(USE_DMR) + #include #include @@ -113,3 +115,6 @@ unsigned char CQR1676::decode(const unsigned char* data) return code >> 7; } + +#endif + diff --git a/QR1676.h b/QR1676.h index dac2c0f..549c143 100644 --- a/QR1676.h +++ b/QR1676.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #ifndef QR1676_H #define QR1676_H +#include "Defines.h" + +#if defined(USE_DMR) + class CQR1676 { public: static void encode(unsigned char* data); @@ -30,3 +34,6 @@ private: }; #endif + +#endif + diff --git a/RS129.cpp b/RS129.cpp index 8cad52c..e152d84 100644 --- a/RS129.cpp +++ b/RS129.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ #include "RS129.h" +#if defined(USE_DMR) + #include #include #include @@ -128,3 +130,5 @@ bool CRS129::check(const unsigned char* in) return in[9U] == parity[2U] && in[10U] == parity[1U] && in[11U] == parity[0U]; } +#endif + diff --git a/RS129.h b/RS129.h index 60f99bd..e21c5e9 100644 --- a/RS129.h +++ b/RS129.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(RS129_H) #define RS129_H +#include "Defines.h" + +#if defined(USE_DMR) + class CRS129 { public: @@ -28,3 +32,6 @@ public: }; #endif + +#endif + diff --git a/RS241213.cpp b/RS241213.cpp index 3e929d0..817b468 100644 --- a/RS241213.cpp +++ b/RS241213.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ #include "RS241213.h" +#if defined(USE_P25) + #include #include @@ -369,3 +371,6 @@ unsigned char CRS241213::gf6Mult(unsigned char a, unsigned char b) const return p; } + +#endif + diff --git a/RS241213.h b/RS241213.h index fe3171a..6c48083 100644 --- a/RS241213.h +++ b/RS241213.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(RS241213_H) #define RS241213_H +#include "Defines.h" + +#if defined(USE_P25) + class CRS241213 { public: @@ -34,3 +38,6 @@ private: }; #endif + +#endif + diff --git a/SHA256.cpp b/SHA256.cpp deleted file mode 100644 index b3366e0..0000000 --- a/SHA256.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. - * Copyright (C) 2011,2015 by Jonathan Naylor G4KLX - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "SHA256.h" - -#include -#include -#include - -#ifdef WORDS_BIGENDIAN -# define SWAP(n) (n) -#else -# define SWAP(n) \ - (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) -#endif - -#define BLOCKSIZE 4096 -#if BLOCKSIZE % 64 != 0 -# error "invalid BLOCKSIZE" -#endif - -/* This array contains the bytes used to pad the buffer to the next - 64-byte boundary. */ -static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; - - -/* - Takes a pointer to a 256 bit block of data (eight 32 bit ints) and - intializes it to the start constants of the SHA256 algorithm. This - must be called before using hash in the call to sha256_hash -*/ -CSHA256::CSHA256() : -m_state(NULL), -m_total(NULL), -m_buflen(0U), -m_buffer(NULL) -{ - m_state = new uint32_t[8U]; - m_total = new uint32_t[2U]; - m_buffer = new uint32_t[32U]; - - init(); -} - -CSHA256::~CSHA256() -{ - delete[] m_state; - delete[] m_total; - delete[] m_buffer; -} - -void CSHA256::init() -{ - m_state[0] = 0x6a09e667UL; - m_state[1] = 0xbb67ae85UL; - m_state[2] = 0x3c6ef372UL; - m_state[3] = 0xa54ff53aUL; - m_state[4] = 0x510e527fUL; - m_state[5] = 0x9b05688cUL; - m_state[6] = 0x1f83d9abUL; - m_state[7] = 0x5be0cd19UL; - - m_total[0] = m_total[1] = 0; - m_buflen = 0; -} - -/* Copy the value from v into the memory location pointed to by *cp, - If your architecture allows unaligned access this is equivalent to - * (uint32_t *) cp = v */ -static inline void set_uint32(unsigned char* cp, uint32_t v) -{ - assert(cp != NULL); - - ::memcpy(cp, &v, sizeof v); -} - -/* Put result from CTX in first 32 bytes following RESBUF. The result - must be in little endian byte order. */ -unsigned char* CSHA256::read(unsigned char* resbuf) -{ - assert(resbuf != NULL); - - for (unsigned int i = 0U; i < 8U; i++) - set_uint32(resbuf + i * sizeof(m_state[0]), SWAP(m_state[i])); - - return resbuf; -} - -/* Process the remaining bytes in the internal buffer and the usual - prolog according to the standard and write the result to RESBUF. */ -void CSHA256::conclude() -{ - /* Take yet unprocessed bytes into account. */ - unsigned int bytes = m_buflen; - unsigned int size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4; - - /* Now count remaining bytes. */ - m_total[0] += bytes; - if (m_total[0] < bytes) - ++m_total[1]; - - /* Put the 64-bit file length in *bits* at the end of the buffer. - Use set_uint32 rather than a simple assignment, to avoid risk of - unaligned access. */ - set_uint32((unsigned char*)&m_buffer[size - 2], SWAP((m_total[1] << 3) | (m_total[0] >> 29))); - set_uint32((unsigned char*)&m_buffer[size - 1], SWAP(m_total[0] << 3)); - - ::memcpy(&((char*)m_buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); - - /* Process last bytes. */ - processBlock((unsigned char*)m_buffer, size * 4); -} - -unsigned char* CSHA256::finish(unsigned char* resbuf) -{ - assert(resbuf != NULL); - - conclude(); - - return read(resbuf); -} - -/* Compute SHA256 message digest for LEN bytes beginning at BUFFER. The - result is always in little endian byte order, so that a byte-wise - output yields to the wanted ASCII representation of the message - digest. */ -unsigned char* CSHA256::buffer(const unsigned char* buffer, unsigned int len, unsigned char* resblock) -{ - assert(buffer != NULL); - assert(resblock != NULL); - - /* Initialize the computation context. */ - init(); - - /* Process whole buffer but last len % 64 bytes. */ - processBytes(buffer, len); - - /* Put result in desired memory area. */ - return finish(resblock); -} - -void CSHA256::processBytes(const unsigned char* buffer, unsigned int len) -{ - assert(buffer != NULL); - - /* When we already have some bits in our internal buffer concatenate - both inputs first. */ - if (m_buflen != 0U) { - unsigned int left_over = m_buflen; - unsigned int add = 128U - left_over > len ? len : 128U - left_over; - - ::memcpy(&((char*)m_buffer)[left_over], buffer, add); - m_buflen += add; - - if (m_buflen > 64U) { - processBlock((unsigned char*)m_buffer, m_buflen & ~63U); - - m_buflen &= 63U; - - /* The regions in the following copy operation cannot overlap. */ - ::memcpy(m_buffer, &((char*)m_buffer)[(left_over + add) & ~63U], m_buflen); - } - - buffer += add; - len -= add; - } - - /* Process available complete blocks. */ - if (len >= 64U) { -//#if !_STRING_ARCH_unaligned -//# define alignof(type) offsetof (struct { char c; type x; }, x) -//# define UNALIGNED_P(p) (((unsigned int) p) % alignof (uint32_t) != 0) -// if (UNALIGNED_P (buffer)) { -// while (len > 64U) { -// ::memcpy(m_buffer, buffer, 64U); -// processBlock((unsigned char*)m_buffer, 64U); -// buffer += 64U; -// len -= 64U; -// } -// } else -//#endif - { - processBlock(buffer, len & ~63U); - buffer += (len & ~63U); - len &= 63U; - } - } - - /* Move remaining bytes in internal buffer. */ - if (len > 0U) { - unsigned int left_over = m_buflen; - - ::memcpy(&((char*)m_buffer)[left_over], buffer, len); - left_over += len; - - if (left_over >= 64U) { - processBlock((unsigned char*)m_buffer, 64U); - left_over -= 64U; - ::memcpy(m_buffer, &m_buffer[16], left_over); - } - - m_buflen = left_over; - } -} - -/* --- Code below is the primary difference between sha1.c and sha256.c --- */ - -/* SHA256 round constants */ -#define K(I) roundConstants[I] -static const uint32_t roundConstants[64] = { - 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, - 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, - 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, - 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, - 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, - 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, - 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, - 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, - 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, - 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, - 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, - 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, - 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, - 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, - 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, - 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL, -}; - -/* Round functions. */ -#define F2(A,B,C) ( ( A & B ) | ( C & ( A | B ) ) ) -#define F1(E,F,G) ( G ^ ( E & ( F ^ G ) ) ) - -/* Process LEN bytes of BUFFER, accumulating context into CTX. - It is assumed that LEN % 64 == 0. - Most of this code comes from GnuPG's cipher/sha1.c. */ - -void CSHA256::processBlock(const unsigned char* buffer, unsigned int len) -{ - assert(buffer != NULL); - - const uint32_t* words = (uint32_t*)buffer; - unsigned int nwords = len / sizeof(uint32_t); - const uint32_t* endp = words + nwords; - uint32_t x[16]; - uint32_t a = m_state[0]; - uint32_t b = m_state[1]; - uint32_t c = m_state[2]; - uint32_t d = m_state[3]; - uint32_t e = m_state[4]; - uint32_t f = m_state[5]; - uint32_t g = m_state[6]; - uint32_t h = m_state[7]; - - /* First increment the byte count. FIPS PUB 180-2 specifies the possible - length of the file up to 2^64 bits. Here we only compute the - number of bytes. Do a double word increment. */ - m_total[0] += len; - if (m_total[0] < len) - ++m_total[1]; - - #define rol(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) - #define S0(x) (rol(x,25)^rol(x,14)^(x>>3)) - #define S1(x) (rol(x,15)^rol(x,13)^(x>>10)) - #define SS0(x) (rol(x,30)^rol(x,19)^rol(x,10)) - #define SS1(x) (rol(x,26)^rol(x,21)^rol(x,7)) - - #define M(I) (tm = S1(x[(I-2)&0x0f]) + x[(I-7)&0x0f] + S0(x[(I-15)&0x0f]) + x[I&0x0f], x[I&0x0f] = tm) - - #define R(A,B,C,D,E,F,G,H,K,M) do { t0 = SS0(A) + F2(A,B,C); \ - t1 = H + SS1(E) + F1(E,F,G) + K + M; \ - D += t1; H = t0 + t1; \ - } while(0) - - while (words < endp) { - uint32_t tm; - uint32_t t0, t1; - /* FIXME: see sha1.c for a better implementation. */ - for (unsigned int t = 0U; t < 16U; t++) { - x[t] = SWAP(*words); - words++; - } - - R( a, b, c, d, e, f, g, h, K( 0), x[ 0] ); - R( h, a, b, c, d, e, f, g, K( 1), x[ 1] ); - R( g, h, a, b, c, d, e, f, K( 2), x[ 2] ); - R( f, g, h, a, b, c, d, e, K( 3), x[ 3] ); - R( e, f, g, h, a, b, c, d, K( 4), x[ 4] ); - R( d, e, f, g, h, a, b, c, K( 5), x[ 5] ); - R( c, d, e, f, g, h, a, b, K( 6), x[ 6] ); - R( b, c, d, e, f, g, h, a, K( 7), x[ 7] ); - R( a, b, c, d, e, f, g, h, K( 8), x[ 8] ); - R( h, a, b, c, d, e, f, g, K( 9), x[ 9] ); - R( g, h, a, b, c, d, e, f, K(10), x[10] ); - R( f, g, h, a, b, c, d, e, K(11), x[11] ); - R( e, f, g, h, a, b, c, d, K(12), x[12] ); - R( d, e, f, g, h, a, b, c, K(13), x[13] ); - R( c, d, e, f, g, h, a, b, K(14), x[14] ); - R( b, c, d, e, f, g, h, a, K(15), x[15] ); - R( a, b, c, d, e, f, g, h, K(16), M(16) ); - R( h, a, b, c, d, e, f, g, K(17), M(17) ); - R( g, h, a, b, c, d, e, f, K(18), M(18) ); - R( f, g, h, a, b, c, d, e, K(19), M(19) ); - R( e, f, g, h, a, b, c, d, K(20), M(20) ); - R( d, e, f, g, h, a, b, c, K(21), M(21) ); - R( c, d, e, f, g, h, a, b, K(22), M(22) ); - R( b, c, d, e, f, g, h, a, K(23), M(23) ); - R( a, b, c, d, e, f, g, h, K(24), M(24) ); - R( h, a, b, c, d, e, f, g, K(25), M(25) ); - R( g, h, a, b, c, d, e, f, K(26), M(26) ); - R( f, g, h, a, b, c, d, e, K(27), M(27) ); - R( e, f, g, h, a, b, c, d, K(28), M(28) ); - R( d, e, f, g, h, a, b, c, K(29), M(29) ); - R( c, d, e, f, g, h, a, b, K(30), M(30) ); - R( b, c, d, e, f, g, h, a, K(31), M(31) ); - R( a, b, c, d, e, f, g, h, K(32), M(32) ); - R( h, a, b, c, d, e, f, g, K(33), M(33) ); - R( g, h, a, b, c, d, e, f, K(34), M(34) ); - R( f, g, h, a, b, c, d, e, K(35), M(35) ); - R( e, f, g, h, a, b, c, d, K(36), M(36) ); - R( d, e, f, g, h, a, b, c, K(37), M(37) ); - R( c, d, e, f, g, h, a, b, K(38), M(38) ); - R( b, c, d, e, f, g, h, a, K(39), M(39) ); - R( a, b, c, d, e, f, g, h, K(40), M(40) ); - R( h, a, b, c, d, e, f, g, K(41), M(41) ); - R( g, h, a, b, c, d, e, f, K(42), M(42) ); - R( f, g, h, a, b, c, d, e, K(43), M(43) ); - R( e, f, g, h, a, b, c, d, K(44), M(44) ); - R( d, e, f, g, h, a, b, c, K(45), M(45) ); - R( c, d, e, f, g, h, a, b, K(46), M(46) ); - R( b, c, d, e, f, g, h, a, K(47), M(47) ); - R( a, b, c, d, e, f, g, h, K(48), M(48) ); - R( h, a, b, c, d, e, f, g, K(49), M(49) ); - R( g, h, a, b, c, d, e, f, K(50), M(50) ); - R( f, g, h, a, b, c, d, e, K(51), M(51) ); - R( e, f, g, h, a, b, c, d, K(52), M(52) ); - R( d, e, f, g, h, a, b, c, K(53), M(53) ); - R( c, d, e, f, g, h, a, b, K(54), M(54) ); - R( b, c, d, e, f, g, h, a, K(55), M(55) ); - R( a, b, c, d, e, f, g, h, K(56), M(56) ); - R( h, a, b, c, d, e, f, g, K(57), M(57) ); - R( g, h, a, b, c, d, e, f, K(58), M(58) ); - R( f, g, h, a, b, c, d, e, K(59), M(59) ); - R( e, f, g, h, a, b, c, d, K(60), M(60) ); - R( d, e, f, g, h, a, b, c, K(61), M(61) ); - R( c, d, e, f, g, h, a, b, K(62), M(62) ); - R( b, c, d, e, f, g, h, a, K(63), M(63) ); - - a = m_state[0] += a; - b = m_state[1] += b; - c = m_state[2] += c; - d = m_state[3] += d; - e = m_state[4] += e; - f = m_state[5] += f; - g = m_state[6] += g; - h = m_state[7] += h; - } -} diff --git a/SHA256.h b/SHA256.h deleted file mode 100644 index 7c48f19..0000000 --- a/SHA256.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc. - * Copyright (C) 2011,2015,2016 by Jonathan Naylor G4KLX - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef SHA256_H -#define SHA256_H - -#include - -enum { - SHA256_DIGEST_SIZE = 256 / 8 -}; - -class CSHA256 { -public: - CSHA256(); - ~CSHA256(); - - /* Starting with the result of former calls of this function (or the - initialization function update the context for the next LEN bytes - starting at BUFFER. - It is necessary that LEN is a multiple of 64!!! */ - void processBlock(const unsigned char* buffer, unsigned int len); - - /* Starting with the result of former calls of this function (or the - initialization function update the context for the next LEN bytes - starting at BUFFER. - It is NOT required that LEN is a multiple of 64. */ - void processBytes(const unsigned char* buffer, unsigned int len); - - /* Process the remaining bytes in the buffer and put result from CTX - in first 32 bytes following RESBUF. The result is always in little - endian byte order, so that a byte-wise output yields to the wanted - ASCII representation of the message digest. */ - unsigned char* finish(unsigned char* resbuf); - - /* Put result from CTX in first 32 bytes following RESBUF. The result is - always in little endian byte order, so that a byte-wise output yields - to the wanted ASCII representation of the message digest. */ - unsigned char* read(unsigned char* resbuf); - - /* Compute SHA256 message digest for LEN bytes beginning at BUFFER. The - result is always in little endian byte order, so that a byte-wise - output yields to the wanted ASCII representation of the message - digest. */ - unsigned char* buffer(const unsigned char* buffer, unsigned int len, unsigned char* resblock); - -private: - uint32_t* m_state; - uint32_t* m_total; - unsigned int m_buflen; - uint32_t* m_buffer; - - void init(); - void conclude(); -}; - -#endif diff --git a/UserDB.cpp b/UserDB.cpp index f6c7e1a..ea5ff84 100644 --- a/UserDB.cpp +++ b/UserDB.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2020 by SASANO Takayoshi JG1UAA + * Copyright (C) 2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,8 @@ #include "UserDB.h" #include "Log.h" +#if defined(USE_DMR) || defined(USE_P25) || defined(USE_NXDN) + #include #include #include @@ -187,3 +190,6 @@ char* CUserDB::tokenize(char* str, char** next) return str; } + +#endif + diff --git a/UserDB.h b/UserDB.h index acae103..1bc75c6 100644 --- a/UserDB.h +++ b/UserDB.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2020 by SASANO Takayoshi JG1UAA + * Copyright (C) 2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +22,9 @@ #include "UserDBentry.h" #include "Mutex.h" +#include "Defines.h" + +#if defined(USE_DMR) || defined(USE_P25) || defined(USE_NXDN) class CUserDB { public: @@ -41,3 +45,6 @@ private: }; #endif + +#endif + diff --git a/UserDBentry.cpp b/UserDBentry.cpp index 0121544..79e193d 100644 --- a/UserDBentry.cpp +++ b/UserDBentry.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2020 by SASANO Takayoshi JG1UAA + * Copyright (C) 2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +17,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "UserDBentry.h" + +#if defined(USE_DMR) || defined(USE_P25) || defined(USE_NXDN) + #include CUserDBentry::CUserDBentry() : @@ -57,3 +61,6 @@ void CUserDBentry::clear(void) { m_db.clear(); } + +#endif + diff --git a/UserDBentry.h b/UserDBentry.h index cbca92f..8f80a45 100644 --- a/UserDBentry.h +++ b/UserDBentry.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2020 by SASANO Takayoshi JG1UAA + * Copyright (C) 2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +20,10 @@ #if !defined(USERDBENTRY_H) #define USERDBENTRY_H +#include "Defines.h" + +#if defined(USE_DMR) || defined(USE_P25) || defined(USE_NXDN) + #include #include #include @@ -48,3 +53,6 @@ private: }; #endif + +#endif + diff --git a/YSFControl.cpp b/YSFControl.cpp index 2342ae3..242107b 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -16,6 +16,8 @@ #include "Sync.h" #include "Log.h" +#if defined(USE_YSF) + #include #include #include @@ -24,8 +26,6 @@ const unsigned int RSSI_COUNT = 13U; // 13 * 100ms = 1300ms const unsigned int BER_COUNT = 13U; // 13 * 100ms = 1300ms -// #define DUMP_YSF - CYSFControl::CYSFControl(const std::string& callsign, bool selfOnly, CYSFNetwork* network, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper) : m_callsign(NULL), m_selfCallsign(NULL), @@ -66,8 +66,7 @@ m_rssiAccum(0U), m_rssiCount(0U), m_bitsCount(0U), m_bitErrsAccum(0U), -m_enabled(true), -m_fp(NULL) +m_enabled(true) { assert(rssiMapper != NULL); @@ -271,9 +270,6 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data) m_bitErrsAccum = 0U; m_bitsCount = 0U; -#if defined(DUMP_YSF) - openFile(); -#endif LogMessage("YSF, received RF header from %10.10s to DG-ID %u", m_rfSource, dgid); writeJSONRF("start", "voice_vw", m_rfSource, dgid); @@ -288,9 +284,6 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data) writeNetwork(data, m_rfFrames % 128U); -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif if (m_duplex) { fich.setMR(m_remoteGateway ? YSF_MR_NOT_BUSY : YSF_MR_BUSY); fich.setDev(m_lowDeviation); @@ -323,9 +316,7 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data) data[1U] = 0x00U; writeNetwork(data, m_rfFrames % 128U); -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif + if (m_duplex) { fich.setMR(m_remoteGateway ? YSF_MR_NOT_BUSY : YSF_MR_BUSY); fich.setDev(m_lowDeviation); @@ -390,9 +381,6 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data) writeQueueRF(data); } -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif m_rfFrames++; writeJSONRSSI(); @@ -450,9 +438,6 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) m_bitErrsAccum = 0U; m_bitsCount = 0U; -#if defined(DUMP_YSF) - openFile(); -#endif LogMessage("YSF, received RF header from %10.10s to DG-ID %u", m_rfSource, dgid); writeJSONRF("start", "voice_dn", m_rfSource, dgid); @@ -467,9 +452,6 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) writeNetwork(data, m_rfFrames % 128U); -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif if (m_duplex) { fich.setMR(m_remoteGateway ? YSF_MR_NOT_BUSY : YSF_MR_BUSY); fich.setDev(m_lowDeviation); @@ -502,9 +484,7 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) data[1U] = 0x00U; writeNetwork(data, m_rfFrames % 128U); -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif + if (m_duplex) { fich.setMR(m_remoteGateway ? YSF_MR_NOT_BUSY : YSF_MR_BUSY); fich.setDev(m_lowDeviation); @@ -583,9 +563,6 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) writeQueueRF(data); } -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif m_rfFrames++; writeJSONRSSI(); @@ -651,9 +628,6 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) m_bitErrsAccum = 0U; m_bitsCount = 0U; -#if defined(DUMP_YSF) - openFile(); -#endif // Build a new header and transmit it unsigned char buffer[YSF_FRAME_LENGTH_BYTES + 2U]; @@ -687,9 +661,6 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) writeQueueRF(buffer); } -#if defined(DUMP_YSF) - writeFile(buffer + 2U); -#endif LogMessage("YSF, received RF late entry from %10.10s to DG-ID %u", m_rfSource, dgid); writeJSONRF("late_entry", "voice_dn", m_rfSource, dgid); @@ -711,9 +682,6 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) writeQueueRF(data); } -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif m_rfFrames++; writeJSONRSSI(); @@ -768,9 +736,6 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data) m_bitErrsAccum = 0U; m_bitsCount = 0U; -#if defined(DUMP_YSF) - openFile(); -#endif LogMessage("YSF, received RF header from %10.10s to DG-ID %u", m_rfSource, dgid); writeJSONRF("start", "data_fr", m_rfSource, dgid); @@ -784,9 +749,7 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data) data[1U] = 0x00U; writeNetwork(data, m_rfFrames % 128U); -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif + if (m_duplex) { fich.setMR(m_remoteGateway ? YSF_MR_NOT_BUSY : YSF_MR_BUSY); fich.setDev(m_lowDeviation); @@ -819,9 +782,7 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data) data[1U] = 0x00U; writeNetwork(data, m_rfFrames % 128U); -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif + if (m_duplex) { fich.setMR(m_remoteGateway ? YSF_MR_NOT_BUSY : YSF_MR_BUSY); fich.setDev(m_lowDeviation); @@ -876,9 +837,6 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data) writeQueueRF(data); } -#if defined(DUMP_YSF) - writeFile(data + 2U); -#endif m_rfFrames++; writeJSONRSSI(); @@ -920,10 +878,6 @@ void CYSFControl::writeEndRF() if (m_network != NULL) m_network->reset(); } - -#if defined(DUMP_YSF) - closeFile(); -#endif } void CYSFControl::writeEndNet() @@ -1169,46 +1123,6 @@ void CYSFControl::writeNetwork(const unsigned char *data, unsigned int count) m_network->write(m_rfSource, m_rfDest, data + 2U, count, data[0U] == TAG_EOT); } -bool CYSFControl::openFile() -{ - if (m_fp != NULL) - return true; - - time_t t; - ::time(&t); - - struct tm* tm = ::localtime(&t); - - char name[100U]; - ::sprintf(name, "YSF_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); - - m_fp = ::fopen(name, "wb"); - if (m_fp == NULL) - return false; - - ::fwrite("YSF", 1U, 3U, m_fp); - - return true; -} - -bool CYSFControl::writeFile(const unsigned char* data) -{ - if (m_fp == NULL) - return false; - - ::fwrite(data, 1U, YSF_FRAME_LENGTH_BYTES, m_fp); - - return true; -} - -void CYSFControl::closeFile() -{ - if (m_fp != NULL) { - ::fclose(m_fp); - m_fp = NULL; - } -} - bool CYSFControl::checkCallsign(const unsigned char* callsign) const { return ::memcmp(callsign, m_selfCallsign, ::strlen((char*)m_selfCallsign)) == 0; @@ -1447,3 +1361,5 @@ std::string CYSFControl::convertBuffer(const unsigned char* buffer) const return callsign; } +#endif + diff --git a/YSFControl.h b/YSFControl.h index 6b96a2e..101e0e1 100644 --- a/YSFControl.h +++ b/YSFControl.h @@ -30,6 +30,8 @@ #include "Timer.h" #include "Modem.h" +#if defined(USE_YSF) + #include #include @@ -90,7 +92,6 @@ private: unsigned int m_bitsCount; unsigned int m_bitErrsAccum; bool m_enabled; - FILE* m_fp; bool processVWData(bool valid, unsigned char *data); bool processDNData(bool valid, unsigned char *data); @@ -122,12 +123,11 @@ private: std::string convertBuffer(const unsigned char* buffer) const; - bool openFile(); - bool writeFile(const unsigned char* data); - void closeFile(); - bool checkCallsign(const unsigned char* callsign) const; void processNetCallsigns(const unsigned char* data, unsigned char dgid); }; #endif + +#endif + diff --git a/YSFConvolution.cpp b/YSFConvolution.cpp index c79bf2a..a6da4ba 100644 --- a/YSFConvolution.cpp +++ b/YSFConvolution.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2016,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ #include "YSFConvolution.h" +#if defined(USE_YSF) + #include #include #include @@ -148,3 +150,6 @@ void CYSFConvolution::encode(const unsigned char* in, unsigned char* out, unsign k++; } } + +#endif + diff --git a/YSFConvolution.h b/YSFConvolution.h index b49ddc5..65bf719 100644 --- a/YSFConvolution.h +++ b/YSFConvolution.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016.2021 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016.2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(YSFConvolution_H) #define YSFConvolution_H +#include "Defines.h" + +#if defined(USE_YSF) + #include class CYSFConvolution { @@ -44,3 +48,5 @@ private: #endif +#endif + diff --git a/YSFFICH.cpp b/YSFFICH.cpp index cbe3175..12a0df9 100644 --- a/YSFFICH.cpp +++ b/YSFFICH.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2019,2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2019,2020,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ #include "CRC.h" #include "Log.h" +#if defined(USE_YSF) + #include #include #include @@ -288,3 +290,6 @@ CYSFFICH& CYSFFICH::operator=(const CYSFFICH& fich) return *this; } + +#endif + diff --git a/YSFFICH.h b/YSFFICH.h index a6e8851..5028080 100644 --- a/YSFFICH.h +++ b/YSFFICH.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2019,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2019,2020,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ #if !defined(YSFFICH_H) #define YSFFICH_H +#include "Defines.h" + +#if defined(USE_YSF) + class CYSFFICH { public: CYSFFICH(const CYSFFICH& fich); @@ -57,3 +61,6 @@ private: }; #endif + +#endif + diff --git a/YSFNetwork.cpp b/YSFNetwork.cpp index d41d651..d8523ae 100644 --- a/YSFNetwork.cpp +++ b/YSFNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2019,2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2019,2020,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,10 +18,11 @@ #include "YSFDefines.h" #include "YSFNetwork.h" -#include "Defines.h" #include "Utils.h" #include "Log.h" +#if defined(USE_YSF) + #include #include #include @@ -204,3 +205,6 @@ void CYSFNetwork::enable(bool enabled) m_enabled = enabled; } + +#endif + diff --git a/YSFNetwork.h b/YSFNetwork.h index 918134b..ad1ae18 100644 --- a/YSFNetwork.h +++ b/YSFNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2020,2021,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,8 +22,11 @@ #include "YSFDefines.h" #include "RingBuffer.h" #include "UDPSocket.h" +#include "Defines.h" #include "Timer.h" +#if defined(USE_YSF) + #include #include @@ -63,3 +66,6 @@ private: }; #endif + +#endif + diff --git a/YSFPayload.cpp b/YSFPayload.cpp index f0fa17f..0d670a7 100644 --- a/YSFPayload.cpp +++ b/YSFPayload.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017,2020 Jonathan Naylor, G4KLX +* Copyright (C) 2016,2017,2020,2023 Jonathan Naylor, G4KLX * Copyright (C) 2016 Mathias Weyland, HB9FRV * * This program is free software; you can redistribute it and/or modify @@ -19,6 +19,8 @@ #include "CRC.h" #include "Log.h" +#if defined(USE_YSF) + #include #include #include @@ -1025,3 +1027,6 @@ void CYSFPayload::reset() m_source = NULL; m_dest = NULL; } + +#endif + diff --git a/YSFPayload.h b/YSFPayload.h index 06b858f..913b87c 100644 --- a/YSFPayload.h +++ b/YSFPayload.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017,2020 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2020,2023 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,9 @@ #define YSFPayload_H #include "AMBEFEC.h" +#include "Defines.h" + +#if defined(USE_YSF) #include @@ -65,3 +68,6 @@ private: }; #endif + +#endif +