2016-01-27 20:01:50 +00:00
|
|
|
/*
|
2017-01-05 19:15:10 +00:00
|
|
|
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
2016-01-27 20:01:50 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(DStarControl_H)
|
|
|
|
#define DStarControl_H
|
|
|
|
|
2017-01-05 19:15:10 +00:00
|
|
|
#include "RSSIInterpolator.h"
|
2016-01-27 20:01:50 +00:00
|
|
|
#include "DStarNetwork.h"
|
|
|
|
#include "DStarSlowData.h"
|
|
|
|
#include "DStarDefines.h"
|
|
|
|
#include "DStarHeader.h"
|
|
|
|
#include "RingBuffer.h"
|
2016-03-14 20:55:15 +00:00
|
|
|
#include "StopWatch.h"
|
2016-01-27 20:01:50 +00:00
|
|
|
#include "AMBEFEC.h"
|
|
|
|
#include "Display.h"
|
|
|
|
#include "Defines.h"
|
|
|
|
#include "Timer.h"
|
|
|
|
#include "Modem.h"
|
|
|
|
|
|
|
|
#include <string>
|
2016-04-06 17:46:05 +00:00
|
|
|
#include <vector>
|
2016-01-27 20:01:50 +00:00
|
|
|
|
|
|
|
class CDStarControl {
|
|
|
|
public:
|
2018-09-14 10:30:48 +00:00
|
|
|
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper);
|
2016-01-27 20:01:50 +00:00
|
|
|
~CDStarControl();
|
|
|
|
|
2016-08-08 20:26:18 +00:00
|
|
|
bool writeModem(unsigned char* data, unsigned int len);
|
2016-01-27 20:01:50 +00:00
|
|
|
|
|
|
|
unsigned int readModem(unsigned char* data);
|
|
|
|
|
2016-03-14 20:55:15 +00:00
|
|
|
void clock();
|
2016-01-27 20:01:50 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned char* m_callsign;
|
|
|
|
unsigned char* m_gateway;
|
2016-04-04 16:40:05 +00:00
|
|
|
bool m_selfOnly;
|
2017-06-10 12:18:18 +00:00
|
|
|
bool m_ackReply;
|
2018-09-14 10:30:48 +00:00
|
|
|
bool m_ackMessage;
|
2018-09-14 17:16:17 +00:00
|
|
|
bool m_errorReply;
|
2017-11-09 09:21:22 +00:00
|
|
|
bool m_remoteGateway;
|
2016-04-06 17:46:05 +00:00
|
|
|
std::vector<std::string> m_blackList;
|
2016-01-27 20:01:50 +00:00
|
|
|
CDStarNetwork* m_network;
|
2016-05-09 17:14:27 +00:00
|
|
|
CDisplay* m_display;
|
2016-01-27 20:01:50 +00:00
|
|
|
bool m_duplex;
|
2016-03-07 18:08:50 +00:00
|
|
|
CRingBuffer<unsigned char> m_queue;
|
2016-02-25 19:54:18 +00:00
|
|
|
CDStarHeader m_rfHeader;
|
|
|
|
CDStarHeader m_netHeader;
|
|
|
|
RPT_RF_STATE m_rfState;
|
|
|
|
RPT_NET_STATE m_netState;
|
2016-01-27 20:01:50 +00:00
|
|
|
bool m_net;
|
|
|
|
CDStarSlowData m_slowData;
|
2016-02-28 17:18:13 +00:00
|
|
|
unsigned char m_rfN;
|
|
|
|
unsigned char m_netN;
|
2016-01-27 20:01:50 +00:00
|
|
|
CTimer m_networkWatchdog;
|
2016-02-25 19:54:18 +00:00
|
|
|
CTimer m_rfTimeoutTimer;
|
|
|
|
CTimer m_netTimeoutTimer;
|
2016-07-15 05:32:56 +00:00
|
|
|
CTimer m_packetTimer;
|
2016-02-01 20:49:52 +00:00
|
|
|
CTimer m_ackTimer;
|
2017-02-16 19:49:58 +00:00
|
|
|
CTimer m_errTimer;
|
2016-03-14 20:55:15 +00:00
|
|
|
CStopWatch m_interval;
|
2016-01-27 20:01:50 +00:00
|
|
|
CStopWatch m_elapsed;
|
2016-02-25 19:54:18 +00:00
|
|
|
unsigned int m_rfFrames;
|
|
|
|
unsigned int m_netFrames;
|
|
|
|
unsigned int m_netLost;
|
2016-01-27 20:01:50 +00:00
|
|
|
CAMBEFEC m_fec;
|
2016-02-25 19:54:18 +00:00
|
|
|
unsigned int m_rfBits;
|
|
|
|
unsigned int m_netBits;
|
|
|
|
unsigned int m_rfErrs;
|
|
|
|
unsigned int m_netErrs;
|
2016-01-27 20:01:50 +00:00
|
|
|
unsigned char* m_lastFrame;
|
2016-07-21 17:09:29 +00:00
|
|
|
bool m_lastFrameValid;
|
2017-01-05 19:15:10 +00:00
|
|
|
CRSSIInterpolator* m_rssiMapper;
|
|
|
|
unsigned char m_rssi;
|
|
|
|
unsigned char m_maxRSSI;
|
|
|
|
unsigned char m_minRSSI;
|
|
|
|
unsigned int m_aveRSSI;
|
|
|
|
unsigned int m_rssiCount;
|
2016-01-27 20:01:50 +00:00
|
|
|
FILE* m_fp;
|
|
|
|
|
|
|
|
void writeNetwork();
|
|
|
|
|
2016-02-25 19:54:18 +00:00
|
|
|
void writeQueueHeaderRF(const unsigned char* data);
|
|
|
|
void writeQueueDataRF(const unsigned char* data);
|
|
|
|
void writeQueueEOTRF();
|
|
|
|
void writeQueueHeaderNet(const unsigned char* data);
|
|
|
|
void writeQueueDataNet(const unsigned char* data);
|
|
|
|
void writeQueueEOTNet();
|
|
|
|
void writeNetworkHeaderRF(const unsigned char* data);
|
|
|
|
void writeNetworkDataRF(const unsigned char* data, unsigned int errors, bool end);
|
|
|
|
|
|
|
|
void writeEndRF();
|
|
|
|
void writeEndNet();
|
2016-01-27 20:01:50 +00:00
|
|
|
|
|
|
|
bool openFile();
|
|
|
|
bool writeFile(const unsigned char* data, unsigned int length);
|
|
|
|
void closeFile();
|
|
|
|
|
2016-07-12 06:05:48 +00:00
|
|
|
bool insertSilence(const unsigned char* data, unsigned char seqNo);
|
2016-01-27 20:01:50 +00:00
|
|
|
void insertSilence(unsigned int count);
|
|
|
|
|
|
|
|
void blankDTMF(unsigned char* data) const;
|
2016-02-01 20:49:52 +00:00
|
|
|
|
|
|
|
void sendAck();
|
2017-02-16 19:49:58 +00:00
|
|
|
void sendError();
|
2016-01-27 20:01:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|