forked from BrandMeister/DMRHost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Modem.h
144 lines (119 loc) · 5.07 KB
/
Modem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Copyright (C) 2011-2018,2020 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.
*/
#pragma once
#include "SerialController.h"
#include "RingBuffer.h"
#include "Defines.h"
#include "Timer.h"
#include <string>
enum RESP_TYPE_MMDVM {
RTM_OK,
RTM_TIMEOUT,
RTM_ERROR
};
class CModem {
public:
CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug);
virtual ~CModem();
virtual void setSerialParams(const std::string& protocol, unsigned int address);
virtual void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency);
virtual void setModeParams(bool dmrEnabled, bool pocsagEnabled);
virtual void setLevels(float rxLevel, float cwIdTXLevel, float dmrTXLevel, float pocsagLevel);
virtual void setDMRParams(unsigned int colorCode);
virtual void setTransparentDataParams(unsigned int sendFrameType);
virtual bool open();
virtual bool hasDMR() const;
virtual bool hasPOCSAG() const;
virtual unsigned int readDMRData1(unsigned char* data);
virtual unsigned int readDMRData2(unsigned char* data);
virtual unsigned int readTransparentData(unsigned char* data);
virtual bool hasDMRSpace1() const;
virtual bool hasDMRSpace2() const;
virtual bool hasPOCSAGSpace() const;
virtual bool hasTX() const;
virtual bool hasError() const;
virtual bool writeConfig();
virtual bool writeDMRData1(const unsigned char* data, unsigned int length);
virtual bool writeDMRData2(const unsigned char* data, unsigned int length);
virtual bool writePOCSAGData(const unsigned char* data, unsigned int length);
virtual bool writeTransparentData(const unsigned char* data, unsigned int length);
virtual bool writeDMRStart(bool tx);
virtual bool writeDMRShortLC(const unsigned char* lc);
virtual bool writeDMRAbort(unsigned int slotNo);
virtual bool setMode(unsigned char mode);
virtual bool sendCWId(const std::string& callsign);
virtual const char* getHWType() const;
virtual void clock(unsigned int ms);
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);
private:
std::string m_port;
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_pocsagTXLevel;
float m_rfLevel;
bool m_trace;
bool m_debug;
unsigned int m_rxFrequency;
unsigned int m_txFrequency;
unsigned int m_pocsagFrequency;
bool m_dmrEnabled;
bool m_pocsagEnabled;
int m_rxDCOffset;
int m_txDCOffset;
CSerialController* m_serial;
unsigned char* m_buffer;
unsigned int m_length;
unsigned int m_offset;
CRingBuffer<unsigned char> m_rxDMRData1;
CRingBuffer<unsigned char> m_rxDMRData2;
CRingBuffer<unsigned char> m_txDMRData1;
CRingBuffer<unsigned char> m_txDMRData2;
CRingBuffer<unsigned char> m_txPOCSAGData;
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;
unsigned int m_pocsagSpace;
bool m_tx;
bool m_error;
unsigned char m_mode;
const char* m_hwType;
unsigned char m_capabilities1;
unsigned char m_capabilities2;
bool readVersion();
bool readStatus();
bool setConfig1();
bool setConfig2();
bool setFrequency();
void printDebug();
RESP_TYPE_MMDVM getResponse();
};