From 082fcc000d094eb5ca67308440e222246caaa246 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 17 Dec 2018 15:00:13 +0100 Subject: [PATCH] Reverse API: RTL-SDR input changes (2) --- plugins/samplesource/rtlsdr/rtlsdrinput.cpp | 22 +++++++++++++++++++-- plugins/samplesource/rtlsdr/rtlsdrinput.h | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp index 42406246b..83af7d601 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp @@ -333,8 +333,7 @@ bool RTLSDRInput::handleMessage(const Message& message) if (cmd.getStartStop()) { - if (m_deviceAPI->initAcquisition()) - { + if (m_deviceAPI->initAcquisition()) { m_deviceAPI->startAcquisition(); } } @@ -343,6 +342,10 @@ bool RTLSDRInput::handleMessage(const Message& message) m_deviceAPI->stopAcquisition(); } + if (m_settings.m_useReverseAPI) { + webapiReverseSendStartStop(cmd.getStartStop()); + } + return true; } else @@ -812,6 +815,21 @@ void RTLSDRInput::webapiReverseSendSettings(QList& deviceSettingsKeys, delete swgDeviceSettings; } +void RTLSDRInput::webapiReverseSendStartStop(bool start) +{ + QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") + .arg(m_settings.m_reverseAPIAddress) + .arg(m_settings.m_reverseAPIPort) + .arg(m_settings.m_reverseAPIDeviceIndex); + m_networkRequest.setUrl(QUrl(channelSettingsURL)); + + if (start) { + m_networkManager->sendCustomRequest(m_networkRequest, "POST"); + } else { + m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); + } +} + void RTLSDRInput::networkManagerFinished(QNetworkReply *reply) { if (reply->error()) diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.h b/plugins/samplesource/rtlsdr/rtlsdrinput.h index f323ea72d..d18b2c7c7 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.h +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.h @@ -168,6 +168,7 @@ private: void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const RTLSDRSettings& settings); void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); void webapiReverseSendSettings(QList& deviceSettingsKeys, const RTLSDRSettings& settings, bool force); + void webapiReverseSendStartStop(bool start); private slots: void networkManagerFinished(QNetworkReply *reply);