mirror of
https://github.com/g4klx/MMDVMHost.git
synced 2026-02-15 12:04:15 +01:00
Make all of the rest of the code base be conditionally compiled.
This commit is contained in:
parent
50d3185432
commit
893952f024
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
5
BCH.cpp
5
BCH.cpp
|
|
@ -71,6 +71,8 @@
|
|||
|
||||
#include "BCH.h"
|
||||
|
||||
#if defined(USE_P25)
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
|
|
@ -137,3 +139,6 @@ void CBCH::encode(unsigned char* nid)
|
|||
WRITE_BIT(nid, i + 16U, b);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
9
BCH.h
9
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
19
CRC.cpp
19
CRC.cpp
|
|
@ -26,6 +26,7 @@
|
|||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
#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
|
||||
|
||||
|
|
|
|||
12
CRC.h
12
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
|
||||
|
|
|
|||
4
Conf.cpp
4
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),
|
||||
|
|
|
|||
4
Conf.h
4
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;
|
||||
|
|
|
|||
|
|
@ -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 <algorithm>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <vector>
|
||||
|
||||
class CDMRAccessControl {
|
||||
|
|
@ -42,3 +46,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -246,3 +248,6 @@ void CDMRCSBK::setCBF(unsigned char cbf)
|
|||
{
|
||||
m_CBF = m_data[3U] = cbf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@
|
|||
|
||||
#include "DMRControl.h"
|
||||
#include "DMRAccessControl.h"
|
||||
#include "Defines.h"
|
||||
#include "DMRCSBK.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(USE_DMR)
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
|
@ -135,3 +136,6 @@ void CDMRControl::enable(bool enabled)
|
|||
m_slot1.enable(enabled);
|
||||
m_slot2.enable(enabled);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@
|
|||
#include "DMRData.h"
|
||||
#include "Modem.h"
|
||||
|
||||
#include "Defines.h"
|
||||
|
||||
#if defined(USE_DMR)
|
||||
|
||||
#include <vector>
|
||||
|
||||
class CDMRControl {
|
||||
|
|
@ -57,3 +61,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -173,3 +175,6 @@ CDMRDataHeader& CDMRDataHeader::operator=(const CDMRDataHeader& header)
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -98,3 +99,6 @@ void CDMREMB::setLCSS(unsigned char lcss)
|
|||
{
|
||||
m_LCSS = lcss;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
9
DMREMB.h
9
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -320,3 +321,6 @@ bool CDMREmbeddedData::getRawData(unsigned char* data) const
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -97,3 +98,6 @@ void CDMRFullLC::encode(const CDMRLC& lc, unsigned char* data, unsigned char typ
|
|||
|
||||
m_bptc.encode(lcData, data);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -216,3 +217,6 @@ void CDMRLC::setDstId(unsigned int id)
|
|||
{
|
||||
m_dstId = id;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
7
DMRLC.h
7
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
|
@ -134,3 +136,6 @@ bool CDMRLookup::exists(unsigned int id)
|
|||
{
|
||||
return m_table.lookup(id, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <string>
|
||||
|
||||
|
|
@ -51,3 +54,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@
|
|||
*/
|
||||
|
||||
#include "DMRNetwork.h"
|
||||
|
||||
#include "Utils.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(USE_DMR)
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -444,3 +445,6 @@ bool CDMRNetwork::write(const unsigned char* data, unsigned int length)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#include "DMRData.h"
|
||||
#include "Defines.h"
|
||||
|
||||
#if defined(USE_DMR)
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <random>
|
||||
|
|
@ -89,3 +91,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
95
DMRSlot.cpp
95
DMRSlot.cpp
|
|
@ -26,6 +26,8 @@
|
|||
#include "CRC.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(USE_DMR)
|
||||
|
||||
#include <cassert>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
10
DMRSlot.h
10
DMRSlot.h
|
|
@ -34,6 +34,8 @@
|
|||
#include "Modem.h"
|
||||
#include "DMRLC.h"
|
||||
|
||||
#if defined(USE_DMR)
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -90,3 +91,6 @@ void CDMRSlotType::setDataType(unsigned char type)
|
|||
{
|
||||
m_dataType = type;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
#include "DMRTA.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(USE_DMR)
|
||||
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -134,3 +136,5 @@ bool CDMRTA::decodeTA()
|
|||
return taLen >= taSize;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
7
DMRTA.h
7
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -372,3 +374,6 @@ unsigned int CDMRTrellis::checkCode(const unsigned char* points, unsigned char*
|
|||
|
||||
return 999U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -260,3 +262,6 @@ void CGolay2087::encode(unsigned char* data)
|
|||
data[1U] = cksum & 0xFFU;
|
||||
data[2U] = cksum >> 8;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cmath>
|
||||
|
||||
#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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
2
Makefile
2
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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -575,3 +577,6 @@ void CNXDNAudio::encode(const unsigned char* in, unsigned char* out, unsigned in
|
|||
WRITE_BIT(out, cPos, cOrig & MASK);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -183,3 +185,6 @@ uint16_t CNXDNCRC::createCRC15(const unsigned char* in, unsigned int length)
|
|||
|
||||
return crc & 0x7FFFU;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdint>
|
||||
|
||||
class CNXDNCRC
|
||||
|
|
@ -40,3 +44,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
#include "Sync.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(USE_NXDN)
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#include "Timer.h"
|
||||
#include "Modem.h"
|
||||
|
||||
#if defined(USE_NXDN)
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -149,3 +151,6 @@ void CNXDNConvolution::encode(const unsigned char* in, unsigned char* out, unsig
|
|||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdint>
|
||||
|
||||
class CNXDNConvolution {
|
||||
|
|
@ -44,3 +48,5 @@ private:
|
|||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -186,3 +187,6 @@ CNXDNFACCH1& CNXDNFACCH1::operator=(const CNXDNFACCH1& facch1)
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -174,3 +175,6 @@ void CNXDNIcomNetwork::enable(bool enabled)
|
|||
|
||||
m_enabled = enabled;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdint>
|
||||
#include <string>
|
||||
|
|
@ -59,3 +62,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -1185,3 +1187,6 @@ void CNXDNKenwoodNetwork::enable(bool enabled)
|
|||
|
||||
m_enabled = enabled;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdint>
|
||||
#include <string>
|
||||
|
|
@ -100,3 +103,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -160,3 +162,6 @@ bool CNXDNLICH::getParity() const
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -115,3 +117,6 @@ CNXDNLayer3& CNXDNLayer3::operator=(const CNXDNLayer3& layer3)
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
|
@ -134,3 +136,6 @@ bool CNXDNLookup::exists(unsigned int id)
|
|||
{
|
||||
return m_table.lookup(id, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <string>
|
||||
|
||||
|
|
@ -51,3 +54,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdint>
|
||||
|
||||
|
|
@ -56,3 +59,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -212,3 +213,6 @@ CNXDNSACCH& CNXDNSACCH::operator=(const CNXDNSACCH& sacch)
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -215,3 +216,6 @@ CNXDNUDCH& CNXDNUDCH::operator=(const CNXDNUDCH& udch)
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -337,3 +339,6 @@ void CP25Audio::encode(unsigned char* data, const unsigned char* imbe, unsigned
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
#include "CRC.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(USE_P25)
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
10
P25Control.h
10
P25Control.h
|
|
@ -32,6 +32,8 @@
|
|||
#include "Modem.h"
|
||||
#include "Timer.h"
|
||||
|
||||
#if defined(USE_P25)
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <gatekeep@gmail.com>
|
||||
*
|
||||
* 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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -467,3 +469,6 @@ void CP25Data::encodeLDUHamming(unsigned char* data, const unsigned char* raw)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <gatekeep@gmail.com>
|
||||
*
|
||||
* 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -128,3 +130,6 @@ unsigned char CP25LowSpeedData::encode(unsigned char in) const
|
|||
{
|
||||
return CCS_PARITY[in];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <gatekeep@gmail.com>
|
||||
*
|
||||
* 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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -187,3 +189,6 @@ unsigned char CP25NID::getDUID() const
|
|||
{
|
||||
return m_duid;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
9
P25NID.h
9
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 <gatekeep@gmail.com>
|
||||
*
|
||||
* 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -443,3 +444,6 @@ void CP25Network::enable(bool enabled)
|
|||
|
||||
m_enabled = enabled;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdint>
|
||||
#include <string>
|
||||
|
|
@ -60,3 +63,6 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -523,3 +525,6 @@ unsigned int CP25Trellis::checkCode12(const unsigned char* points, unsigned char
|
|||
|
||||
return 999U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -130,3 +132,6 @@ unsigned int CP25Utils::compare(const unsigned char* data1, const unsigned char*
|
|||
|
||||
return errs;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstring>
|
||||
|
|
@ -86,3 +89,6 @@ void CPseudoTTYController::close()
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstring>
|
||||
|
|
@ -41,3 +45,6 @@ protected:
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -113,3 +115,6 @@ unsigned char CQR1676::decode(const unsigned char* data)
|
|||
|
||||
return code >> 7;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
9
QR1676.h
9
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
9
RS129.h
9
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
|
|
@ -369,3 +371,6 @@ unsigned char CRS241213::gf6Mult(unsigned char a, unsigned char b) const
|
|||
|
||||
return p;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
373
SHA256.cpp
373
SHA256.cpp
|
|
@ -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 <cstdio>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue