2016-01-14 18:45:04 +00:00
|
|
|
/*
|
2020-04-09 21:55:20 +00:00
|
|
|
* Copyright (C) 2011-2018,2020 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
|
|
|
|
|
2020-05-23 15:49:21 +00:00
|
|
|
#include "SerialPort.h"
|
2016-01-14 18:45:04 +00:00
|
|
|
#include "RingBuffer.h"
|
2016-09-05 16:40:43 +00:00
|
|
|
#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:
|
2018-07-30 13:58:35 +00:00
|
|
|
CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug);
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual ~CModem();
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2020-05-23 12:03:55 +00:00
|
|
|
virtual void setSerialParams(const std::string& protocol, unsigned int address, unsigned int speed);
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency);
|
2020-04-12 14:10:51 +00:00
|
|
|
virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled, bool fmEnabled);
|
2020-04-24 11:59:33 +00:00
|
|
|
virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel, float fmTXLevel);
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual void setDMRParams(unsigned int colorCode);
|
|
|
|
virtual void setYSFParams(bool loDev, unsigned int txHang);
|
2020-05-06 16:10:23 +00:00
|
|
|
virtual void setP25Params(unsigned int txHang);
|
|
|
|
virtual void setNXDNParams(unsigned int txHang);
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual void setTransparentDataParams(unsigned int sendFrameType);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2020-05-04 21:30:16 +00:00
|
|
|
virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch);
|
2020-04-18 13:59:19 +00:00
|
|
|
virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel);
|
2020-05-12 12:43:43 +00:00
|
|
|
virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel);
|
2020-05-07 20:49:18 +00:00
|
|
|
virtual void setFMExtParams(const std::string& ack, unsigned int audioBoost);
|
2020-04-09 21:55:20 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool open();
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual unsigned int readDStarData(unsigned char* data);
|
|
|
|
virtual unsigned int readDMRData1(unsigned char* data);
|
|
|
|
virtual unsigned int readDMRData2(unsigned char* data);
|
|
|
|
virtual unsigned int readYSFData(unsigned char* data);
|
|
|
|
virtual unsigned int readP25Data(unsigned char* data);
|
|
|
|
virtual unsigned int readNXDNData(unsigned char* data);
|
2020-05-07 15:08:58 +00:00
|
|
|
virtual unsigned int readFMData(unsigned char* data);
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual unsigned int readTransparentData(unsigned char* data);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual unsigned int readSerial(unsigned char* data, unsigned int length);
|
2016-10-06 17:38:16 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool hasDStarSpace() const;
|
|
|
|
virtual bool hasDMRSpace1() const;
|
|
|
|
virtual bool hasDMRSpace2() const;
|
|
|
|
virtual bool hasYSFSpace() const;
|
|
|
|
virtual bool hasP25Space() const;
|
|
|
|
virtual bool hasNXDNSpace() const;
|
|
|
|
virtual bool hasPOCSAGSpace() const;
|
2020-05-07 15:08:58 +00:00
|
|
|
virtual unsigned int getFMSpace() const;
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool hasTX() const;
|
|
|
|
virtual bool hasCD() const;
|
2016-05-05 16:56:18 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool hasLockout() const;
|
|
|
|
virtual bool hasError() const;
|
2016-03-03 18:01:01 +00:00
|
|
|
|
2020-05-02 20:40:55 +00:00
|
|
|
virtual bool writeConfig();
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool writeDStarData(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeDMRData1(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeDMRData2(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeYSFData(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeP25Data(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeNXDNData(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writePOCSAGData(const unsigned char* data, unsigned int length);
|
2020-05-07 15:08:58 +00:00
|
|
|
virtual bool writeFMData(const unsigned char* data, unsigned int length);
|
2018-10-31 15:38:56 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool writeTransparentData(const unsigned char* data, unsigned int length);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool writeDStarInfo(const char* my1, const char* my2, const char* your, const char* type, const char* reflector);
|
|
|
|
virtual bool writeDMRInfo(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
|
|
|
|
virtual bool writeYSFInfo(const char* source, const char* dest, const char* type, const char* origin);
|
|
|
|
virtual bool writeP25Info(const char* source, bool group, unsigned int dest, const char* type);
|
|
|
|
virtual bool writeNXDNInfo(const char* source, bool group, unsigned int dest, const char* type);
|
|
|
|
virtual bool writePOCSAGInfo(unsigned int ric, const std::string& message);
|
|
|
|
virtual bool writeIPInfo(const std::string& address);
|
2018-10-31 15:38:56 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool writeDMRStart(bool tx);
|
|
|
|
virtual bool writeDMRShortLC(const unsigned char* lc);
|
|
|
|
virtual bool writeDMRAbort(unsigned int slotNo);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool writeSerial(const unsigned char* data, unsigned int length);
|
2016-10-06 17:38:16 +00:00
|
|
|
|
2020-04-11 19:42:05 +00:00
|
|
|
virtual unsigned char getMode() const;
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool setMode(unsigned char mode);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual bool sendCWId(const std::string& callsign);
|
2016-05-09 20:55:44 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual HW_TYPE getHWType() const;
|
2016-09-05 16:40:43 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual void clock(unsigned int ms);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2018-12-07 09:36:11 +00:00
|
|
|
virtual void close();
|
|
|
|
|
|
|
|
static CModem* createModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_port;
|
2017-03-23 20:26:17 +00:00
|
|
|
unsigned int m_dmrColorCode;
|
|
|
|
bool m_ysfLoDev;
|
2018-05-21 20:32:33 +00:00
|
|
|
unsigned int m_ysfTXHang;
|
2020-05-06 16:10:23 +00:00
|
|
|
unsigned int m_p25TXHang;
|
|
|
|
unsigned int m_nxdnTXHang;
|
2016-06-22 19:42:14 +00:00
|
|
|
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;
|
2017-06-02 15:34:55 +00:00
|
|
|
float m_rxLevel;
|
|
|
|
float m_cwIdTXLevel;
|
|
|
|
float m_dstarTXLevel;
|
|
|
|
float m_dmrTXLevel;
|
|
|
|
float m_ysfTXLevel;
|
|
|
|
float m_p25TXLevel;
|
2018-01-11 19:35:33 +00:00
|
|
|
float m_nxdnTXLevel;
|
2018-06-07 17:46:03 +00:00
|
|
|
float m_pocsagTXLevel;
|
2020-04-12 14:10:51 +00:00
|
|
|
float m_fmTXLevel;
|
2017-12-30 15:05:11 +00:00
|
|
|
float m_rfLevel;
|
2017-04-14 13:05:30 +00:00
|
|
|
bool m_trace;
|
2016-01-14 18:45:04 +00:00
|
|
|
bool m_debug;
|
2016-02-18 17:37:23 +00:00
|
|
|
unsigned int m_rxFrequency;
|
|
|
|
unsigned int m_txFrequency;
|
2018-06-12 18:40:49 +00:00
|
|
|
unsigned int m_pocsagFrequency;
|
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;
|
2018-01-11 19:35:33 +00:00
|
|
|
bool m_nxdnEnabled;
|
2018-06-07 17:46:03 +00:00
|
|
|
bool m_pocsagEnabled;
|
2020-04-12 14:10:51 +00:00
|
|
|
bool m_fmEnabled;
|
2017-10-28 11:37:32 +00:00
|
|
|
int m_rxDCOffset;
|
2017-08-20 11:07:57 +00:00
|
|
|
int m_txDCOffset;
|
2020-05-23 15:49:21 +00:00
|
|
|
ISerialPort* m_serial;
|
2016-01-14 18:45:04 +00:00
|
|
|
unsigned char* m_buffer;
|
2016-03-21 18:16:58 +00:00
|
|
|
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;
|
2018-01-11 19:35:33 +00:00
|
|
|
CRingBuffer<unsigned char> m_rxNXDNData;
|
|
|
|
CRingBuffer<unsigned char> m_txNXDNData;
|
2018-06-07 17:46:03 +00:00
|
|
|
CRingBuffer<unsigned char> m_txPOCSAGData;
|
2020-05-07 15:08:58 +00:00
|
|
|
CRingBuffer<unsigned char> m_rxFMData;
|
|
|
|
CRingBuffer<unsigned char> m_txFMData;
|
2018-03-22 07:13:13 +00:00
|
|
|
CRingBuffer<unsigned char> m_rxTransparentData;
|
|
|
|
CRingBuffer<unsigned char> m_txTransparentData;
|
2018-09-13 18:35:12 +00:00
|
|
|
unsigned int m_sendTransparentDataFrameType;
|
2016-01-14 18:45:04 +00:00
|
|
|
CTimer m_statusTimer;
|
2016-02-16 17:31:28 +00:00
|
|
|
CTimer m_inactivityTimer;
|
2016-03-31 10:42:12 +00:00
|
|
|
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;
|
2018-01-11 19:35:33 +00:00
|
|
|
unsigned int m_nxdnSpace;
|
2018-06-07 17:46:03 +00:00
|
|
|
unsigned int m_pocsagSpace;
|
2020-05-07 15:08:58 +00:00
|
|
|
unsigned int m_fmSpace;
|
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;
|
2020-04-11 19:42:05 +00:00
|
|
|
unsigned char m_mode;
|
2016-09-05 16:40:43 +00:00
|
|
|
HW_TYPE m_hwType;
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2020-04-18 13:59:19 +00:00
|
|
|
std::string m_fmCallsign;
|
|
|
|
unsigned int m_fmCallsignSpeed;
|
|
|
|
unsigned int m_fmCallsignFrequency;
|
|
|
|
unsigned int m_fmCallsignTime;
|
|
|
|
unsigned int m_fmCallsignHoldoff;
|
2020-04-22 20:51:43 +00:00
|
|
|
float m_fmCallsignHighLevel;
|
|
|
|
float m_fmCallsignLowLevel;
|
2020-04-18 13:59:19 +00:00
|
|
|
bool m_fmCallsignAtStart;
|
|
|
|
bool m_fmCallsignAtEnd;
|
2020-05-04 21:30:16 +00:00
|
|
|
bool m_fmCallsignAtLatch;
|
2020-04-18 13:59:19 +00:00
|
|
|
std::string m_fmRfAck;
|
2020-05-07 20:49:18 +00:00
|
|
|
std::string m_fmExtAck;
|
2020-04-18 13:59:19 +00:00
|
|
|
unsigned int m_fmAckSpeed;
|
|
|
|
unsigned int m_fmAckFrequency;
|
|
|
|
unsigned int m_fmAckMinTime;
|
|
|
|
unsigned int m_fmAckDelay;
|
|
|
|
float m_fmAckLevel;
|
|
|
|
unsigned int m_fmTimeout;
|
|
|
|
float m_fmTimeoutLevel;
|
|
|
|
float m_fmCtcssFrequency;
|
2020-05-12 12:43:43 +00:00
|
|
|
unsigned int m_fmCtcssHighThreshold;
|
|
|
|
unsigned int m_fmCtcssLowThreshold;
|
2020-04-18 13:59:19 +00:00
|
|
|
float m_fmCtcssLevel;
|
|
|
|
unsigned int m_fmKerchunkTime;
|
|
|
|
unsigned int m_fmHangTime;
|
2020-04-25 14:15:56 +00:00
|
|
|
bool m_fmUseCOS;
|
2020-05-06 10:26:54 +00:00
|
|
|
bool m_fmCOSInvert;
|
2020-04-28 13:39:14 +00:00
|
|
|
unsigned int m_fmRFAudioBoost;
|
2020-05-07 20:49:18 +00:00
|
|
|
unsigned int m_fmExtAudioBoost;
|
2020-04-25 21:43:14 +00:00
|
|
|
float m_fmMaxDevLevel;
|
2020-05-07 20:49:18 +00:00
|
|
|
bool m_fmExtEnable;
|
2020-04-18 13:59:19 +00:00
|
|
|
|
2016-01-14 18:45:04 +00:00
|
|
|
bool readVersion();
|
|
|
|
bool readStatus();
|
|
|
|
bool setConfig();
|
2016-02-18 17:37:23 +00:00
|
|
|
bool setFrequency();
|
2020-04-18 13:59:19 +00:00
|
|
|
bool setFMCallsignParams();
|
|
|
|
bool setFMAckParams();
|
|
|
|
bool setFMMiscParams();
|
2020-05-07 20:49:18 +00:00
|
|
|
bool setFMExtParams();
|
2016-01-14 18:45:04 +00:00
|
|
|
|
|
|
|
void printDebug();
|
|
|
|
|
2016-03-21 18:16:58 +00:00
|
|
|
RESP_TYPE_MMDVM getResponse();
|
2016-01-14 18:45:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|