2016-01-14 18:45:04 +00:00
|
|
|
/*
|
2021-02-16 22:34:25 +00:00
|
|
|
* Copyright (C) 2011-2018,2020,2021 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.
|
|
|
|
*/
|
|
|
|
|
2021-02-17 21:36:47 +00:00
|
|
|
#ifndef Modem_H
|
|
|
|
#define Modem_H
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2021-02-17 21:36:47 +00:00
|
|
|
#include "ModemPort.h"
|
|
|
|
#include "RingBuffer.h"
|
2016-09-05 16:40:43 +00:00
|
|
|
#include "Defines.h"
|
2021-02-17 21:36:47 +00:00
|
|
|
#include "Timer.h"
|
2016-01-14 18:45:04 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2021-02-17 21:36:47 +00:00
|
|
|
enum RESP_TYPE_MMDVM {
|
|
|
|
RTM_OK,
|
|
|
|
RTM_TIMEOUT,
|
|
|
|
RTM_ERROR
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SERIAL_STATE {
|
|
|
|
SS_START,
|
|
|
|
SS_LENGTH1,
|
|
|
|
SS_LENGTH2,
|
|
|
|
SS_TYPE,
|
|
|
|
SS_DATA
|
|
|
|
};
|
|
|
|
|
|
|
|
class CModem {
|
2016-01-14 18:45:04 +00:00
|
|
|
public:
|
2021-02-17 21:36:47 +00:00
|
|
|
CModem(bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool useCOSAsLockout, bool trace, bool debug);
|
|
|
|
~CModem();
|
|
|
|
|
|
|
|
void setPort(IModemPort* port);
|
2022-07-29 16:49:08 +00:00
|
|
|
void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel);
|
2021-02-17 21:36:47 +00:00
|
|
|
void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool m17Enabled, bool pocsagEnabled, bool fmEnabled, bool ax25Enabled);
|
2022-07-29 16:49:08 +00:00
|
|
|
void setLevels(float rxLevel, float cwIdTXLevel, float dmrTXLevel);
|
2021-02-17 21:36:47 +00:00
|
|
|
void setDMRParams(unsigned int colorCode);
|
|
|
|
void setYSFParams(bool loDev, unsigned int txHang);
|
|
|
|
void setP25Params(unsigned int txHang);
|
|
|
|
void setNXDNParams(unsigned int txHang);
|
|
|
|
void setM17Params(unsigned int txHang);
|
|
|
|
void setAX25Params(int rxTwist, unsigned int txDelay, unsigned int slotTime, unsigned int pPersist);
|
|
|
|
void setTransparentDataParams(unsigned int sendFrameType);
|
|
|
|
|
|
|
|
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);
|
|
|
|
void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel);
|
2021-09-06 20:47:23 +00:00
|
|
|
void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, unsigned int accessMode, bool linkMode, bool cosInvert, bool noiseSquelch, unsigned int squelchHighThreshold, unsigned int squelchLowThreshold, unsigned int rfAudioBoost, float maxDevLevel);
|
2021-02-17 21:36:47 +00:00
|
|
|
void setFMExtParams(const std::string& ack, unsigned int audioBoost);
|
|
|
|
|
|
|
|
bool open();
|
|
|
|
|
2021-05-08 18:34:44 +00:00
|
|
|
bool hasDStar() const;
|
|
|
|
bool hasDMR() const;
|
|
|
|
bool hasYSF() const;
|
|
|
|
bool hasP25() const;
|
|
|
|
bool hasNXDN() const;
|
|
|
|
bool hasM17() const;
|
|
|
|
bool hasPOCSAG() const;
|
|
|
|
bool hasFM() const;
|
|
|
|
bool hasAX25() const;
|
|
|
|
|
|
|
|
unsigned int getVersion() const;
|
|
|
|
|
2021-02-17 21:36:47 +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);
|
|
|
|
unsigned int readP25Data(unsigned char* data);
|
|
|
|
unsigned int readNXDNData(unsigned char* data);
|
|
|
|
unsigned int readM17Data(unsigned char* data);
|
|
|
|
unsigned int readFMData(unsigned char* data);
|
|
|
|
unsigned int readAX25Data(unsigned char* data);
|
|
|
|
|
|
|
|
bool hasDStarSpace() const;
|
|
|
|
bool hasDMRSpace1() const;
|
|
|
|
bool hasDMRSpace2() const;
|
|
|
|
bool hasYSFSpace() const;
|
|
|
|
bool hasP25Space() const;
|
|
|
|
bool hasNXDNSpace() const;
|
|
|
|
bool hasM17Space() const;
|
|
|
|
bool hasPOCSAGSpace() const;
|
|
|
|
unsigned int getFMSpace() const;
|
|
|
|
bool hasAX25Space() const;
|
|
|
|
|
|
|
|
bool hasTX() const;
|
|
|
|
bool hasCD() const;
|
|
|
|
|
|
|
|
bool hasLockout() const;
|
|
|
|
bool hasError() const;
|
|
|
|
|
|
|
|
bool writeConfig();
|
|
|
|
bool writeDMRData1(const unsigned char* data, unsigned int length);
|
|
|
|
bool writeDMRData2(const unsigned char* data, unsigned int length);
|
|
|
|
bool writeDMRInfo(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
|
|
|
|
bool writeIPInfo(const std::string& address);
|
|
|
|
|
|
|
|
bool writeDMRStart(bool tx);
|
|
|
|
bool writeDMRShortLC(const unsigned char* lc);
|
|
|
|
bool writeDMRAbort(unsigned int slotNo);
|
|
|
|
|
|
|
|
bool writeTransparentData(const unsigned char* data, unsigned int length);
|
|
|
|
unsigned int readTransparentData(unsigned char* data);
|
|
|
|
|
|
|
|
bool writeSerial(const unsigned char* data, unsigned int length);
|
|
|
|
unsigned int readSerial(unsigned char* data, unsigned int length);
|
|
|
|
|
|
|
|
unsigned char getMode() const;
|
|
|
|
bool setMode(unsigned char mode);
|
|
|
|
|
|
|
|
bool sendCWId(const std::string& callsign);
|
|
|
|
|
|
|
|
HW_TYPE getHWType() const;
|
|
|
|
|
|
|
|
void clock(unsigned int ms);
|
|
|
|
|
|
|
|
void close();
|
2016-01-14 18:45:04 +00:00
|
|
|
|
|
|
|
private:
|
2021-02-17 21:36:47 +00:00
|
|
|
unsigned int m_protocolVersion;
|
|
|
|
unsigned int m_dmrColorCode;
|
|
|
|
bool m_duplex;
|
|
|
|
bool m_rxInvert;
|
|
|
|
bool m_txInvert;
|
|
|
|
bool m_pttInvert;
|
|
|
|
unsigned int m_txDelay;
|
|
|
|
unsigned int m_dmrDelay;
|
|
|
|
float m_rxLevel;
|
|
|
|
float m_cwIdTXLevel;
|
|
|
|
float m_dmrTXLevel;
|
|
|
|
float m_rfLevel;
|
|
|
|
bool m_useCOSAsLockout;
|
|
|
|
bool m_trace;
|
|
|
|
bool m_debug;
|
|
|
|
unsigned int m_rxFrequency;
|
|
|
|
unsigned int m_txFrequency;
|
|
|
|
bool m_dstarEnabled;
|
|
|
|
bool m_dmrEnabled;
|
|
|
|
int m_rxDCOffset;
|
|
|
|
int m_txDCOffset;
|
|
|
|
IModemPort* m_port;
|
|
|
|
unsigned char* m_buffer;
|
|
|
|
unsigned int m_length;
|
|
|
|
unsigned int m_offset;
|
|
|
|
SERIAL_STATE m_state;
|
|
|
|
unsigned char m_type;
|
|
|
|
CRingBuffer<unsigned char> m_rxDMRData1;
|
|
|
|
CRingBuffer<unsigned char> m_rxDMRData2;
|
|
|
|
CRingBuffer<unsigned char> m_txDMRData1;
|
|
|
|
CRingBuffer<unsigned char> m_txDMRData2;
|
|
|
|
CRingBuffer<unsigned char> m_rxSerialData;
|
|
|
|
CRingBuffer<unsigned char> m_txSerialData;
|
|
|
|
CRingBuffer<unsigned char> m_rxTransparentData;
|
|
|
|
CRingBuffer<unsigned char> m_txTransparentData;
|
|
|
|
unsigned int m_sendTransparentDataFrameType;
|
|
|
|
CTimer m_statusTimer;
|
|
|
|
CTimer m_inactivityTimer;
|
|
|
|
CTimer m_playoutTimer;
|
|
|
|
unsigned int m_dmrSpace1;
|
|
|
|
unsigned int m_dmrSpace2;
|
|
|
|
bool m_tx;
|
|
|
|
bool m_cd;
|
|
|
|
bool m_lockout;
|
|
|
|
bool m_error;
|
|
|
|
unsigned char m_mode;
|
|
|
|
HW_TYPE m_hwType;
|
2021-05-08 18:34:44 +00:00
|
|
|
unsigned char m_capabilities1;
|
|
|
|
unsigned char m_capabilities2;
|
2021-02-17 21:36:47 +00:00
|
|
|
|
|
|
|
bool readVersion();
|
|
|
|
bool readStatus();
|
|
|
|
bool setConfig1();
|
|
|
|
bool setConfig2();
|
|
|
|
bool setFrequency();
|
|
|
|
bool setFMCallsignParams();
|
|
|
|
bool setFMAckParams();
|
|
|
|
bool setFMMiscParams();
|
|
|
|
bool setFMExtParams();
|
|
|
|
|
|
|
|
void printDebug();
|
|
|
|
|
|
|
|
RESP_TYPE_MMDVM getResponse();
|
2016-01-14 18:45:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|