diff --git a/sdrsrv/webapi/webapiadaptersrv.cpp b/sdrsrv/webapi/webapiadaptersrv.cpp index ce4a30335..b4d068264 100644 --- a/sdrsrv/webapi/webapiadaptersrv.cpp +++ b/sdrsrv/webapi/webapiadaptersrv.cpp @@ -23,6 +23,7 @@ #include "SWGInstanceSummaryResponse.h" #include "SWGInstanceDevicesResponse.h" +#include "SWGInstanceChannelsResponse.h" #include "SWGErrorResponse.h" #include "maincore.h" @@ -35,6 +36,8 @@ #include "dsp/devicesamplesource.h" #include "channel/channelsourceapi.h" #include "channel/channelsinkapi.h" +#include "plugin/pluginapi.h" +#include "plugin/pluginmanager.h" #include "webapiadaptersrv.h" WebAPIAdapterSrv::WebAPIAdapterSrv(MainCore& mainCore) : @@ -109,6 +112,32 @@ int WebAPIAdapterSrv::instanceDevices( return 200; } +int WebAPIAdapterSrv::instanceChannels( + bool tx, + SWGSDRangel::SWGInstanceChannelsResponse& response, + SWGSDRangel::SWGErrorResponse& error __attribute__((unused))) +{ + PluginAPI::ChannelRegistrations *channelRegistrations = tx ? m_mainCore.m_pluginManager->getTxChannelRegistrations() : m_mainCore.m_pluginManager->getRxChannelRegistrations(); + int nbChannelDevices = channelRegistrations->size(); + response.setChannelcount(nbChannelDevices); + QList *channels = response.getChannels(); + + for (int i = 0; i < nbChannelDevices; i++) + { + channels->append(new SWGSDRangel::SWGChannelListItem); + PluginInterface *channelInterface = channelRegistrations->at(i).m_plugin; + const PluginDescriptor& pluginDescriptor = channelInterface->getPluginDescriptor(); + *channels->back()->getVersion() = pluginDescriptor.version; + *channels->back()->getName() = pluginDescriptor.displayedName; + channels->back()->setTx(tx); + *channels->back()->getIdUri() = channelRegistrations->at(i).m_channelIdURI; + *channels->back()->getId() = channelRegistrations->at(i).m_channelId; + channels->back()->setIndex(i); + } + + return 200; +} + void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList) { deviceSetList->init(); diff --git a/sdrsrv/webapi/webapiadaptersrv.h b/sdrsrv/webapi/webapiadaptersrv.h index 715ed1257..5baf3985e 100644 --- a/sdrsrv/webapi/webapiadaptersrv.h +++ b/sdrsrv/webapi/webapiadaptersrv.h @@ -45,6 +45,11 @@ public: SWGSDRangel::SWGInstanceDevicesResponse& response, SWGSDRangel::SWGErrorResponse& error); + virtual int instanceChannels( + bool tx, + SWGSDRangel::SWGInstanceChannelsResponse& response, + SWGSDRangel::SWGErrorResponse& error); + private: MainCore& m_mainCore;