Skip to content

Commit

Permalink
Start full host support got P25.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Sep 8, 2016
1 parent 694fe6b commit dc2028d
Show file tree
Hide file tree
Showing 12 changed files with 320 additions and 44 deletions.
76 changes: 74 additions & 2 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ enum SECTION {
SECTION_DSTAR,
SECTION_DMR,
SECTION_FUSION,
SECTION_P25,
SECTION_DSTAR_NETWORK,
SECTION_DMR_NETWORK,
SECTION_FUSION_NETWORK,
SECTION_P25_NETWORK,
SECTION_TFTSERIAL,
SECTION_HD44780,
SECTION_NEXTION,
Expand Down Expand Up @@ -80,6 +82,7 @@ m_modemRXLevel(50U),
m_modemDStarTXLevel(50U),
m_modemDMRTXLevel(50U),
m_modemYSFTXLevel(50U),
m_modemP25TXLevel(50U),
m_modemOscOffset(0),
m_modemRSSIMultiplier(0),
m_modemRSSIOffset(0),
Expand Down Expand Up @@ -107,6 +110,8 @@ m_dmrLookupFile(),
m_dmrCallHang(3U),
m_dmrTXHang(4U),
m_fusionEnabled(true),
m_p25Enabled(true),
m_p25Id(0U),
m_dstarNetworkEnabled(true),
m_dstarGatewayAddress(),
m_dstarGatewayPort(0U),
Expand All @@ -127,6 +132,11 @@ m_fusionNetworkMyPort(0U),
m_fusionNetworkGwyAddress(),
m_fusionNetworkGwyPort(0U),
m_fusionNetworkDebug(false),
m_p25NetworkEnabled(true),
m_p25GatewayAddress(),
m_p25GatewayPort(0U),
m_p25LocalPort(0U),
m_p25NetworkDebug(false),
m_tftSerialPort("/dev/ttyAMA0"),
m_tftSerialBrightness(50U),
m_hd44780Rows(2U),
Expand Down Expand Up @@ -186,13 +196,17 @@ bool CConf::read()
section = SECTION_DMR;
else if (::strncmp(buffer, "[System Fusion]", 15U) == 0)
section = SECTION_FUSION;
else if (::strncmp(buffer, "[P25]", 5U) == 0)
section = SECTION_P25;
else if (::strncmp(buffer, "[D-Star Network]", 16U) == 0)
section = SECTION_DSTAR_NETWORK;
else if (::strncmp(buffer, "[DMR Network]", 13U) == 0)
section = SECTION_DMR_NETWORK;
else if (::strncmp(buffer, "[System Fusion Network]", 23U) == 0)
section = SECTION_FUSION_NETWORK;
else if (::strncmp(buffer, "[TFT Serial]", 12U) == 0)
else if (::strncmp(buffer, "[P25 Network]", 13U) == 0)
section = SECTION_P25_NETWORK;
else if (::strncmp(buffer, "[TFT Serial]", 12U) == 0)
section = SECTION_TFTSERIAL;
else if (::strncmp(buffer, "[HD44780]", 9U) == 0)
section = SECTION_HD44780;
Expand Down Expand Up @@ -280,13 +294,15 @@ bool CConf::read()
else if (::strcmp(key, "RXLevel") == 0)
m_modemRXLevel = (unsigned int)::atoi(value);
else if (::strcmp(key, "TXLevel") == 0)
m_modemDStarTXLevel = m_modemDMRTXLevel = m_modemYSFTXLevel = (unsigned int)::atoi(value);
m_modemDStarTXLevel = m_modemDMRTXLevel = m_modemYSFTXLevel = m_modemP25TXLevel = (unsigned int)::atoi(value);
else if (::strcmp(key, "D-StarTXLevel") == 0)
m_modemDStarTXLevel = (unsigned int)::atoi(value);
else if (::strcmp(key, "DMRTXLevel") == 0)
m_modemDMRTXLevel = (unsigned int)::atoi(value);
else if (::strcmp(key, "YSFTXLevel") == 0)
m_modemYSFTXLevel = (unsigned int)::atoi(value);
else if (::strcmp(key, "P25TXLevel") == 0)
m_modemP25TXLevel = (unsigned int)::atoi(value);
else if (::strcmp(key, "OscOffset") == 0)
m_modemOscOffset = ::atoi(value);
else if (::strcmp(key, "RSSIMultiplier") == 0)
Expand Down Expand Up @@ -418,6 +434,11 @@ bool CConf::read()
} else if (section == SECTION_FUSION) {
if (::strcmp(key, "Enable") == 0)
m_fusionEnabled = ::atoi(value) == 1;
} else if (section == SECTION_P25) {
if (::strcmp(key, "Enable") == 0)
m_p25Enabled = ::atoi(value) == 1;
else if (::strcmp(key, "Id") == 0)
m_p25Id = (unsigned int)::atoi(value);
} else if (section == SECTION_DSTAR_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_dstarNetworkEnabled = ::atoi(value) == 1;
Expand Down Expand Up @@ -461,6 +482,17 @@ bool CConf::read()
m_fusionNetworkGwyPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_fusionNetworkDebug = ::atoi(value) == 1;
} else if (section == SECTION_P25_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_p25NetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "GatewayAddress") == 0)
m_p25GatewayAddress = value;
else if (::strcmp(key, "GatewayPort") == 0)
m_p25GatewayPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "LocalPort") == 0)
m_p25LocalPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_p25NetworkDebug = ::atoi(value) == 1;
} else if (section == SECTION_TFTSERIAL) {
if (::strcmp(key, "Port") == 0)
m_tftSerialPort = value;
Expand Down Expand Up @@ -680,6 +712,11 @@ unsigned int CConf::getModemYSFTXLevel() const
return m_modemYSFTXLevel;
}

unsigned int CConf::getModemP25TXLevel() const
{
return m_modemP25TXLevel;
}

int CConf::getModemOscOffset() const
{
return m_modemOscOffset;
Expand Down Expand Up @@ -804,6 +841,16 @@ bool CConf::getFusionEnabled() const
return m_fusionEnabled;
}

bool CConf::getP25Enabled() const
{
return m_p25Enabled;
}

unsigned int CConf::getP25Id() const
{
return m_p25Id;
}

bool CConf::getDStarNetworkEnabled() const
{
return m_dstarNetworkEnabled;
Expand Down Expand Up @@ -904,6 +951,31 @@ bool CConf::getFusionNetworkDebug() const
return m_fusionNetworkDebug;
}

bool CConf::getP25NetworkEnabled() const
{
return m_p25NetworkEnabled;
}

std::string CConf::getP25GatewayAddress() const
{
return m_p25GatewayAddress;
}

unsigned int CConf::getP25GatewayPort() const
{
return m_p25GatewayPort;
}

unsigned int CConf::getP25LocalPort() const
{
return m_p25LocalPort;
}

bool CConf::getP25NetworkDebug() const
{
return m_p25NetworkDebug;
}

std::string CConf::getTFTSerialPort() const
{
return m_tftSerialPort;
Expand Down
22 changes: 22 additions & 0 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class CConf
unsigned int getModemDStarTXLevel() const;
unsigned int getModemDMRTXLevel() const;
unsigned int getModemYSFTXLevel() const;
unsigned int getModemP25TXLevel() const;
int getModemOscOffset() const;
int getModemRSSIMultiplier() const;
int getModemRSSIOffset() const;
Expand Down Expand Up @@ -105,6 +106,10 @@ class CConf
// The System Fusion section
bool getFusionEnabled() const;

// The P25 section
bool getP25Enabled() const;
unsigned int getP25Id() const;

// The D-Star Network section
bool getDStarNetworkEnabled() const;
std::string getDStarGatewayAddress() const;
Expand All @@ -131,6 +136,13 @@ class CConf
unsigned int getFusionNetworkGwyPort() const;
bool getFusionNetworkDebug() const;

// The P25 Network section
bool getP25NetworkEnabled() const;
std::string getP25GatewayAddress() const;
unsigned int getP25GatewayPort() const;
unsigned int getP25LocalPort() const;
bool getP25NetworkDebug() const;

// The TFTSERIAL section
std::string getTFTSerialPort() const;
unsigned int getTFTSerialBrightness() const;
Expand Down Expand Up @@ -197,6 +209,7 @@ class CConf
unsigned int m_modemDStarTXLevel;
unsigned int m_modemDMRTXLevel;
unsigned int m_modemYSFTXLevel;
unsigned int m_modemP25TXLevel;
int m_modemOscOffset;
int m_modemRSSIMultiplier;
int m_modemRSSIOffset;
Expand Down Expand Up @@ -228,6 +241,9 @@ class CConf

bool m_fusionEnabled;

bool m_p25Enabled;
unsigned int m_p25Id;

bool m_dstarNetworkEnabled;
std::string m_dstarGatewayAddress;
unsigned int m_dstarGatewayPort;
Expand All @@ -251,6 +267,12 @@ class CConf
unsigned int m_fusionNetworkGwyPort;
bool m_fusionNetworkDebug;

bool m_p25NetworkEnabled;
std::string m_p25GatewayAddress;
unsigned int m_p25GatewayPort;
unsigned int m_p25LocalPort;
bool m_p25NetworkDebug;

std::string m_tftSerialPort;
unsigned int m_tftSerialBrightness;

Expand Down
12 changes: 12 additions & 0 deletions MMDVM.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ TXLevel=50
# D-StarTXLevel=50
# DMRTXLevel=50
# YSFTXLevel=50
# P25TXLevel=50
OscOffset=0
RSSIMultiplier=1
RSSIOffset=10
Expand Down Expand Up @@ -76,6 +77,10 @@ TXHang=4
[System Fusion]
Enable=1

[P25]
Enable=1
Id=123456

[D-Star Network]
Enable=1
GatewayAddress=127.0.0.1
Expand All @@ -102,6 +107,13 @@ GwyAddress=127.0.0.1
GwyPort=4200
Debug=0

[P25 Network]
Enable=1
GatewayAddress=127.0.0.1
GatewayPort=20010
LocalPort=20011
Debug=0

[TFT Serial]
Port=/dev/ttyAMA0
Brightness=50
Expand Down
21 changes: 19 additions & 2 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ m_timeout(180U),
m_dstarEnabled(false),
m_dmrEnabled(false),
m_ysfEnabled(false),
m_p25Enabled(false),
m_callsign()
{
}
Expand Down Expand Up @@ -684,6 +685,7 @@ bool CMMDVMHost::createModem()
unsigned int dstarTXLevel = m_conf.getModemDStarTXLevel();
unsigned int dmrTXLevel = m_conf.getModemDMRTXLevel();
unsigned int ysfTXLevel = m_conf.getModemYSFTXLevel();
unsigned int p25TXLevel = m_conf.getModemP25TXLevel();
bool debug = m_conf.getModemDebug();
unsigned int colorCode = m_conf.getDMRColorCode();
unsigned int rxFrequency = m_conf.getRxFrequency();
Expand All @@ -701,14 +703,15 @@ bool CMMDVMHost::createModem()
LogInfo(" D-Star TX Level: %u%%", dstarTXLevel);
LogInfo(" DMR TX Level: %u%%", dmrTXLevel);
LogInfo(" YSF TX Level: %u%%", ysfTXLevel);
LogInfo(" P25 TX Level: %u%%", p25TXLevel);
LogInfo(" RX Frequency: %uHz", rxFrequency);
LogInfo(" TX Frequency: %uHz", txFrequency);

LogInfo(" Osc. Offset: %dppm", oscOffset);

m_modem = new CModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, oscOffset, debug);
m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled);
m_modem->setLevels(rxLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel);
m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled);
m_modem->setLevels(rxLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel);
m_modem->setRFParams(rxFrequency, txFrequency);
m_modem->setDMRParams(colorCode);

Expand Down Expand Up @@ -844,6 +847,7 @@ void CMMDVMHost::readParams()
m_dstarEnabled = m_conf.getDStarEnabled();
m_dmrEnabled = m_conf.getDMREnabled();
m_ysfEnabled = m_conf.getFusionEnabled();
m_p25Enabled = m_conf.getP25Enabled();
m_duplex = m_conf.getDuplex();
m_callsign = m_conf.getCallsign();
m_timeout = m_conf.getTimeout();
Expand All @@ -860,6 +864,7 @@ void CMMDVMHost::readParams()
LogInfo(" D-Star: %s", m_dstarEnabled ? "enabled" : "disabled");
LogInfo(" DMR: %s", m_dmrEnabled ? "enabled" : "disabled");
LogInfo(" YSF: %s", m_ysfEnabled ? "enabled" : "disabled");
LogInfo(" P25: %s", m_p25Enabled ? "enabled" : "disabled");
}

void CMMDVMHost::createDisplay()
Expand Down Expand Up @@ -989,6 +994,18 @@ void CMMDVMHost::setMode(unsigned char mode)
m_modeTimer.start();
break;

case MODE_P25:
if (m_dstarNetwork != NULL)
m_dstarNetwork->enable(false);
if (m_dmrNetwork != NULL)
m_dmrNetwork->enable(false);
if (m_ysfNetwork != NULL)
m_ysfNetwork->enable(false);
m_modem->setMode(MODE_P25);
m_mode = MODE_P25;
m_modeTimer.start();
break;

case MODE_LOCKOUT:
LogMessage("Mode set to Lockout");
if (m_dstarNetwork != NULL)
Expand Down
1 change: 1 addition & 0 deletions MMDVMHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class CMMDVMHost
bool m_dstarEnabled;
bool m_dmrEnabled;
bool m_ysfEnabled;
bool m_p25Enabled;
std::string m_callsign;

void readParams();
Expand Down
1 change: 1 addition & 0 deletions MMDVMHost.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<ClInclude Include="Modem.h" />
<ClInclude Include="Nextion.h" />
<ClInclude Include="NullDisplay.h" />
<ClInclude Include="P25Defines.h" />
<ClInclude Include="QR1676.h" />
<ClInclude Include="RingBuffer.h" />
<ClInclude Include="RS129.h" />
Expand Down
3 changes: 3 additions & 0 deletions MMDVMHost.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@
<ClInclude Include="DMRAccessControl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="P25Defines.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="BPTC19696.cpp">
Expand Down
Loading

0 comments on commit dc2028d

Please sign in to comment.