From 9819e01da598c4ec1326277744186363ea193706 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 9 Dec 2017 12:41:42 +0100 Subject: [PATCH] Web API: implemented device run APIs for BladeRF input, SDRdaemon input and SDRplay --- .../samplesource/bladerfinput/CMakeLists.txt | 6 ++++ .../bladerfinput/bladerfinput.cpp | 35 +++++++++++++++++++ .../samplesource/bladerfinput/bladerfinput.h | 9 +++++ .../bladerfinput/bladerfinput.pro | 2 ++ .../bladerfinput/bladerfinputplugin.cpp | 2 +- .../sdrdaemonsource/CMakeLists.txt | 6 ++++ .../sdrdaemonsource/sdrdaemonsource.pro | 2 ++ .../sdrdaemonsource/sdrdaemonsourceinput.cpp | 35 +++++++++++++++++++ .../sdrdaemonsource/sdrdaemonsourceinput.h | 9 +++++ .../sdrdaemonsource/sdrdaemonsourceplugin.cpp | 2 +- plugins/samplesource/sdrplay/CMakeLists.txt | 6 ++++ plugins/samplesource/sdrplay/sdrplayinput.cpp | 34 ++++++++++++++++++ plugins/samplesource/sdrplay/sdrplayinput.h | 9 +++++ .../samplesource/sdrplay/sdrplayplugin.cpp | 2 +- 14 files changed, 156 insertions(+), 3 deletions(-) diff --git a/plugins/samplesource/bladerfinput/CMakeLists.txt b/plugins/samplesource/bladerfinput/CMakeLists.txt index a905044da..2daf77264 100644 --- a/plugins/samplesource/bladerfinput/CMakeLists.txt +++ b/plugins/samplesource/bladerfinput/CMakeLists.txt @@ -1,5 +1,7 @@ project(bladerfinput) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + set(bladerfinput_SOURCES bladerfinputgui.cpp bladerfinput.cpp @@ -24,6 +26,7 @@ if (BUILD_DEBIAN) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${CMAKE_SOURCE_DIR}/devices ${LIBBLADERFLIBSRC}/include ${LIBBLADERFLIBSRC}/src @@ -32,6 +35,7 @@ else (BUILD_DEBIAN) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${CMAKE_SOURCE_DIR}/devices ${LIBBLADERF_INCLUDE_DIR} ) @@ -57,6 +61,7 @@ target_link_libraries(inputbladerf bladerf sdrbase sdrgui + swagger bladerfdevice ) else (BUILD_DEBIAN) @@ -65,6 +70,7 @@ target_link_libraries(inputbladerf ${LIBBLADERF_LIBRARIES} sdrbase sdrgui + swagger bladerfdevice ) endif (BUILD_DEBIAN) diff --git a/plugins/samplesource/bladerfinput/bladerfinput.cpp b/plugins/samplesource/bladerfinput/bladerfinput.cpp index b050df35a..c670bae7b 100644 --- a/plugins/samplesource/bladerfinput/bladerfinput.cpp +++ b/plugins/samplesource/bladerfinput/bladerfinput.cpp @@ -20,6 +20,10 @@ #include #include +#include "SWGDeviceSettings.h" +#include "SWGRtlSdrSettings.h" +#include "SWGDeviceState.h" + #include "util/simpleserializer.h" #include "dsp/dspcommands.h" #include "dsp/dspengine.h" @@ -542,6 +546,37 @@ bladerf_lna_gain BladerfInput::getLnaGain(int lnaGain) } } +int BladerfInput::webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + +int BladerfInput::webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + if (run) + { + if (m_deviceAPI->initAcquisition()) + { + m_deviceAPI->startAcquisition(); + DSPEngine::instance()->startAudioOutput(); + } + } + else + { + m_deviceAPI->stopAcquisition(); + DSPEngine::instance()->stopAudioOutput(); + } + + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + //struct bladerf *BladerfInput::open_bladerf_from_serial(const char *serial) //{ // int status; diff --git a/plugins/samplesource/bladerfinput/bladerfinput.h b/plugins/samplesource/bladerfinput/bladerfinput.h index 5276ad418..4d6321db6 100644 --- a/plugins/samplesource/bladerfinput/bladerfinput.h +++ b/plugins/samplesource/bladerfinput/bladerfinput.h @@ -87,6 +87,15 @@ public: virtual bool handleMessage(const Message& message); + virtual int webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + + virtual int webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + private: bool openDevice(); void closeDevice(); diff --git a/plugins/samplesource/bladerfinput/bladerfinput.pro b/plugins/samplesource/bladerfinput/bladerfinput.pro index 2d452f5bd..9275a3542 100644 --- a/plugins/samplesource/bladerfinput/bladerfinput.pro +++ b/plugins/samplesource/bladerfinput/bladerfinput.pro @@ -22,6 +22,7 @@ CONFIG(MINGW64):LIBBLADERFSRC = "D:\softs\bladeRF\host\libraries\libbladeRF\incl INCLUDEPATH += $$PWD INCLUDEPATH += ../../../sdrbase INCLUDEPATH += ../../../sdrgui +INCLUDEPATH += ../../../swagger/sdrangel/code/qt5/client INCLUDEPATH += ../../../devices INCLUDEPATH += $$LIBBLADERFSRC @@ -44,6 +45,7 @@ FORMS += bladerfinputgui.ui LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase LIBS += -L../../../sdrgui/$${build_subdir} -lsdrgui +LIBS += -L../../../swagger/$${build_subdir} -lswagger LIBS += -L../../../libbladerf/$${build_subdir} -llibbladerf LIBS += -L../../../devices/$${build_subdir} -ldevices diff --git a/plugins/samplesource/bladerfinput/bladerfinputplugin.cpp b/plugins/samplesource/bladerfinput/bladerfinputplugin.cpp index e35097438..6730aa1d0 100644 --- a/plugins/samplesource/bladerfinput/bladerfinputplugin.cpp +++ b/plugins/samplesource/bladerfinput/bladerfinputplugin.cpp @@ -27,7 +27,7 @@ const PluginDescriptor BlderfInputPlugin::m_pluginDescriptor = { QString("BladerRF Input"), - QString("3.8.2"), + QString("3.8.6"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/plugins/samplesource/sdrdaemonsource/CMakeLists.txt b/plugins/samplesource/sdrdaemonsource/CMakeLists.txt index 327325e6e..477561e9b 100644 --- a/plugins/samplesource/sdrdaemonsource/CMakeLists.txt +++ b/plugins/samplesource/sdrdaemonsource/CMakeLists.txt @@ -1,5 +1,7 @@ project(sdrdaemonsource) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + if (HAS_SSSE3) message(STATUS "SDRdaemonSource: use SSSE3 SIMD" ) elseif (HAS_NEON) @@ -49,6 +51,7 @@ if (BUILD_DEBIAN) target_include_directories(inputsdrdaemonsource PUBLIC . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${LIBCM256CCSRC} ${LIBNANOMSG_INCLUDE_DIR} ) @@ -56,6 +59,7 @@ else (BUILD_DEBIAN) target_include_directories(inputsdrdaemonsource PUBLIC . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${CM256CC_INCLUDE_DIR} ${LIBNANOMSG_INCLUDE_DIR} ) @@ -68,6 +72,7 @@ target_link_libraries(inputsdrdaemonsource ${LIBNANOMSG_LIBRARIES} sdrbase sdrgui + swagger ) else (BUILD_DEBIAN) target_link_libraries(inputsdrdaemonsource @@ -76,6 +81,7 @@ target_link_libraries(inputsdrdaemonsource ${LIBNANOMSG_LIBRARIES} sdrbase sdrgui + swagger ) endif (BUILD_DEBIAN) diff --git a/plugins/samplesource/sdrdaemonsource/sdrdaemonsource.pro b/plugins/samplesource/sdrdaemonsource/sdrdaemonsource.pro index bd1208a55..c7a9489c0 100644 --- a/plugins/samplesource/sdrdaemonsource/sdrdaemonsource.pro +++ b/plugins/samplesource/sdrdaemonsource/sdrdaemonsource.pro @@ -20,6 +20,7 @@ CONFIG(MINGW64):LIBCM256CCSRC = "D:\softs\cm256cc" INCLUDEPATH += $$PWD INCLUDEPATH += ../../../sdrbase INCLUDEPATH += ../../../sdrgui +INCLUDEPATH += ../../../swagger/sdrangel/code/qt5/client INCLUDEPATH += $$LIBNANOMSGSRC/src INCLUDEPATH += $$LIBCM256CCSRC @@ -55,6 +56,7 @@ FORMS += sdrdaemonsourcegui.ui LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase LIBS += -L../../../sdrgui/$${build_subdir} -lsdrgui +LIBS += -L../../../swagger/$${build_subdir} -lswagger LIBS += -L../../../nanomsg/$${build_subdir} -lnanomsg LIBS += -L../../../cm256cc/$${build_subdir} -lcm256cc diff --git a/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceinput.cpp b/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceinput.cpp index beb5842b3..844f1fabf 100644 --- a/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceinput.cpp +++ b/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceinput.cpp @@ -18,6 +18,10 @@ #include #include +#include "SWGDeviceSettings.h" +#include "SWGRtlSdrSettings.h" +#include "SWGDeviceState.h" + #include "util/simpleserializer.h" #include "dsp/dspcommands.h" #include "dsp/dspengine.h" @@ -206,3 +210,34 @@ void SDRdaemonSourceInput::setMessageQueueToGUI(MessageQueue *queue) m_SDRdaemonUDPHandler->setMessageQueueToGUI(queue); } +int SDRdaemonSourceInput::webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + +int SDRdaemonSourceInput::webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + if (run) + { + if (m_deviceAPI->initAcquisition()) + { + m_deviceAPI->startAcquisition(); + DSPEngine::instance()->startAudioOutput(); + } + } + else + { + m_deviceAPI->stopAcquisition(); + DSPEngine::instance()->stopAudioOutput(); + } + + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + diff --git a/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceinput.h b/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceinput.h index cb44ecea2..3307ee795 100644 --- a/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceinput.h +++ b/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceinput.h @@ -320,6 +320,15 @@ public: virtual void setMessageQueueToGUI(MessageQueue *queue); + virtual int webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + + virtual int webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + private: DeviceSourceAPI *m_deviceAPI; QMutex m_mutex; diff --git a/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceplugin.cpp b/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceplugin.cpp index 00fa7a77f..0ea0f75fd 100644 --- a/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceplugin.cpp +++ b/plugins/samplesource/sdrdaemonsource/sdrdaemonsourceplugin.cpp @@ -26,7 +26,7 @@ const PluginDescriptor SDRdaemonSourcePlugin::m_pluginDescriptor = { QString("SDRdaemon source input"), - QString("3.8.0"), + QString("3.8.6"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/plugins/samplesource/sdrplay/CMakeLists.txt b/plugins/samplesource/sdrplay/CMakeLists.txt index 2b698a4f1..aa9464e53 100644 --- a/plugins/samplesource/sdrplay/CMakeLists.txt +++ b/plugins/samplesource/sdrplay/CMakeLists.txt @@ -1,5 +1,7 @@ project(sdrplay) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + set(sdrplay_SOURCES sdrplaygui.cpp sdrplayinput.cpp @@ -24,6 +26,7 @@ if (BUILD_DEBIAN) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${LIBMIRISDRSRC}/include ${LIBMIRISDRSRC}/src ) @@ -31,6 +34,7 @@ else (BUILD_DEBIAN) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${LIBMIRISDR_INCLUDE_DIR} ) endif (BUILD_DEBIAN) @@ -52,6 +56,7 @@ target_link_libraries(inputsdrplay mirisdr sdrbase sdrgui + swagger ) else (BUILD_DEBIAN) target_link_libraries(inputsdrplay @@ -59,6 +64,7 @@ target_link_libraries(inputsdrplay ${LIBMIRISDR_LIBRARIES} sdrbase sdrgui + swagger ) endif (BUILD_DEBIAN) diff --git a/plugins/samplesource/sdrplay/sdrplayinput.cpp b/plugins/samplesource/sdrplay/sdrplayinput.cpp index d2ab34756..853f43cca 100644 --- a/plugins/samplesource/sdrplay/sdrplayinput.cpp +++ b/plugins/samplesource/sdrplay/sdrplayinput.cpp @@ -18,6 +18,10 @@ #include #include +#include "SWGDeviceSettings.h" +#include "SWGRtlSdrSettings.h" +#include "SWGDeviceState.h" + #include "util/simpleserializer.h" #include "dsp/dspcommands.h" #include "dsp/dspengine.h" @@ -566,4 +570,34 @@ bool SDRPlayInput::setCenterFrequency(quint64 freq_hz) } } +int SDRPlayInput::webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + +int SDRPlayInput::webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + if (run) + { + if (m_deviceAPI->initAcquisition()) + { + m_deviceAPI->startAcquisition(); + DSPEngine::instance()->startAudioOutput(); + } + } + else + { + m_deviceAPI->stopAcquisition(); + DSPEngine::instance()->stopAudioOutput(); + } + + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} diff --git a/plugins/samplesource/sdrplay/sdrplayinput.h b/plugins/samplesource/sdrplay/sdrplayinput.h index a1bbe8a7c..64fec2227 100644 --- a/plugins/samplesource/sdrplay/sdrplayinput.h +++ b/plugins/samplesource/sdrplay/sdrplayinput.h @@ -114,6 +114,15 @@ public: virtual bool handleMessage(const Message& message); + virtual int webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + + virtual int webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + private: bool openDevice(); void closeDevice(); diff --git a/plugins/samplesource/sdrplay/sdrplayplugin.cpp b/plugins/samplesource/sdrplay/sdrplayplugin.cpp index 30902facc..0302ce288 100644 --- a/plugins/samplesource/sdrplay/sdrplayplugin.cpp +++ b/plugins/samplesource/sdrplay/sdrplayplugin.cpp @@ -25,7 +25,7 @@ const PluginDescriptor SDRPlayPlugin::m_pluginDescriptor = { QString("SDRPlay RSP1 Input"), - QString("3.8.0"), + QString("3.8.6"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true,