From d3395278c62e896999c341c1c79031068dd022cd Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 15 Jan 2018 19:22:01 +0000 Subject: [PATCH] Add locally timed DMR roaming beacons. --- Conf.cpp | 8 ++++---- Conf.h | 6 +++--- MMDVM.ini | 2 +- MMDVMHost.cpp | 30 +++++++++++++++++++----------- MMDVMHost.h | 3 ++- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 64139fc..5e2b2bc 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 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 @@ -110,7 +110,7 @@ m_dstarErrorReply(true), m_dstarRemoteGateway(false), m_dstarModeHang(10U), m_dmrEnabled(false), -m_dmrBeacons(false), +m_dmrBeacons(0U), m_dmrId(0U), m_dmrColorCode(2U), m_dmrSelfOnly(false), @@ -423,7 +423,7 @@ bool CConf::read() if (::strcmp(key, "Enable") == 0) m_dmrEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Beacons") == 0) - m_dmrBeacons = ::atoi(value) == 1; + m_dmrBeacons = (unsigned int)::atoi(value); else if (::strcmp(key, "Id") == 0) m_dmrId = (unsigned int)::atoi(value); else if (::strcmp(key, "ColorCode") == 0) @@ -928,7 +928,7 @@ bool CConf::getDMREnabled() const return m_dmrEnabled; } -bool CConf::getDMRBeacons() const +unsigned int CConf::getDMRBeacons() const { return m_dmrBeacons; } diff --git a/Conf.h b/Conf.h index ee48c99..719d6e8 100644 --- a/Conf.h +++ b/Conf.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 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 @@ -103,7 +103,7 @@ public: // The DMR section bool getDMREnabled() const; - bool getDMRBeacons() const; + unsigned int getDMRBeacons() const; unsigned int getDMRId() const; unsigned int getDMRColorCode() const; bool getDMREmbeddedLCOnly() const; @@ -278,7 +278,7 @@ private: unsigned int m_dstarModeHang; bool m_dmrEnabled; - bool m_dmrBeacons; + unsigned int m_dmrBeacons; unsigned int m_dmrId; unsigned int m_dmrColorCode; bool m_dmrSelfOnly; diff --git a/MMDVM.ini b/MMDVM.ini index 16f9ec9..0f18be8 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -77,7 +77,7 @@ RemoteGateway=0 [DMR] Enable=1 -Beacons=1 +Beacons=0 ColorCode=1 SelfOnly=0 EmbeddedLCOnly=0 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 61f3e73..22b755c 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -144,6 +144,7 @@ m_dmrNetModeHang(3U), m_ysfNetModeHang(3U), m_p25NetModeHang(3U), m_modeTimer(1000U), +m_dmrBeaconTimer(1000U), m_dmrTXTimer(1000U), m_cwIdTimer(1000U), m_duplex(false), @@ -310,9 +311,6 @@ int CMMDVMHost::run() m_cwIdTimer.start(); } - CTimer dmrBeaconTimer(1000U, 4U); - bool dmrBeaconsEnabled = m_dmrEnabled && m_conf.getDMRBeacons(); - // For all modes we handle RSSI std::string rssiMappingFile = m_conf.getModemRSSIMappingFile(); @@ -381,6 +379,7 @@ int CMMDVMHost::run() unsigned int callHang = m_conf.getDMRCallHang(); unsigned int txHang = m_conf.getDMRTXHang(); m_dmrRFModeHang = m_conf.getDMRModeHang(); + unsigned int dmrBeacons = m_conf.getDMRBeacons(); if (txHang > m_dmrRFModeHang) txHang = m_dmrRFModeHang; @@ -414,6 +413,12 @@ int CMMDVMHost::run() LogInfo(" TX Hang: %us", txHang); LogInfo(" Mode Hang: %us", m_dmrRFModeHang); + if (dmrBeacons > 0U) { + LogInfo(" DMR Roaming Beacons: %u mins", dmrBeacons); + m_dmrBeaconTimer.setTimeout(dmrBeacons * 60U); + m_dmrBeaconTimer.start(); + } + dmr = new CDMRControl(id, colorCode, callHang, selfOnly, embeddedLCOnly, dumpTAData, prefixes, blackList, whiteList, slot1TGWhiteList, slot2TGWhiteList, m_timeout, m_modem, m_dmrNetwork, m_display, m_duplex, m_lookup, rssi); m_dmrTXTimer.setTimeout(txHang); @@ -461,6 +466,8 @@ int CMMDVMHost::run() p25 = new CP25Control(nac, id, selfOnly, uidOverride, m_p25Network, m_display, m_timeout, m_duplex, m_lookup, remoteGateway, rssi); } + CTimer dmrBeaconTimer(1000U, 4U); + setMode(MODE_IDLE); LogMessage("MMDVMHost-%s is running", VERSION); @@ -720,14 +727,6 @@ int CMMDVMHost::run() } } - if (m_dmrNetwork != NULL) { - bool run = m_dmrNetwork->wantsBeacon(); - if (dmrBeaconsEnabled && run && m_mode == MODE_IDLE && !m_modem->hasTX()) { - setMode(MODE_DMR); - dmrBeaconTimer.start(); - } - } - unsigned int ms = stopWatch.elapsed(); stopWatch.start(); @@ -766,6 +765,15 @@ int CMMDVMHost::run() } } + m_dmrBeaconTimer.clock(ms); + if (m_dmrBeaconTimer.isRunning() && m_dmrBeaconTimer.hasExpired()) { + if (m_mode == MODE_IDLE && !m_modem->hasTX()) { + setMode(MODE_DMR); + m_dmrBeaconTimer.start(); + dmrBeaconTimer.start(); + } + } + dmrBeaconTimer.clock(ms); if (dmrBeaconTimer.isRunning() && dmrBeaconTimer.hasExpired()) { setMode(MODE_IDLE); diff --git a/MMDVMHost.h b/MMDVMHost.h index 190a805..c096033 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 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 @@ -59,6 +59,7 @@ private: unsigned int m_ysfNetModeHang; unsigned int m_p25NetModeHang; CTimer m_modeTimer; + CTimer m_dmrBeaconTimer; CTimer m_dmrTXTimer; CTimer m_cwIdTimer; bool m_duplex;