MMDVMHost-Private/Modem.h

153 lines
5 KiB
C
Raw Normal View History

2016-01-14 18:45:04 +00:00
/*
2017-01-31 20:07:35 +00:00
* Copyright (C) 2011-2017 by Jonathan Naylor G4KLX
2016-01-14 18:45:04 +00: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 "SerialController.h"
#include "RingBuffer.h"
#include "Defines.h"
2016-01-14 18:45:04 +00:00
#include "Timer.h"
#include <string>
enum RESP_TYPE_MMDVM {
RTM_OK,
RTM_TIMEOUT,
RTM_ERROR
};
class CModem {
public:
2017-02-20 21:36:35 +00: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 18:45:04 +00:00
void setRFParams(unsigned int rxFrequency, unsigned int txFrequency);
2016-09-08 17:38:59 +00:00
void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled);
2016-10-10 16:46:37 +00: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 18:45:04 +00:00
bool open();
2016-01-14 18:45:04 +00: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 17:38:59 +00:00
unsigned int readP25Data(unsigned char* data);
2016-01-14 18:45:04 +00: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 17:38:59 +00:00
bool hasP25Space() const;
2016-01-14 18:45:04 +00:00
bool hasTX() const;
2016-11-17 10:48:42 +00:00
bool hasCD() const;
2016-03-03 18:01:01 +00:00
bool hasLockout() const;
2016-03-21 22:47:58 +00:00
bool hasError() const;
2016-03-03 18:01:01 +00: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 17:38:59 +00:00
bool writeP25Data(const unsigned char* data, unsigned int length);
2016-01-14 18:45:04 +00:00
bool writeDMRStart(bool tx);
bool writeDMRShortLC(const unsigned char* lc);
2016-06-17 06:37:49 +00:00
bool writeDMRAbort(unsigned int slotNo);
2016-01-14 18:45:04 +00:00
bool writeSerial(const unsigned char* data, unsigned int length);
bool setMode(unsigned char mode);
2016-01-14 18:45:04 +00:00
2016-05-09 20:55:44 +00:00
bool sendCWId(const std::string& callsign);
HW_TYPE getHWType() const;
void clock(unsigned int ms);
2016-01-14 18:45:04 +00:00
void close();
2016-01-14 18:45:04 +00:00
private:
std::string m_port;
unsigned int m_colorCode;
bool m_duplex;
2016-01-14 18:45:04 +00:00
bool m_rxInvert;
bool m_txInvert;
bool m_pttInvert;
unsigned int m_txDelay;
2016-03-17 18:12:14 +00:00
unsigned int m_dmrDelay;
2016-01-14 18:45:04 +00:00
unsigned int m_rxLevel;
2016-10-10 16:46:37 +00:00
unsigned int m_cwIdTXLevel;
2016-08-09 06:08:37 +00:00
unsigned int m_dstarTXLevel;
unsigned int m_dmrTXLevel;
unsigned int m_ysfTXLevel;
2016-09-08 17:38:59 +00:00
unsigned int m_p25TXLevel;
int m_oscOffset;
2017-02-20 21:36:35 +00:00
std::string m_samplesDir;
2016-01-14 18:45:04 +00:00
bool m_debug;
unsigned int m_rxFrequency;
unsigned int m_txFrequency;
2016-01-14 18:45:04 +00:00
bool m_dstarEnabled;
bool m_dmrEnabled;
bool m_ysfEnabled;
2016-09-08 17:38:59 +00:00
bool m_p25Enabled;
2016-01-14 18:45:04 +00:00
CSerialController m_serial;
unsigned char* m_buffer;
unsigned int m_length;
unsigned int m_offset;
2016-01-14 18:45:04 +00:00
CRingBuffer<unsigned char> m_rxDStarData;
CRingBuffer<unsigned char> m_txDStarData;
CRingBuffer<unsigned char> m_rxDMRData1;
CRingBuffer<unsigned char> m_rxDMRData2;
CRingBuffer<unsigned char> m_txDMRData1;
CRingBuffer<unsigned char> m_txDMRData2;
CRingBuffer<unsigned char> m_rxYSFData;
CRingBuffer<unsigned char> m_txYSFData;
2016-09-08 17:38:59 +00:00
CRingBuffer<unsigned char> m_rxP25Data;
CRingBuffer<unsigned char> m_txP25Data;
2016-01-14 18:45:04 +00:00
CTimer m_statusTimer;
CTimer m_inactivityTimer;
CTimer m_playoutTimer;
2016-01-14 18:45:04 +00:00
unsigned int m_dstarSpace;
unsigned int m_dmrSpace1;
unsigned int m_dmrSpace2;
unsigned int m_ysfSpace;
2016-09-08 17:38:59 +00:00
unsigned int m_p25Space;
2016-01-14 18:45:04 +00:00
bool m_tx;
2016-11-17 10:48:42 +00:00
bool m_cd;
2016-03-03 18:01:01 +00:00
bool m_lockout;
2016-03-21 22:47:58 +00:00
bool m_error;
HW_TYPE m_hwType;
2016-01-14 18:45:04 +00:00
bool readVersion();
bool readStatus();
bool setConfig();
bool setFrequency();
2016-01-14 18:45:04 +00:00
void printDebug();
2017-02-20 21:36:35 +00:00
void dumpSamples();
2016-01-14 18:45:04 +00:00
RESP_TYPE_MMDVM getResponse();
2016-01-14 18:45:04 +00:00
};
#endif