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;