mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-30 23:55:16 -04:00
KiwiSDR: implemented report in REST API
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
#include "SWGDeviceReport.h"
|
||||
#include "SWGKiwiSDRReport.h"
|
||||
|
||||
#include "kiwisdrinput.h"
|
||||
#include "device/deviceapi.h"
|
||||
@@ -251,6 +253,15 @@ bool KiwiSDRInput::handleMessage(const Message& message)
|
||||
}
|
||||
}
|
||||
|
||||
int KiwiSDRInput::getStatus() const
|
||||
{
|
||||
if (m_kiwiSDRWorker) {
|
||||
return m_kiwiSDRWorker->getStatus();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool KiwiSDRInput::applySettings(const KiwiSDRSettings& settings, bool force)
|
||||
{
|
||||
QList<QString> reverseAPIKeys;
|
||||
@@ -376,6 +387,17 @@ int KiwiSDRInput::webapiSettingsPutPatch(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int KiwiSDRInput::webapiReportGet(
|
||||
SWGSDRangel::SWGDeviceReport& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setKiwiSdrReport(new SWGSDRangel::SWGKiwiSDRReport());
|
||||
response.getKiwiSdrReport()->init();
|
||||
webapiFormatDeviceReport(response);
|
||||
return 200;
|
||||
}
|
||||
|
||||
void KiwiSDRInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const KiwiSDRSettings& settings)
|
||||
{
|
||||
response.getKiwiSdrSettings()->setGain(settings.m_gain);
|
||||
@@ -389,6 +411,11 @@ void KiwiSDRInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& re
|
||||
}
|
||||
}
|
||||
|
||||
void KiwiSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
||||
{
|
||||
response.getKiwiSdrReport()->setStatus(getStatus());
|
||||
}
|
||||
|
||||
void KiwiSDRInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const KiwiSDRSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
|
||||
@@ -156,6 +156,10 @@ public:
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiReportGet(
|
||||
SWGSDRangel::SWGDeviceReport& response,
|
||||
QString& errorMessage);
|
||||
|
||||
private:
|
||||
DeviceAPI *m_deviceAPI;
|
||||
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
||||
@@ -169,8 +173,10 @@ private:
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QNetworkRequest m_networkRequest;
|
||||
|
||||
int getStatus() const;
|
||||
bool applySettings(const KiwiSDRSettings& settings, bool force);
|
||||
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const KiwiSDRSettings& settings);
|
||||
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const KiwiSDRSettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ KiwiSDRWorker::KiwiSDRWorker(SampleSinkFifo* sampleFifo)
|
||||
m_samplesBuf(),
|
||||
m_centerFrequency(1450000),
|
||||
m_gain(20),
|
||||
m_useAGC(true)
|
||||
m_useAGC(true),
|
||||
m_status(0)
|
||||
{
|
||||
connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
|
||||
@@ -48,11 +49,13 @@ void KiwiSDRWorker::onConnected()
|
||||
void KiwiSDRWorker::onDisconnected()
|
||||
{
|
||||
qDebug("KiwiSDRWorker::onDisconnected");
|
||||
m_status = 4;
|
||||
emit updateStatus(4);
|
||||
}
|
||||
|
||||
void KiwiSDRWorker::onSocketError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
m_status = 3;
|
||||
emit updateStatus(3);
|
||||
}
|
||||
|
||||
@@ -91,6 +94,7 @@ void KiwiSDRWorker::onBinaryMessageReceived(const QByteArray &message)
|
||||
sendGain();
|
||||
sendCenterFrequency();
|
||||
m_timer.start(5000);
|
||||
m_status = 2;
|
||||
emit updateStatus(2);
|
||||
}
|
||||
}
|
||||
@@ -139,6 +143,7 @@ void KiwiSDRWorker::onServerAddressChanged(QString serverAddress)
|
||||
return;
|
||||
m_serverAddress = serverAddress;
|
||||
|
||||
m_status = 1;
|
||||
emit updateStatus(1);
|
||||
|
||||
QString url("ws://");
|
||||
|
||||
@@ -28,6 +28,7 @@ class KiwiSDRWorker : public QObject {
|
||||
|
||||
public:
|
||||
KiwiSDRWorker(SampleSinkFifo* sampleFifo);
|
||||
int getStatus() const { return m_status; }
|
||||
|
||||
private:
|
||||
QTimer m_timer;
|
||||
@@ -42,6 +43,8 @@ private:
|
||||
uint32_t m_gain;
|
||||
bool m_useAGC;
|
||||
|
||||
int m_status; //!< See GUI for status number detail
|
||||
|
||||
void sendCenterFrequency();
|
||||
void sendGain();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user