Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new remote command: #736

Merged
merged 1 commit into from Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions DStarNetwork.cpp
Expand Up @@ -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());
Expand Down
35 changes: 35 additions & 0 deletions MMDVMHost.cpp
Expand Up @@ -28,6 +28,7 @@
#include "I2CController.h"
#endif
#include "UDPController.h"
#include "DStarDefines.h"
#include "Version.h"
#include "StopWatch.h"
#include "Defines.h"
Expand Down Expand Up @@ -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") + "\"";
}
1 change: 1 addition & 0 deletions MMDVMHost.h
Expand Up @@ -57,6 +57,7 @@ class CMMDVMHost
int run();

void buildNetworkStatusString(std::string &str);
void buildNetworkHostsString(std::string &str);

private:
CConf m_conf;
Expand Down
2 changes: 1 addition & 1 deletion RemoteCommand.cpp
Expand Up @@ -25,7 +25,7 @@
#include <chrono>
#include <thread>

const unsigned int BUFFER_LENGTH = 100U;
const unsigned int BUFFER_LENGTH = 1024U;

int main(int argc, char** argv)
{
Expand Down
8 changes: 8 additions & 0 deletions RemoteControl.cpp
Expand Up @@ -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";
}
Expand Down
3 changes: 2 additions & 1 deletion RemoteControl.h
Expand Up @@ -56,7 +56,8 @@ enum REMOTE_COMMAND {
RCD_PAGE,
RCD_CW,
RCD_RELOAD,
RCD_CONNECTION_STATUS
RCD_CONNECTION_STATUS,
RCD_CONFIG_HOSTS
};

class CRemoteControl {
Expand Down