mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 15:09:23 +08:00
Add the optional DMR network options command.
This commit is contained in:
9
Conf.cpp
9
Conf.cpp
@@ -135,6 +135,7 @@ m_dmrNetworkAddress(),
|
||||
m_dmrNetworkPort(0U),
|
||||
m_dmrNetworkLocal(0U),
|
||||
m_dmrNetworkPassword(),
|
||||
m_dmrNetworkOptions(),
|
||||
m_dmrNetworkDebug(false),
|
||||
m_dmrNetworkJitter(300U),
|
||||
m_dmrNetworkSlot1(true),
|
||||
@@ -506,6 +507,8 @@ bool CConf::read()
|
||||
m_dmrNetworkLocal = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Password") == 0)
|
||||
m_dmrNetworkPassword = value;
|
||||
else if (::strcmp(key, "Options") == 0)
|
||||
m_dmrNetworkOptions = value;
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
m_dmrNetworkDebug = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Jitter") == 0)
|
||||
@@ -590,7 +593,6 @@ bool CConf::read()
|
||||
m_oledBrightness = (unsigned char)::atoi(value);
|
||||
else if (::strcmp(key, "Brightness") == 0)
|
||||
m_oledInvert = (unsigned char)::atoi(value);
|
||||
|
||||
} else if (section == SECTION_LCDPROC) {
|
||||
if (::strcmp(key, "Address") == 0)
|
||||
m_lcdprocAddress = value;
|
||||
@@ -1017,6 +1019,11 @@ std::string CConf::getDMRNetworkPassword() const
|
||||
return m_dmrNetworkPassword;
|
||||
}
|
||||
|
||||
std::string CConf::getDMRNetworkOptions() const
|
||||
{
|
||||
return m_dmrNetworkOptions;
|
||||
}
|
||||
|
||||
bool CConf::getDMRNetworkDebug() const
|
||||
{
|
||||
return m_dmrNetworkDebug;
|
||||
|
||||
2
Conf.h
2
Conf.h
@@ -136,6 +136,7 @@ public:
|
||||
unsigned int getDMRNetworkPort() const;
|
||||
unsigned int getDMRNetworkLocal() const;
|
||||
std::string getDMRNetworkPassword() const;
|
||||
std::string getDMRNetworkOptions() const;
|
||||
bool getDMRNetworkDebug() const;
|
||||
unsigned int getDMRNetworkJitter() const;
|
||||
bool getDMRNetworkSlot1() const;
|
||||
@@ -288,6 +289,7 @@ private:
|
||||
unsigned int m_dmrNetworkPort;
|
||||
unsigned int m_dmrNetworkLocal;
|
||||
std::string m_dmrNetworkPassword;
|
||||
std::string m_dmrNetworkOptions;
|
||||
bool m_dmrNetworkDebug;
|
||||
unsigned int m_dmrNetworkJitter;
|
||||
bool m_dmrNetworkSlot1;
|
||||
|
||||
@@ -52,6 +52,7 @@ m_buffer(NULL),
|
||||
m_salt(NULL),
|
||||
m_streamId(NULL),
|
||||
m_rxData(1000U, "DMR Network"),
|
||||
m_options(),
|
||||
m_callsign(),
|
||||
m_rxFrequency(0U),
|
||||
m_txFrequency(0U),
|
||||
@@ -97,6 +98,11 @@ CDMRNetwork::~CDMRNetwork()
|
||||
delete[] m_id;
|
||||
}
|
||||
|
||||
void CDMRNetwork::setOptions(const std::string& options)
|
||||
{
|
||||
m_options = options;
|
||||
}
|
||||
|
||||
void CDMRNetwork::setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, float latitude, float longitude, int height, const std::string& location, const std::string& description, const std::string& url)
|
||||
{
|
||||
m_callsign = callsign;
|
||||
@@ -362,6 +368,17 @@ void CDMRNetwork::clock(unsigned int ms)
|
||||
m_retryTimer.start();
|
||||
break;
|
||||
case WAITING_AUTHORISATION:
|
||||
if (m_options.empty()) {
|
||||
writeConfig();
|
||||
m_status = WAITING_CONFIG;
|
||||
} else {
|
||||
writeOptions();
|
||||
m_status = WAITING_OPTIONS;
|
||||
}
|
||||
m_timeoutTimer.start();
|
||||
m_retryTimer.start();
|
||||
break;
|
||||
case WAITING_OPTIONS:
|
||||
writeConfig();
|
||||
m_status = WAITING_CONFIG;
|
||||
m_timeoutTimer.start();
|
||||
@@ -398,6 +415,9 @@ void CDMRNetwork::clock(unsigned int ms)
|
||||
case WAITING_AUTHORISATION:
|
||||
writeAuthorisation();
|
||||
break;
|
||||
case WAITING_OPTIONS:
|
||||
writeOptions();
|
||||
break;
|
||||
case WAITING_CONFIG:
|
||||
writeConfig();
|
||||
break;
|
||||
@@ -450,6 +470,14 @@ bool CDMRNetwork::writeAuthorisation()
|
||||
return write(out, 40U);
|
||||
}
|
||||
|
||||
bool CDMRNetwork::writeOptions()
|
||||
{
|
||||
char buffer[300U];
|
||||
::sprintf(buffer, "RPTO%s", m_options.c_str());
|
||||
|
||||
return write((unsigned char*)buffer, (unsigned int)::strlen(buffer));
|
||||
}
|
||||
|
||||
bool CDMRNetwork::writeConfig()
|
||||
{
|
||||
const char* software = "MMDVM";
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, bool rssi, HW_TYPE hwType);
|
||||
~CDMRNetwork();
|
||||
|
||||
void setOptions(const std::string& options);
|
||||
|
||||
void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, float latitude, float longitude, int height, const std::string& location, const std::string& description, const std::string& url);
|
||||
|
||||
bool open();
|
||||
@@ -69,6 +71,7 @@ private:
|
||||
WAITING_CONNECT,
|
||||
WAITING_LOGIN,
|
||||
WAITING_AUTHORISATION,
|
||||
WAITING_OPTIONS,
|
||||
WAITING_CONFIG,
|
||||
RUNNING
|
||||
};
|
||||
@@ -82,6 +85,8 @@ private:
|
||||
|
||||
CRingBuffer<unsigned char> m_rxData;
|
||||
|
||||
std::string m_options;
|
||||
|
||||
std::string m_callsign;
|
||||
unsigned int m_rxFrequency;
|
||||
unsigned int m_txFrequency;
|
||||
@@ -98,6 +103,7 @@ private:
|
||||
|
||||
bool writeLogin();
|
||||
bool writeAuthorisation();
|
||||
bool writeOptions();
|
||||
bool writeConfig();
|
||||
bool writePing();
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ Port=62031
|
||||
Jitter=300
|
||||
# Local=3350
|
||||
Password=PASSWORD
|
||||
# Options=
|
||||
RSSI=0
|
||||
Slot1=1
|
||||
Slot2=1
|
||||
|
||||
@@ -903,6 +903,12 @@ bool CMMDVMHost::createDMRNetwork()
|
||||
|
||||
m_dmrNetwork = new CDMRNetwork(address, port, local, id, password, m_duplex, VERSION, debug, slot1, slot2, rssi, hwType);
|
||||
|
||||
std::string options = m_conf.getDMRNetworkOptions();
|
||||
if (!options.empty()) {
|
||||
LogInfo(" Options: %s", options.c_str());
|
||||
m_dmrNetwork->setOptions(options);
|
||||
}
|
||||
|
||||
unsigned int rxFrequency = m_conf.getRxFrequency();
|
||||
unsigned int txFrequency = m_conf.getTxFrequency();
|
||||
unsigned int power = m_conf.getPower();
|
||||
|
||||
Reference in New Issue
Block a user