Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add identification of the DMR Gateway to connected networks.
  • Loading branch information
g4klx committed Jun 4, 2018
1 parent aa4c906 commit afe593d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions DMRGateway.cpp
Expand Up @@ -997,7 +997,7 @@ bool CDMRGateway::createDMRNetwork1()
LogInfo(" Local: random");
LogInfo(" Location Data: %s", location ? "yes" : "no");

m_dmrNetwork1 = new CDMRNetwork(address, port, local, id, password, m_dmr1Name, debug);
m_dmrNetwork1 = new CDMRNetwork(address, port, local, id, password, m_dmr1Name, VERSION, debug);

std::string options = m_conf.getDMRNetwork1Options();
if (options.empty())
Expand Down Expand Up @@ -1124,7 +1124,7 @@ bool CDMRGateway::createDMRNetwork2()
LogInfo(" Local: random");
LogInfo(" Location Data: %s", location ? "yes" : "no");

m_dmrNetwork2 = new CDMRNetwork(address, port, local, id, password, m_dmr2Name, debug);
m_dmrNetwork2 = new CDMRNetwork(address, port, local, id, password, m_dmr2Name, VERSION, debug);

std::string options = m_conf.getDMRNetwork2Options();
if (options.empty())
Expand Down Expand Up @@ -1251,7 +1251,7 @@ bool CDMRGateway::createDMRNetwork3()
LogInfo(" Local: random");
LogInfo(" Location Data: %s", location ? "yes" : "no");

m_dmrNetwork3 = new CDMRNetwork(address, port, local, id, password, m_dmr3Name, debug);
m_dmrNetwork3 = new CDMRNetwork(address, port, local, id, password, m_dmr3Name, VERSION, debug);

std::string options = m_conf.getDMRNetwork3Options();
if (options.empty())
Expand Down Expand Up @@ -1427,7 +1427,7 @@ bool CDMRGateway::linkXLX(unsigned int number)
m_xlxConnected = false;
m_xlxRelink.stop();

m_xlxNetwork = new CDMRNetwork(reflector->m_address, m_xlxPort, m_xlxLocal, m_xlxId, m_xlxPassword, "XLX", m_xlxDebug);
m_xlxNetwork = new CDMRNetwork(reflector->m_address, m_xlxPort, m_xlxLocal, m_xlxId, m_xlxPassword, "XLX", VERSION, m_xlxDebug);

unsigned char config[400U];
unsigned int len = getConfig("XLX", config);
Expand Down
12 changes: 10 additions & 2 deletions DMRNetwork.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,12 +31,13 @@ const unsigned int BUFFER_LENGTH = 500U;
const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U;


CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, const std::string& name, bool debug) :
CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, const std::string& name, const char* version, bool debug) :
m_address(),
m_port(port),
m_id(NULL),
m_password(password),
m_name(name),
m_version(version),
m_debug(debug),
m_socket(local),
m_status(WAITING_CONNECT),
Expand All @@ -54,6 +55,7 @@ m_beacon(false)
assert(port > 0U);
assert(id > 1000U);
assert(!password.empty());
assert(version != NULL);

m_address = CUDPSocket::lookup(address);

Expand Down Expand Up @@ -473,6 +475,12 @@ bool CDMRNetwork::writeConfig()
::memcpy(buffer + 4U, m_id, 4U);
::memcpy(buffer + 8U, m_configData, m_configLen);

char software[40U];
::sprintf(software, "DMRGateway-%s", m_version);

::memset(buffer + 222U, ' ', 40U);
::memcpy(buffer + 222U, software, ::strlen(software));

return write((unsigned char*)buffer, m_configLen + 8U);
}

Expand Down
5 changes: 3 additions & 2 deletions DMRNetwork.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -30,7 +30,7 @@
class CDMRNetwork
{
public:
CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, const std::string& name, bool debug);
CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, const std::string& name, const char* version, bool debug);
~CDMRNetwork();

void setOptions(const std::string& options);
Expand Down Expand Up @@ -61,6 +61,7 @@ class CDMRNetwork
uint8_t* m_id;
std::string m_password;
std::string m_name;
const char* m_version;
bool m_debug;
CUDPSocket m_socket;

Expand Down

0 comments on commit afe593d

Please sign in to comment.