2016-09-08 20:27:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 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(P25Control_H)
|
|
|
|
#define P25Control_H
|
|
|
|
|
2016-09-20 05:53:30 +00:00
|
|
|
#include "P25LowSpeedData.h"
|
2016-09-08 20:27:21 +00:00
|
|
|
#include "RingBuffer.h"
|
2016-09-14 06:41:37 +00:00
|
|
|
#include "P25Network.h"
|
2016-09-12 22:26:05 +00:00
|
|
|
#include "DMRLookup.h"
|
|
|
|
#include "P25Audio.h"
|
2016-09-08 20:27:21 +00:00
|
|
|
#include "Defines.h"
|
|
|
|
#include "Display.h"
|
2016-09-12 22:26:05 +00:00
|
|
|
#include "P25Data.h"
|
|
|
|
#include "P25NID.h"
|
2016-09-08 20:27:21 +00:00
|
|
|
#include "Modem.h"
|
|
|
|
#include "Timer.h"
|
|
|
|
|
2016-09-15 19:28:56 +00:00
|
|
|
#include <cstdio>
|
|
|
|
|
2016-09-08 20:27:21 +00:00
|
|
|
class CP25Control {
|
|
|
|
public:
|
2016-09-27 18:55:36 +00:00
|
|
|
CP25Control(unsigned int nac, CP25Network* network, CDisplay* display, unsigned int timeout, bool duplex, CDMRLookup* lookup);
|
2016-09-08 20:27:21 +00:00
|
|
|
~CP25Control();
|
|
|
|
|
|
|
|
bool writeModem(unsigned char* data, unsigned int len);
|
|
|
|
|
|
|
|
unsigned int readModem(unsigned char* data);
|
|
|
|
|
|
|
|
void clock(unsigned int ms);
|
|
|
|
|
|
|
|
private:
|
2016-09-20 17:46:28 +00:00
|
|
|
unsigned int m_nac;
|
|
|
|
CP25Network* m_network;
|
|
|
|
CDisplay* m_display;
|
|
|
|
bool m_duplex;
|
|
|
|
CDMRLookup* m_lookup;
|
2016-09-08 20:27:21 +00:00
|
|
|
CRingBuffer<unsigned char> m_queue;
|
2016-09-20 17:46:28 +00:00
|
|
|
RPT_RF_STATE m_rfState;
|
|
|
|
RPT_NET_STATE m_netState;
|
|
|
|
CTimer m_rfTimeout;
|
|
|
|
CTimer m_netTimeout;
|
|
|
|
CTimer m_networkWatchdog;
|
|
|
|
unsigned int m_rfFrames;
|
|
|
|
unsigned int m_rfBits;
|
|
|
|
unsigned int m_rfErrs;
|
|
|
|
unsigned int m_netFrames;
|
|
|
|
unsigned int m_netLost;
|
|
|
|
CP25NID m_nid;
|
|
|
|
unsigned char m_lastDUID;
|
|
|
|
CP25Audio m_audio;
|
|
|
|
CP25Data m_rfData;
|
|
|
|
CP25Data m_netData;
|
2016-09-22 18:39:19 +00:00
|
|
|
CP25LowSpeedData m_rfLSD;
|
|
|
|
CP25LowSpeedData m_netLSD;
|
2016-09-20 17:46:28 +00:00
|
|
|
unsigned char* m_netLDU1;
|
|
|
|
unsigned char* m_netLDU2;
|
2016-09-27 18:26:24 +00:00
|
|
|
unsigned char* m_lastIMBE;
|
2016-09-28 06:53:45 +00:00
|
|
|
unsigned char* m_rfLDU;
|
2016-09-20 17:46:28 +00:00
|
|
|
FILE* m_fp;
|
2016-09-08 20:27:21 +00:00
|
|
|
|
|
|
|
void writeQueueRF(const unsigned char* data, unsigned int length);
|
2016-09-15 19:28:56 +00:00
|
|
|
void writeQueueNet(const unsigned char* data, unsigned int length);
|
2016-09-28 06:53:45 +00:00
|
|
|
void writeNetwork(const unsigned char *data, unsigned char type, bool end);
|
2016-09-15 19:28:56 +00:00
|
|
|
void writeNetwork();
|
|
|
|
|
2016-09-08 20:27:21 +00:00
|
|
|
void addBusyBits(unsigned char* data, unsigned int length, bool b1, bool b2);
|
2016-09-15 19:28:56 +00:00
|
|
|
|
2016-10-04 17:37:08 +00:00
|
|
|
void checkNetLDU1();
|
|
|
|
void checkNetLDU2();
|
|
|
|
|
2016-09-27 18:26:24 +00:00
|
|
|
void insertMissingAudio(unsigned char* data);
|
|
|
|
|
2016-09-27 17:59:17 +00:00
|
|
|
void createRFHeader();
|
|
|
|
|
|
|
|
void createNetHeader();
|
|
|
|
void createNetLDU1();
|
|
|
|
void createNetLDU2();
|
2016-09-28 06:53:45 +00:00
|
|
|
void createNetTerminator();
|
2016-09-20 17:46:28 +00:00
|
|
|
|
2016-09-15 19:28:56 +00:00
|
|
|
bool openFile();
|
|
|
|
bool writeFile(const unsigned char* data, unsigned char length);
|
|
|
|
void closeFile();
|
2016-09-08 20:27:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|