diff --git a/BaseCommon/Utils.cpp b/BaseCommon/Utils.cpp index c5d6746..da3c3e2 100644 --- a/BaseCommon/Utils.cpp +++ b/BaseCommon/Utils.cpp @@ -126,7 +126,7 @@ void CUtils::dump(const char* title, const unsigned char* data, unsigned int len assert(title != NULL); assert(data != NULL); - CLog::logInfo("%s\n", title); + CLog::logDebug("%s\n", title); unsigned int offset = 0U; diff --git a/Common/DCSProtocolHandlerPool.cpp b/Common/DCSProtocolHandlerPool.cpp index cc00e43..f8fdf7a 100644 --- a/Common/DCSProtocolHandlerPool.cpp +++ b/Common/DCSProtocolHandlerPool.cpp @@ -80,11 +80,12 @@ void CDCSProtocolHandlerPool::release(CDCSProtocolHandler *handler) assert(handler != NULL); for (auto it=m_pool.begin(); it!=m_pool.end(); it++) { if (it->second == handler) { + unsigned int port = handler->getPort(); m_pool.erase(it); handler->close(); delete handler ; - m_index = m_pool.end(); // since we removed an element, m_index is ouot of order, just move it back to the end - CLog::logInfo("Released DCS ProtocolHandler on port %u.\n", it->first); + m_index = m_pool.end(); // since we removed an element, m_index is out of order, just move it back to the end + CLog::logInfo("Released DCS ProtocolHandler on port %u.\n", port); return; } diff --git a/Common/DExtraProtocolHandlerPool.cpp b/Common/DExtraProtocolHandlerPool.cpp index c356858..3704850 100644 --- a/Common/DExtraProtocolHandlerPool.cpp +++ b/Common/DExtraProtocolHandlerPool.cpp @@ -80,11 +80,12 @@ void CDExtraProtocolHandlerPool::release(CDExtraProtocolHandler *handler) assert(handler != NULL); for (auto it=m_pool.begin(); it!=m_pool.end(); it++) { if (it->second == handler) { + unsigned int port = handler->getPort(); m_pool.erase(it); handler->close(); delete handler; m_index = m_pool.end(); // m_index might be out of order, reset it - CLog::logInfo("Releasing DExtra Protocol Handler on port %u.\n", it->first); + CLog::logInfo("Releasing DExtra Protocol Handler on port %u.\n", port); return; } diff --git a/Common/DPlusProtocolHandlerPool.cpp b/Common/DPlusProtocolHandlerPool.cpp index b9ef667..ed8d63a 100644 --- a/Common/DPlusProtocolHandlerPool.cpp +++ b/Common/DPlusProtocolHandlerPool.cpp @@ -81,11 +81,12 @@ void CDPlusProtocolHandlerPool::release(CDPlusProtocolHandler *handler) assert(handler != NULL); for (auto it=m_pool.begin(); it!=m_pool.end(); it++) { if (it->second == handler) { + unsigned int port = handler->getPort(); m_pool.erase(it); handler->close(); delete handler; m_index = m_pool.end(); // m_index might be ut of order so reset it - CLog::logInfo("Releasing DPlus ProtocolHandler on port %u.\n", it->first); + CLog::logInfo("Releasing DPlus ProtocolHandler on port %u.\n", port); return; } } diff --git a/Common/Defs.h b/Common/Defs.h index 9cb2d07..01edb0c 100644 --- a/Common/Defs.h +++ b/Common/Defs.h @@ -50,6 +50,24 @@ enum RECONNECT { RECONNECT_180MINS }; +inline const char* reconnectToString(RECONNECT r) { + switch (r) { + case RECONNECT_NEVER: return "never"; + case RECONNECT_FIXED: return "fixed"; + case RECONNECT_5MINS: return "5 minutes"; + case RECONNECT_10MINS: return "10 minutes"; + case RECONNECT_15MINS: return "15 minutes"; + case RECONNECT_20MINS: return "20 minutes"; + case RECONNECT_25MINS: return "25 minutes"; + case RECONNECT_30MINS: return "30 minutes"; + case RECONNECT_60MINS: return "60 minutes"; + case RECONNECT_90MINS: return "90 minutes"; + case RECONNECT_120MINS: return "120 minutes"; + case RECONNECT_180MINS: return "180 minutes"; + default: return "unknown"; + } +} + enum DIRECTION { DIR_INCOMING, DIR_OUTGOING diff --git a/Common/RemoteHandler.cpp b/Common/RemoteHandler.cpp index 7372e98..1722ec9 100644 --- a/Common/RemoteHandler.cpp +++ b/Common/RemoteHandler.cpp @@ -95,9 +95,9 @@ void CRemoteHandler::process() RECONNECT reconnect; m_handler.readLink(callsign, reconnect, reflector); if (reflector.empty()) - CLog::logInfo("Remote control user has linked \"%s\" to \"None\" with reconnect %d", callsign.c_str(), int(reconnect)); + CLog::logInfo("Remote control user requesting link \"%s\" to \"None\" with reconnect %s", callsign.c_str(), reconnectToString(reconnect)); else - CLog::logInfo("Remote control user has linked \"%s\" to \"%s\" with reconnect %d", callsign.c_str(), reflector.c_str(), int(reconnect)); + CLog::logInfo("Remote control user requesting link \"%s\" to \"%s\" with reconnect %s", callsign.c_str(), reflector.c_str(), reconnectToString(reconnect)); link(callsign, reconnect, reflector, true); } break; @@ -105,7 +105,7 @@ void CRemoteHandler::process() std::string callsign, reflector; PROTOCOL protocol; m_handler.readUnlink(callsign, protocol, reflector); - CLog::logInfo("Remote control user has unlinked \"%s\" from \"%s\" for protocol %d", callsign.c_str(), reflector.c_str(), int(protocol)); + CLog::logInfo("Remote control user requesting unlink \"%s\" from \"%s\" for protocol %d", callsign.c_str(), reflector.c_str(), int(protocol)); unlink(callsign, protocol, reflector); } break; @@ -114,9 +114,9 @@ void CRemoteHandler::process() RECONNECT reconnect; m_handler.readLinkScr(callsign, reconnect, reflector); if (reflector.empty()) - CLog::logInfo("Remote control user has linked \"%s\" to \"None\" with reconnect %d from localhost", callsign.c_str(), reconnect); + CLog::logInfo("Remote control user requesting link \"%s\" to \"None\" with reconnect %s from localhost", callsign.c_str(), reconnectToString(reconnect)); else - CLog::logInfo("Remote control user has linked \"%s\" to \"%s\" with reconnect %d from localhost", callsign.c_str(), reflector.c_str(), reconnect); + CLog::logInfo("Remote control user requesting link \"%s\" to \"%s\" with reconnect %s from localhost", callsign.c_str(), reflector.c_str(), reconnectToString(reconnect)); link(callsign, reconnect, reflector, false); } break; @@ -155,6 +155,7 @@ void CRemoteHandler::sendRepeater(const std::string& callsign) { CRepeaterHandler* repeater = CRepeaterHandler::findDVRepeater(callsign); if (repeater == NULL) { + CLog::logInfo("Remote requesting invalid repeater \"%s\"", callsign.c_str()); m_handler.sendNAK("Invalid repeater callsign"); return; } @@ -195,6 +196,7 @@ void CRemoteHandler::link(const std::string& callsign, RECONNECT reconnect, cons { CRepeaterHandler* repeater = CRepeaterHandler::findDVRepeater(callsign); if (repeater == NULL) { + CLog::logInfo("Remote requesting link for invalid repeater \"%s\"", callsign.c_str()); m_handler.sendNAK("Invalid repeater callsign"); return; } @@ -209,6 +211,7 @@ void CRemoteHandler::unlink(const std::string& callsign, PROTOCOL protocol, cons { CRepeaterHandler* repeater = CRepeaterHandler::findDVRepeater(callsign); if (repeater == NULL) { + CLog::logInfo("Remote requesting unlink for invalid repeater \"%s\"", callsign.c_str()); m_handler.sendNAK("Invalid repeater callsign"); return; } diff --git a/Common/RepeaterHandler.cpp b/Common/RepeaterHandler.cpp index 3fbb913..b100cf1 100644 --- a/Common/RepeaterHandler.cpp +++ b/Common/RepeaterHandler.cpp @@ -169,40 +169,7 @@ m_heardTimer(1000U, 0U, 100U) // 100ms m_pollTimer.start(); - switch (m_linkReconnect) { - case RECONNECT_5MINS: - m_linkReconnectTimer.start(5U * 60U); - break; - case RECONNECT_10MINS: - m_linkReconnectTimer.start(10U * 60U); - break; - case RECONNECT_15MINS: - m_linkReconnectTimer.start(15U * 60U); - break; - case RECONNECT_20MINS: - m_linkReconnectTimer.start(20U * 60U); - break; - case RECONNECT_25MINS: - m_linkReconnectTimer.start(25U * 60U); - break; - case RECONNECT_30MINS: - m_linkReconnectTimer.start(30U * 60U); - break; - case RECONNECT_60MINS: - m_linkReconnectTimer.start(60U * 60U); - break; - case RECONNECT_90MINS: - m_linkReconnectTimer.start(90U * 60U); - break; - case RECONNECT_120MINS: - m_linkReconnectTimer.start(120U * 60U); - break; - case RECONNECT_180MINS: - m_linkReconnectTimer.start(180U * 60U); - break; - default: - break; - } + setReconnectTimer(m_linkReconnect); #ifdef USE_ANNOUNCE wxFileName messageFile; @@ -1504,7 +1471,7 @@ void CRepeaterHandler::clockInt(unsigned int ms) linkInt(m_linkStartup); } - m_linkReconnectTimer.start(); + setReconnectTimer(m_linkReconnect); } // If the ircDDB query timer has expired @@ -1842,45 +1809,9 @@ void CRepeaterHandler::link(RECONNECT reconnect, const std::string& reflector) } #endif - m_linkStartup = reflector; - m_linkReconnect = reconnect; - m_linkReconnectTimer.stop(); - - switch (m_linkReconnect) { - case RECONNECT_5MINS: - m_linkReconnectTimer.start(5U * 60U); - break; - case RECONNECT_10MINS: - m_linkReconnectTimer.start(10U * 60U); - break; - case RECONNECT_15MINS: - m_linkReconnectTimer.start(15U * 60U); - break; - case RECONNECT_20MINS: - m_linkReconnectTimer.start(20U * 60U); - break; - case RECONNECT_25MINS: - m_linkReconnectTimer.start(25U * 60U); - break; - case RECONNECT_30MINS: - m_linkReconnectTimer.start(30U * 60U); - break; - case RECONNECT_60MINS: - m_linkReconnectTimer.start(60U * 60U); - break; - case RECONNECT_90MINS: - m_linkReconnectTimer.start(90U * 60U); - break; - case RECONNECT_120MINS: - m_linkReconnectTimer.start(120U * 60U); - break; - case RECONNECT_180MINS: - m_linkReconnectTimer.start(180U * 60U); - break; - default: - break; - } + + setReconnectTimer(reconnect); // Nothing to do if ((m_linkStatus != LS_NONE && m_linkRepeater == reflector) || @@ -1973,7 +1904,7 @@ void CRepeaterHandler::link(RECONNECT reconnect, const std::string& reflector) CDPlusHandler::unlink(this); CDCSHandler::unlink(this); - linkInt(m_linkStartup); + linkInt(reflector); } void CRepeaterHandler::unlink(PROTOCOL protocol, const std::string& reflector) @@ -3085,6 +3016,24 @@ void CRepeaterHandler::readAPRSFrame(CAPRSFrame& frame) } } +void CRepeaterHandler::setReconnectTimer(RECONNECT reconnect) +{ + CLog::logDebug("Reconnect timer set to %s", reconnectToString(reconnect)); + switch (reconnect) { + case RECONNECT_5MINS: m_linkReconnectTimer.start( 5U * 60U); break; + case RECONNECT_10MINS: m_linkReconnectTimer.start(10U * 60U); break; + case RECONNECT_15MINS: m_linkReconnectTimer.start(15U * 60U); break; + case RECONNECT_20MINS: m_linkReconnectTimer.start(20U * 60U); break; + case RECONNECT_25MINS: m_linkReconnectTimer.start(25U * 60U); break; + case RECONNECT_30MINS: m_linkReconnectTimer.start(30U * 60U); break; + case RECONNECT_60MINS: m_linkReconnectTimer.start(60U * 60U); break; + case RECONNECT_90MINS: m_linkReconnectTimer.start(90U * 60U); break; + case RECONNECT_120MINS: m_linkReconnectTimer.start(120U * 60U); break; + case RECONNECT_180MINS: m_linkReconnectTimer.start(180U * 60U); break; + default: break; + } +} + #ifdef USE_CCS bool CRepeaterHandler::isCCSCommand(const std::string& command) const { diff --git a/Common/RepeaterHandler.h b/Common/RepeaterHandler.h index c5ed834..7587472 100644 --- a/Common/RepeaterHandler.h +++ b/Common/RepeaterHandler.h @@ -317,6 +317,8 @@ private: void triggerInfo(); + void setReconnectTimer(RECONNECT reconnect); + #ifdef USE_CCS bool isCCSCommand(const std::string& command) const; #endif diff --git a/DGWRemoteControl/DGWRemoteControlApp.cpp b/DGWRemoteControl/DGWRemoteControlApp.cpp index 6f8c0fe..12e63fc 100644 --- a/DGWRemoteControl/DGWRemoteControlApp.cpp +++ b/DGWRemoteControl/DGWRemoteControlApp.cpp @@ -48,8 +48,11 @@ int main(int argc, const char* argv[]) ::fprintf(stderr, "\ndgwremotecontrol v%s : invalid command line usage:\n\n", LONG_VERSION.c_str()); ::fprintf(stderr, "\t\tdgwremotecontrol [-name ] link \n"); ::fprintf(stderr, "\t\tdgwremotecontrol [-name ] unlink\n"); +#ifdef USE_STARNET ::fprintf(stderr, "\t\tdgwremotecontrol [-name ] drop \n"); - ::fprintf(stderr, "\t\tdgwremotecontrol [-name ] drop all\n\n"); + ::fprintf(stderr, "\t\tdgwremotecontrol [-name ] drop all\n"); +#endif + ::fprintf(stderr, "\n"); return 1; } diff --git a/README.md b/README.md index 6933f4f..44954a3 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,7 @@ The testing framwework used is Google Test. # 6. Version History ## 6.1. Version 1.0 +- [**Bugfix**] Fix repeater not reverting to startup reflector after issueing a command through remote control. ([#56](https://github.com/F4FXL/DStarGateway/issues/56)) - [**Bugfix**] Fix corrupted slow data leading to DV Text Message not being sent to ircddb. Thanks to Manfred DL1JM for all the testing. ([#55](https://github.com/F4FXL/DStarGateway/issues/55)) - [**Improvement**] Add version info to output of --version ([#56](https://github.com/F4FXL/DStarGateway/issues/56)) - [**Improvement**] Automatically download hosts files on startup. It is also possible to specify custom hosts files to override hosts from the internet. Needs some configuration adjustement, see example.cfg. ([#50](https://github.com/F4FXL/DStarGateway/issues/50))