diff --git a/configs/config.example.yml b/configs/config.example.yml index 919f5e71..c3b99627 100644 --- a/configs/config.example.yml +++ b/configs/config.example.yml @@ -333,14 +333,14 @@ system: # control channel to give the control channel "real time" traffic channel updates. # controlCh: - # REST API IP Address for control channel. - restAddress: 127.0.0.1 - # REST API Port number for control channel. - restPort: 9990 + # REST API IP Address for control channel. (If blank, notifications are disabled.) + restAddress: + # REST API Port number for control channel. (If 0, notifications are disabled.) + restPort: 0 # REST API access password for control channel. restPassword: "PASSWORD" # Flag indicating voice channels will notify the control channel of traffic status. - notifyEnable: true + notifyEnable: false # # Voice Channels diff --git a/src/dmr/Control.cpp b/src/dmr/Control.cpp index b870bbd1..f729d481 100644 --- a/src/dmr/Control.cpp +++ b/src/dmr/Control.cpp @@ -181,7 +181,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::vector(true); + bool notifyCC = controlCh["notifyEnable"].as(false); m_slot1->setNotifyCC(notifyCC); m_slot2->setNotifyCC(notifyCC); @@ -210,6 +210,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::vector void Slot::notifyCC_ReleaseGrant(uint32_t dstId) { - // callback REST API to release the granted TG on the specified control channel - if (!m_controlChData.address().empty() && m_controlChData.port() > 0) { - if (!m_notifyCC) { - return; - } + if (m_controlChData.address().empty()) { + return; + } - json::object req = json::object(); - int state = modem::DVM_STATE::STATE_DMR; - req["state"].set(state); - req["dstId"].set(dstId); - uint8_t slot = m_slotNo; - req["slot"].set(slot); - - int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_RELEASE_TG, req, 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); - } + if (m_controlChData.port() == 0) { + return; + } + + if (!m_notifyCC) { + return; + } + + // callback REST API to release the granted TG on the specified control channel + json::object req = json::object(); + int state = modem::DVM_STATE::STATE_DMR; + req["state"].set(state); + req["dstId"].set(dstId); + uint8_t slot = m_slotNo; + req["slot"].set(slot); + + int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), + HTTP_PUT, PUT_RELEASE_TG, req, 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); } } @@ -971,24 +977,30 @@ void Slot::notifyCC_ReleaseGrant(uint32_t dstId) /// void Slot::notifyCC_TouchGrant(uint32_t dstId) { - // callback REST API to touch the granted TG on the specified control channel - if (!m_controlChData.address().empty() && m_controlChData.port() > 0) { - if (!m_notifyCC) { - return; - } + if (m_controlChData.address().empty()) { + return; + } - json::object req = json::object(); - int state = modem::DVM_STATE::STATE_DMR; - req["state"].set(state); - req["dstId"].set(dstId); - uint8_t slot = m_slotNo; - req["slot"].set(slot); - - int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_TOUCH_TG, req, 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); - } + if (m_controlChData.port() == 0) { + return; + } + + if (!m_notifyCC) { + return; + } + + // callback REST API to touch the granted TG on the specified control channel + json::object req = json::object(); + int state = modem::DVM_STATE::STATE_DMR; + req["state"].set(state); + req["dstId"].set(dstId); + uint8_t slot = m_slotNo; + req["slot"].set(slot); + + int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), + HTTP_PUT, PUT_TOUCH_TG, req, 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/Host.cpp b/src/host/Host.cpp index eb4bbd29..17df4f49 100644 --- a/src/host/Host.cpp +++ b/src/host/Host.cpp @@ -1833,14 +1833,18 @@ bool Host::readParams() { yaml::Node controlCh = rfssConfig["controlCh"]; - std::string restApiAddress = controlCh["restAddress"].as("127.0.0.1"); + std::string restApiAddress = controlCh["restAddress"].as(""); uint16_t restApiPort = (uint16_t)controlCh["restPort"].as(REST_API_DEFAULT_PORT); std::string restApiPassword = controlCh["restPassword"].as(); VoiceChData data = VoiceChData(0U, restApiAddress, restApiPort, restApiPassword); m_controlChData = data; - ::LogInfoEx(LOG_HOST, "Control Channel REST API Adddress %s:%u", m_controlChData.address().c_str(), m_controlChData.port()); + if (!m_controlChData.address().empty() && m_controlChData.port() > 0) { + ::LogInfoEx(LOG_HOST, "Control Channel REST API Adddress %s:%u", m_controlChData.address().c_str(), m_controlChData.port()); + } else { + ::LogInfoEx(LOG_HOST, "No Control Channel REST API Configured, CC notify disabled"); + } } /* diff --git a/src/nxdn/Control.cpp b/src/nxdn/Control.cpp index d2806875..479048b8 100644 --- a/src/nxdn/Control.cpp +++ b/src/nxdn/Control.cpp @@ -322,7 +322,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw yaml::Node rfssConfig = systemConf["config"]; yaml::Node controlCh = rfssConfig["controlCh"]; - m_notifyCC = controlCh["notifyEnable"].as(true); + m_notifyCC = controlCh["notifyEnable"].as(false); if (printOptions) { LogInfo(" Silence Threshold: %u (%.1f%%)", m_voice->m_silenceThreshold, float(m_voice->m_silenceThreshold) / 12.33F); @@ -334,6 +334,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw } } + LogInfo(" Notify Control: %s", m_notifyCC ? "yes" : "no"); LogInfo(" Verify Affiliation: %s", m_trunk->m_verifyAff ? "yes" : "no"); LogInfo(" Verify Registration: %s", m_trunk->m_verifyReg ? "yes" : "no"); } @@ -920,22 +921,29 @@ void Control::processNetwork() /// void Control::notifyCC_ReleaseGrant(uint32_t dstId) { - // callback REST API to release the granted TG on the specified control channel - if (!m_controlChData.address().empty() && m_controlChData.port() > 0) { - if (!m_notifyCC) { - return; - } + if (m_controlChData.address().empty()) { + return; + } - json::object req = json::object(); - int state = modem::DVM_STATE::STATE_NXDN; - req["state"].set(state); - req["dstId"].set(dstId); + if (m_controlChData.port() == 0) { + return; + } - int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_RELEASE_TG, req, 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); - } + if (!m_notifyCC) { + return; + } + + + // callback REST API to release the granted TG on the specified control channel + json::object req = json::object(); + int state = modem::DVM_STATE::STATE_NXDN; + req["state"].set(state); + req["dstId"].set(dstId); + + int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), + HTTP_PUT, PUT_RELEASE_TG, req, 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); } } @@ -945,22 +953,28 @@ void Control::notifyCC_ReleaseGrant(uint32_t dstId) /// void Control::notifyCC_TouchGrant(uint32_t dstId) { - // callback REST API to touch the granted TG on the specified control channel - if (!m_controlChData.address().empty() && m_controlChData.port() > 0) { - if (!m_notifyCC) { - return; - } + if (m_controlChData.address().empty()) { + return; + } + + if (m_controlChData.port() == 0) { + return; + } - json::object req = json::object(); - int state = modem::DVM_STATE::STATE_NXDN; - req["state"].set(state); - req["dstId"].set(dstId); + if (!m_notifyCC) { + return; + } - int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_TOUCH_TG, req, 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); - } + // callback REST API to touch the granted TG on the specified control channel + json::object req = json::object(); + int state = modem::DVM_STATE::STATE_NXDN; + req["state"].set(state); + req["dstId"].set(dstId); + + int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), + HTTP_PUT, PUT_TOUCH_TG, req, 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/p25/Control.cpp b/src/p25/Control.cpp index da881a21..dffc9300 100644 --- a/src/p25/Control.cpp +++ b/src/p25/Control.cpp @@ -366,7 +366,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw yaml::Node rfssConfig = systemConf["config"]; yaml::Node controlCh = rfssConfig["controlCh"]; - m_notifyCC = controlCh["notifyEnable"].as(true); + m_notifyCC = controlCh["notifyEnable"].as(false); // voice on control forcibly disables CC notification if (m_voiceOnControl) { @@ -384,6 +384,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw } } + LogInfo(" Notify Control: %s", m_notifyCC ? "yes" : "no"); LogInfo(" Disable Network HDUs: %s", m_disableNetworkHDU ? "yes" : "no"); if (!m_trunk->m_ctrlTSDUMBF) { LogInfo(" Disable Multi-Block TSDUs: yes"); @@ -1299,22 +1300,28 @@ void Control::processNetwork() /// void Control::notifyCC_ReleaseGrant(uint32_t dstId) { - // callback REST API to release the granted TG on the specified control channel - if (!m_controlChData.address().empty() && m_controlChData.port() > 0) { - if (!m_notifyCC) { - return; - } + if (m_controlChData.address().empty()) { + return; + } - json::object req = json::object(); - int state = modem::DVM_STATE::STATE_P25; - req["state"].set(state); - req["dstId"].set(dstId); + if (m_controlChData.port() == 0) { + return; + } - int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_RELEASE_TG, req, 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); - } + if (!m_notifyCC) { + return; + } + + // callback REST API to release the granted TG on the specified control channel + json::object req = json::object(); + int state = modem::DVM_STATE::STATE_P25; + req["state"].set(state); + req["dstId"].set(dstId); + + int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), + HTTP_PUT, PUT_RELEASE_TG, req, 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); } } @@ -1324,22 +1331,28 @@ void Control::notifyCC_ReleaseGrant(uint32_t dstId) /// void Control::notifyCC_TouchGrant(uint32_t dstId) { - // callback REST API to touch the granted TG on the specified control channel - if (!m_controlChData.address().empty() && m_controlChData.port() > 0) { - if (!m_notifyCC) { - return; - } + if (m_controlChData.address().empty()) { + return; + } + + if (m_controlChData.port() == 0) { + return; + } - json::object req = json::object(); - int state = modem::DVM_STATE::STATE_P25; - req["state"].set(state); - req["dstId"].set(dstId); + if (!m_notifyCC) { + return; + } - int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), - HTTP_PUT, PUT_TOUCH_TG, req, 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); - } + // callback REST API to touch the granted TG on the specified control channel + json::object req = json::object(); + int state = modem::DVM_STATE::STATE_P25; + req["state"].set(state); + req["dstId"].set(dstId); + + int ret = RESTClient::send(m_controlChData.address(), m_controlChData.port(), m_controlChData.password(), + HTTP_PUT, PUT_TOUCH_TG, req, 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); } }