Server: web API: implemented /sdrangel/channels GET

pull/127/head
f4exb 2017-12-18 13:36:27 +01:00
rodzic 07be97c658
commit 8d447dc827
2 zmienionych plików z 34 dodań i 0 usunięć

Wyświetl plik

@ -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<SWGSDRangel::SWGChannelListItem*> *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();

Wyświetl plik

@ -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;