Skip to content

Commit

Permalink
Add more DMR beacon parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Jan 16, 2018
1 parent cae6bed commit 323179d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 29 deletions.
22 changes: 19 additions & 3 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ m_dstarErrorReply(true),
m_dstarRemoteGateway(false),
m_dstarModeHang(10U),
m_dmrEnabled(false),
m_dmrBeacons(0U),
m_dmrBeacons(false),
m_dmrBeaconInterval(60U),
m_dmrBeaconDuration(3U),
m_dmrId(0U),
m_dmrColorCode(2U),
m_dmrSelfOnly(false),
Expand Down Expand Up @@ -423,7 +425,11 @@ bool CConf::read()
if (::strcmp(key, "Enable") == 0)
m_dmrEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Beacons") == 0)
m_dmrBeacons = (unsigned int)::atoi(value);
m_dmrBeacons = ::atoi(value) == 1;
else if (::strcmp(key, "BeaconInterval") == 0)
m_dmrBeaconInterval = (unsigned int)::atoi(value);
else if (::strcmp(key, "BeaconDuration") == 0)
m_dmrBeaconDuration = (unsigned int)::atoi(value);
else if (::strcmp(key, "Id") == 0)
m_dmrId = (unsigned int)::atoi(value);
else if (::strcmp(key, "ColorCode") == 0)
Expand Down Expand Up @@ -928,11 +934,21 @@ bool CConf::getDMREnabled() const
return m_dmrEnabled;
}

unsigned int CConf::getDMRBeacons() const
bool CConf::getDMRBeacons() const
{
return m_dmrBeacons;
}

unsigned int CConf::getDMRBeaconInterval() const
{
return m_dmrBeaconInterval;
}

unsigned int CConf::getDMRBeaconDuration() const
{
return m_dmrBeaconDuration;
}

unsigned int CConf::getDMRId() const
{
return m_dmrId;
Expand Down
8 changes: 6 additions & 2 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ class CConf

// The DMR section
bool getDMREnabled() const;
unsigned int getDMRBeacons() const;
bool getDMRBeacons() const;
unsigned int getDMRBeaconInterval() const;
unsigned int getDMRBeaconDuration() const;
unsigned int getDMRId() const;
unsigned int getDMRColorCode() const;
bool getDMREmbeddedLCOnly() const;
Expand Down Expand Up @@ -278,7 +280,9 @@ class CConf
unsigned int m_dstarModeHang;

bool m_dmrEnabled;
unsigned int m_dmrBeacons;
bool m_dmrBeacons;
unsigned int m_dmrBeaconInterval;
unsigned int m_dmrBeaconDuration;
unsigned int m_dmrId;
unsigned int m_dmrColorCode;
bool m_dmrSelfOnly;
Expand Down
2 changes: 2 additions & 0 deletions MMDVM.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ RemoteGateway=0
[DMR]
Enable=1
Beacons=0
BeaconInterval=60
BeaconDuration=3
ColorCode=1
SelfOnly=0
EmbeddedLCOnly=0
Expand Down
53 changes: 30 additions & 23 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ m_dmrNetModeHang(3U),
m_ysfNetModeHang(3U),
m_p25NetModeHang(3U),
m_modeTimer(1000U),
m_dmrBeaconTimer(1000U),
m_dmrTXTimer(1000U),
m_cwIdTimer(1000U),
m_duplex(false),
Expand Down Expand Up @@ -364,6 +363,9 @@ int CMMDVMHost::run()
dstar = new CDStarControl(m_callsign, module, selfOnly, ackReply, ackTime, errorReply, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi);
}

CTimer dmrBeaconIntervalTimer(1000U);
CTimer dmrBeaconDurationTimer(1000U);

CDMRControl* dmr = NULL;
if (m_dmrEnabled) {
unsigned int id = m_conf.getDMRId();
Expand All @@ -379,7 +381,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();
bool dmrBeacons = m_conf.getDMRBeacons();

if (txHang > m_dmrRFModeHang)
txHang = m_dmrRFModeHang;
Expand Down Expand Up @@ -413,10 +415,17 @@ 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();
if (dmrBeacons) {
unsigned int dmrBeaconInterval = m_conf.getDMRBeaconInterval();
unsigned int dmrBeaconDuration = m_conf.getDMRBeaconDuration();

LogInfo(" DMR Roaming Beacon Interval: %us", dmrBeaconInterval);
LogInfo(" DMR Roaming Beacon Duration: %us", dmrBeaconDuration);

dmrBeaconDurationTimer.setTimeout(dmrBeaconDuration);

dmrBeaconIntervalTimer.setTimeout(dmrBeaconInterval);
dmrBeaconIntervalTimer.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);
Expand Down Expand Up @@ -466,8 +475,6 @@ 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);
Expand Down Expand Up @@ -523,13 +530,13 @@ int CMMDVMHost::run()
if (ret) {
m_modeTimer.setTimeout(m_dmrRFModeHang);
setMode(MODE_DMR);
dmrBeaconTimer.stop();
dmrBeaconDurationTimer.stop();
}
} else {
m_modeTimer.setTimeout(m_dmrRFModeHang);
setMode(MODE_DMR);
dmr->writeModemSlot1(data, len);
dmrBeaconTimer.stop();
dmrBeaconDurationTimer.stop();
}
} else if (m_mode == MODE_DMR) {
if (m_duplex && !m_modem->hasTX()) {
Expand All @@ -541,7 +548,7 @@ int CMMDVMHost::run()
} else {
bool ret = dmr->writeModemSlot1(data, len);
if (ret) {
dmrBeaconTimer.stop();
dmrBeaconDurationTimer.stop();
m_modeTimer.start();
if (m_duplex)
m_dmrTXTimer.start();
Expand All @@ -560,13 +567,13 @@ int CMMDVMHost::run()
if (ret) {
m_modeTimer.setTimeout(m_dmrRFModeHang);
setMode(MODE_DMR);
dmrBeaconTimer.stop();
dmrBeaconDurationTimer.stop();
}
} else {
m_modeTimer.setTimeout(m_dmrRFModeHang);
setMode(MODE_DMR);
dmr->writeModemSlot2(data, len);
dmrBeaconTimer.stop();
dmrBeaconDurationTimer.stop();
}
} else if (m_mode == MODE_DMR) {
if (m_duplex && !m_modem->hasTX()) {
Expand All @@ -578,7 +585,7 @@ int CMMDVMHost::run()
} else {
bool ret = dmr->writeModemSlot2(data, len);
if (ret) {
dmrBeaconTimer.stop();
dmrBeaconDurationTimer.stop();
m_modeTimer.start();
if (m_duplex)
m_dmrTXTimer.start();
Expand Down Expand Up @@ -658,7 +665,7 @@ int CMMDVMHost::run()
m_dmrTXTimer.start();
}
m_modem->writeDMRData1(data, len);
dmrBeaconTimer.stop();
dmrBeaconDurationTimer.stop();
m_modeTimer.start();
} else if (m_mode != MODE_LOCKOUT) {
LogWarning("DMR data received when in mode %u", m_mode);
Expand All @@ -680,7 +687,7 @@ int CMMDVMHost::run()
m_dmrTXTimer.start();
}
m_modem->writeDMRData2(data, len);
dmrBeaconTimer.stop();
dmrBeaconDurationTimer.stop();
m_modeTimer.start();
} else if (m_mode != MODE_LOCKOUT) {
LogWarning("DMR data received when in mode %u", m_mode);
Expand Down Expand Up @@ -765,19 +772,19 @@ int CMMDVMHost::run()
}
}

m_dmrBeaconTimer.clock(ms);
if (m_dmrBeaconTimer.isRunning() && m_dmrBeaconTimer.hasExpired()) {
dmrBeaconIntervalTimer.clock(ms);
if (dmrBeaconIntervalTimer.isRunning() && dmrBeaconIntervalTimer.hasExpired()) {
if (m_mode == MODE_IDLE && !m_modem->hasTX()) {
setMode(MODE_DMR);
m_dmrBeaconTimer.start();
dmrBeaconTimer.start();
dmrBeaconIntervalTimer.start();
dmrBeaconDurationTimer.start();
}
}

dmrBeaconTimer.clock(ms);
if (dmrBeaconTimer.isRunning() && dmrBeaconTimer.hasExpired()) {
dmrBeaconDurationTimer.clock(ms);
if (dmrBeaconDurationTimer.isRunning() && dmrBeaconDurationTimer.hasExpired()) {
setMode(MODE_IDLE);
dmrBeaconTimer.stop();
dmrBeaconDurationTimer.stop();
}

m_dmrTXTimer.clock(ms);
Expand Down
1 change: 0 additions & 1 deletion MMDVMHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class CMMDVMHost
unsigned int m_ysfNetModeHang;
unsigned int m_p25NetModeHang;
CTimer m_modeTimer;
CTimer m_dmrBeaconTimer;
CTimer m_dmrTXTimer;
CTimer m_cwIdTimer;
bool m_duplex;
Expand Down

0 comments on commit 323179d

Please sign in to comment.