Skip to content

Commit ae9e6ea

Browse files
committed
Reset the mode's state machines when going to the disabled state.
1 parent b16aaa6 commit ae9e6ea

15 files changed

+286
-2
lines changed

DMRControl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,9 @@ bool CDMRControl::isBusy() const
130130

131131
return m_slot2.isBusy();
132132
}
133+
134+
void CDMRControl::enable(bool enabled)
135+
{
136+
m_slot1.enable(enabled);
137+
m_slot2.enable(enabled);
138+
}

DMRControl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class CDMRControl {
4646

4747
bool isBusy() const;
4848

49+
void enable(bool enabled);
50+
4951
private:
5052
unsigned int m_colorCode;
5153
CModem* m_modem;

DMRSlot.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ m_maxRSSI(0U),
115115
m_minRSSI(0U),
116116
m_aveRSSI(0U),
117117
m_rssiCount(0U),
118+
m_enabled(true),
118119
m_fp(NULL)
119120
{
120121
m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U];
@@ -2096,3 +2097,49 @@ bool CDMRSlot::isBusy() const
20962097
{
20972098
return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE;
20982099
}
2100+
2101+
void CDMRSlot::enable(bool enabled)
2102+
{
2103+
if (!enabled && m_enabled) {
2104+
m_queue.clear();
2105+
2106+
// Reset the RF section
2107+
m_rfState = RS_RF_LISTENING;
2108+
2109+
m_rfTimeoutTimer.stop();
2110+
m_rfTimeout = false;
2111+
2112+
m_rfFrames = 0U;
2113+
m_rfErrs = 0U;
2114+
m_rfBits = 1U;
2115+
2116+
m_rfSeqNo = 0U;
2117+
m_rfN = 0U;
2118+
2119+
delete m_rfLC;
2120+
m_rfLC = NULL;
2121+
2122+
// Reset the networking section
2123+
m_netState = RS_NET_IDLE;
2124+
2125+
m_lastFrameValid = false;
2126+
2127+
m_networkWatchdog.stop();
2128+
m_netTimeoutTimer.stop();
2129+
m_packetTimer.stop();
2130+
m_netTimeout = false;
2131+
2132+
m_netFrames = 0U;
2133+
m_netLost = 0U;
2134+
2135+
m_netErrs = 0U;
2136+
m_netBits = 1U;
2137+
2138+
m_netN = 0U;
2139+
2140+
delete m_netLC;
2141+
m_netLC = NULL;
2142+
}
2143+
2144+
m_enabled = enabled;
2145+
}

DMRSlot.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class CDMRSlot {
6060

6161
bool isBusy() const;
6262

63+
void enable(bool enabled);
64+
6365
static void init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter);
6466

6567
private:
@@ -107,6 +109,7 @@ class CDMRSlot {
107109
unsigned char m_minRSSI;
108110
unsigned int m_aveRSSI;
109111
unsigned int m_rssiCount;
112+
bool m_enabled;
110113
FILE* m_fp;
111114

112115
static unsigned int m_colorCode;

DStarControl.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ m_maxRSSI(0U),
8181
m_minRSSI(0U),
8282
m_aveRSSI(0U),
8383
m_rssiCount(0U),
84+
m_enabled(true),
8485
m_fp(NULL)
8586
{
8687
assert(display != NULL);
@@ -1226,3 +1227,26 @@ bool CDStarControl::isBusy() const
12261227
{
12271228
return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE;
12281229
}
1230+
1231+
void CDStarControl::enable(bool enabled)
1232+
{
1233+
if (!enabled && m_enabled) {
1234+
m_queue.clear();
1235+
1236+
// Reset the RF section
1237+
m_rfState = RS_RF_LISTENING;
1238+
1239+
m_rfTimeoutTimer.stop();
1240+
1241+
// Reset the networking section
1242+
m_netState = RS_NET_IDLE;
1243+
1244+
m_lastFrameValid = false;
1245+
1246+
m_netTimeoutTimer.stop();
1247+
m_networkWatchdog.stop();
1248+
m_packetTimer.stop();
1249+
}
1250+
1251+
m_enabled = enabled;
1252+
}

DStarControl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class CDStarControl {
4848

4949
bool isBusy() const;
5050

51+
void enable(bool enabled);
52+
5153
private:
5254
unsigned char* m_callsign;
5355
unsigned char* m_gateway;
@@ -93,6 +95,7 @@ class CDStarControl {
9395
unsigned char m_minRSSI;
9496
unsigned int m_aveRSSI;
9597
unsigned int m_rssiCount;
98+
bool m_enabled;
9699
FILE* m_fp;
97100

98101
void writeNetwork();

MMDVMHost.cpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,16 @@ void CMMDVMHost::setMode(unsigned char mode)
14571457
m_nxdnNetwork->enable(false);
14581458
if (m_pocsagNetwork != NULL)
14591459
m_pocsagNetwork->enable(false);
1460+
if (m_dmr != NULL)
1461+
m_dmr->enable(false);
1462+
if (m_ysf != NULL)
1463+
m_ysf->enable(false);
1464+
if (m_p25 != NULL)
1465+
m_p25->enable(false);
1466+
if (m_nxdn != NULL)
1467+
m_nxdn->enable(false);
1468+
if (m_pocsag != NULL)
1469+
m_pocsag->enable(false);
14601470
m_modem->setMode(MODE_DSTAR);
14611471
if (m_ump != NULL)
14621472
m_ump->setMode(MODE_DSTAR);
@@ -1477,6 +1487,16 @@ void CMMDVMHost::setMode(unsigned char mode)
14771487
m_nxdnNetwork->enable(false);
14781488
if (m_pocsagNetwork != NULL)
14791489
m_pocsagNetwork->enable(false);
1490+
if (m_dstar != NULL)
1491+
m_dstar->enable(false);
1492+
if (m_ysf != NULL)
1493+
m_ysf->enable(false);
1494+
if (m_p25 != NULL)
1495+
m_p25->enable(false);
1496+
if (m_nxdn != NULL)
1497+
m_nxdn->enable(false);
1498+
if (m_pocsag != NULL)
1499+
m_pocsag->enable(false);
14801500
m_modem->setMode(MODE_DMR);
14811501
if (m_ump != NULL)
14821502
m_ump->setMode(MODE_DMR);
@@ -1501,6 +1521,16 @@ void CMMDVMHost::setMode(unsigned char mode)
15011521
m_nxdnNetwork->enable(false);
15021522
if (m_pocsagNetwork != NULL)
15031523
m_pocsagNetwork->enable(false);
1524+
if (m_dstar != NULL)
1525+
m_dstar->enable(false);
1526+
if (m_dmr != NULL)
1527+
m_dmr->enable(false);
1528+
if (m_p25 != NULL)
1529+
m_p25->enable(false);
1530+
if (m_nxdn != NULL)
1531+
m_nxdn->enable(false);
1532+
if (m_pocsag != NULL)
1533+
m_pocsag->enable(false);
15041534
m_modem->setMode(MODE_YSF);
15051535
if (m_ump != NULL)
15061536
m_ump->setMode(MODE_YSF);
@@ -1521,6 +1551,16 @@ void CMMDVMHost::setMode(unsigned char mode)
15211551
m_nxdnNetwork->enable(false);
15221552
if (m_pocsagNetwork != NULL)
15231553
m_pocsagNetwork->enable(false);
1554+
if (m_dstar != NULL)
1555+
m_dstar->enable(false);
1556+
if (m_dmr != NULL)
1557+
m_dmr->enable(false);
1558+
if (m_ysf != NULL)
1559+
m_ysf->enable(false);
1560+
if (m_nxdn != NULL)
1561+
m_nxdn->enable(false);
1562+
if (m_pocsag != NULL)
1563+
m_pocsag->enable(false);
15241564
m_modem->setMode(MODE_P25);
15251565
if (m_ump != NULL)
15261566
m_ump->setMode(MODE_P25);
@@ -1541,6 +1581,16 @@ void CMMDVMHost::setMode(unsigned char mode)
15411581
m_p25Network->enable(false);
15421582
if (m_pocsagNetwork != NULL)
15431583
m_pocsagNetwork->enable(false);
1584+
if (m_dstar != NULL)
1585+
m_dstar->enable(false);
1586+
if (m_dmr != NULL)
1587+
m_dmr->enable(false);
1588+
if (m_ysf != NULL)
1589+
m_ysf->enable(false);
1590+
if (m_p25 != NULL)
1591+
m_p25->enable(false);
1592+
if (m_pocsag != NULL)
1593+
m_pocsag->enable(false);
15441594
m_modem->setMode(MODE_NXDN);
15451595
if (m_ump != NULL)
15461596
m_ump->setMode(MODE_NXDN);
@@ -1561,6 +1611,16 @@ void CMMDVMHost::setMode(unsigned char mode)
15611611
m_p25Network->enable(false);
15621612
if (m_nxdnNetwork != NULL)
15631613
m_nxdnNetwork->enable(false);
1614+
if (m_dstar != NULL)
1615+
m_dstar->enable(false);
1616+
if (m_dmr != NULL)
1617+
m_dmr->enable(false);
1618+
if (m_ysf != NULL)
1619+
m_ysf->enable(false);
1620+
if (m_p25 != NULL)
1621+
m_p25->enable(false);
1622+
if (m_nxdn != NULL)
1623+
m_nxdn->enable(false);
15641624
m_modem->setMode(MODE_POCSAG);
15651625
if (m_ump != NULL)
15661626
m_ump->setMode(MODE_POCSAG);
@@ -1584,6 +1644,18 @@ void CMMDVMHost::setMode(unsigned char mode)
15841644
m_nxdnNetwork->enable(false);
15851645
if (m_pocsagNetwork != NULL)
15861646
m_pocsagNetwork->enable(false);
1647+
if (m_dstar != NULL)
1648+
m_dstar->enable(false);
1649+
if (m_dmr != NULL)
1650+
m_dmr->enable(false);
1651+
if (m_ysf != NULL)
1652+
m_ysf->enable(false);
1653+
if (m_p25 != NULL)
1654+
m_p25->enable(false);
1655+
if (m_nxdn != NULL)
1656+
m_nxdn->enable(false);
1657+
if (m_pocsag != NULL)
1658+
m_pocsag->enable(false);
15871659
if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) {
15881660
m_modem->writeDMRStart(false);
15891661
m_dmrTXTimer.stop();
@@ -1612,6 +1684,18 @@ void CMMDVMHost::setMode(unsigned char mode)
16121684
m_nxdnNetwork->enable(false);
16131685
if (m_pocsagNetwork != NULL)
16141686
m_pocsagNetwork->enable(false);
1687+
if (m_dstar != NULL)
1688+
m_dstar->enable(false);
1689+
if (m_dmr != NULL)
1690+
m_dmr->enable(false);
1691+
if (m_ysf != NULL)
1692+
m_ysf->enable(false);
1693+
if (m_p25 != NULL)
1694+
m_p25->enable(false);
1695+
if (m_nxdn != NULL)
1696+
m_nxdn->enable(false);
1697+
if (m_pocsag != NULL)
1698+
m_pocsag->enable(false);
16151699
if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) {
16161700
m_modem->writeDMRStart(false);
16171701
m_dmrTXTimer.stop();
@@ -1638,6 +1722,18 @@ void CMMDVMHost::setMode(unsigned char mode)
16381722
m_nxdnNetwork->enable(true);
16391723
if (m_pocsagNetwork != NULL)
16401724
m_pocsagNetwork->enable(true);
1725+
if (m_dstar != NULL)
1726+
m_dstar->enable(false);
1727+
if (m_dmr != NULL)
1728+
m_dmr->enable(false);
1729+
if (m_ysf != NULL)
1730+
m_ysf->enable(false);
1731+
if (m_p25 != NULL)
1732+
m_p25->enable(false);
1733+
if (m_nxdn != NULL)
1734+
m_nxdn->enable(false);
1735+
if (m_pocsag != NULL)
1736+
m_pocsag->enable(false);
16411737
if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) {
16421738
m_modem->writeDMRStart(false);
16431739
m_dmrTXTimer.stop();

NXDNControl.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ m_maxRSSI(0U),
7171
m_minRSSI(0U),
7272
m_aveRSSI(0U),
7373
m_rssiCount(0U),
74+
m_enabled(true),
7475
m_fp(NULL)
7576
{
7677
assert(display != NULL);
@@ -1086,3 +1087,30 @@ bool CNXDNControl::isBusy() const
10861087
{
10871088
return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE;
10881089
}
1090+
1091+
void CNXDNControl::enable(bool enabled)
1092+
{
1093+
if (!enabled && m_enabled) {
1094+
m_queue.clear();
1095+
1096+
// Reset the RF section
1097+
m_rfState = RS_RF_LISTENING;
1098+
1099+
m_rfMask = 0x00U;
1100+
m_rfLayer3.reset();
1101+
1102+
m_rfTimeoutTimer.stop();
1103+
1104+
// Reset the networking section
1105+
m_netState = RS_NET_IDLE;
1106+
1107+
m_netMask = 0x00U;
1108+
m_netLayer3.reset();
1109+
1110+
m_netTimeoutTimer.stop();
1111+
m_networkWatchdog.stop();
1112+
m_packetTimer.stop();
1113+
}
1114+
1115+
m_enabled = enabled;
1116+
}

NXDNControl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class CNXDNControl {
4747

4848
bool isBusy() const;
4949

50+
void enable(bool enabled);
51+
5052
private:
5153
unsigned int m_ran;
5254
unsigned int m_id;
@@ -79,6 +81,7 @@ class CNXDNControl {
7981
unsigned char m_minRSSI;
8082
unsigned int m_aveRSSI;
8183
unsigned int m_rssiCount;
84+
bool m_enabled;
8285
FILE* m_fp;
8386

8487
bool processVoice(unsigned char usc, unsigned char option, unsigned char *data);

P25Control.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ m_maxRSSI(0U),
8080
m_minRSSI(0U),
8181
m_aveRSSI(0U),
8282
m_rssiCount(0U),
83+
m_enabled(true),
8384
m_fp(NULL)
8485
{
8586
assert(display != NULL);
@@ -1160,3 +1161,23 @@ bool CP25Control::isBusy() const
11601161
{
11611162
return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE;
11621163
}
1164+
1165+
void CP25Control::enable(bool enabled)
1166+
{
1167+
if (!enabled && m_enabled) {
1168+
m_queue.clear();
1169+
1170+
// Reset the RF section
1171+
m_rfState = RS_RF_LISTENING;
1172+
m_rfTimeout.stop();
1173+
m_rfData.reset();
1174+
1175+
// Reset the networking section
1176+
m_netTimeout.stop();
1177+
m_networkWatchdog.stop();
1178+
m_netData.reset();
1179+
m_netState = RS_NET_IDLE;
1180+
}
1181+
1182+
m_enabled = enabled;
1183+
}

0 commit comments

Comments
 (0)