2016-01-14 19:45:04 +01:00
|
|
|
/*
|
2021-02-17 22:36:47 +01:00
|
|
|
* Copyright (C) 2015-2021 by Jonathan Naylor G4KLX
|
2016-01-14 19:45:04 +01: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(DMRSlot_H)
|
|
|
|
#define DMRSlot_H
|
|
|
|
|
2016-12-21 20:58:46 +01:00
|
|
|
#include "RSSIInterpolator.h"
|
2017-01-10 20:27:12 +01:00
|
|
|
#include "DMREmbeddedData.h"
|
2016-09-14 08:41:37 +02:00
|
|
|
#include "DMRNetwork.h"
|
2018-12-08 15:09:59 +01:00
|
|
|
#include "DMRTA.h"
|
2016-01-14 19:45:04 +01:00
|
|
|
#include "RingBuffer.h"
|
2016-02-28 19:22:17 +01:00
|
|
|
#include "StopWatch.h"
|
2016-04-12 19:26:13 +02:00
|
|
|
#include "DMRLookup.h"
|
2016-01-19 21:13:20 +01:00
|
|
|
#include "AMBEFEC.h"
|
2016-01-14 19:45:04 +01:00
|
|
|
#include "DMRSlot.h"
|
|
|
|
#include "DMRData.h"
|
|
|
|
#include "Display.h"
|
2016-01-19 18:43:33 +01:00
|
|
|
#include "Defines.h"
|
2016-01-14 19:45:04 +01:00
|
|
|
#include "Timer.h"
|
|
|
|
#include "Modem.h"
|
2016-02-15 19:45:57 +01:00
|
|
|
#include "DMRLC.h"
|
2016-01-14 19:45:04 +01:00
|
|
|
|
2016-04-04 20:03:38 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2017-10-04 12:20:37 +02:00
|
|
|
enum ACTIVITY_TYPE {
|
2017-10-04 22:56:40 +02:00
|
|
|
ACTIVITY_NONE,
|
|
|
|
ACTIVITY_VOICE,
|
|
|
|
ACTIVITY_DATA,
|
|
|
|
ACTIVITY_CSBK,
|
|
|
|
ACTIVITY_EMERG
|
2017-10-04 12:20:37 +02:00
|
|
|
};
|
2017-10-03 11:03:13 +02:00
|
|
|
|
2016-01-14 19:45:04 +01:00
|
|
|
class CDMRSlot {
|
|
|
|
public:
|
|
|
|
CDMRSlot(unsigned int slotNo, unsigned int timeout);
|
|
|
|
~CDMRSlot();
|
|
|
|
|
2017-03-12 20:06:47 +01:00
|
|
|
bool writeModem(unsigned char* data, unsigned int len);
|
2016-01-14 19:45:04 +01:00
|
|
|
|
|
|
|
unsigned int readModem(unsigned char* data);
|
|
|
|
|
|
|
|
void writeNetwork(const CDMRData& data);
|
|
|
|
|
2016-03-14 21:55:15 +01:00
|
|
|
void clock();
|
2016-01-14 19:45:04 +01:00
|
|
|
|
2019-01-10 10:05:15 +01:00
|
|
|
bool isBusy() const;
|
|
|
|
|
2019-01-19 18:15:24 +01:00
|
|
|
void enable(bool enabled);
|
|
|
|
|
2021-02-17 22:36:47 +01:00
|
|
|
static void init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter, DMR_OVCM_TYPES ovcm);
|
2016-01-14 19:45:04 +01:00
|
|
|
|
|
|
|
private:
|
2016-01-19 18:43:33 +01:00
|
|
|
unsigned int m_slotNo;
|
2016-03-07 19:08:50 +01:00
|
|
|
CRingBuffer<unsigned char> m_queue;
|
2016-02-25 20:54:18 +01:00
|
|
|
RPT_RF_STATE m_rfState;
|
|
|
|
RPT_NET_STATE m_netState;
|
2017-01-10 20:27:12 +01:00
|
|
|
CDMREmbeddedData m_rfEmbeddedLC;
|
|
|
|
CDMREmbeddedData* m_rfEmbeddedData;
|
|
|
|
unsigned int m_rfEmbeddedReadN;
|
|
|
|
unsigned int m_rfEmbeddedWriteN;
|
2017-02-12 19:37:00 +01:00
|
|
|
unsigned char m_rfTalkerId;
|
2018-12-08 15:09:59 +01:00
|
|
|
CDMRTA m_rfTalkerAlias;
|
2017-01-10 20:27:12 +01:00
|
|
|
CDMREmbeddedData m_netEmbeddedLC;
|
|
|
|
CDMREmbeddedData* m_netEmbeddedData;
|
|
|
|
unsigned int m_netEmbeddedReadN;
|
|
|
|
unsigned int m_netEmbeddedWriteN;
|
2017-02-12 19:37:00 +01:00
|
|
|
unsigned char m_netTalkerId;
|
2016-02-25 20:54:18 +01:00
|
|
|
CDMRLC* m_rfLC;
|
|
|
|
CDMRLC* m_netLC;
|
2016-02-28 18:40:15 +01:00
|
|
|
unsigned char m_rfSeqNo;
|
2016-02-28 18:18:13 +01:00
|
|
|
unsigned char m_rfN;
|
2018-07-22 03:01:55 +02:00
|
|
|
unsigned char m_lastrfN;
|
2016-03-03 18:08:24 +01:00
|
|
|
unsigned char m_netN;
|
2016-01-19 18:43:33 +01:00
|
|
|
CTimer m_networkWatchdog;
|
2016-02-25 20:54:18 +01:00
|
|
|
CTimer m_rfTimeoutTimer;
|
|
|
|
CTimer m_netTimeoutTimer;
|
2018-02-08 21:25:03 +01:00
|
|
|
CTimer m_packetTimer;
|
2016-03-14 21:55:15 +01:00
|
|
|
CStopWatch m_interval;
|
2018-02-08 21:25:03 +01:00
|
|
|
CStopWatch m_elapsed;
|
2016-02-25 20:54:18 +01:00
|
|
|
unsigned int m_rfFrames;
|
|
|
|
unsigned int m_netFrames;
|
|
|
|
unsigned int m_netLost;
|
2016-01-19 21:13:20 +01:00
|
|
|
CAMBEFEC m_fec;
|
2016-02-25 20:54:18 +01:00
|
|
|
unsigned int m_rfBits;
|
|
|
|
unsigned int m_netBits;
|
|
|
|
unsigned int m_rfErrs;
|
|
|
|
unsigned int m_netErrs;
|
2017-03-12 20:06:47 +01:00
|
|
|
bool m_rfTimeout;
|
|
|
|
bool m_netTimeout;
|
2018-02-08 21:25:03 +01:00
|
|
|
unsigned char* m_lastFrame;
|
|
|
|
bool m_lastFrameValid;
|
2016-08-11 18:28:47 +02:00
|
|
|
unsigned char m_rssi;
|
2017-01-05 20:15:10 +01:00
|
|
|
unsigned char m_maxRSSI;
|
|
|
|
unsigned char m_minRSSI;
|
|
|
|
unsigned int m_aveRSSI;
|
|
|
|
unsigned int m_rssiCount;
|
2019-01-19 18:15:24 +01:00
|
|
|
bool m_enabled;
|
2016-01-19 18:43:33 +01:00
|
|
|
FILE* m_fp;
|
2016-01-14 19:45:04 +01:00
|
|
|
|
|
|
|
static unsigned int m_colorCode;
|
2016-07-21 19:09:29 +02:00
|
|
|
|
2017-01-16 13:10:23 +01:00
|
|
|
static bool m_embeddedLCOnly;
|
2017-02-27 21:17:55 +01:00
|
|
|
static bool m_dumpTAData;
|
2017-01-16 13:10:23 +01:00
|
|
|
|
2021-02-17 22:36:47 +01:00
|
|
|
static CModem* m_modem;
|
2020-12-06 17:12:54 +01:00
|
|
|
static IDMRNetwork* m_network;
|
2016-05-09 19:14:27 +02:00
|
|
|
static CDisplay* m_display;
|
2016-02-15 19:01:21 +01:00
|
|
|
static bool m_duplex;
|
2016-04-12 19:26:13 +02:00
|
|
|
static CDMRLookup* m_lookup;
|
2016-06-16 22:40:05 +02:00
|
|
|
static unsigned int m_hangCount;
|
2019-11-17 03:57:58 +01:00
|
|
|
static DMR_OVCM_TYPES m_ovcm;
|
2016-01-14 19:45:04 +01:00
|
|
|
|
2016-12-21 20:58:46 +01:00
|
|
|
static CRSSIInterpolator* m_rssiMapper;
|
2016-08-08 22:26:18 +02:00
|
|
|
|
2018-02-08 21:25:03 +01:00
|
|
|
static unsigned int m_jitterTime;
|
|
|
|
static unsigned int m_jitterSlots;
|
|
|
|
|
2016-01-14 19:45:04 +01:00
|
|
|
static unsigned char* m_idle;
|
|
|
|
|
2017-10-03 11:03:13 +02:00
|
|
|
static FLCO m_flco1;
|
2016-01-14 19:45:04 +01:00
|
|
|
static unsigned char m_id1;
|
2017-10-04 12:20:37 +02:00
|
|
|
static ACTIVITY_TYPE m_activity1;
|
2016-01-14 19:45:04 +01:00
|
|
|
static FLCO m_flco2;
|
|
|
|
static unsigned char m_id2;
|
2017-10-04 12:20:37 +02:00
|
|
|
static ACTIVITY_TYPE m_activity2;
|
2016-01-14 19:45:04 +01:00
|
|
|
|
2017-11-26 18:56:20 +01:00
|
|
|
void logGPSPosition(const unsigned char* data);
|
2017-11-13 21:48:47 +01:00
|
|
|
|
2016-02-25 20:54:18 +01:00
|
|
|
void writeQueueRF(const unsigned char* data);
|
|
|
|
void writeQueueNet(const unsigned char* data);
|
2016-03-23 18:30:06 +01:00
|
|
|
void writeNetworkRF(const unsigned char* data, unsigned char dataType, unsigned char errors = 0U);
|
|
|
|
void writeNetworkRF(const unsigned char* data, unsigned char dataType, FLCO flco, unsigned int srcId, unsigned int dstId, unsigned char errors = 0U);
|
2016-01-14 19:45:04 +01:00
|
|
|
|
2016-02-25 20:54:18 +01:00
|
|
|
void writeEndRF(bool writeEnd = false);
|
|
|
|
void writeEndNet(bool writeEnd = false);
|
2016-01-14 19:45:04 +01:00
|
|
|
|
|
|
|
bool openFile();
|
|
|
|
bool writeFile(const unsigned char* data);
|
|
|
|
void closeFile();
|
|
|
|
|
2018-02-08 21:25:03 +01:00
|
|
|
bool insertSilence(const unsigned char* data, unsigned char seqNo);
|
|
|
|
void insertSilence(unsigned int count);
|
2016-01-19 20:34:49 +01:00
|
|
|
|
2017-10-04 12:20:37 +02:00
|
|
|
static void setShortLC(unsigned int slotNo, unsigned int id, FLCO flco = FLCO_GROUP, ACTIVITY_TYPE type = ACTIVITY_NONE);
|
2016-01-14 19:45:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|