mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-24 11:12:27 -04: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 <unistd.h>
|
||||||
|
|
||||||
#include "SWGInstanceSummaryResponse.h"
|
#include "SWGInstanceSummaryResponse.h"
|
||||||
|
#include "SWGInstanceDevicesResponse.h"
|
||||||
#include "SWGErrorResponse.h"
|
#include "SWGErrorResponse.h"
|
||||||
|
|
||||||
#include "maincore.h"
|
#include "maincore.h"
|
||||||
@ -29,6 +30,7 @@
|
|||||||
#include "device/deviceset.h"
|
#include "device/deviceset.h"
|
||||||
#include "device/devicesinkapi.h"
|
#include "device/devicesinkapi.h"
|
||||||
#include "device/devicesourceapi.h"
|
#include "device/devicesourceapi.h"
|
||||||
|
#include "device/deviceenumerator.h"
|
||||||
#include "dsp/devicesamplesink.h"
|
#include "dsp/devicesamplesink.h"
|
||||||
#include "dsp/devicesamplesource.h"
|
#include "dsp/devicesamplesource.h"
|
||||||
#include "channel/channelsourceapi.h"
|
#include "channel/channelsourceapi.h"
|
||||||
@ -81,6 +83,32 @@ int WebAPIAdapterSrv::instanceDelete(
|
|||||||
return 200;
|
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)
|
void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList)
|
||||||
{
|
{
|
||||||
deviceSetList->init();
|
deviceSetList->init();
|
||||||
|
@ -40,6 +40,11 @@ public:
|
|||||||
SWGSDRangel::SWGInstanceSummaryResponse& response,
|
SWGSDRangel::SWGInstanceSummaryResponse& response,
|
||||||
SWGSDRangel::SWGErrorResponse& error);
|
SWGSDRangel::SWGErrorResponse& error);
|
||||||
|
|
||||||
|
virtual int instanceDevices(
|
||||||
|
bool tx,
|
||||||
|
SWGSDRangel::SWGInstanceDevicesResponse& response,
|
||||||
|
SWGSDRangel::SWGErrorResponse& error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainCore& m_mainCore;
|
MainCore& m_mainCore;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user