MMDVMHost/Modem.h

117 lines
3.8 KiB
C
Raw Permalink Normal View History

2016-01-14 19:45:04 +01:00
/*
2017-01-31 21:07:35 +01:00
* Copyright (C) 2011-2017 by Jonathan Naylor G4KLX
2016-01-14 19:45:04 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef MODEM_H
#define MODEM_H
#include "RingBuffer.h"
#include "Defines.h"
2016-01-14 19:45:04 +01:00
#include "Timer.h"
#include <string>
2017-02-26 13:43:59 +01:00
#include <cstdint>
2016-01-14 19:45:04 +01:00
class CModem {
public:
2017-02-20 22:36:35 +01:00
CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, int oscOffset, const std::string& samplesDir, bool debug = false);
~CModem();
2016-01-14 19:45:04 +01:00
void setRFParams(unsigned int rxFrequency, unsigned int txFrequency);
2016-09-08 19:38:59 +02:00
void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled);
2016-10-10 18:46:37 +02:00
void setLevels(unsigned int rxLevel, unsigned int cwIdTXLevel, unsigned int dstarTXLevel, unsigned int dmrTXLevel, unsigned int ysfTXLevel, unsigned int p25Enabled);
void setDMRParams(unsigned int colorCode);
2016-01-14 19:45:04 +01:00
bool open();
2016-01-14 19:45:04 +01:00
unsigned int readDStarData(unsigned char* data);
unsigned int readDMRData1(unsigned char* data);
unsigned int readDMRData2(unsigned char* data);
unsigned int readYSFData(unsigned char* data);
2016-09-08 19:38:59 +02:00
unsigned int readP25Data(unsigned char* data);
2016-01-14 19:45:04 +01:00
unsigned int readSerial(unsigned char* data, unsigned int length);
bool hasDStarSpace() const;
bool hasDMRSpace1() const;
bool hasDMRSpace2() const;
bool hasYSFSpace() const;
2016-09-08 19:38:59 +02:00
bool hasP25Space() const;
2016-01-14 19:45:04 +01:00
bool hasTX() const;
2016-11-17 11:48:42 +01:00
bool hasCD() const;
2016-03-03 19:01:01 +01:00
bool hasLockout() const;
2016-03-21 23:47:58 +01:00
bool hasError() const;
2016-03-03 19:01:01 +01:00
bool writeDStarData(const unsigned char* data, unsigned int length);
bool writeDMRData1(const unsigned char* data, unsigned int length);
bool writeDMRData2(const unsigned char* data, unsigned int length);
bool writeYSFData(const unsigned char* data, unsigned int length);
2016-09-08 19:38:59 +02:00
bool writeP25Data(const unsigned char* data, unsigned int length);
2016-01-14 19:45:04 +01:00
bool writeDMRStart(bool tx);
bool writeDMRShortLC(const unsigned char* lc);
2016-06-17 08:37:49 +02:00
bool writeDMRAbort(unsigned int slotNo);
2016-01-14 19:45:04 +01:00
bool writeSerial(const unsigned char* data, unsigned int length);
bool setMode(unsigned char mode);
2016-01-14 19:45:04 +01:00
2016-05-09 22:55:44 +02:00
bool sendCWId(const std::string& callsign);
HW_TYPE getHWType() const;
void clock(unsigned int ms);
2016-01-14 19:45:04 +01:00
void close();
2016-01-14 19:45:04 +01:00
private:
2017-02-20 22:36:35 +01:00
std::string m_samplesDir;
2016-01-14 19:45:04 +01:00
bool m_debug;
CRingBuffer<unsigned char> m_rxDStarData;
CRingBuffer<unsigned char> m_rxDMRData2;
CRingBuffer<unsigned char> m_rxYSFData;
2016-09-08 19:38:59 +02:00
CRingBuffer<unsigned char> m_rxP25Data;
2017-03-01 20:05:27 +01:00
CTimer m_dmrTimer;
2017-02-26 13:43:59 +01:00
CTimer m_ysfTimer;
2017-03-01 20:05:27 +01:00
CTimer m_p25Timer;
FILE* m_dmrFP;
2017-02-26 13:43:59 +01:00
FILE* m_ysfFP;
FILE* m_p25FP;
2017-03-01 20:05:27 +01:00
int16_t m_thresholdVal;
int16_t m_centreVal;
int16_t m_threshold[16U];
int16_t m_centre[16U];
uint16_t m_averagePtr;
2017-02-26 13:43:59 +01:00
void processYSF();
void processP25();
2017-03-01 20:05:27 +01:00
void processDMR();
2017-02-26 13:43:59 +01:00
2017-03-01 20:05:27 +01:00
void dmrCalculateLevels(const int16_t* symbols);
void dmrSamplesToBits(const int16_t* symbols, unsigned char* buffer);
2017-02-26 13:43:59 +01:00
2017-03-01 20:05:27 +01:00
void ysfCalculateLevels(const int16_t* symbols);
2017-02-26 13:43:59 +01:00
void ysfSamplesToBits(const int16_t* symbols, unsigned char* buffer);
void p25CalculateLevels(const int16_t* symbols);
void p25SamplesToBits(const int16_t* symbols, unsigned char* buffer);
2016-01-14 19:45:04 +01:00
};
#endif