mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
Server: web API: implemented /sdrangel/devices GET
This commit is contained in:
parent
2784a026d6
commit
07be97c658
@ -22,6 +22,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "SWGInstanceSummaryResponse.h"
|
||||
#include "SWGInstanceDevicesResponse.h"
|
||||
#include "SWGErrorResponse.h"
|
||||
|
||||
#include "maincore.h"
|
||||
@ -29,6 +30,7 @@
|
||||
#include "device/deviceset.h"
|
||||
#include "device/devicesinkapi.h"
|
||||
#include "device/devicesourceapi.h"
|
||||
#include "device/deviceenumerator.h"
|
||||
#include "dsp/devicesamplesink.h"
|
||||
#include "dsp/devicesamplesource.h"
|
||||
#include "channel/channelsourceapi.h"
|
||||
@ -81,6 +83,32 @@ int WebAPIAdapterSrv::instanceDelete(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceDevices(
|
||||
bool tx,
|
||||
SWGSDRangel::SWGInstanceDevicesResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
{
|
||||
int nbSamplingDevices = tx ? DeviceEnumerator::instance()->getNbTxSamplingDevices() : DeviceEnumerator::instance()->getNbRxSamplingDevices();
|
||||
response.setDevicecount(nbSamplingDevices);
|
||||
QList<SWGSDRangel::SWGDeviceListItem*> *devices = response.getDevices();
|
||||
|
||||
for (int i = 0; i < nbSamplingDevices; i++)
|
||||
{
|
||||
PluginInterface::SamplingDevice samplingDevice = tx ? DeviceEnumerator::instance()->getTxSamplingDevice(i) : DeviceEnumerator::instance()->getRxSamplingDevice(i);
|
||||
devices->append(new SWGSDRangel::SWGDeviceListItem);
|
||||
*devices->back()->getDisplayedName() = samplingDevice.displayedName;
|
||||
*devices->back()->getHwType() = samplingDevice.hardwareId;
|
||||
*devices->back()->getSerial() = samplingDevice.serial;
|
||||
devices->back()->setSequence(samplingDevice.sequence);
|
||||
devices->back()->setTx(!samplingDevice.rxElseTx);
|
||||
devices->back()->setNbStreams(samplingDevice.deviceNbItems);
|
||||
devices->back()->setDeviceSetIndex(samplingDevice.claimed);
|
||||
devices->back()->setIndex(i);
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList)
|
||||
{
|
||||
deviceSetList->init();
|
||||
|
@ -40,6 +40,11 @@ public:
|
||||
SWGSDRangel::SWGInstanceSummaryResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDevices(
|
||||
bool tx,
|
||||
SWGSDRangel::SWGInstanceDevicesResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
private:
|
||||
MainCore& m_mainCore;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user