Skip to content

Commit

Permalink
Add the concept of fixed modes.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Jan 18, 2019
1 parent 76badb2 commit b16aaa6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
62 changes: 50 additions & 12 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ m_cwCallsign(),
m_lockFileEnabled(false),
m_lockFileName(),
m_mobileGPS(NULL),
m_remoteControl(NULL)
m_remoteControl(NULL),
m_fixedMode(false)
{
}

Expand Down Expand Up @@ -593,7 +594,26 @@ int CMMDVMHost::run()
}
}

setMode(MODE_IDLE);
// If only one voice mode is enabled, fix to that mode.
if (m_dstar != NULL && m_dmr == NULL && m_ysf == NULL && m_p25 == NULL && m_nxdn == NULL && m_pocsag == NULL) {
m_fixedMode = true;
setMode(MODE_DSTAR);
} else if (m_dstar == NULL && m_dmr != NULL && m_ysf == NULL && m_p25 == NULL && m_nxdn == NULL && m_pocsag == NULL) {
m_fixedMode = true;
setMode(MODE_DMR);
} else if (m_dstar == NULL && m_dmr == NULL && m_ysf != NULL && m_p25 == NULL && m_nxdn == NULL && m_pocsag == NULL) {
m_fixedMode = true;
setMode(MODE_YSF);
} else if (m_dstar == NULL && m_dmr == NULL && m_ysf == NULL && m_p25 != NULL && m_nxdn == NULL && m_pocsag == NULL) {
m_fixedMode = true;
setMode(MODE_P25);
} else if (m_dstar == NULL && m_dmr == NULL && m_ysf == NULL && m_p25 == NULL && m_nxdn != NULL && m_pocsag == NULL) {
m_fixedMode = true;
setMode(MODE_NXDN);
} else {
m_fixedMode = false;
setMode(MODE_IDLE);
}

LogMessage("MMDVMHost-%s is running", VERSION);

Expand Down Expand Up @@ -767,8 +787,10 @@ int CMMDVMHost::run()
if (transparentSocket != NULL && len > 0U)
transparentSocket->write(data, len, transparentAddress, transparentPort);

if (m_modeTimer.isRunning() && m_modeTimer.hasExpired())
setMode(MODE_IDLE);
if (!m_fixedMode) {
if (m_modeTimer.isRunning() && m_modeTimer.hasExpired())
setMode(MODE_IDLE);
}

if (m_dstar != NULL) {
ret = m_modem->hasDStarSpace();
Expand Down Expand Up @@ -927,7 +949,9 @@ int CMMDVMHost::run()
m_display->clock(ms);

m_modem->clock(ms);
m_modeTimer.clock(ms);

if (!m_fixedMode)
m_modeTimer.clock(ms);

if (m_dstar != NULL)
m_dstar->clock();
Expand Down Expand Up @@ -1684,32 +1708,46 @@ void CMMDVMHost::remoteControl()
REMOTE_COMMAND command = m_remoteControl->getCommand();
switch(command) {
case RCD_MODE_IDLE:
if (m_mode != MODE_IDLE)
if (m_mode != MODE_IDLE) {
m_fixedMode = false;
setMode(MODE_IDLE);
}
break;
case RCD_MODE_LOCKOUT:
if (m_mode != MODE_LOCKOUT)
if (m_mode != MODE_LOCKOUT) {
m_fixedMode = false;
setMode(MODE_LOCKOUT);
}
break;
case RCD_MODE_DSTAR:
if (m_dstar != NULL && m_mode != MODE_DSTAR)
if (m_dstar != NULL && m_mode != MODE_DSTAR) {
m_fixedMode = true;
setMode(MODE_DSTAR);
}
break;
case RCD_MODE_DMR:
if (m_dmr != NULL && m_mode != MODE_DMR)
if (m_dmr != NULL && m_mode != MODE_DMR) {
m_fixedMode = true;
setMode(MODE_DMR);
}
break;
case RCD_MODE_YSF:
if (m_ysf != NULL && m_mode != MODE_YSF)
if (m_ysf != NULL && m_mode != MODE_YSF) {
m_fixedMode = true;
setMode(MODE_YSF);
}
break;
case RCD_MODE_P25:
if (m_p25 != NULL && m_mode != MODE_P25)
if (m_p25 != NULL && m_mode != MODE_P25) {
m_fixedMode = true;
setMode(MODE_P25);
}
break;
case RCD_MODE_NXDN:
if (m_nxdn != NULL && m_mode != MODE_NXDN)
if (m_nxdn != NULL && m_mode != MODE_NXDN) {
m_fixedMode = true;
setMode(MODE_NXDN);
}
break;
default:
break;
Expand Down
1 change: 1 addition & 0 deletions MMDVMHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class CMMDVMHost
std::string m_lockFileName;
CMobileGPS* m_mobileGPS;
CRemoteControl* m_remoteControl;
bool m_fixedMode;

void readParams();
bool createModem();
Expand Down

0 comments on commit b16aaa6

Please sign in to comment.