1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 10:05:46 -05:00

BladeRF2: REST API: implemented actions: implementation

This commit is contained in:
f4exb 2020-03-30 21:35:29 +02:00
parent 69a7540ce3
commit 597633009c
3 changed files with 55 additions and 0 deletions

View File

@ -26,6 +26,8 @@
#include "SWGDeviceState.h"
#include "SWGDeviceReport.h"
#include "SWGBladeRF2InputReport.h"
#include "SWGDeviceActions.h"
#include "SWGBladeRF2InputActions.h"
#include "device/deviceapi.h"
#include "dsp/dspcommands.h"
@ -1248,6 +1250,37 @@ int BladeRF2Input::webapiRun(
return 200;
}
int BladeRF2Input::webapiActionsPost(
const QStringList& deviceActionsKeys,
SWGSDRangel::SWGDeviceActions& query,
QString& errorMessage)
{
SWGSDRangel::SWGBladeRF2InputActions *swgBladeRF2InputActions = query.getBladeRf2InputActions();
if (swgBladeRF2InputActions)
{
if (deviceActionsKeys.contains("record"))
{
bool record = swgBladeRF2InputActions->getRecord() != 0;
MsgFileRecord *msg = MsgFileRecord::create(record);
getInputMessageQueue()->push(msg);
if (getMessageQueueToGUI())
{
MsgFileRecord *msgToGUI = MsgFileRecord::create(record);
getMessageQueueToGUI()->push(msgToGUI);
}
}
return 202;
}
else
{
errorMessage = "Missing BladeRF2InputActions in query";
return 400;
}
}
void BladeRF2Input::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const BladeRF2InputSettings& settings, bool force)
{
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();

View File

@ -182,6 +182,11 @@ public:
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage);
virtual int webapiActionsPost(
const QStringList& deviceActionsKeys,
SWGSDRangel::SWGDeviceActions& actions,
QString& errorMessage);
static void webapiFormatDeviceSettings(
SWGSDRangel::SWGDeviceSettings& response,
const BladeRF2InputSettings& settings);

View File

@ -216,6 +216,23 @@ bool BladeRF2InputGui::handleMessage(const Message& message)
return true;
}
else if (BladeRF2Input::MsgFileRecord::match(message)) // API action "record" feedback
{
const BladeRF2Input::MsgFileRecord& notif = (const BladeRF2Input::MsgFileRecord&) message;
bool record = notif.getStartStop();
ui->record->blockSignals(true);
ui->record->setChecked(record);
if (record) {
ui->record->setStyleSheet("QToolButton { background-color : red; }");
} else {
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
}
ui->record->blockSignals(false);
return true;
}
else
{
return false;