Merge branch 'master' into M17_AX25_FM

This commit is contained in:
Jonathan Naylor
2021-03-22 22:14:54 +00:00
21 changed files with 90 additions and 10 deletions

View File

@@ -316,6 +316,11 @@ bool CDMRDirectNetwork::writeTalkerAlias(unsigned int id, unsigned char type, co
return write(buffer, 15U); return write(buffer, 15U);
} }
bool CDMRDirectNetwork::isConnected() const
{
return (m_status == RUNNING);
}
void CDMRDirectNetwork::close() void CDMRDirectNetwork::close()
{ {
LogMessage("Closing DMR Network"); LogMessage("Closing DMR Network");

View File

@@ -55,6 +55,8 @@ public:
virtual void clock(unsigned int ms); virtual void clock(unsigned int ms);
virtual bool isConnected() const;
virtual void close(); virtual void close();
private: private:

View File

@@ -287,6 +287,11 @@ bool CDMRGatewayNetwork::writeTalkerAlias(unsigned int id, unsigned char type, c
return write(buffer, 15U); return write(buffer, 15U);
} }
bool CDMRGatewayNetwork::isConnected() const
{
return (m_enabled && (m_addrLen != 0));
}
void CDMRGatewayNetwork::close() void CDMRGatewayNetwork::close()
{ {
LogMessage("DMR, Closing DMR Network"); LogMessage("DMR, Closing DMR Network");

View File

@@ -56,6 +56,8 @@ public:
virtual void clock(unsigned int ms); virtual void clock(unsigned int ms);
virtual bool isConnected() const;
virtual void close(); virtual void close();
private: private:

View File

@@ -48,6 +48,8 @@ public:
virtual void clock(unsigned int ms) = 0; virtual void clock(unsigned int ms) = 0;
virtual bool isConnected() const = 0;
virtual void close() = 0; virtual void close() = 0;
private: private:

View File

@@ -314,6 +314,11 @@ void CDStarNetwork::reset()
m_inId = 0U; m_inId = 0U;
} }
bool CDStarNetwork::isConnected() const
{
return (m_enabled && (m_addrLen != 0));
}
void CDStarNetwork::close() void CDStarNetwork::close()
{ {
m_socket.close(); m_socket.close();

View File

@@ -46,6 +46,8 @@ public:
void reset(); void reset();
bool isConnected() const;
void close(); void close();
void clock(unsigned int ms); void clock(unsigned int ms);

View File

@@ -699,7 +699,7 @@ int CMMDVMHost::run()
LogInfo(" Address: %s", address.c_str()); LogInfo(" Address: %s", address.c_str());
LogInfo(" Port: %u", port); LogInfo(" Port: %u", port);
m_remoteControl = new CRemoteControl(address, port); m_remoteControl = new CRemoteControl(this, address, port);
ret = m_remoteControl->open(); ret = m_remoteControl->open();
if (!ret) { if (!ret) {
@@ -2622,3 +2622,14 @@ void CMMDVMHost::processEnableCommand(bool& mode, bool enabled)
if (!m_modem->writeConfig()) if (!m_modem->writeConfig())
LogError("Cannot write Config to MMDVM"); LogError("Cannot write Config to MMDVM");
} }
void CMMDVMHost::buildNetworkStatusString(std::string &str)
{
str = "";
str += std::string("dstar:") + (((m_dstarNetwork == NULL) || (m_dstarEnabled == false)) ? "n/a" : (m_dstarNetwork->isConnected() ? "conn" : "disc"));
str += std::string(" dmr:") + (((m_dmrNetwork == NULL) || (m_dmrEnabled == false)) ? "n/a" : (m_dmrNetwork->isConnected() ? "conn" : "disc"));
str += std::string(" ysf:") + (((m_ysfNetwork == NULL) || (m_ysfEnabled == false)) ? "n/a" : (m_ysfNetwork->isConnected() ? "conn" : "disc"));
str += std::string(" p25:") + (((m_p25Network == NULL) || (m_p25Enabled == false)) ? "n/a" : (m_p25Network->isConnected() ? "conn" : "disc"));
str += std::string(" nxdn:") + (((m_nxdnNetwork == NULL) || (m_nxdnEnabled == false)) ? "n/a" : (m_nxdnNetwork->isConnected() ? "conn" : "disc"));
str += std::string(" fm:") + (m_fmEnabled ? "conn" : "n/a");
}

View File

@@ -56,6 +56,8 @@ public:
int run(); int run();
void buildNetworkStatusString(std::string &str);
private: private:
CConf m_conf; CConf m_conf;
CModem* m_modem; CModem* m_modem;

View File

@@ -153,6 +153,11 @@ void CNXDNIcomNetwork::reset()
{ {
} }
bool CNXDNIcomNetwork::isConnected() const
{
return (m_enabled && (m_addrLen != 0));
}
void CNXDNIcomNetwork::close() void CNXDNIcomNetwork::close()
{ {
m_socket.close(); m_socket.close();

View File

@@ -43,6 +43,8 @@ public:
virtual void reset(); virtual void reset();
virtual bool isConnected() const;
virtual void close(); virtual void close();
virtual void clock(unsigned int ms); virtual void clock(unsigned int ms);

View File

@@ -835,6 +835,11 @@ void CNXDNKenwoodNetwork::reset()
m_seen4 = false; m_seen4 = false;
} }
bool CNXDNKenwoodNetwork::isConnected() const
{
return (m_enabled && (m_rtcpAddrLen != 0U) && (m_rtpAddrLen != 0U));
}
void CNXDNKenwoodNetwork::close() void CNXDNKenwoodNetwork::close()
{ {
m_rtcpSocket.close(); m_rtcpSocket.close();

View File

@@ -42,6 +42,8 @@ public:
virtual void reset(); virtual void reset();
virtual bool isConnected() const;
virtual void close(); virtual void close();
virtual void clock(unsigned int ms); virtual void clock(unsigned int ms);

View File

@@ -46,6 +46,8 @@ public:
virtual void reset() = 0; virtual void reset() = 0;
virtual bool isConnected() const = 0;
virtual void close() = 0; virtual void close() = 0;
virtual void clock(unsigned int ms) = 0; virtual void clock(unsigned int ms) = 0;

View File

@@ -424,6 +424,11 @@ unsigned int CP25Network::read(unsigned char* data, unsigned int length)
return c; return c;
} }
bool CP25Network::isConnected() const
{
return (m_enabled && (m_addrLen != 0));
}
void CP25Network::close() void CP25Network::close()
{ {
m_socket.close(); m_socket.close();

View File

@@ -43,6 +43,8 @@ public:
unsigned int read(unsigned char* data, unsigned int length); unsigned int read(unsigned char* data, unsigned int length);
bool isConnected() const;
void close(); void close();
void clock(unsigned int ms); void clock(unsigned int ms);

View File

@@ -75,7 +75,7 @@ int CRemoteCommand::send(const std::string& command)
int retStatus = 0; int retStatus = 0;
if (CUDPSocket::lookup("127.0.0.1", m_port, addr, addrLen) != 0) { if (CUDPSocket::lookup("127.0.0.1", m_port, addr, addrLen) != 0) {
LogError("Unable to resolve the address of the host"); ::fprintf(stderr, "Unable to resolve the address of the host\n");
return 1; return 1;
} }
@@ -91,14 +91,14 @@ int CRemoteCommand::send(const std::string& command)
return 1; return 1;
} }
LogMessage("Command sent: \"%s\" to port: %u", command.c_str(), m_port); ::fprintf(stdout, "Command sent: \"%s\" to port: %u\n", command.c_str(), m_port);
std::this_thread::sleep_for(std::chrono::milliseconds(50)); std::this_thread::sleep_for(std::chrono::milliseconds(50));
int len = socket.read((unsigned char*)&buffer[0], BUFFER_LENGTH, addr, addrLen); int len = socket.read((unsigned char*)buffer, BUFFER_LENGTH, addr, addrLen);
if (len > 0) { if (len > 0) {
buffer[len] = '\0'; buffer[len] = '\0';
LogMessage("%s", buffer); ::fprintf(stdout, "%s\n", buffer);
} }
else else
{ {

View File

@@ -17,6 +17,7 @@
*/ */
#include "RemoteControl.h" #include "RemoteControl.h"
#include "MMDVMHost.h"
#include "Log.h" #include "Log.h"
#include <cstdio> #include <cstdio>
@@ -32,7 +33,8 @@ const unsigned int CW_ARGS = 2U;
const unsigned int BUFFER_LENGTH = 100U; const unsigned int BUFFER_LENGTH = 100U;
CRemoteControl::CRemoteControl(const std::string address, unsigned int port) : CRemoteControl::CRemoteControl(CMMDVMHost *host, const std::string address, unsigned int port) :
m_host(host),
m_socket(address, port), m_socket(address, port),
m_command(RCD_NONE), m_command(RCD_NONE),
m_args() m_args()
@@ -141,9 +143,17 @@ REMOTE_COMMAND CRemoteControl::getCommand()
} else if (m_args.at(0U) == "reload") { } else if (m_args.at(0U) == "reload") {
// Reload command is in the form of "reload" // Reload command is in the form of "reload"
m_command = RCD_RELOAD; m_command = RCD_RELOAD;
} } else if (m_args.at(0U) == "status") {
else if (m_host != NULL) {
m_host->buildNetworkStatusString(replyStr);
} else {
replyStr = "KO";
}
m_command = RCD_CONNECTION_STATUS;
} else {
replyStr = "KO"; replyStr = "KO";
}
::snprintf(buffer, BUFFER_LENGTH * 2, "%s remote command of \"%s\" received", ((m_command == RCD_NONE) ? "Invalid" : "Valid"), command); ::snprintf(buffer, BUFFER_LENGTH * 2, "%s remote command of \"%s\" received", ((m_command == RCD_NONE) ? "Invalid" : "Valid"), command);
if (m_command == RCD_NONE) { if (m_command == RCD_NONE) {

View File

@@ -24,6 +24,8 @@
#include <vector> #include <vector>
#include <string> #include <string>
class CMMDVMHost;
enum REMOTE_COMMAND { enum REMOTE_COMMAND {
RCD_NONE, RCD_NONE,
RCD_MODE_IDLE, RCD_MODE_IDLE,
@@ -53,12 +55,13 @@ enum REMOTE_COMMAND {
RCD_DISABLE_AX25, RCD_DISABLE_AX25,
RCD_PAGE, RCD_PAGE,
RCD_CW, RCD_CW,
RCD_RELOAD RCD_RELOAD,
RCD_CONNECTION_STATUS
}; };
class CRemoteControl { class CRemoteControl {
public: public:
CRemoteControl(const std::string address, unsigned int port); CRemoteControl(class CMMDVMHost *host, const std::string address, unsigned int port);
~CRemoteControl(); ~CRemoteControl();
bool open(); bool open();
@@ -74,6 +77,7 @@ public:
void close(); void close();
private: private:
CMMDVMHost* m_host;
CUDPSocket m_socket; CUDPSocket m_socket;
REMOTE_COMMAND m_command; REMOTE_COMMAND m_command;
std::vector<std::string> m_args; std::vector<std::string> m_args;

View File

@@ -183,6 +183,11 @@ void CYSFNetwork::reset()
::memset(m_tag, ' ', YSF_CALLSIGN_LENGTH); ::memset(m_tag, ' ', YSF_CALLSIGN_LENGTH);
} }
bool CYSFNetwork::isConnected() const
{
return m_enabled && (m_addrLen != 0U);
}
void CYSFNetwork::close() void CYSFNetwork::close()
{ {
m_socket.close(); m_socket.close();

View File

@@ -42,6 +42,8 @@ public:
void reset(); void reset();
bool isConnected() const;
void close(); void close();
void clock(unsigned int ms); void clock(unsigned int ms);