MMDVMHost-Private/P25Control.h

113 lines
3.6 KiB
C
Raw Normal View History

/*
2017-01-05 19:15:10 +00:00
* Copyright (C) 2016,2017 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
2017-01-05 19:15:10 +00:00
#include "RSSIInterpolator.h"
2016-09-20 05:53:30 +00:00
#include "P25LowSpeedData.h"
#include "RingBuffer.h"
#include "P25Network.h"
#include "DMRLookup.h"
#include "P25Audio.h"
#include "Defines.h"
#include "Display.h"
#include "P25Data.h"
#include "P25NID.h"
#include "Modem.h"
#include "Timer.h"
#include <cstdio>
class CP25Control {
public:
CP25Control(unsigned int nac, unsigned int id, bool selfOly, bool uidOverride, CP25Network* network, CDisplay* display, unsigned int timeout, bool duplex, CDMRLookup* lookup, bool remoteGateway, CRSSIInterpolator* rssiMapper);
~CP25Control();
bool writeModem(unsigned char* data, unsigned int len);
unsigned int readModem(unsigned char* data);
void clock(unsigned int ms);
private:
2017-01-05 19:15:10 +00:00
unsigned int m_nac;
unsigned int m_id;
bool m_selfOnly;
2017-03-29 19:46:27 +00:00
bool m_uidOverride;
bool m_remoteGateway;
2017-01-05 19:15:10 +00:00
CP25Network* m_network;
CDisplay* m_display;
bool m_duplex;
CDMRLookup* m_lookup;
CRingBuffer<unsigned char> m_queue;
2017-01-05 19:15:10 +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;
CP25LowSpeedData m_rfLSD;
CP25LowSpeedData m_netLSD;
unsigned char* m_netLDU1;
unsigned char* m_netLDU2;
unsigned char* m_lastIMBE;
unsigned char* m_rfLDU;
CRSSIInterpolator* m_rssiMapper;
unsigned char m_rssi;
unsigned char m_maxRSSI;
unsigned char m_minRSSI;
unsigned int m_aveRSSI;
unsigned int m_rssiCount;
FILE* m_fp;
void writeQueueRF(const unsigned char* data, unsigned int length);
void writeQueueNet(const unsigned char* data, unsigned int length);
void writeNetwork(const unsigned char *data, unsigned char type, bool end);
void writeNetwork();
void addBusyBits(unsigned char* data, unsigned int length, bool b1, bool b2);
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();
void createNetTerminator();
2016-09-20 17:46:28 +00:00
bool openFile();
bool writeFile(const unsigned char* data, unsigned char length);
void closeFile();
};
#endif