Skip to content

Commit

Permalink
Re-introduce optional network DMR beacons.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Naylor committed Nov 5, 2019
1 parent 079c95a commit 98e0869
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 23 deletions.
11 changes: 6 additions & 5 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ m_dstarErrorReply(true),
m_dstarRemoteGateway(false),
m_dstarModeHang(10U),
m_dmrEnabled(false),
m_dmrBeacons(false),
m_dmrBeacons(DMR_BEACONS_OFF),
m_dmrBeaconInterval(60U),
m_dmrBeaconDuration(3U),
m_dmrId(0U),
Expand Down Expand Up @@ -530,10 +530,11 @@ bool CConf::read()
if (::strcmp(key, "Enable") == 0)
m_dmrEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Beacons") == 0)
m_dmrBeacons = ::atoi(value) == 1;
else if (::strcmp(key, "BeaconInterval") == 0)
m_dmrBeacons = ::atoi(value) == 1 ? DMR_BEACONS_NETWORK : DMR_BEACONS_OFF;
else if (::strcmp(key, "BeaconInterval") == 0) {
m_dmrBeacons = m_dmrBeacons != DMR_BEACONS_OFF ? DMR_BEACONS_TIMED : DMR_BEACONS_OFF;
m_dmrBeaconInterval = (unsigned int)::atoi(value);
else if (::strcmp(key, "BeaconDuration") == 0)
} else if (::strcmp(key, "BeaconDuration") == 0)
m_dmrBeaconDuration = (unsigned int)::atoi(value);
else if (::strcmp(key, "Id") == 0)
m_dmrId = (unsigned int)::atoi(value);
Expand Down Expand Up @@ -1174,7 +1175,7 @@ bool CConf::getDMREnabled() const
return m_dmrEnabled;
}

bool CConf::getDMRBeacons() const
DMR_BEACONS CConf::getDMRBeacons() const
{
return m_dmrBeacons;
}
Expand Down
2 changes: 1 addition & 1 deletion Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class CConf

// The DMR section
bool getDMREnabled() const;
bool getDMRBeacons() const;
DMR_BEACONS getDMRBeacons() const;
unsigned int getDMRBeaconInterval() const;
unsigned int getDMRBeaconDuration() const;
unsigned int getDMRId() const;
Expand Down
6 changes: 6 additions & 0 deletions Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@ enum RPT_NET_STATE {
RS_NET_DATA
};

enum DMR_BEACONS {
DMR_BEACONS_OFF,
DMR_BEACONS_NETWORK,
DMR_BEACONS_TIMED
};

#endif
68 changes: 51 additions & 17 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ int CMMDVMHost::run()
unsigned int txHang = m_conf.getDMRTXHang();
unsigned int jitter = m_conf.getDMRNetworkJitter();
m_dmrRFModeHang = m_conf.getDMRModeHang();
bool dmrBeacons = m_conf.getDMRBeacons();
DMR_BEACONS dmrBeacons = m_conf.getDMRBeacons();
bool ovcm = m_conf.getDMROVCM();

if (txHang > m_dmrRFModeHang)
Expand Down Expand Up @@ -479,17 +479,33 @@ int CMMDVMHost::run()
LogInfo(" Mode Hang: %us", m_dmrRFModeHang);
LogInfo(" OVCM: %s", ovcm ? "on" : "off");

if (dmrBeacons) {
unsigned int dmrBeaconInterval = m_conf.getDMRBeaconInterval();
unsigned int dmrBeaconDuration = m_conf.getDMRBeaconDuration();
switch (dmrBeacons) {
case DMR_BEACONS_NETWORK: {
unsigned int dmrBeaconDuration = m_conf.getDMRBeaconDuration();

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

dmrBeaconDurationTimer.setTimeout(dmrBeaconDuration);
dmrBeaconDurationTimer.setTimeout(dmrBeaconDuration);
}
break;
case DMR_BEACONS_TIMED: {
unsigned int dmrBeaconInterval = m_conf.getDMRBeaconInterval();
unsigned int dmrBeaconDuration = m_conf.getDMRBeaconDuration();

LogInfo(" DMR Roaming Beacons Type: timed");
LogInfo(" DMR Roaming Beacons Interval: %us", dmrBeaconInterval);
LogInfo(" DMR Roaming Beacons Duration: %us", dmrBeaconDuration);

dmrBeaconDurationTimer.setTimeout(dmrBeaconDuration);

dmrBeaconIntervalTimer.setTimeout(dmrBeaconInterval);
dmrBeaconIntervalTimer.start();
dmrBeaconIntervalTimer.setTimeout(dmrBeaconInterval);
dmrBeaconIntervalTimer.start();
}
break;
default:
LogInfo(" DMR Roaming Beacons Type: off");
break;
}

m_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_dmrLookup, rssi, jitter, ovcm);
Expand Down Expand Up @@ -977,14 +993,32 @@ int CMMDVMHost::run()
}
}

dmrBeaconIntervalTimer.clock(ms);
if (dmrBeaconIntervalTimer.isRunning() && dmrBeaconIntervalTimer.hasExpired()) {
if ((m_mode == MODE_IDLE || m_mode == MODE_DMR) && !m_modem->hasTX()) {
if (!m_fixedMode && m_mode == MODE_IDLE)
setMode(MODE_DMR);
dmrBeaconIntervalTimer.start();
dmrBeaconDurationTimer.start();
}
switch (dmrBeacons) {
case DMR_BEACONS_TIMED:
dmrBeaconIntervalTimer.clock(ms);
if (dmrBeaconIntervalTimer.isRunning() && dmrBeaconIntervalTimer.hasExpired()) {
if ((m_mode == MODE_IDLE || m_mode == MODE_DMR) && !m_modem->hasTX()) {
if (!m_fixedMode && m_mode == MODE_IDLE)
setMode(MODE_DMR);
dmrBeaconIntervalTimer.start();
dmrBeaconDurationTimer.start();
}
}
break;
case DMR_BEACONS_NETWORK:
if (m_dmrNetwork != NULL) {
bool beacon = m_dmrNetwork->wantsBeacon();
if (beacon) {
if ((m_mode == MODE_IDLE || m_mode == MODE_DMR) && !m_modem->hasTX()) {
if (!m_fixedMode && m_mode == MODE_IDLE)
setMode(MODE_DMR);
dmrBeaconDurationTimer.start();
}
}
}
break;
default:
break;
}

dmrBeaconDurationTimer.clock(ms);
Expand Down

0 comments on commit 98e0869

Please sign in to comment.