diff --git a/DMRControl.cpp b/DMRControl.cpp index 53b075496..54fcb10b4 100644 --- a/DMRControl.cpp +++ b/DMRControl.cpp @@ -130,3 +130,9 @@ bool CDMRControl::isBusy() const return m_slot2.isBusy(); } + +void CDMRControl::enable(bool enabled) +{ + m_slot1.enable(enabled); + m_slot2.enable(enabled); +} diff --git a/DMRControl.h b/DMRControl.h index 22c46b826..7bafbbc42 100644 --- a/DMRControl.h +++ b/DMRControl.h @@ -46,6 +46,8 @@ class CDMRControl { bool isBusy() const; + void enable(bool enabled); + private: unsigned int m_colorCode; CModem* m_modem; diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 66c34d3ab..f4d29b164 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -115,6 +115,7 @@ m_maxRSSI(0U), m_minRSSI(0U), m_aveRSSI(0U), m_rssiCount(0U), +m_enabled(true), m_fp(NULL) { m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U]; @@ -2096,3 +2097,49 @@ bool CDMRSlot::isBusy() const { return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; } + +void CDMRSlot::enable(bool enabled) +{ + if (!enabled && m_enabled) { + m_queue.clear(); + + // Reset the RF section + m_rfState = RS_RF_LISTENING; + + m_rfTimeoutTimer.stop(); + m_rfTimeout = false; + + m_rfFrames = 0U; + m_rfErrs = 0U; + m_rfBits = 1U; + + m_rfSeqNo = 0U; + m_rfN = 0U; + + delete m_rfLC; + m_rfLC = NULL; + + // Reset the networking section + m_netState = RS_NET_IDLE; + + m_lastFrameValid = false; + + m_networkWatchdog.stop(); + m_netTimeoutTimer.stop(); + m_packetTimer.stop(); + m_netTimeout = false; + + m_netFrames = 0U; + m_netLost = 0U; + + m_netErrs = 0U; + m_netBits = 1U; + + m_netN = 0U; + + delete m_netLC; + m_netLC = NULL; + } + + m_enabled = enabled; +} diff --git a/DMRSlot.h b/DMRSlot.h index 8e0559adb..7f0add3ac 100644 --- a/DMRSlot.h +++ b/DMRSlot.h @@ -60,6 +60,8 @@ class CDMRSlot { bool isBusy() const; + void enable(bool enabled); + static void init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter); private: @@ -107,6 +109,7 @@ class CDMRSlot { unsigned char m_minRSSI; unsigned int m_aveRSSI; unsigned int m_rssiCount; + bool m_enabled; FILE* m_fp; static unsigned int m_colorCode; diff --git a/DStarControl.cpp b/DStarControl.cpp index 780458af5..f0394c73b 100644 --- a/DStarControl.cpp +++ b/DStarControl.cpp @@ -81,6 +81,7 @@ m_maxRSSI(0U), m_minRSSI(0U), m_aveRSSI(0U), m_rssiCount(0U), +m_enabled(true), m_fp(NULL) { assert(display != NULL); @@ -1226,3 +1227,26 @@ bool CDStarControl::isBusy() const { return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; } + +void CDStarControl::enable(bool enabled) +{ + if (!enabled && m_enabled) { + m_queue.clear(); + + // Reset the RF section + m_rfState = RS_RF_LISTENING; + + m_rfTimeoutTimer.stop(); + + // Reset the networking section + m_netState = RS_NET_IDLE; + + m_lastFrameValid = false; + + m_netTimeoutTimer.stop(); + m_networkWatchdog.stop(); + m_packetTimer.stop(); + } + + m_enabled = enabled; +} diff --git a/DStarControl.h b/DStarControl.h index 7118e637d..1598df249 100644 --- a/DStarControl.h +++ b/DStarControl.h @@ -48,6 +48,8 @@ class CDStarControl { bool isBusy() const; + void enable(bool enabled); + private: unsigned char* m_callsign; unsigned char* m_gateway; @@ -93,6 +95,7 @@ class CDStarControl { unsigned char m_minRSSI; unsigned int m_aveRSSI; unsigned int m_rssiCount; + bool m_enabled; FILE* m_fp; void writeNetwork(); diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 40c07b3ab..ba3318e6a 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1457,6 +1457,16 @@ void CMMDVMHost::setMode(unsigned char mode) m_nxdnNetwork->enable(false); if (m_pocsagNetwork != NULL) m_pocsagNetwork->enable(false); + if (m_dmr != NULL) + m_dmr->enable(false); + if (m_ysf != NULL) + m_ysf->enable(false); + if (m_p25 != NULL) + m_p25->enable(false); + if (m_nxdn != NULL) + m_nxdn->enable(false); + if (m_pocsag != NULL) + m_pocsag->enable(false); m_modem->setMode(MODE_DSTAR); if (m_ump != NULL) m_ump->setMode(MODE_DSTAR); @@ -1477,6 +1487,16 @@ void CMMDVMHost::setMode(unsigned char mode) m_nxdnNetwork->enable(false); if (m_pocsagNetwork != NULL) m_pocsagNetwork->enable(false); + if (m_dstar != NULL) + m_dstar->enable(false); + if (m_ysf != NULL) + m_ysf->enable(false); + if (m_p25 != NULL) + m_p25->enable(false); + if (m_nxdn != NULL) + m_nxdn->enable(false); + if (m_pocsag != NULL) + m_pocsag->enable(false); m_modem->setMode(MODE_DMR); if (m_ump != NULL) m_ump->setMode(MODE_DMR); @@ -1501,6 +1521,16 @@ void CMMDVMHost::setMode(unsigned char mode) m_nxdnNetwork->enable(false); if (m_pocsagNetwork != NULL) m_pocsagNetwork->enable(false); + if (m_dstar != NULL) + m_dstar->enable(false); + if (m_dmr != NULL) + m_dmr->enable(false); + if (m_p25 != NULL) + m_p25->enable(false); + if (m_nxdn != NULL) + m_nxdn->enable(false); + if (m_pocsag != NULL) + m_pocsag->enable(false); m_modem->setMode(MODE_YSF); if (m_ump != NULL) m_ump->setMode(MODE_YSF); @@ -1521,6 +1551,16 @@ void CMMDVMHost::setMode(unsigned char mode) m_nxdnNetwork->enable(false); if (m_pocsagNetwork != NULL) m_pocsagNetwork->enable(false); + if (m_dstar != NULL) + m_dstar->enable(false); + if (m_dmr != NULL) + m_dmr->enable(false); + if (m_ysf != NULL) + m_ysf->enable(false); + if (m_nxdn != NULL) + m_nxdn->enable(false); + if (m_pocsag != NULL) + m_pocsag->enable(false); m_modem->setMode(MODE_P25); if (m_ump != NULL) m_ump->setMode(MODE_P25); @@ -1541,6 +1581,16 @@ void CMMDVMHost::setMode(unsigned char mode) m_p25Network->enable(false); if (m_pocsagNetwork != NULL) m_pocsagNetwork->enable(false); + if (m_dstar != NULL) + m_dstar->enable(false); + if (m_dmr != NULL) + m_dmr->enable(false); + if (m_ysf != NULL) + m_ysf->enable(false); + if (m_p25 != NULL) + m_p25->enable(false); + if (m_pocsag != NULL) + m_pocsag->enable(false); m_modem->setMode(MODE_NXDN); if (m_ump != NULL) m_ump->setMode(MODE_NXDN); @@ -1561,6 +1611,16 @@ void CMMDVMHost::setMode(unsigned char mode) m_p25Network->enable(false); if (m_nxdnNetwork != NULL) m_nxdnNetwork->enable(false); + if (m_dstar != NULL) + m_dstar->enable(false); + if (m_dmr != NULL) + m_dmr->enable(false); + if (m_ysf != NULL) + m_ysf->enable(false); + if (m_p25 != NULL) + m_p25->enable(false); + if (m_nxdn != NULL) + m_nxdn->enable(false); m_modem->setMode(MODE_POCSAG); if (m_ump != NULL) m_ump->setMode(MODE_POCSAG); @@ -1584,6 +1644,18 @@ void CMMDVMHost::setMode(unsigned char mode) m_nxdnNetwork->enable(false); if (m_pocsagNetwork != NULL) m_pocsagNetwork->enable(false); + if (m_dstar != NULL) + m_dstar->enable(false); + if (m_dmr != NULL) + m_dmr->enable(false); + if (m_ysf != NULL) + m_ysf->enable(false); + if (m_p25 != NULL) + m_p25->enable(false); + if (m_nxdn != NULL) + m_nxdn->enable(false); + if (m_pocsag != NULL) + m_pocsag->enable(false); if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) { m_modem->writeDMRStart(false); m_dmrTXTimer.stop(); @@ -1612,6 +1684,18 @@ void CMMDVMHost::setMode(unsigned char mode) m_nxdnNetwork->enable(false); if (m_pocsagNetwork != NULL) m_pocsagNetwork->enable(false); + if (m_dstar != NULL) + m_dstar->enable(false); + if (m_dmr != NULL) + m_dmr->enable(false); + if (m_ysf != NULL) + m_ysf->enable(false); + if (m_p25 != NULL) + m_p25->enable(false); + if (m_nxdn != NULL) + m_nxdn->enable(false); + if (m_pocsag != NULL) + m_pocsag->enable(false); if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) { m_modem->writeDMRStart(false); m_dmrTXTimer.stop(); @@ -1638,6 +1722,18 @@ void CMMDVMHost::setMode(unsigned char mode) m_nxdnNetwork->enable(true); if (m_pocsagNetwork != NULL) m_pocsagNetwork->enable(true); + if (m_dstar != NULL) + m_dstar->enable(false); + if (m_dmr != NULL) + m_dmr->enable(false); + if (m_ysf != NULL) + m_ysf->enable(false); + if (m_p25 != NULL) + m_p25->enable(false); + if (m_nxdn != NULL) + m_nxdn->enable(false); + if (m_pocsag != NULL) + m_pocsag->enable(false); if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) { m_modem->writeDMRStart(false); m_dmrTXTimer.stop(); diff --git a/NXDNControl.cpp b/NXDNControl.cpp index a07e1b78d..5334cb78e 100644 --- a/NXDNControl.cpp +++ b/NXDNControl.cpp @@ -71,6 +71,7 @@ m_maxRSSI(0U), m_minRSSI(0U), m_aveRSSI(0U), m_rssiCount(0U), +m_enabled(true), m_fp(NULL) { assert(display != NULL); @@ -1086,3 +1087,30 @@ bool CNXDNControl::isBusy() const { return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; } + +void CNXDNControl::enable(bool enabled) +{ + if (!enabled && m_enabled) { + m_queue.clear(); + + // Reset the RF section + m_rfState = RS_RF_LISTENING; + + m_rfMask = 0x00U; + m_rfLayer3.reset(); + + m_rfTimeoutTimer.stop(); + + // Reset the networking section + m_netState = RS_NET_IDLE; + + m_netMask = 0x00U; + m_netLayer3.reset(); + + m_netTimeoutTimer.stop(); + m_networkWatchdog.stop(); + m_packetTimer.stop(); + } + + m_enabled = enabled; +} diff --git a/NXDNControl.h b/NXDNControl.h index c8c056ab1..5c441e22e 100644 --- a/NXDNControl.h +++ b/NXDNControl.h @@ -47,6 +47,8 @@ class CNXDNControl { bool isBusy() const; + void enable(bool enabled); + private: unsigned int m_ran; unsigned int m_id; @@ -79,6 +81,7 @@ class CNXDNControl { unsigned char m_minRSSI; unsigned int m_aveRSSI; unsigned int m_rssiCount; + bool m_enabled; FILE* m_fp; bool processVoice(unsigned char usc, unsigned char option, unsigned char *data); diff --git a/P25Control.cpp b/P25Control.cpp index 07555a379..1d90b2c28 100644 --- a/P25Control.cpp +++ b/P25Control.cpp @@ -80,6 +80,7 @@ m_maxRSSI(0U), m_minRSSI(0U), m_aveRSSI(0U), m_rssiCount(0U), +m_enabled(true), m_fp(NULL) { assert(display != NULL); @@ -1160,3 +1161,23 @@ bool CP25Control::isBusy() const { return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; } + +void CP25Control::enable(bool enabled) +{ + if (!enabled && m_enabled) { + m_queue.clear(); + + // Reset the RF section + m_rfState = RS_RF_LISTENING; + m_rfTimeout.stop(); + m_rfData.reset(); + + // Reset the networking section + m_netTimeout.stop(); + m_networkWatchdog.stop(); + m_netData.reset(); + m_netState = RS_NET_IDLE; + } + + m_enabled = enabled; +} diff --git a/P25Control.h b/P25Control.h index 450bf967d..35e12bc6b 100644 --- a/P25Control.h +++ b/P25Control.h @@ -48,6 +48,8 @@ class CP25Control { bool isBusy() const; + void enable(bool enabled); + private: unsigned int m_nac; unsigned int m_id; @@ -90,6 +92,7 @@ class CP25Control { unsigned char m_minRSSI; unsigned int m_aveRSSI; unsigned int m_rssiCount; + bool m_enabled; FILE* m_fp; void writeQueueRF(const unsigned char* data, unsigned int length); diff --git a/POCSAGControl.cpp b/POCSAGControl.cpp index 498a0a7a4..85728cbca 100644 --- a/POCSAGControl.cpp +++ b/POCSAGControl.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 Jonathan Naylor, G4KLX +* Copyright (C) 2018,2019 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 @@ -69,6 +69,7 @@ m_buffer(), m_ric(0U), m_text(), m_state(PS_NONE), +m_enabled(true), m_fp(NULL) { assert(display != NULL); @@ -414,3 +415,15 @@ void CPOCSAGControl::closeFile() m_fp = NULL; } } + +void CPOCSAGControl::enable(bool enabled) +{ + if (!enabled && m_enabled) { + m_queue.clear(); + m_output.clear(); + + m_state = PS_NONE; + } + + m_enabled = enabled; +} diff --git a/POCSAGControl.h b/POCSAGControl.h index 828e4cbe2..844644a0a 100644 --- a/POCSAGControl.h +++ b/POCSAGControl.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2018 by Jonathan Naylor G4KLX +* Copyright (C) 2018,2019 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 @@ -39,6 +39,8 @@ class CPOCSAGControl { void clock(unsigned int ms); + void enable(bool enabled); + private: CPOCSAGNetwork* m_network; CDisplay* m_display; @@ -58,6 +60,7 @@ class CPOCSAGControl { uint32_t m_ric; std::string m_text; POCSAG_STATE m_state; + bool m_enabled; FILE* m_fp; bool processData(); diff --git a/YSFControl.cpp b/YSFControl.cpp index fe4ce6d81..f098d8af9 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -63,6 +63,7 @@ m_maxRSSI(0U), m_minRSSI(0U), m_aveRSSI(0U), m_rssiCount(0U), +m_enabled(true), m_fp(NULL) { assert(display != NULL); @@ -1323,3 +1324,31 @@ bool CYSFControl::isBusy() const { return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; } + +void CYSFControl::enable(bool enabled) +{ + if (!enabled && m_enabled) { + m_queue.clear(); + + // Reset the RF section + m_rfState = RS_RF_LISTENING; + + m_rfTimeoutTimer.stop(); + m_rfPayload.reset(); + + // These variables are free'd by YSFPayload + m_rfSource = NULL; + m_rfDest = NULL; + + // Reset the networking section + m_netState = RS_NET_IDLE; + + m_netTimeoutTimer.stop(); + m_networkWatchdog.stop(); + m_packetTimer.stop(); + + m_netPayload.reset(); + } + + m_enabled = enabled; +} diff --git a/YSFControl.h b/YSFControl.h index 3bbc7a4cf..e5702ac32 100644 --- a/YSFControl.h +++ b/YSFControl.h @@ -48,6 +48,8 @@ class CYSFControl { bool isBusy() const; + void enable(bool enabled); + private: unsigned char* m_callsign; unsigned char* m_selfCallsign; @@ -88,6 +90,7 @@ class CYSFControl { unsigned char m_minRSSI; unsigned int m_aveRSSI; unsigned int m_rssiCount; + bool m_enabled; FILE* m_fp; bool processVWData(bool valid, unsigned char *data);