Skip to content

Commit

Permalink
Merge pull request #736 from f1rmb/hosts_remote_command
Browse files Browse the repository at this point in the history
Add new remote command:
  • Loading branch information
g4klx committed Jan 24, 2022
2 parents fed4400 + a30ae3a commit f81e8fb
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions DStarNetwork.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit f81e8fb

Please sign in to comment.