support transferring local logs to the FNE;

pull/1/head
Bryan Biedenkapp 5 years ago
parent 28bb91fbd2
commit fd99530376

@ -79,6 +79,7 @@ static char LEVELS[] = " DMIWEF";
// ---------------------------------------------------------------------------
// Global Functions
// ---------------------------------------------------------------------------
/// <summary>
/// Helper to open the detailed log file, file handle.
/// </summary>
@ -146,6 +147,17 @@ static bool ActivityLogOpen()
return m_actFpLog != NULL;
}
/// <summary>
/// Sets the instance of the Network class to transfer the activity log with.
/// </summary>
/// <param name="network">Instance of the Network class.</param>
void LogSetNetwork(void* network)
{
// note: The Network class is passed here as a void so we can avoid including the Network.h
// header in Log.h. This is dirty and probably terrible...
m_network = (network::Network*)network;
}
/// <summary>
/// Initializes the activity log.
/// </summary>
@ -229,18 +241,7 @@ void ActivityLog(const char *mode, const bool sourceRf, const char* msg, ...)
}
/// <summary>
/// Sets the instance of the Network class to transfer the activity log with.
/// </summary>
/// <param name="network">Instance of the Network class.</param>
void ActivityLogSetNetwork(void* network)
{
// Note: The Network class is passed here as a void so we can avoid including the Network.h
// header in Log.h. This is dirty and probably terrible...
m_network = (network::Network*)network;
}
/// <summary>
/// Initializes the detailed log.
/// Initializes the diagnostics log.
/// </summary>
/// <param name="filePath">Full-path to the detailed log file.</param>
/// <param name="fileRoot">Prefix of the detailed log file name.</param>
@ -256,7 +257,7 @@ bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uin
}
/// <summary>
/// Finalizes the detailed log.
/// Finalizes the diagnostics log.
/// </summary>
void LogFinalise()
{
@ -265,7 +266,7 @@ void LogFinalise()
}
/// <summary>
/// Writes a new entry to the detailed log.
/// Writes a new entry to the diagnostics log.
/// </summary>
/// <param name="level">Log level.</param>
/// <param name="module">Module name the log entry was genearted from.</param>
@ -306,6 +307,13 @@ void Log(uint32_t level, const char *module, const char* fmt, ...)
va_end(vl);
if (m_network != NULL) {
// don't transfer debug data...
if (level > 1U) {
m_network->writeDiagLog(buffer);
}
}
if (level >= m_fileLevel && m_fileLevel != 0U) {
bool ret = ::LogOpen();
if (!ret)

10
Log.h

@ -62,6 +62,8 @@
// ---------------------------------------------------------------------------
// Global Functions
// ---------------------------------------------------------------------------
/// <summary>Sets the instance of the Network class to transfer the activity log with.</summary>
extern HOST_SW_API void LogSetNetwork(void* network);
/// <summary>Initializes the activity log.</summary>
extern HOST_SW_API bool ActivityLogInitialise(const std::string& filePath, const std::string& fileRoot);
@ -69,14 +71,12 @@ extern HOST_SW_API bool ActivityLogInitialise(const std::string& filePath, const
extern HOST_SW_API void ActivityLogFinalise();
/// <summary>Writes a new entry to the activity log.</summary>
extern HOST_SW_API void ActivityLog(const char* mode, const bool sourceRf, const char* msg, ...);
/// <summary>Sets the instance of the Network class to transfer the activity log with.</summary>
extern HOST_SW_API void ActivityLogSetNetwork(void* network);
/// <summary>Initializes the detailed log.</summary>
/// <summary>Initializes the diagnostics log.</summary>
extern HOST_SW_API bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uint32_t fileLevel, uint32_t displayLevel);
/// <summary>Finalizes the detailed log.</summary>
/// <summary>Finalizes the diagnostics log.</summary>
extern HOST_SW_API void LogFinalise();
/// <summary>Writes a new entry to the detailed log.</summary>
/// <summary>Writes a new entry to the diagnostics log.</summary>
extern HOST_SW_API void Log(uint32_t level, const char* module, const char* fmt, ...);
#endif // __LOG_H__

@ -16,8 +16,9 @@ network:
password: "PASSWORD"
slot1: true
slot2: true
transferActivityLog: false
updateLookups: false
allowActivityTransfer: false
allowDiagnosticTransfer: false
debug: false
protocols:
dmr:

@ -1284,7 +1284,8 @@ bool Host::createNetwork()
std::string password = networkConf["password"].as<std::string>();
bool slot1 = networkConf["slot1"].as<bool>(true);
bool slot2 = networkConf["slot2"].as<bool>(true);
bool transferActivityLog = networkConf["transferActivityLog"].as<bool>(false);
bool allowActivityTransfer = networkConf["allowActivityTransfer"].as<bool>(false);
bool allowDiagnosticTransfer = networkConf["allowDiagnosticTransfer"].as<bool>(false);
bool updateLookup = networkConf["updateLookups"].as<bool>(false);
bool debug = networkConf["debug"].as<bool>(false);
@ -1303,14 +1304,15 @@ bool Host::createNetwork()
LogInfo(" DMR Jitter: %ums", jitter);
LogInfo(" Slot 1: %s", slot1 ? "enabled" : "disabled");
LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled");
LogInfo(" Transfer Activity Log: %s", transferActivityLog ? "enabled" : "disabled");
LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "enabled" : "disabled");
LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "enabled" : "disabled");
LogInfo(" Update Lookups: %s", updateLookup ? "enabled" : "disabled");
if (debug) {
LogInfo(" Debug: yes");
}
m_network = new Network(address, port, local, id, password, m_duplex, debug, slot1, slot2, transferActivityLog, updateLookup);
m_network = new Network(address, port, local, id, password, m_duplex, debug, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup);
m_network->setLookups(m_ridLookup, m_tidLookup);
m_network->setConfig(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_power,
@ -1325,7 +1327,7 @@ bool Host::createNetwork()
}
m_network->enable(true);
::ActivityLogSetNetwork(m_network);
::LogSetNetwork(m_network);
// initialize network remote command
m_remoteControl = new RemoteControl(rconAddress, rconPort);

@ -52,12 +52,14 @@ using namespace network;
/// <param name="debug"></param>
/// <param name="slot1">Flag indicating whether DMR slot 1 is enabled for network traffic.</param>
/// <param name="slot2">Flag indicating whether DMR slot 2 is enabled for network traffic.</param>
/// <param name="transferActivityLog">Flag indicating that the system activity log will be sent to the network.</param>
BaseNetwork::BaseNetwork(uint32_t localPort, uint32_t id, bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog) :
/// <param name="allowActivityTransfer">Flag indicating that the system activity logs will be sent to the network.</param>
/// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param>
BaseNetwork::BaseNetwork(uint32_t localPort, uint32_t id, bool duplex, bool debug, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer) :
m_id(id),
m_slot1(slot1),
m_slot2(slot2),
m_transferActivityLog(transferActivityLog),
m_allowActivityTransfer(allowActivityTransfer),
m_allowDiagnosticTransfer(allowDiagnosticTransfer),
m_duplex(duplex),
m_debug(debug),
m_socket(localPort),
@ -381,7 +383,7 @@ bool BaseNetwork::writeP25PDU(const uint32_t llId, const uint8_t dataType, const
/// <returns></returns>
bool BaseNetwork::writeActLog(const char* message)
{
if (!m_transferActivityLog)
if (!m_allowActivityTransfer)
return false;
if (m_status != NET_STAT_RUNNING)
return false;
@ -391,13 +393,37 @@ bool BaseNetwork::writeActLog(const char* message)
char buffer[DATA_PACKET_LENGTH];
uint32_t len = ::strlen(message);
::memcpy(buffer + 0U, TAG_REPEATER_LOG, 7U);
::memcpy(buffer + 0U, TAG_TRANSFER_ACT_LOG, 7U);
__SET_UINT32(m_id, buffer, 7U);
::strcpy(buffer + 11U, message);
return write((uint8_t*)buffer, (uint32_t)len + 12U);
}
/// <summary>
/// Writes the local diagnostics log to the network.
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
bool BaseNetwork::writeDiagLog(const char* message)
{
if (!m_allowDiagnosticTransfer)
return false;
if (m_status != NET_STAT_RUNNING)
return false;
assert(message != NULL);
char buffer[DATA_PACKET_LENGTH];
uint32_t len = ::strlen(message);
::memcpy(buffer + 0U, TAG_TRANSFER_DIAG_LOG, 8U);
__SET_UINT32(m_id, buffer, 8U);
::strcpy(buffer + 12U, message);
return write((uint8_t*)buffer, (uint32_t)len + 13U);
}
/// <summary>
/// Resets the DMR ring buffer for the given slot.
/// </summary>

@ -74,7 +74,8 @@
#define TAG_REPEATER_CLOSING "RPTCL"
#define TAG_REPEATER_PING "RPTPING"
#define TAG_REPEATER_LOG "TRNSLOG"//"RPTALOG"
#define TAG_TRANSFER_ACT_LOG "TRNSLOG"
#define TAG_TRANSFER_DIAG_LOG "TRNSDIAG"
namespace network
{
@ -173,7 +174,7 @@ namespace network
class HOST_SW_API BaseNetwork {
public:
/// <summary>Initializes a new instance of the BaseNetwork class.</summary>
BaseNetwork(uint32_t localPort, uint32_t id, bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog);
BaseNetwork(uint32_t localPort, uint32_t id, bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog, bool transferDiagnosticLog);
/// <summary>Finalizes a instance of the BaseNetwork class.</summary>
virtual ~BaseNetwork();
@ -201,6 +202,9 @@ namespace network
/// <summary>Writes the local activity log to the network.</summary>
virtual bool writeActLog(const char* message);
/// <summary>Writes the local activity log to the network.</summary>
virtual bool writeDiagLog(const char* message);
/// <summary>Updates the timer by the passed number of milliseconds.</summary>
virtual void clock(uint32_t ms) = 0;
@ -221,7 +225,8 @@ namespace network
bool m_slot1;
bool m_slot2;
bool m_transferActivityLog;
bool m_allowActivityTransfer;
bool m_allowDiagnosticTransfer;
bool m_duplex;
bool m_debug;

@ -55,11 +55,12 @@ using namespace network;
/// <param name="duplex">Flag indicating full-duplex operation.</param>
/// <param name="slot1">Flag indicating whether DMR slot 1 is enabled for network traffic.</param>
/// <param name="slot2">Flag indicating whether DMR slot 2 is enabled for network traffic.</param>
/// <param name="transferActivityLog">Flag indicating that the system activity log will be sent to the network.</param>
/// <param name="allowActivityTransfer">Flag indicating that the system activity logs will be sent to the network.</param>
/// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param>
/// <param name="updateLookup">Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network.</param>
Network::Network(const std::string& address, uint32_t port, uint32_t local, uint32_t id, const std::string& password,
bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog, bool updateLookup) :
BaseNetwork(local, id, duplex, debug, slot1, slot2, transferActivityLog),
bool duplex, bool debug, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup) :
BaseNetwork(local, id, duplex, debug, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer),
m_addressStr(address),
m_address(),
m_port(port),
@ -275,16 +276,13 @@ void Network::clock(uint32_t ms)
}
else if (::memcmp(m_buffer, TAG_MASTER_NAK, 6U) == 0) {
if (m_status == NET_STAT_RUNNING) {
LogWarning(LOG_NET, "Login to the master has failed, retrying login ...");
LogWarning(LOG_NET, "Master returned a NAK; attemping to relogin ...");
m_status = NET_STAT_WAITING_LOGIN;
m_timeoutTimer.start();
m_retryTimer.start();
}
else {
// Once the modem death spiral has been prevented in Modem.cpp
// the Network sometimes times out and reaches here.
// We want it to reconnect so...
LogError(LOG_NET, "Login to the master has failed, retrying network ...");
LogError(LOG_NET, "Master returned a NAK; network reconnect ...");
close();
open();
return;

@ -50,7 +50,7 @@ namespace network
public:
/// <summary>Initializes a new instance of the Network class.</summary>
Network(const std::string& address, uint32_t port, uint32_t local, uint32_t id, const std::string& password,
bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog, bool updateLookup);
bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog, bool transferDiagnosticLog, bool updateLookup);
/// <summary>Finalizes a instance of the Network class.</summary>
~Network();

Loading…
Cancel
Save

Powered by TurnKey Linux.