Changes for DVMega via the host.

This commit is contained in:
Jonathan Naylor 2016-03-08 17:26:51 +00:00
parent fb1cebdc64
commit a2d456b98f
5 changed files with 34 additions and 20 deletions

View file

@ -31,14 +31,14 @@ const unsigned int BUFFER_LENGTH = 500U;
const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 53U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 53U;
CDMRIPSC::CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug, bool slot1, bool slot2) : CDMRIPSC::CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2) :
m_address(), m_address(),
m_port(port), m_port(port),
m_id(NULL), m_id(NULL),
m_password(password), m_password(password),
m_debug(debug), m_duplex(duplex),
m_software(software),
m_version(version), m_version(version),
m_debug(debug),
m_socket(), m_socket(),
m_enabled(false), m_enabled(false),
m_slot1(slot1), m_slot1(slot1),
@ -427,13 +427,19 @@ bool CDMRIPSC::writeAuthorisation()
bool CDMRIPSC::writeConfig() bool CDMRIPSC::writeConfig()
{ {
char* software = "MMDVM";
char slots = '0'; char slots = '0';
if (m_duplex) {
if (m_slot1 && m_slot2) if (m_slot1 && m_slot2)
slots = '3'; slots = '3';
else if (m_slot1 && !m_slot2) else if (m_slot1 && !m_slot2)
slots = '1'; slots = '1';
else if (!m_slot1 && m_slot2) else if (!m_slot1 && m_slot2)
slots = '2'; slots = '2';
} else {
software = "MMDVM-DVMega";
slots = '4';
}
char buffer[400U]; char buffer[400U];
@ -442,7 +448,7 @@ bool CDMRIPSC::writeConfig()
::sprintf(buffer + 8U, "%-8.8s%09u%09u%02u%02u%08f%09f%03d%-20.20s%-19.19s%c%-124.124s%-40.40s%-40.40s", m_callsign.c_str(), ::sprintf(buffer + 8U, "%-8.8s%09u%09u%02u%02u%08f%09f%03d%-20.20s%-19.19s%c%-124.124s%-40.40s%-40.40s", m_callsign.c_str(),
m_rxFrequency, m_txFrequency, m_power, m_colorCode, m_latitude, m_longitude, m_height, m_location.c_str(), m_rxFrequency, m_txFrequency, m_power, m_colorCode, m_latitude, m_longitude, m_height, m_location.c_str(),
m_description.c_str(), slots, m_url.c_str(), m_software, m_version); m_description.c_str(), slots, m_url.c_str(), m_version, software);
return write((unsigned char*)buffer, 302U); return write((unsigned char*)buffer, 302U);
} }

View file

@ -30,7 +30,7 @@
class CDMRIPSC class CDMRIPSC
{ {
public: public:
CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug, bool slot1, bool slot2); CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2);
~CDMRIPSC(); ~CDMRIPSC();
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); 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);
@ -54,9 +54,9 @@ private:
unsigned int m_port; unsigned int m_port;
uint8_t* m_id; uint8_t* m_id;
std::string m_password; std::string m_password;
bool m_debug; bool m_duplex;
const char* m_software;
const char* m_version; const char* m_version;
bool m_debug;
CUDPSocket m_socket; CUDPSocket m_socket;
bool m_enabled; bool m_enabled;
bool m_slot1; bool m_slot1;

View file

@ -29,10 +29,11 @@
const unsigned int BUFFER_LENGTH = 100U; const unsigned int BUFFER_LENGTH = 100U;
CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, const std::string& version, bool debug) : CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool duplex, const char* version, bool debug) :
m_socket(localPort), m_socket(localPort),
m_address(), m_address(),
m_port(gatewayPort), m_port(gatewayPort),
m_duplex(duplex),
m_version(version), m_version(version),
m_debug(debug), m_debug(debug),
m_enabled(false), m_enabled(false),
@ -174,9 +175,15 @@ void CDStarNetwork::clock(unsigned int ms)
if (m_pollTimer.hasExpired()) { if (m_pollTimer.hasExpired()) {
char text[60U]; char text[60U];
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
::sprintf(text, "win_mmdvm-%s", m_version.c_str()); if (m_duplex)
::sprintf(text, "win_mmdvm-%s", m_version);
else
::sprintf(text, "win_mmdvm-dvmega-%s", m_version);
#else #else
::sprintf(text, "linux_mmdvm-%s", m_version.c_str()); if (m_duplex)
::sprintf(text, "linux_mmdvm-%s", m_version);
else
::sprintf(text, "linux_mmdvm-dvmega-%s", m_version);
#endif #endif
writePoll(text); writePoll(text);
m_pollTimer.start(); m_pollTimer.start();

View file

@ -29,7 +29,7 @@
class CDStarNetwork { class CDStarNetwork {
public: public:
CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, const std::string& version, bool debug); CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool duplex, const char* version, bool debug);
~CDStarNetwork(); ~CDStarNetwork();
bool open(); bool open();
@ -53,7 +53,8 @@ private:
CUDPSocket m_socket; CUDPSocket m_socket;
in_addr m_address; in_addr m_address;
unsigned int m_port; unsigned int m_port;
std::string m_version; bool m_duplex;
const char* m_version;
bool m_debug; bool m_debug;
bool m_enabled; bool m_enabled;
uint16_t m_outId; uint16_t m_outId;

View file

@ -453,7 +453,7 @@ bool CMMDVMHost::createDStarNetwork()
LogInfo(" Gateway Port: %u", gatewayPort); LogInfo(" Gateway Port: %u", gatewayPort);
LogInfo(" Local Port: %u", localPort); LogInfo(" Local Port: %u", localPort);
m_dstarNetwork = new CDStarNetwork(gatewayAddress, gatewayPort, localPort, VERSION, debug); m_dstarNetwork = new CDStarNetwork(gatewayAddress, gatewayPort, localPort, m_duplex, VERSION, debug);
bool ret = m_dstarNetwork->open(); bool ret = m_dstarNetwork->open();
if (!ret) { if (!ret) {
@ -483,7 +483,7 @@ bool CMMDVMHost::createDMRNetwork()
LogInfo(" Slot 1: %s", slot1 ? "enabled" : "disabled"); LogInfo(" Slot 1: %s", slot1 ? "enabled" : "disabled");
LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled"); LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled");
m_dmrNetwork = new CDMRIPSC(address, port, id, password, VERSION, "MMDVM", debug, slot1, slot2); m_dmrNetwork = new CDMRIPSC(address, port, id, password, m_duplex, VERSION, debug, slot1, slot2);
std::string callsign = m_conf.getCallsign(); std::string callsign = m_conf.getCallsign();
unsigned int rxFrequency = m_conf.getRxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency();