From 0896c2520ea7c7272f4de3855fe70cd84c397760 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 18 Dec 2017 22:39:32 +0100 Subject: [PATCH] Server: web API: implemented /sdrangel/dvserial --- sdrsrv/webapi/webapiadaptersrv.cpp | 34 ++++++++++++++++++++++++++++++ sdrsrv/webapi/webapiadaptersrv.h | 5 +++++ 2 files changed, 39 insertions(+) diff --git a/sdrsrv/webapi/webapiadaptersrv.cpp b/sdrsrv/webapi/webapiadaptersrv.cpp index 26d48caf4..994087346 100644 --- a/sdrsrv/webapi/webapiadaptersrv.cpp +++ b/sdrsrv/webapi/webapiadaptersrv.cpp @@ -28,6 +28,7 @@ #include "SWGAudioDevices.h" #include "SWGAudioDevicesSelect.h" #include "SWGLocationInformation.h" +#include "SWGDVSeralDevices.h" #include "SWGErrorResponse.h" #include "maincore.h" @@ -291,6 +292,39 @@ int WebAPIAdapterSrv::instanceLocationPut( return 200; } +int WebAPIAdapterSrv::instanceDVSerialPatch( + bool dvserial, + SWGSDRangel::SWGDVSeralDevices& response, + SWGSDRangel::SWGErrorResponse& error __attribute__((unused))) +{ + m_mainCore.m_dspEngine->setDVSerialSupport(dvserial); + response.init(); + + if (dvserial) + { + std::vector deviceNames; + m_mainCore.m_dspEngine->getDVSerialNames(deviceNames); + response.setNbDevices((int) deviceNames.size()); + QList *deviceNamesList = response.getDvSerialDevices(); + + std::vector::iterator it = deviceNames.begin(); + std::string deviceNamesStr = "DV Serial devices found: "; + + while (it != deviceNames.end()) + { + deviceNamesList->append(new SWGSDRangel::SWGDVSerialDevice); + *deviceNamesList->back()->getDeviceName() = QString::fromStdString(*it); + ++it; + } + } + else + { + response.setNbDevices(0); + } + + return 200; +} + void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList) { deviceSetList->init(); diff --git a/sdrsrv/webapi/webapiadaptersrv.h b/sdrsrv/webapi/webapiadaptersrv.h index c0a931dfa..c36eaffd3 100644 --- a/sdrsrv/webapi/webapiadaptersrv.h +++ b/sdrsrv/webapi/webapiadaptersrv.h @@ -74,6 +74,11 @@ public: SWGSDRangel::SWGLocationInformation& response, SWGSDRangel::SWGErrorResponse& error); + virtual int instanceDVSerialPatch( + bool dvserial, + SWGSDRangel::SWGDVSeralDevices& response, + SWGSDRangel::SWGErrorResponse& error); + private: MainCore& m_mainCore;