diff --git a/Conf.cpp b/Conf.cpp index 9eb3112..87bd6bb 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -71,6 +71,7 @@ m_modemDebug(false), m_dstarEnabled(true), m_dstarModule("C"), m_dmrEnabled(true), +m_dmrBeacons(false), m_dmrId(0U), m_dmrColorCode(2U), m_fusionEnabled(true), @@ -209,6 +210,8 @@ bool CConf::read() } else if (section == SECTION_DMR) { if (::strcmp(key, "Enabled") == 0) m_dmrEnabled = ::atoi(value) == 1; + else if (::strcmp(key, "Beacons") == 0) + m_dmrBeacons = ::atoi(value) == 1; else if (::strcmp(key, "Id") == 0) m_dmrId = (unsigned int)::atoi(value); else if (::strcmp(key, "ColorCode") == 0) @@ -403,6 +406,11 @@ bool CConf::getDMREnabled() const return m_dmrEnabled; } +bool CConf::getDMRBeacons() const +{ + return m_dmrBeacons; +} + unsigned int CConf::getDMRId() const { return m_dmrId; diff --git a/Conf.h b/Conf.h index d81f189..a7eceab 100644 --- a/Conf.h +++ b/Conf.h @@ -69,6 +69,7 @@ public: // The DMR section bool getDMREnabled() const; + bool getDMRBeacons() const; unsigned int getDMRId() const; unsigned int getDMRColorCode() const; @@ -134,6 +135,7 @@ private: std::string m_dstarModule; bool m_dmrEnabled; + bool m_dmrBeacons; unsigned int m_dmrId; unsigned int m_dmrColorCode; diff --git a/Log.cpp b/Log.cpp index 19a6198..a48bf8e 100644 --- a/Log.cpp +++ b/Log.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,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 @@ -53,7 +53,7 @@ static bool LogOpen() } char filename[50U]; -#if defined(WIN32) +#if defined(_WIN32) || defined(_WIN64) ::sprintf(filename, "%s\\%s-%04d-%02d-%02d.log", m_path.c_str(), m_root.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); #else ::sprintf(filename, "%s/%s-%04d-%02d-%02d.log", m_path.c_str(), m_root.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); diff --git a/MMDVM.ini b/MMDVM.ini index 21e3220..2fad19c 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -9,8 +9,8 @@ Display=None RXFrequency=435000000 TXFrequency=435000000 Power=1 -Latitude=51.0 -Longitude=-1.0 +Latitude=0.0 +Longitude=0.0 Height=0 Location=Nowhere Description=Multi-Mode Repeater @@ -40,6 +40,7 @@ Module=C [DMR] Enable=1 +Beacons=1 Id=123456 ColorCode=1 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b21c1f4..2bb49ac 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -30,14 +30,14 @@ #include -#if !defined(WIN32) +#if !defined(_WIN32) && !defined(_WIN64) #include #include #endif static bool m_killed = false; -#if !defined(WIN32) +#if !defined(_WIN32) && !defined(_WIN64) static void sigHandler(int) { m_killed = true; @@ -55,7 +55,7 @@ int main(int argc, char** argv) return 1; } -#if !defined(WIN32) +#if !defined(_WIN32) && !defined(_WIN64) ::signal(SIGUSR1, sigHandler); #endif @@ -120,6 +120,9 @@ int CMMDVMHost::run() return 1; } + CTimer dmrBeaconTimer(1000U, 4U); + bool dmrBeaconsEnabled = m_dmrEnabled && m_conf.getDMRBeacons(); + CStopWatch stopWatch; stopWatch.start(); @@ -188,6 +191,7 @@ int CMMDVMHost::run() } } else if (mode == MODE_DMR) { dmr->writeModemSlot1(data); + dmrBeaconTimer.stop(); modeTimer.start(); } else { LogWarning("DMR data received when in mode %u", mode); @@ -208,6 +212,7 @@ int CMMDVMHost::run() } } else if (mode == MODE_DMR) { dmr->writeModemSlot2(data); + dmrBeaconTimer.stop(); modeTimer.start(); } else { LogWarning("DMR data received when in mode %u", mode); @@ -272,6 +277,7 @@ int CMMDVMHost::run() } if (len > 0U && mode == MODE_DMR) { m_modem->writeDMRData1(data, len); + dmrBeaconTimer.stop(); modeTimer.start(); } } @@ -285,6 +291,7 @@ int CMMDVMHost::run() } if (len > 0U && mode == MODE_DMR) { m_modem->writeDMRData2(data, len); + dmrBeaconTimer.stop(); modeTimer.start(); } } @@ -306,6 +313,16 @@ int CMMDVMHost::run() } } + if (m_dmrNetwork != NULL) { + bool run = m_dmrNetwork->wantsBeacon(); + + if (dmrBeaconsEnabled && run && mode == MODE_IDLE) { + mode = MODE_DMR; + m_modem->writeDMRStart(true); + dmrBeaconTimer.start(); + } + } + unsigned int ms = stopWatch.elapsed(); m_modem->clock(ms); modeTimer.clock(ms); @@ -317,8 +334,15 @@ int CMMDVMHost::run() ysf->clock(ms); stopWatch.start(); + dmrBeaconTimer.clock(ms); + if (dmrBeaconTimer.isRunning() && dmrBeaconTimer.hasExpired()) { + dmrBeaconTimer.stop(); + m_modem->writeDMRStart(false); + mode = MODE_IDLE; + } + if (ms < 5U) { -#if defined(WIN32) +#if defined(_WIN32) || defined(_WIN64) ::Sleep(5UL); // 5ms #else ::usleep(5000); // 5ms diff --git a/SHA256.h b/SHA256.h index 24d7be5..8dd739b 100644 --- a/SHA256.h +++ b/SHA256.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc. - * Copyright (C) 2011,2015 by Jonathan Naylor G4KLX + * Copyright (C) 2011,2015,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 @@ -20,7 +20,7 @@ #ifndef SHA256_H #define SHA256_H -#if defined(WIN32) +#if defined(_WIN32) || defined(_WIN64) typedef unsigned int uint32_t; #else #include diff --git a/SerialController.cpp b/SerialController.cpp index 25a6eaf..7cc8a9e 100644 --- a/SerialController.cpp +++ b/SerialController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2004,2007-2011,2013,2014,2015 by Jonathan Naylor G4KLX + * Copyright (C) 2002-2004,2007-2011,2013,2014-2016 by Jonathan Naylor G4KLX * Copyright (C) 1999-2001 by Thomas Sailor HB9JNX * * This program is free software; you can redistribute it and/or modify @@ -24,7 +24,7 @@ #include -#if defined(WIN32) +#if defined(_WIN32) || defined(_WIN64) #include #include #else @@ -37,7 +37,7 @@ #endif -#if defined(WIN32) +#if defined(_WIN32) || defined(_WIN64) const unsigned int BUFFER_LENGTH = 1000U; diff --git a/StopWatch.h b/StopWatch.h index 645664c..4b44cb6 100644 --- a/StopWatch.h +++ b/StopWatch.h @@ -35,7 +35,7 @@ public: unsigned int elapsed(); private: -#if defined(WIN32) +#if defined(_WIN32) || defined(_WIN64) LARGE_INTEGER m_frequency; LARGE_INTEGER m_start; #else