From b169ccefadeb5b9291b9a83b54f6e580bc1a1047 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 19 Aug 2018 20:08:07 +0200 Subject: [PATCH] SDRdaemon: Web API: implemented daemonRunPost and daemonRunDelete --- sdrdaemon/webapi/webapiadapterdaemon.cpp | 46 ++++++++++++++++++++---- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/sdrdaemon/webapi/webapiadapterdaemon.cpp b/sdrdaemon/webapi/webapiadapterdaemon.cpp index 27e84849e..c240702fe 100644 --- a/sdrdaemon/webapi/webapiadapterdaemon.cpp +++ b/sdrdaemon/webapi/webapiadapterdaemon.cpp @@ -253,7 +253,7 @@ int WebAPIAdapterDaemon::daemonSettingsPutPatch( } int WebAPIAdapterDaemon::daemonRunGet( - SWGSDRangel::SWGDeviceState& response __attribute__((unused)), + SWGSDRangel::SWGDeviceState& response, SWGSDRangel::SWGErrorResponse& error) { error.init(); @@ -278,21 +278,53 @@ int WebAPIAdapterDaemon::daemonRunGet( } int WebAPIAdapterDaemon::daemonRunPost( - SWGSDRangel::SWGDeviceState& response __attribute__((unused)), + SWGSDRangel::SWGDeviceState& response, SWGSDRangel::SWGErrorResponse& error) { error.init(); - *error.getMessage() = "Not implemented"; - return 501; + + if (m_sdrDaemonMain.m_deviceSourceEngine) // Rx + { + DeviceSampleSource *source = m_sdrDaemonMain.m_deviceSourceAPI->getSampleSource(); + response.init(); + return source->webapiRun(true, response, *error.getMessage()); + } + else if (m_sdrDaemonMain.m_deviceSinkEngine) // Tx + { + DeviceSampleSink *sink = m_sdrDaemonMain.m_deviceSinkAPI->getSampleSink(); + response.init(); + return sink->webapiRun(true, response, *error.getMessage()); + } + else + { + *error.getMessage() = QString("DeviceSet error"); + return 500; + } } int WebAPIAdapterDaemon::daemonRunDelete( - SWGSDRangel::SWGDeviceState& response __attribute__((unused)), + SWGSDRangel::SWGDeviceState& response, SWGSDRangel::SWGErrorResponse& error) { error.init(); - *error.getMessage() = "Not implemented"; - return 501; + + if (m_sdrDaemonMain.m_deviceSourceEngine) // Rx + { + DeviceSampleSource *source = m_sdrDaemonMain.m_deviceSourceAPI->getSampleSource(); + response.init(); + return source->webapiRun(false, response, *error.getMessage()); + } + else if (m_sdrDaemonMain.m_deviceSinkEngine) // Tx + { + DeviceSampleSink *sink = m_sdrDaemonMain.m_deviceSinkAPI->getSampleSink(); + response.init(); + return sink->webapiRun(false, response, *error.getMessage()); + } + else + { + *error.getMessage() = QString("DeviceSet error"); + return 500; + } } int WebAPIAdapterDaemon::daemonReportGet(