From 11fc87896c353bec06b37963574de452d83d44ea Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 29 Jun 2023 11:59:52 +0100 Subject: [PATCH] Make compiling AX.25 conditional. --- AX25Control.cpp | 49 +++----------------------- AX25Control.h | 10 +++--- AX25Network.cpp | 8 +++-- AX25Network.h | 9 ++++- Conf.cpp | 22 ++++++++++++ Conf.h | 6 ++++ MMDVMHost.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++++---- MMDVMHost.h | 7 ++++ 8 files changed, 147 insertions(+), 57 deletions(-) diff --git a/AX25Control.cpp b/AX25Control.cpp index 20cd733..573ea43 100644 --- a/AX25Control.cpp +++ b/AX25Control.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Jonathan Naylor, G4KLX + * Copyright (C) 2020,2023 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 @@ -16,6 +16,8 @@ #include "Utils.h" #include "Log.h" +#if defined(USE_AX25) + #include #include #include @@ -23,8 +25,6 @@ #include -// #define DUMP_AX25 - const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U }; #define WRITE_BIT1(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7]) @@ -82,47 +82,6 @@ unsigned int CAX25Control::readModem(unsigned char* data) return length; } -bool CAX25Control::openFile() -{ - if (m_fp != NULL) - return true; - - time_t t; - ::time(&t); - - struct tm* tm = ::localtime(&t); - - char name[100U]; - ::sprintf(name, "AX25_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); - - m_fp = ::fopen(name, "wb"); - if (m_fp == NULL) - return false; - - ::fwrite("AX25", 1U, 4U, m_fp); - - return true; -} - -bool CAX25Control::writeFile(const unsigned char* data, unsigned int length) -{ - if (m_fp == NULL) - return false; - - ::fwrite(&length, 1U, sizeof(unsigned int), m_fp); - ::fwrite(data, 1U, length, m_fp); - - return true; -} - -void CAX25Control::closeFile() -{ - if (m_fp != NULL) { - ::fclose(m_fp); - m_fp = NULL; - } -} - void CAX25Control::enable(bool enabled) { m_enabled = enabled; @@ -424,3 +383,5 @@ bool CAX25Control::decodeAddressJSON(const unsigned char* data, std::string& tex return (data[6U] & 0x01U) == 0x00U; } +#endif + diff --git a/AX25Control.h b/AX25Control.h index 88ecf69..f1403cb 100644 --- a/AX25Control.h +++ b/AX25Control.h @@ -20,6 +20,9 @@ #define AX25Control_H #include "AX25Network.h" +#include "Defines.h" + +#if defined(USE_AX25) #include @@ -44,10 +47,9 @@ private: void decodeJSON(const char* source, const unsigned char* data, unsigned int length); bool decodeAddress(const unsigned char* data, std::string& text, bool isDigi = false) const; bool decodeAddressJSON(const unsigned char* data, std::string& text, bool& isDigi) const; - - bool openFile(); - bool writeFile(const unsigned char* data, unsigned int length); - void closeFile(); }; #endif + +#endif + diff --git a/AX25Network.cpp b/AX25Network.cpp index d7f876d..e0d330a 100644 --- a/AX25Network.cpp +++ b/AX25Network.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 by Jonathan Naylor G4KLX + * Copyright (C) 2020,2023 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 @@ -18,10 +18,11 @@ #include "AX25Network.h" #include "AX25Defines.h" -#include "Defines.h" #include "Utils.h" #include "Log.h" +#if defined(USE_AX25) + #include #include #include @@ -181,3 +182,6 @@ void CAX25Network::enable(bool enabled) m_rxLength = 0U; } } + +#endif + diff --git a/AX25Network.h b/AX25Network.h index c972ccb..1d6ba0a 100644 --- a/AX25Network.h +++ b/AX25Network.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX + * Copyright (C) 2020,2021,2023 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 @@ -19,6 +19,10 @@ #ifndef AX25Network_H #define AX25Network_H +#include "Defines.h" + +#if defined(USE_AX25) + #if defined(_WIN32) || defined(_WIN64) #include "UARTController.h" #else @@ -60,3 +64,6 @@ private: }; #endif + +#endif + diff --git a/Conf.cpp b/Conf.cpp index d021f5b..41b357c 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -46,7 +46,9 @@ enum SECTION { SECTION_M17, SECTION_POCSAG, SECTION_FM, +#if defined(USE_AX25) SECTION_AX25, +#endif SECTION_DSTAR_NETWORK, SECTION_DMR_NETWORK, SECTION_FUSION_NETWORK, @@ -55,7 +57,9 @@ enum SECTION { SECTION_M17_NETWORK, SECTION_POCSAG_NETWORK, SECTION_FM_NETWORK, +#if defined(USE_AX25) SECTION_AX25_NETWORK, +#endif SECTION_LOCK_FILE, SECTION_REMOTE_CONTROL }; @@ -222,12 +226,14 @@ m_fmRFAudioBoost(1U), m_fmMaxDevLevel(90.0F), m_fmExtAudioBoost(1U), m_fmModeHang(10U), +#if defined(USE_AX25) m_ax25Enabled(false), m_ax25TXDelay(300U), m_ax25RXTwist(6), m_ax25SlotTime(30U), m_ax25PPersist(128U), m_ax25Trace(false), +#endif m_dstarNetworkEnabled(false), m_dstarGatewayAddress(), m_dstarGatewayPort(0U), @@ -293,10 +299,12 @@ m_fmTXAudioGain(1.0F), m_fmRXAudioGain(1.0F), m_fmNetworkModeHang(3U), m_fmNetworkDebug(false), +#if defined(USE_AX25) m_ax25NetworkEnabled(false), m_ax25NetworkPort(), m_ax25NetworkSpeed(9600U), m_ax25NetworkDebug(false), +#endif m_lockFileEnabled(false), m_lockFileName(), m_remoteControlEnabled(false) @@ -357,8 +365,10 @@ bool CConf::read() section = SECTION_POCSAG; else if (::strncmp(buffer, "[FM]", 4U) == 0) section = SECTION_FM; +#if defined(USE_AX25) else if (::strncmp(buffer, "[AX.25]", 7U) == 0) section = SECTION_AX25; +#endif else if (::strncmp(buffer, "[D-Star Network]", 16U) == 0) section = SECTION_DSTAR_NETWORK; else if (::strncmp(buffer, "[DMR Network]", 13U) == 0) @@ -375,8 +385,10 @@ bool CConf::read() section = SECTION_POCSAG_NETWORK; else if (::strncmp(buffer, "[FM Network]", 12U) == 0) section = SECTION_FM_NETWORK; +#if defined(USE_AX25) else if (::strncmp(buffer, "[AX.25 Network]", 15U) == 0) section = SECTION_AX25_NETWORK; +#endif else if (::strncmp(buffer, "[Lock File]", 11U) == 0) section = SECTION_LOCK_FILE; else if (::strncmp(buffer, "[Remote Control]", 16U) == 0) @@ -851,6 +863,7 @@ bool CConf::read() m_fmExtAudioBoost = (unsigned int)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) m_fmModeHang = (unsigned int)::atoi(value); +#if defined(USE_AX25) } else if (section == SECTION_AX25) { if (::strcmp(key, "Enable") == 0) m_ax25Enabled = ::atoi(value) == 1; @@ -864,6 +877,7 @@ bool CConf::read() m_ax25PPersist = (unsigned int)::atoi(value); else if (::strcmp(key, "Trace") == 0) m_ax25Trace = ::atoi(value) == 1; +#endif } else if (section == SECTION_DSTAR_NETWORK) { if (::strcmp(key, "Enable") == 0) m_dstarNetworkEnabled = ::atoi(value) == 1; @@ -1000,6 +1014,7 @@ bool CConf::read() m_fmNetworkModeHang = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) m_fmNetworkDebug = ::atoi(value) == 1; +#if defined(USE_AX25) } else if (section == SECTION_AX25_NETWORK) { if (::strcmp(key, "Enable") == 0) m_ax25NetworkEnabled = ::atoi(value) == 1; @@ -1009,6 +1024,7 @@ bool CConf::read() m_ax25NetworkSpeed = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) m_ax25NetworkDebug = ::atoi(value) == 1; +#endif } else if (section == SECTION_LOCK_FILE) { if (::strcmp(key, "Enable") == 0) m_lockFileEnabled = ::atoi(value) == 1; @@ -1305,10 +1321,12 @@ float CConf::getModemFMTXLevel() const return m_modemFMTXLevel; } +#if defined(USE_AX25) float CConf::getModemAX25TXLevel() const { return m_modemAX25TXLevel; } +#endif std::string CConf::getModemRSSIMappingFile () const { @@ -1825,6 +1843,7 @@ unsigned int CConf::getFMModeHang() const return m_fmModeHang; } +#if defined(USE_AX25) bool CConf::getAX25Enabled() const { return m_ax25Enabled; @@ -1854,6 +1873,7 @@ bool CConf::getAX25Trace() const { return m_ax25Trace; } +#endif bool CConf::getDStarNetworkEnabled() const { @@ -2180,6 +2200,7 @@ bool CConf::getFMNetworkDebug() const return m_fmNetworkDebug; } +#if defined(USE_AX25) bool CConf::getAX25NetworkEnabled() const { return m_ax25NetworkEnabled; @@ -2199,6 +2220,7 @@ bool CConf::getAX25NetworkDebug() const { return m_ax25NetworkDebug; } +#endif bool CConf::getLockFileEnabled() const { diff --git a/Conf.h b/Conf.h index 818e007..9608f1f 100644 --- a/Conf.h +++ b/Conf.h @@ -101,7 +101,9 @@ public: float getModemM17TXLevel() const; float getModemPOCSAGTXLevel() const; float getModemFMTXLevel() const; +#if defined(USE_AX25) float getModemAX25TXLevel() const; +#endif std::string getModemRSSIMappingFile() const; bool getModemUseCOSAsLockout() const; bool getModemTrace() const; @@ -186,6 +188,7 @@ public: bool getPOCSAGEnabled() const; unsigned int getPOCSAGFrequency() const; +#if defined(USE_AX25) // The AX.25 section bool getAX25Enabled() const; unsigned int getAX25TXDelay() const; @@ -193,6 +196,7 @@ public: unsigned int getAX25SlotTime() const; unsigned int getAX25PPersist() const; bool getAX25Trace() const; +#endif // The FM Section bool getFMEnabled() const; @@ -313,11 +317,13 @@ public: unsigned int getFMNetworkModeHang() const; bool getFMNetworkDebug() const; +#if defined(USE_AX25) // The AX.25 Network section bool getAX25NetworkEnabled() const; std::string getAX25NetworkPort() const; unsigned int getAX25NetworkSpeed() const; bool getAX25NetworkDebug() const; +#endif // The Lock File section bool getLockFileEnabled() const; diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 9b57272..1ba6583 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -30,7 +30,6 @@ #include "DStarDefines.h" #include "Version.h" #include "StopWatch.h" -#include "Defines.h" #include "Thread.h" #include "Utils.h" #include "Log.h" @@ -155,7 +154,9 @@ m_nxdn(NULL), m_m17(NULL), m_pocsag(NULL), m_fm(NULL), +#if defined(USE_AX25) m_ax25(NULL), +#endif m_dstarNetwork(NULL), m_dmrNetwork(NULL), m_ysfNetwork(NULL), @@ -164,7 +165,9 @@ m_nxdnNetwork(NULL), m_m17Network(NULL), m_pocsagNetwork(NULL), m_fmNetwork(NULL), +#if defined(USE_AX25) m_ax25Network(NULL), +#endif m_mode(MODE_IDLE), m_dstarRFModeHang(10U), m_dmrRFModeHang(10U), @@ -357,10 +360,12 @@ int CMMDVMHost::run() m_pocsagEnabled = false; } +#if defined(USE_AX25) if (m_ax25Enabled && !m_modem->hasAX25()) { LogWarning("AX.25 enabled in the host but not in the modem firmware, disabling"); m_ax25Enabled = false; } +#endif LogInfo("Opening network connections"); writeJSONMessage("Opening network connections"); @@ -413,11 +418,13 @@ int CMMDVMHost::run() return 1; } +#if defined(USE_AX25) if (m_ax25Enabled && m_conf.getAX25NetworkEnabled()) { ret = createAX25Network(); if (!ret) return 1; } +#endif sockaddr_storage transparentAddress; unsigned int transparentAddrLen; @@ -733,6 +740,7 @@ int CMMDVMHost::run() pocsagTimer.start(); } +#if defined(USE_AX25) if (m_ax25Enabled) { unsigned int txDelay = m_conf.getAX25TXDelay(); int rxTwist = m_conf.getAX25RXTwist(); @@ -749,6 +757,7 @@ int CMMDVMHost::run() m_ax25 = new CAX25Control(m_ax25Network, trace); } +#endif if (m_fmEnabled) { bool preEmphasis = m_conf.getFMPreEmphasis(); @@ -963,6 +972,7 @@ int CMMDVMHost::run() } } +#if defined(USE_AX25) len = m_modem->readAX25Data(data); if (m_ax25 != NULL && len > 0U) { if (m_mode == MODE_IDLE || m_mode == MODE_FM) { @@ -971,6 +981,7 @@ int CMMDVMHost::run() LogWarning("NXDN modem data received when in mode %u", m_mode); } } +#endif len = m_modem->readTransparentData(data); if (transparentSocket != NULL && len > 0U) @@ -1160,6 +1171,7 @@ int CMMDVMHost::run() } } +#if defined(USE_AX25) if (m_ax25 != NULL) { ret = m_modem->hasAX25Space(); if (ret) { @@ -1174,6 +1186,7 @@ int CMMDVMHost::run() } } } +#endif if (transparentSocket != NULL) { sockaddr_storage address; @@ -1357,10 +1370,12 @@ int CMMDVMHost::run() delete m_fmNetwork; } +#if defined(USE_AX25) if (m_ax25Network != NULL) { m_ax25Network->close(); delete m_ax25Network; } +#endif if (transparentSocket != NULL) { transparentSocket->close(); @@ -1380,7 +1395,9 @@ int CMMDVMHost::run() delete m_m17; delete m_pocsag; delete m_fm; +#if defined(USE_AX25) delete m_ax25; +#endif LogInfo("MMDVMHost-%s has stopped", VERSION); writeJSONMessage("MMDVMHost has stopped"); @@ -1422,7 +1439,11 @@ bool CMMDVMHost::createModem() float m17TXLevel = m_conf.getModemM17TXLevel(); float pocsagTXLevel = m_conf.getModemPOCSAGTXLevel(); float fmTXLevel = m_conf.getModemFMTXLevel(); +#if defined(USE_AX25) float ax25TXLevel = m_conf.getModemAX25TXLevel(); +#else + float ax25TXLevel = 0.0F; +#endif bool trace = m_conf.getModemTrace(); bool debug = m_conf.getModemDebug(); unsigned int colorCode = m_conf.getDMRColorCode(); @@ -1439,10 +1460,12 @@ bool CMMDVMHost::createModem() int rxDCOffset = m_conf.getModemRXDCOffset(); int txDCOffset = m_conf.getModemTXDCOffset(); float rfLevel = m_conf.getModemRFLevel(); +#if defined(USE_AX25) int rxTwist = m_conf.getAX25RXTwist(); unsigned int ax25TXDelay = m_conf.getAX25TXDelay(); unsigned int ax25SlotTime = m_conf.getAX25SlotTime(); unsigned int ax25PPersist = m_conf.getAX25PPersist(); +#endif bool useCOSAsLockout = m_conf.getModemUseCOSAsLockout(); LogInfo("Modem Parameters"); @@ -1484,7 +1507,9 @@ bool CMMDVMHost::createModem() LogInfo(" M17 TX Level: %.1f%%", m17TXLevel); LogInfo(" POCSAG TX Level: %.1f%%", pocsagTXLevel); LogInfo(" FM TX Level: %.1f%%", fmTXLevel); +#if defined(USE_AX25) LogInfo(" AX.25 TX Level: %.1f%%", ax25TXLevel); +#endif LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset); LogInfo(" Use COS as Lockout: %s", useCOSAsLockout ? "yes" : "no"); @@ -1513,7 +1538,9 @@ bool CMMDVMHost::createModem() m_modem->setP25Params(p25TXHang); m_modem->setNXDNParams(nxdnTXHang); m_modem->setM17Params(m17TXHang); +#if defined(USE_AX25) m_modem->setAX25Params(rxTwist, ax25TXDelay, ax25SlotTime, ax25PPersist); +#endif if (m_fmEnabled) { std::string callsign = m_conf.getFMCallsign(); @@ -1890,6 +1917,7 @@ bool CMMDVMHost::createFMNetwork() return true; } +#if defined(USE_AX25) bool CMMDVMHost::createAX25Network() { std::string port = m_conf.getAX25NetworkPort(); @@ -1913,6 +1941,7 @@ bool CMMDVMHost::createAX25Network() return true; } +#endif void CMMDVMHost::readParams() { @@ -1924,7 +1953,9 @@ void CMMDVMHost::readParams() m_m17Enabled = m_conf.getM17Enabled(); m_pocsagEnabled = m_conf.getPOCSAGEnabled(); m_fmEnabled = m_conf.getFMEnabled(); +#if defined(USE_AX25) m_ax25Enabled = m_conf.getAX25Enabled(); +#endif m_duplex = m_conf.getDuplex(); m_callsign = m_conf.getCallsign(); m_id = m_conf.getId(); @@ -1943,7 +1974,9 @@ void CMMDVMHost::readParams() LogInfo(" M17: %s", m_m17Enabled ? "enabled" : "disabled"); LogInfo(" POCSAG: %s", m_pocsagEnabled ? "enabled" : "disabled"); LogInfo(" FM: %s", m_fmEnabled ? "enabled" : "disabled"); +#if defined(USE_AX25) LogInfo(" AX.25: %s", m_ax25Enabled ? "enabled" : "disabled"); +#endif } void CMMDVMHost::setMode(unsigned char mode) @@ -1968,8 +2001,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(false); if (m_fmNetwork != NULL) m_fmNetwork->enable(false); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(false); +#endif if (m_dstar != NULL) m_dstar->enable(true); if (m_dmr != NULL) @@ -1986,8 +2021,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(false); if (m_fm != NULL) m_fm->enable(false); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(false); +#endif m_modem->setMode(MODE_DSTAR); m_mode = MODE_DSTAR; m_modeTimer.start(); @@ -2013,8 +2050,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(false); if (m_fmNetwork != NULL) m_fmNetwork->enable(false); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(false); +#endif if (m_dstar != NULL) m_dstar->enable(false); if (m_dmr != NULL) @@ -2031,8 +2070,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(false); if (m_fm != NULL) m_fm->enable(false); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(false); +#endif m_modem->setMode(MODE_DMR); if (m_duplex) { m_modem->writeDMRStart(true); @@ -2062,8 +2103,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(false); if (m_fmNetwork != NULL) m_fmNetwork->enable(false); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(false); +#endif if (m_dstar != NULL) m_dstar->enable(false); if (m_dmr != NULL) @@ -2080,8 +2123,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(false); if (m_fm != NULL) m_fm->enable(false); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(false); +#endif m_modem->setMode(MODE_YSF); m_mode = MODE_YSF; m_modeTimer.start(); @@ -2107,8 +2152,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(false); if (m_fmNetwork != NULL) m_fmNetwork->enable(false); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(false); +#endif if (m_dstar != NULL) m_dstar->enable(false); if (m_dmr != NULL) @@ -2125,8 +2172,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(false); if (m_fm != NULL) m_fm->enable(false); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(false); +#endif m_modem->setMode(MODE_P25); m_mode = MODE_P25; m_modeTimer.start(); @@ -2152,8 +2201,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(false); if (m_fmNetwork != NULL) m_fmNetwork->enable(false); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(false); +#endif if (m_dstar != NULL) m_dstar->enable(false); if (m_dmr != NULL) @@ -2170,8 +2221,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(false); if (m_fm != NULL) m_fm->enable(false); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(false); +#endif m_modem->setMode(MODE_NXDN); m_mode = MODE_NXDN; m_modeTimer.start(); @@ -2197,8 +2250,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(false); if (m_fmNetwork != NULL) m_fmNetwork->enable(false); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(false); +#endif if (m_dstar != NULL) m_dstar->enable(false); if (m_dmr != NULL) @@ -2215,8 +2270,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(false); if (m_fm != NULL) m_fm->enable(false); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(false); +#endif m_modem->setMode(MODE_M17); m_mode = MODE_M17; m_modeTimer.start(); @@ -2242,8 +2299,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(true); if (m_fmNetwork != NULL) m_fmNetwork->enable(false); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(false); +#endif if (m_dstar != NULL) m_dstar->enable(false); if (m_dmr != NULL) @@ -2260,8 +2319,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(true); if (m_fm != NULL) m_fm->enable(false); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(false); +#endif m_modem->setMode(MODE_POCSAG); m_mode = MODE_POCSAG; m_modeTimer.start(); @@ -2287,8 +2348,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(false); if (m_fmNetwork != NULL) m_fmNetwork->enable(true); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(true); +#endif if (m_dstar != NULL) m_dstar->enable(false); if (m_dmr != NULL) @@ -2305,8 +2368,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(false); if (m_fm != NULL) m_fm->enable(true); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(true); +#endif if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) { m_modem->writeDMRStart(false); m_dmrTXTimer.stop(); @@ -2336,8 +2401,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(false); if (m_fmNetwork != NULL) m_fmNetwork->enable(false); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(false); +#endif if (m_dstar != NULL) m_dstar->enable(false); if (m_dmr != NULL) @@ -2354,8 +2421,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(false); if (m_fm != NULL) m_fm->enable(false); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(false); +#endif if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) { m_modem->writeDMRStart(false); m_dmrTXTimer.stop(); @@ -2386,8 +2455,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(false); if (m_fmNetwork != NULL) m_fmNetwork->enable(false); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(false); +#endif if (m_dstar != NULL) m_dstar->enable(false); if (m_dmr != NULL) @@ -2404,8 +2475,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(false); if (m_fm != NULL) m_fm->enable(false); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(false); +#endif if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) { m_modem->writeDMRStart(false); m_dmrTXTimer.stop(); @@ -2434,8 +2507,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsagNetwork->enable(true); if (m_fmNetwork != NULL) m_fmNetwork->enable(true); +#if defined(USE_AX25) if (m_ax25Network != NULL) m_ax25Network->enable(true); +#endif if (m_dstar != NULL) m_dstar->enable(true); if (m_dmr != NULL) @@ -2452,8 +2527,10 @@ void CMMDVMHost::setMode(unsigned char mode) m_pocsag->enable(true); if (m_fm != NULL) m_fm->enable(true); +#if defined(USE_AX25) if (m_ax25 != NULL) m_ax25->enable(true); +#endif if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) { m_modem->writeDMRStart(false); m_dmrTXTimer.stop(); @@ -2475,7 +2552,7 @@ void CMMDVMHost::setMode(unsigned char mode) } } -void CMMDVMHost::createLockFile(const char* mode) const +void CMMDVMHost::createLockFile(const char* mode) const { if (m_lockFileEnabled) { FILE* fp = ::fopen(m_lockFileName.c_str(), "wt"); @@ -2486,7 +2563,7 @@ void CMMDVMHost::createLockFile(const char* mode) const } } -void CMMDVMHost::removeLockFile() const +void CMMDVMHost::removeLockFile() const { if (m_lockFileEnabled) ::remove(m_lockFileName.c_str()); @@ -2566,7 +2643,7 @@ void CMMDVMHost::remoteControl(const std::string& commandString) m_nxdnNetwork->enable(true); break; case RCD_ENABLE_M17: - if (m_m17 != NULL && m_m17Enabled == false) + if (m_m17 != NULL && !m_m17Enabled) processEnableCommand(m_m17Enabled, true); if (m_m17Network != NULL) m_m17Network->enable(true); @@ -2575,10 +2652,12 @@ void CMMDVMHost::remoteControl(const std::string& commandString) if (!m_fmEnabled) processEnableCommand(m_fmEnabled, true); break; +#if defined(USE_AX25) case RCD_ENABLE_AX25: if (!m_ax25Enabled) processEnableCommand(m_ax25Enabled, true); break; +#endif case RCD_DISABLE_DSTAR: if (m_dstar != NULL && m_dstarEnabled) processEnableCommand(m_dstarEnabled, false); @@ -2610,7 +2689,7 @@ void CMMDVMHost::remoteControl(const std::string& commandString) m_nxdnNetwork->enable(false); break; case RCD_DISABLE_M17: - if (m_m17 != NULL && m_m17Enabled == true) + if (m_m17 != NULL && m_m17Enabled) processEnableCommand(m_m17Enabled, false); if (m_m17Network != NULL) m_m17Network->enable(false); @@ -2619,10 +2698,12 @@ void CMMDVMHost::remoteControl(const std::string& commandString) if (m_fmEnabled) processEnableCommand(m_fmEnabled, false); break; +#if defined(USE_AX25) case RCD_DISABLE_AX25: - if (m_ax25Enabled == true) + if (m_ax25Enabled) processEnableCommand(m_ax25Enabled, false); break; +#endif case RCD_PAGE: if (m_pocsag != NULL) { unsigned int ric = m_remoteControl->getArgUInt(0U); diff --git a/MMDVMHost.h b/MMDVMHost.h index a975036..dd65d3e 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -40,6 +40,7 @@ #include "FMNetwork.h" #include "DMRLookup.h" #include "FMControl.h" +#include "Defines.h" #include "Timer.h" #include "Modem.h" #include "Conf.h" @@ -68,7 +69,9 @@ private: CM17Control* m_m17; CPOCSAGControl* m_pocsag; CFMControl* m_fm; +#if defined(USE_AX25) CAX25Control* m_ax25; +#endif CDStarNetwork* m_dstarNetwork; CDMRNetwork* m_dmrNetwork; CYSFNetwork* m_ysfNetwork; @@ -77,7 +80,9 @@ private: CM17Network* m_m17Network; CPOCSAGNetwork* m_pocsagNetwork; CFMNetwork* m_fmNetwork; +#if defined(USE_AX25) CAX25Network* m_ax25Network; +#endif unsigned char m_mode; unsigned int m_dstarRFModeHang; unsigned int m_dmrRFModeHang; @@ -129,7 +134,9 @@ private: bool createM17Network(); bool createPOCSAGNetwork(); bool createFMNetwork(); +#if defined(USE_AX25) bool createAX25Network(); +#endif void writeSerial(const std::string& message);