2016-01-27 20:01:50 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015,2016 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(DStarControl_H)
|
|
|
|
#define DStarControl_H
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
|
|
|
class CDStarControl {
|
|
|
|
public:
|
2016-04-04 16:40:05 +00:00
|
|
|
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, CDStarNetwork* network, IDisplay* display, unsigned int timeout, bool duplex);
|
2016-01-27 20:01:50 +00:00
|
|
|
~CDStarControl();
|
|
|
|
|
2016-02-02 18:17:36 +00:00
|
|
|
bool writeModem(unsigned char* data);
|
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;
|
2016-01-27 20:01:50 +00:00
|
|
|
CDStarNetwork* m_network;
|
|
|
|
IDisplay* m_display;
|
|
|
|
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;
|
|
|
|
CTimer m_holdoffTimer;
|
2016-02-25 19:54:18 +00:00
|
|
|
CTimer m_rfTimeoutTimer;
|
|
|
|
CTimer m_netTimeoutTimer;
|
2016-01-27 20:01:50 +00:00
|
|
|
CTimer m_packetTimer;
|
2016-02-01 20:49:52 +00:00
|
|
|
CTimer m_ackTimer;
|
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;
|
|
|
|
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();
|
|
|
|
|
|
|
|
void insertSilence(const unsigned char* data, unsigned char seqNo);
|
|
|
|
void insertSilence(unsigned int count);
|
|
|
|
|
|
|
|
void blankDTMF(unsigned char* data) const;
|
2016-02-01 20:49:52 +00:00
|
|
|
|
|
|
|
void sendAck();
|
2016-01-27 20:01:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|