diff --git a/plugins/samplesource/airspy/CMakeLists.txt b/plugins/samplesource/airspy/CMakeLists.txt index 56cd563f0..022530bff 100644 --- a/plugins/samplesource/airspy/CMakeLists.txt +++ b/plugins/samplesource/airspy/CMakeLists.txt @@ -1,5 +1,7 @@ project(airspy) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + set(airspy_SOURCES airspygui.cpp airspyinput.cpp @@ -24,6 +26,7 @@ if (BUILD_DEBIAN) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${LIBAIRSPYSRC} ${LIBAIRSPYSRC}/libairspy/src ) @@ -31,6 +34,7 @@ else (BUILD_DEBIAN) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${LIBAIRSPY_INCLUDE_DIR} ) endif (BUILD_DEBIAN) @@ -56,6 +60,7 @@ target_link_libraries(inputairspy airspy sdrbase sdrgui + swagger ) else (BUILD_DEBIAN) target_link_libraries(inputairspy @@ -63,6 +68,7 @@ target_link_libraries(inputairspy ${LIBAIRSPY_LIBRARIES} sdrbase sdrgui + swagger ) endif (BUILD_DEBIAN) diff --git a/plugins/samplesource/airspy/airspy.pro b/plugins/samplesource/airspy/airspy.pro index 5cded93f4..3348db739 100644 --- a/plugins/samplesource/airspy/airspy.pro +++ b/plugins/samplesource/airspy/airspy.pro @@ -16,6 +16,7 @@ CONFIG(MINGW64):LIBAIRSPYSRC = "D:\softs\libairspy" INCLUDEPATH += $$PWD INCLUDEPATH += ../../../sdrbase INCLUDEPATH += ../../../sdrgui +INCLUDEPATH += ../../../swagger/sdrangel/code/qt5/client INCLUDEPATH += $$LIBAIRSPYSRC DEFINES += LIBAIRSPY_DYN_RATES @@ -44,6 +45,7 @@ FORMS += airspygui.ui LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase LIBS += -L../../../sdrgui/$${build_subdir} -lsdrgui +LIBS += -L../../../swagger/$${build_subdir} -lswagger LIBS += -L../../../libairspy/$${build_subdir} -llibairspy RESOURCES = ../../../sdrgui/resources/res.qrc diff --git a/plugins/samplesource/airspy/airspyinput.cpp b/plugins/samplesource/airspy/airspyinput.cpp index b7fb98556..e6b10d2a6 100644 --- a/plugins/samplesource/airspy/airspyinput.cpp +++ b/plugins/samplesource/airspy/airspyinput.cpp @@ -16,8 +16,12 @@ #include #include +#include #include +#include "SWGDeviceSettings.h" +#include "SWGDeviceState.h" + #include "airspygui.h" #include "airspyinput.h" @@ -565,3 +569,31 @@ struct airspy_device *AirspyInput::open_airspy_from_sequence(int sequence) return 0; } + +int AirspyInput::webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + +int AirspyInput::webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + MsgStartStop *message = MsgStartStop::create(run); + m_inputMessageQueue.push(message); + + if (m_guiMessageQueue) // forward to GUI if any + { + MsgStartStop *msgToGUI = MsgStartStop::create(run); + m_guiMessageQueue->push(msgToGUI); + } + + usleep(100000); + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + diff --git a/plugins/samplesource/airspy/airspyinput.h b/plugins/samplesource/airspy/airspyinput.h index 8ef9d7102..73a5dba7c 100644 --- a/plugins/samplesource/airspy/airspyinput.h +++ b/plugins/samplesource/airspy/airspyinput.h @@ -104,7 +104,16 @@ public: virtual bool handleMessage(const Message& message); - static const qint64 loLowLimitFreq; + virtual int webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + + virtual int webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + + static const qint64 loLowLimitFreq; static const qint64 loHighLimitFreq; private: diff --git a/plugins/samplesource/fcdpro/fcdproinput.cpp b/plugins/samplesource/fcdpro/fcdproinput.cpp index 997b83da8..90230f652 100644 --- a/plugins/samplesource/fcdpro/fcdproinput.cpp +++ b/plugins/samplesource/fcdpro/fcdproinput.cpp @@ -20,6 +20,10 @@ #include #include #include +#include + +#include "SWGDeviceSettings.h" +#include "SWGDeviceState.h" #include "dsp/dspcommands.h" #include "dsp/dspengine.h" @@ -697,3 +701,30 @@ void FCDProInput::set_lo_ppm() { set_center_freq((double) m_settings.m_centerFrequency); } + +int FCDProInput::webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + +int FCDProInput::webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + MsgStartStop *message = MsgStartStop::create(run); + m_inputMessageQueue.push(message); + + if (m_guiMessageQueue) // forward to GUI if any + { + MsgStartStop *msgToGUI = MsgStartStop::create(run); + m_guiMessageQueue->push(msgToGUI); + } + + usleep(100000); + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} diff --git a/plugins/samplesource/fcdpro/fcdproinput.h b/plugins/samplesource/fcdpro/fcdproinput.h index 401643365..248db0db0 100644 --- a/plugins/samplesource/fcdpro/fcdproinput.h +++ b/plugins/samplesource/fcdpro/fcdproinput.h @@ -110,7 +110,16 @@ public: virtual bool handleMessage(const Message& message); - void set_center_freq(double freq); + virtual int webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + + virtual int webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + + void set_center_freq(double freq); void set_bias_t(bool on); void set_lnaGain(int index); void set_rfFilter(int index); diff --git a/plugins/samplesource/fcdproplus/fcdproplusinput.cpp b/plugins/samplesource/fcdproplus/fcdproplusinput.cpp index b54dd5f80..dd232ccc7 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusinput.cpp +++ b/plugins/samplesource/fcdproplus/fcdproplusinput.cpp @@ -19,6 +19,10 @@ #include #include #include +#include + +#include "SWGDeviceSettings.h" +#include "SWGDeviceState.h" #include "dsp/dspcommands.h" #include "dsp/dspengine.h" @@ -409,6 +413,32 @@ void FCDProPlusInput::set_lo_ppm() set_center_freq((double) m_settings.m_centerFrequency); } +int FCDProPlusInput::webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + +int FCDProPlusInput::webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + MsgStartStop *message = MsgStartStop::create(run); + m_inputMessageQueue.push(message); + + if (m_guiMessageQueue) // forward to GUI if any + { + MsgStartStop *msgToGUI = MsgStartStop::create(run); + m_guiMessageQueue->push(msgToGUI); + } + + usleep(100000); + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} diff --git a/plugins/samplesource/fcdproplus/fcdproplusinput.h b/plugins/samplesource/fcdproplus/fcdproplusinput.h index 9aa7ef3bc..46108a514 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusinput.h +++ b/plugins/samplesource/fcdproplus/fcdproplusinput.h @@ -109,7 +109,16 @@ public: virtual bool handleMessage(const Message& message); - void set_center_freq(double freq); + virtual int webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + + virtual int webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage); + + void set_center_freq(double freq); void set_bias_t(bool on); void set_lna_gain(bool on); void set_mixer_gain(bool on); diff --git a/plugins/samplesource/filesource/filesourceinput.cpp b/plugins/samplesource/filesource/filesourceinput.cpp index d4183117f..e6189f363 100644 --- a/plugins/samplesource/filesource/filesourceinput.cpp +++ b/plugins/samplesource/filesource/filesourceinput.cpp @@ -16,10 +16,12 @@ #include #include +#include #include #include "SWGDeviceSettings.h" #include "SWGFileSourceSettings.h" +#include "SWGDeviceState.h" #include "util/simpleserializer.h" #include "dsp/dspcommands.h" @@ -324,3 +326,31 @@ int FileSourceInput::webapiSettingsGet( *response.getFileSourceSettings()->getFileName() = m_settings.m_fileName; return 200; } + +int FileSourceInput::webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + +int FileSourceInput::webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage __attribute__((unused))) +{ + MsgStartStop *message = MsgStartStop::create(run); + m_inputMessageQueue.push(message); + + if (m_guiMessageQueue) // forward to GUI if any + { + MsgStartStop *msgToGUI = MsgStartStop::create(run); + m_guiMessageQueue->push(msgToGUI); + } + + usleep(100000); + m_deviceAPI->getDeviceEngineStateStr(*response.getState()); + return 200; +} + diff --git a/plugins/samplesource/filesource/filesourceinput.h b/plugins/samplesource/filesource/filesourceinput.h index 4abb37655..b905446a6 100644 --- a/plugins/samplesource/filesource/filesourceinput.h +++ b/plugins/samplesource/filesource/filesourceinput.h @@ -247,7 +247,16 @@ public: SWGSDRangel::SWGDeviceSettings& response, QString& errorMessage); -private: + 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; Settings m_settings;