diff --git a/src/common/network/udp/Socket.cpp b/src/common/network/udp/Socket.cpp index f291c3b4..846e7e22 100644 --- a/src/common/network/udp/Socket.cpp +++ b/src/common/network/udp/Socket.cpp @@ -293,6 +293,7 @@ bool Socket::write(const uint8_t* buffer, uint32_t length, const sockaddr_storag *lenWritten = -1; } + LogError(LOG_NET, "tried to write datagram with no file descriptor? this shouldn't happen BUGBUG"); return false; } @@ -383,6 +384,7 @@ bool Socket::write(BufferVector& buffers, ssize_t* lenWritten) noexcept *lenWritten = -1; } + LogError(LOG_NET, "tried to write datagram with no file descriptor? this shouldn't happen BUGBUG"); return false; } diff --git a/src/host/dmr/Slot.cpp b/src/host/dmr/Slot.cpp index da8b484d..2181d4ef 100644 --- a/src/host/dmr/Slot.cpp +++ b/src/host/dmr/Slot.cpp @@ -717,7 +717,7 @@ void Slot::touchGrantTG(uint32_t dstId) ::lookups::VoiceChData voiceCh = m_affiliations->getRFChData(chNo); if (m_verbose) { - LogMessage(LOG_DMR, "DMR Slot %u, VC %s:%u, call in progress, TG grant, srcId = %u, dstId = %u, chId = %u, chNo = %u", m_slotNo, voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); + LogMessage(LOG_DMR, "DMR Slot %u, VC %s:%u, call in progress, srcId = %u, dstId = %u, chId = %u, chNo = %u", m_slotNo, voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); } m_affiliations->touchGrant(dstId); @@ -876,7 +876,7 @@ void Slot::init(Control* dmr, bool authoritative, uint32_t colorCode, SiteData s req["clear"].set(clear); RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), tscc->m_debug); + HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), REST_QUICK_WAIT, tscc->m_debug); } else { ::LogError(LOG_DMR, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to clear payload channel, chNo = %u, slot = %u", tscc->m_slotNo, chNo, slot); @@ -893,7 +893,7 @@ void Slot::init(Control* dmr, bool authoritative, uint32_t colorCode, SiteData s req["slot"].set(slot); RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), m_dmr->m_debug); + HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), REST_QUICK_WAIT, m_dmr->m_debug); } else { ::LogError(LOG_DMR, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to clear TG permit, chNo = %u, slot = %u", tscc->m_slotNo, chNo, slot); @@ -1115,7 +1115,7 @@ void Slot::notifyCC_ReleaseGrant(uint32_t dstId) req["slot"].set(slot); int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_RELEASE_TG, req, m_controlChData.ssl(), m_debug); + HTTP_PUT, PUT_RELEASE_TG, req, m_controlChData.ssl(), REST_QUICK_WAIT, m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError(LOG_DMR, "DMR Slot %u, failed to notify the CC %s:%u of the release of, dstId = %u", m_slotNo, m_controlChData.address().c_str(), m_controlChData.port(), dstId); } @@ -1148,7 +1148,7 @@ void Slot::notifyCC_TouchGrant(uint32_t dstId) req["slot"].set(slot); int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_TOUCH_TG, req, m_controlChData.ssl(), m_debug); + HTTP_PUT, PUT_TOUCH_TG, req, m_controlChData.ssl(), REST_QUICK_WAIT, m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError(LOG_DMR, "DMR Slot %u, failed to notify the CC %s:%u of the touch of, dstId = %u", m_slotNo, m_controlChData.address().c_str(), m_controlChData.port(), dstId); } diff --git a/src/host/dmr/packet/ControlSignaling.cpp b/src/host/dmr/packet/ControlSignaling.cpp index 785d1729..d91b5d84 100644 --- a/src/host/dmr/packet/ControlSignaling.cpp +++ b/src/host/dmr/packet/ControlSignaling.cpp @@ -900,7 +900,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_ req["slot"].set(slot); int ret = RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), m_tscc->m_debug); + HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), REST_QUICK_WAIT, m_tscc->m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to permit TG for use, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); m_tscc->m_affiliations->releaseGrant(dstId, false); @@ -951,7 +951,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_ req["voice"].set(voice); RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), m_tscc->m_debug); + HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), REST_QUICK_WAIT, m_tscc->m_debug); } else { ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); @@ -978,7 +978,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_ req["slot"].set(slot); int ret = RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), m_tscc->m_debug); + HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), REST_QUICK_WAIT, m_tscc->m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to permit TG for use, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); m_tscc->m_affiliations->releaseGrant(dstId, false); @@ -1027,7 +1027,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_ req["voice"].set(voice); RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), m_tscc->m_debug); + HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), REST_QUICK_WAIT, m_tscc->m_debug); } else { ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); @@ -1185,7 +1185,7 @@ bool ControlSignaling::writeRF_CSBK_Data_Grant(uint32_t srcId, uint32_t dstId, u req["voice"].set(voice); RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), m_tscc->m_debug); + HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), REST_QUICK_WAIT, m_tscc->m_debug); } else { ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); @@ -1232,7 +1232,7 @@ bool ControlSignaling::writeRF_CSBK_Data_Grant(uint32_t srcId, uint32_t dstId, u req["voice"].set(voice); RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), m_tscc->m_debug); + HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, voiceChData.ssl(), REST_QUICK_WAIT, m_tscc->m_debug); } else { ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); diff --git a/src/host/nxdn/Control.cpp b/src/host/nxdn/Control.cpp index 2545b934..ea0d3ffe 100644 --- a/src/host/nxdn/Control.cpp +++ b/src/host/nxdn/Control.cpp @@ -297,7 +297,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw req["dstId"].set(dstId); RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), m_debug); + HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), REST_QUICK_WAIT, m_debug); } else { ::LogError(LOG_NXDN, "NXDN, " NXDN_RTCH_MSG_TYPE_VCALL_RESP ", failed to clear TG permit, chNo = %u", chNo); @@ -769,7 +769,7 @@ void Control::touchGrantTG(uint32_t dstId) ::lookups::VoiceChData voiceCh = m_affiliations.getRFChData(chNo); if (m_verbose) { - LogMessage(LOG_NXDN, "VC %s:%u, call in progress, TG grant, srcId = %u, dstId = %u, chId = %u, chNo = %u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); + LogMessage(LOG_NXDN, "VC %s:%u, call in progress, srcId = %u, dstId = %u, chId = %u, chNo = %u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); } m_affiliations.touchGrant(dstId); @@ -1052,7 +1052,7 @@ void Control::notifyCC_ReleaseGrant(uint32_t dstId) req["dstId"].set(dstId); int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_RELEASE_TG, req, m_controlChData.ssl(), m_debug); + HTTP_PUT, PUT_RELEASE_TG, req, m_controlChData.ssl(), REST_QUICK_WAIT, m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError(LOG_NXDN, "failed to notify the CC %s:%u of the release of, dstId = %u", m_controlChData.address().c_str(), m_controlChData.port(), dstId); } @@ -1083,7 +1083,7 @@ void Control::notifyCC_TouchGrant(uint32_t dstId) req["dstId"].set(dstId); int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_TOUCH_TG, req, m_controlChData.ssl(), m_debug); + HTTP_PUT, PUT_TOUCH_TG, req, m_controlChData.ssl(), REST_QUICK_WAIT, m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError(LOG_NXDN, "failed to notify the CC %s:%u of the touch of, dstId = %u", m_controlChData.address().c_str(), m_controlChData.port(), dstId); } diff --git a/src/host/nxdn/packet/ControlSignaling.cpp b/src/host/nxdn/packet/ControlSignaling.cpp index 2bc0b04d..e9b996ff 100644 --- a/src/host/nxdn/packet/ControlSignaling.cpp +++ b/src/host/nxdn/packet/ControlSignaling.cpp @@ -607,7 +607,7 @@ bool ControlSignaling::writeRF_Message_Grant(uint32_t srcId, uint32_t dstId, uin req["dstId"].set(dstId); int ret = RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), m_nxdn->m_debug); + HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), REST_QUICK_WAIT, m_nxdn->m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError((net) ? LOG_NET : LOG_RF, "NXDN, %s, failed to permit TG for use, chNo = %u", rcch->toString().c_str(), chNo); m_nxdn->m_affiliations.releaseGrant(dstId, false); diff --git a/src/host/p25/Control.cpp b/src/host/p25/Control.cpp index 4aca7f2d..df17df06 100644 --- a/src/host/p25/Control.cpp +++ b/src/host/p25/Control.cpp @@ -433,7 +433,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw req["dstId"].set(dstId); RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), m_debug); + HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), REST_DEFAULT_WAIT, m_debug); } else { ::LogError(LOG_P25, P25_TSDU_STR ", TSBK_IOSP_GRP_VCH (Group Voice Channel Grant), failed to clear TG permit, chNo = %u", chNo); @@ -1019,7 +1019,7 @@ void Control::touchGrantTG(uint32_t dstId) ::lookups::VoiceChData voiceCh = m_affiliations.getRFChData(chNo); if (m_verbose) { - LogMessage(LOG_P25, "VC %s:%u, call in progress, TG grant, srcId = %u, dstId = %u, chId = %u, chNo = %u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); + LogMessage(LOG_P25, "VC %s:%u, call in progress, srcId = %u, dstId = %u, chId = %u, chNo = %u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); } m_affiliations.touchGrant(dstId); @@ -1460,7 +1460,7 @@ void Control::notifyCC_ReleaseGrant(uint32_t dstId) req["dstId"].set(dstId); int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_RELEASE_TG, req, m_controlChData.ssl(), m_debug); + HTTP_PUT, PUT_RELEASE_TG, req, m_controlChData.ssl(), REST_QUICK_WAIT, m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError(LOG_P25, "failed to notify the CC %s:%u of the release of, dstId = %u", m_controlChData.address().c_str(), m_controlChData.port(), dstId); } @@ -1491,7 +1491,7 @@ void Control::notifyCC_TouchGrant(uint32_t dstId) req["dstId"].set(dstId); int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_TOUCH_TG, req, m_controlChData.ssl(), m_debug); + HTTP_PUT, PUT_TOUCH_TG, req, m_controlChData.ssl(), REST_QUICK_WAIT, m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError(LOG_P25, "failed to notify the CC %s:%u of the touch of, dstId = %u", m_controlChData.address().c_str(), m_controlChData.port(), dstId); } diff --git a/src/host/p25/packet/ControlSignaling.cpp b/src/host/p25/packet/ControlSignaling.cpp index d53dee6b..037b3038 100644 --- a/src/host/p25/packet/ControlSignaling.cpp +++ b/src/host/p25/packet/ControlSignaling.cpp @@ -2300,7 +2300,7 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ req["dstId"].set(dstId); int ret = RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), m_p25->m_debug); + HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), REST_QUICK_WAIT, m_p25->m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBK_IOSP_GRP_VCH (Group Voice Channel Grant), failed to permit TG for use, chNo = %u", chNo); m_p25->m_affiliations.releaseGrant(dstId, false); @@ -2354,7 +2354,7 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ req["dstId"].set(dstId); int ret = RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), - HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), m_p25->m_debug); + HTTP_PUT, PUT_PERMIT_TG, req, voiceChData.ssl(), REST_QUICK_WAIT, m_p25->m_debug); if (ret != network::rest::http::HTTPPayload::StatusType::OK) { ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBK_IOSP_UU_VCH (Unit-to-Unit Voice Channel Grant), failed to permit TG for use, chNo = %u", chNo); m_p25->m_affiliations.releaseGrant(dstId, false); diff --git a/src/remote/RESTClient.cpp b/src/remote/RESTClient.cpp index 298896d7..8daad9a9 100644 --- a/src/remote/RESTClient.cpp +++ b/src/remote/RESTClient.cpp @@ -97,7 +97,7 @@ bool parseResponseBody(const HTTPPayload& response, json::object& obj) /// Network Hostname/IP address to connect to. /// Network port number. /// Authentication password. -/// +/// Flag indicating whether or not HTTPS is enabled. /// Flag indicating whether debug is enabled. RESTClient::RESTClient(const std::string& address, uint32_t port, const std::string& password, bool enableSSL, bool debug) : m_address(address), @@ -152,14 +152,14 @@ int RESTClient::send(const std::string method, const std::string endpoint, json: /// REST API method. /// REST API endpoint. /// REST API endpoint payload. -/// +/// Flag indicating whether or not HTTPS is enabled. /// Flag indicating whether debug is enabled. /// EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. int RESTClient::send(const std::string& address, uint32_t port, const std::string& password, const std::string method, - const std::string endpoint, json::object payload, bool enableSSL, bool debug) + const std::string endpoint, json::object payload, bool enableSSL, int timeout, bool debug) { json::object rsp = json::object(); - return send(address, port, password, method, endpoint, payload, rsp, enableSSL, debug); + return send(address, port, password, method, endpoint, payload, rsp, enableSSL, timeout, debug); } /// @@ -172,11 +172,12 @@ int RESTClient::send(const std::string& address, uint32_t port, const std::strin /// REST API endpoint. /// REST API endpoint payload. /// REST API endpoint response. -/// +/// Flag indicating whether or not HTTPS is enabled. +/// REST response wait timeout. /// Flag indicating whether debug is enabled. /// EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. int RESTClient::send(const std::string& address, uint32_t port, const std::string& password, const std::string method, - const std::string endpoint, json::object payload, json::object& response, bool enableSSL, bool debug) + const std::string endpoint, json::object payload, json::object& response, bool enableSSL, int timeout, bool debug) { if (address.empty()) { return ERRNO_NO_ADDRESS; @@ -429,11 +430,12 @@ void RESTClient::responseHandler(const HTTPPayload& request, HTTPPayload& reply) /// /// /// -bool RESTClient::wait() +/// +bool RESTClient::wait(const int t) { m_responseAvailable = false; - int timeout = 500; + int timeout = t; while (!m_responseAvailable && timeout > 0) { timeout--; Thread::sleep(1); diff --git a/src/remote/RESTClient.h b/src/remote/RESTClient.h index 28b20496..b5dfab53 100644 --- a/src/remote/RESTClient.h +++ b/src/remote/RESTClient.h @@ -19,6 +19,9 @@ #include +#define REST_DEFAULT_WAIT 500 +#define REST_QUICK_WAIT 150 + // --------------------------------------------------------------------------- // Class Declaration // This class implements the REST client logic. @@ -39,10 +42,10 @@ public: /// Sends remote control command to the specified modem. static int send(const std::string& address, uint32_t port, const std::string& password, const std::string method, - const std::string endpoint, json::object payload, bool enableSSL, bool debug = false); + const std::string endpoint, json::object payload, bool enableSSL, int timeout = REST_DEFAULT_WAIT, bool debug = false); /// Sends remote control command to the specified modem. static int send(const std::string& address, uint32_t port, const std::string& password, const std::string method, - const std::string endpoint, json::object payload, json::object& response, bool enableSSL, bool debug = false); + const std::string endpoint, json::object payload, json::object& response, bool enableSSL, int timeout, bool debug = false); private: typedef network::rest::http::HTTPPayload HTTPPayload; @@ -50,7 +53,7 @@ private: static void responseHandler(const HTTPPayload& request, HTTPPayload& reply); /// - static bool wait(); + static bool wait(const int t = REST_DEFAULT_WAIT); std::string m_address; uint32_t m_port;