Skip to content

Commit

Permalink
Simplify the Host to DMR Gateway protocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Aug 26, 2020
1 parent 6e89e49 commit b344248
Show file tree
Hide file tree
Showing 18 changed files with 378 additions and 383 deletions.
74 changes: 31 additions & 43 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ enum SECTION {
SECTION_DMR_NETWORK_4,
SECTION_DMR_NETWORK_5,
SECTION_XLX_NETWORK,
SECTION_DYNAMIC_TG_CONTROL
SECTION_DYNAMIC_TG_CONTROL,
SECTION_GPSD,
};

CConf::CConf(const std::string& file) :
Expand All @@ -59,14 +60,9 @@ m_logDisplayLevel(0U),
m_logFileLevel(0U),
m_logFilePath(),
m_logFileRoot(),
m_infoEnabled(false),
m_infoRXFrequency(0U),
m_infoTXFrequency(0U),
m_infoPower(0U),
m_infoLatitude(0.0F),
m_infoLongitude(0.0F),
m_infoHeight(0),
m_infoLocation(),
m_infoDescription(),
m_infoURL(),
m_dmrNetwork1Enabled(false),
Expand Down Expand Up @@ -175,7 +171,10 @@ m_xlxNetworkDebug(false),
m_xlxNetworkUserControl(true),
m_xlxNetworkModule(),
m_dynamicTGControlEnabled(false),
m_dynamicTGControlPort(3769U)
m_dynamicTGControlPort(3769U),
m_gpsdEnabled(false),
m_gpsdAddress(),
m_gpsdPort()
{
}

Expand Down Expand Up @@ -221,6 +220,8 @@ bool CConf::read()
section = SECTION_DMR_NETWORK_5;
else if (::strncmp(buffer, "[Dynamic TG Control]", 20U) == 0)
section = SECTION_DYNAMIC_TG_CONTROL;
else if (::strncmp(buffer, "[GPSD]", 6U) == 0)
section = SECTION_GPSD;
else
section = SECTION_NONE;

Expand Down Expand Up @@ -280,22 +281,12 @@ bool CConf::read()
else if (::strcmp(key, "Directory") == 0)
m_voiceDirectory = value;
} else if (section == SECTION_INFO) {
if (::strcmp(key, "Enabled") == 0)
m_infoEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "TXFrequency") == 0)
m_infoTXFrequency = (unsigned int)::atoi(value);
else if (::strcmp(key, "RXFrequency") == 0)
m_infoRXFrequency = (unsigned int)::atoi(value);
else if (::strcmp(key, "Power") == 0)
m_infoPower = (unsigned int)::atoi(value);
else if (::strcmp(key, "Latitude") == 0)
if (::strcmp(key, "Latitude") == 0)
m_infoLatitude = float(::atof(value));
else if (::strcmp(key, "Longitude") == 0)
m_infoLongitude = float(::atof(value));
else if (::strcmp(key, "Height") == 0)
m_infoHeight = ::atoi(value);
else if (::strcmp(key, "Location") == 0)
m_infoLocation = value;
else if (::strcmp(key, "Description") == 0)
m_infoDescription = value;
else if (::strcmp(key, "URL") == 0)
Expand Down Expand Up @@ -946,6 +937,13 @@ bool CConf::read()
m_dynamicTGControlEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Port") == 0)
m_dynamicTGControlPort = (unsigned int)::atoi(value);
} else if (section == SECTION_GPSD) {
if (::strcmp(key, "Enable") == 0)
m_gpsdEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Address") == 0)
m_gpsdAddress = value;
else if (::strcmp(key, "Port") == 0)
m_gpsdPort = value;
}
}

Expand Down Expand Up @@ -1034,26 +1032,6 @@ std::string CConf::getVoiceDirectory() const
return m_voiceDirectory;
}

bool CConf::getInfoEnabled() const
{
return m_infoEnabled;
}

unsigned int CConf::getInfoRXFrequency() const
{
return m_infoRXFrequency;
}

unsigned int CConf::getInfoTXFrequency() const
{
return m_infoTXFrequency;
}

unsigned int CConf::getInfoPower() const
{
return m_infoPower;
}

float CConf::getInfoLatitude() const
{
return m_infoLatitude;
Expand All @@ -1069,11 +1047,6 @@ int CConf::getInfoHeight() const
return m_infoHeight;
}

std::string CConf::getInfoLocation() const
{
return m_infoLocation;
}

std::string CConf::getInfoDescription() const
{
return m_infoDescription;
Expand Down Expand Up @@ -1631,3 +1604,18 @@ unsigned int CConf::getDynamicTGControlPort() const
{
return m_dynamicTGControlPort;
}

bool CConf::getGPSDEnabled() const
{
return m_gpsdEnabled;
}

std::string CConf::getGPSDAddress() const
{
return m_gpsdAddress;
}

std::string CConf::getGPSDPort() const
{
return m_gpsdPort;
}
19 changes: 9 additions & 10 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,9 @@ class CConf
std::string getVoiceDirectory() const;

// The Info section
bool getInfoEnabled() const;
unsigned int getInfoRXFrequency() const;
unsigned int getInfoTXFrequency() const;
unsigned int getInfoPower() const;
float getInfoLatitude() const;
float getInfoLongitude() const;
int getInfoHeight() const;
std::string getInfoLocation() const;
std::string getInfoDescription() const;
std::string getInfoURL() const;

Expand Down Expand Up @@ -232,6 +227,11 @@ class CConf
bool getDynamicTGControlEnabled() const;
unsigned int getDynamicTGControlPort() const;

// The GPSD section
bool getGPSDEnabled() const;
std::string getGPSDAddress() const;
std::string getGPSDPort() const;

private:
std::string m_file;
bool m_daemon;
Expand All @@ -253,14 +253,9 @@ class CConf
std::string m_logFilePath;
std::string m_logFileRoot;

bool m_infoEnabled;
unsigned int m_infoRXFrequency;
unsigned int m_infoTXFrequency;
unsigned int m_infoPower;
float m_infoLatitude;
float m_infoLongitude;
int m_infoHeight;
std::string m_infoLocation;
std::string m_infoDescription;
std::string m_infoURL;

Expand Down Expand Up @@ -377,6 +372,10 @@ class CConf

bool m_dynamicTGControlEnabled;
unsigned int m_dynamicTGControlPort;

bool m_gpsdEnabled;
std::string m_gpsdAddress;
std::string m_gpsdPort;
};

#endif
Loading

0 comments on commit b344248

Please sign in to comment.