diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index 918d989..dbb6a2c 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -51,6 +51,7 @@ m_random() m_addrLen = 0U; m_linkReflector = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH]; + ::memset(m_linkReflector, 0, DSTAR_LONG_CALLSIGN_LENGTH); std::random_device rd; std::mt19937 mt(rd()); diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 36f6faf..11f3231 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -28,6 +28,7 @@ #include "I2CController.h" #endif #include "UDPController.h" +#include "DStarDefines.h" #include "Version.h" #include "StopWatch.h" #include "Defines.h" @@ -2701,3 +2702,37 @@ void CMMDVMHost::buildNetworkStatusString(std::string &str) str += std::string(" m17:") + (((m_m17Network == NULL) || (m_m17Enabled == false)) ? "n/a" : (m_m17Network->isConnected() ? "conn" : "disc")); str += std::string(" fm:") + (m_fmEnabled ? "conn" : "n/a"); } + +void CMMDVMHost::buildNetworkHostsString(std::string &str) +{ + str = ""; + + std::string dstarReflector; + if (m_dstarEnabled && (m_dstarNetwork != NULL)) { + unsigned char ref[DSTAR_LONG_CALLSIGN_LENGTH + 1]; + LINK_STATUS status; + + ::memset(ref, 0, sizeof(ref)); + + m_dstarNetwork->getStatus(status, &ref[0]); + switch (status) { + case LINK_STATUS::LS_LINKED_LOOPBACK: + case LINK_STATUS::LS_LINKED_DEXTRA: + case LINK_STATUS::LS_LINKED_DPLUS: + case LINK_STATUS::LS_LINKED_DCS: + case LINK_STATUS::LS_LINKED_CCS: + dstarReflector = std::string((char *)ref); + break; + + default: + break; + } + } + str += std::string("dstar:\"") + ((dstarReflector.length() == 0) ? "NONE" : dstarReflector) + "\""; + str += std::string(" dmr:\"") + ((m_dmrEnabled && (m_dmrNetwork != NULL)) ? m_conf.getDMRNetworkRemoteAddress() : "NONE") + "\""; + str += std::string(" ysf:\"") + ((m_ysfEnabled && (m_ysfNetwork != NULL)) ? m_conf.getFusionNetworkGatewayAddress() : "NONE") + "\""; + str += std::string(" p25:\"") + ((m_p25Enabled && (m_p25Network != NULL)) ? m_conf.getP25GatewayAddress() : "NONE") + "\""; + str += std::string(" nxdn:\"") + ((m_nxdnEnabled && (m_nxdnNetwork != NULL)) ? m_conf.getNXDNGatewayAddress() : "NONE") + "\""; + str += std::string(" m17:\"") + ((m_m17Enabled && (m_m17Network != NULL)) ? m_conf.getM17GatewayAddress() : "NONE") + "\""; + str += std::string(" fm:\"") + ((m_fmEnabled && (m_fmNetwork != NULL)) ? m_conf.getFMGatewayAddress() : "NONE") + "\""; +} diff --git a/MMDVMHost.h b/MMDVMHost.h index ee312e3..a97f72e 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -57,6 +57,7 @@ public: int run(); void buildNetworkStatusString(std::string &str); + void buildNetworkHostsString(std::string &str); private: CConf m_conf; diff --git a/RemoteCommand.cpp b/RemoteCommand.cpp index c893d79..4b9dcec 100644 --- a/RemoteCommand.cpp +++ b/RemoteCommand.cpp @@ -25,7 +25,7 @@ #include #include -const unsigned int BUFFER_LENGTH = 100U; +const unsigned int BUFFER_LENGTH = 1024U; int main(int argc, char** argv) { diff --git a/RemoteControl.cpp b/RemoteControl.cpp index d24fe46..35aa947 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -151,6 +151,14 @@ REMOTE_COMMAND CRemoteControl::getCommand() } m_command = RCD_CONNECTION_STATUS; + } else if (m_args.at(0U) == "hosts") { + if (m_host != NULL) { + m_host->buildNetworkHostsString(replyStr); + } else { + replyStr = "KO"; + } + + m_command = RCD_CONFIG_HOSTS; } else { replyStr = "KO"; } diff --git a/RemoteControl.h b/RemoteControl.h index 4d47055..5f2610c 100644 --- a/RemoteControl.h +++ b/RemoteControl.h @@ -56,7 +56,8 @@ enum REMOTE_COMMAND { RCD_PAGE, RCD_CW, RCD_RELOAD, - RCD_CONNECTION_STATUS + RCD_CONNECTION_STATUS, + RCD_CONFIG_HOSTS }; class CRemoteControl {