diff options
-rw-r--r-- | src/DabMod.cpp | 14 | ||||
-rw-r--r-- | src/EtiReader.cpp | 9 | ||||
-rw-r--r-- | src/EtiReader.h | 2 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 0ab112b..e0e8a5b 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -114,9 +114,11 @@ class ModulatorData : public RemoteControllable { ModulatorData() : RemoteControllable("mainloop") { RC_ADD_PARAMETER(num_modulator_restarts, "(Read-only) Number of mod restarts"); RC_ADD_PARAMETER(most_recent_edi_decoded, "(Read-only) UNIX Timestamp of most recently decoded EDI frame"); + RC_ADD_PARAMETER(edi_source, "(Read-only) URL of the EDI/TCP source"); RC_ADD_PARAMETER(running_since, "(Read-only) UNIX Timestamp of most recent modulator restart"); RC_ADD_PARAMETER(ensemble_label, "(Read-only) Label of the ensemble"); RC_ADD_PARAMETER(ensemble_eid, "(Read-only) Ensemble ID"); + RC_ADD_PARAMETER(ensemble_services, "(Read-only, only JSON) Ensemble service information"); RC_ADD_PARAMETER(num_services, "(Read-only) Number of services in the ensemble"); } @@ -165,6 +167,14 @@ class ModulatorData : public RemoteControllable { throw ParameterError("Not available yet"); } } + else if (parameter == "edi_source") { + if (ediInput) { + ss << ediInput->ediTransport.getTcpUri(); + } + else { + throw ParameterError("Not available yet"); + } + } else if (parameter == "num_services") { if (ediInput) { ss << ediInput->ediReader.getSubchannels().size(); @@ -173,6 +183,9 @@ class ModulatorData : public RemoteControllable { throw ParameterError("Not available yet"); } } + else if (parameter == "ensemble_services") { + throw ParameterError("ensemble_services is only available through 'showjson'"); + } else { ss << "Parameter '" << parameter << "' is not exported by controllable " << get_rc_name(); @@ -189,6 +202,7 @@ class ModulatorData : public RemoteControllable { map["most_recent_edi_decoded"].v = most_recent_edi_decoded; if (ediInput) { + map["edi_source"].v = ediInput->ediTransport.getTcpUri(); map["num_services"].v = ediInput->ediReader.getSubchannels().size(); const auto ens = ediInput->ediReader.getEnsembleInfo(); diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp index 244cc18..eda2f23 100644 --- a/src/EtiReader.cpp +++ b/src/EtiReader.cpp @@ -540,8 +540,8 @@ void EdiTransport::Open(const std::string& uri) { etiLog.level(info) << "Opening EDI :" << uri; - const string proto = uri.substr(0, 3); - if (proto == "udp") { + const string proto = uri.substr(0, 6); + if (proto == "udp://") { if (m_proto == Proto::TCP) { throw std::invalid_argument("Cannot specify both TCP and UDP urls"); } @@ -571,7 +571,7 @@ void EdiTransport::Open(const std::string& uri) m_proto = Proto::UDP; m_enabled = true; } - else if (proto == "tcp") { + else if (proto == "tcp://") { if (m_proto != Proto::Unspecified) { throw std::invalid_argument("Cannot call Open several times with TCP"); } @@ -582,10 +582,11 @@ void EdiTransport::Open(const std::string& uri) } m_port = std::stoi(uri.substr(found_port+1)); - const std::string hostname = uri.substr(6, found_port-6);// skip tcp:// + const std::string hostname = uri.substr(6, found_port-6); etiLog.level(info) << "EDI TCP connect to " << hostname << ":" << m_port; + m_tcp_uri = uri; m_tcpclient.connect(hostname, m_port); m_proto = Proto::TCP; m_enabled = true; diff --git a/src/EtiReader.h b/src/EtiReader.h index 29091bd..703e42a 100644 --- a/src/EtiReader.h +++ b/src/EtiReader.h @@ -221,6 +221,7 @@ class EdiTransport { void Open(const std::string& uri); bool isEnabled(void) const { return m_enabled; } + std::string getTcpUri(void) const { return m_tcp_uri; } /* Receive a packet and give it to the decoder. Returns * true if a packet was received, false in case of socket @@ -229,6 +230,7 @@ class EdiTransport { bool rxPacket(void); private: + std::string m_tcp_uri; bool m_enabled; int m_port; std::string m_bindto; |