1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

PlutoSDR MIMO: REST API fixes

This commit is contained in:
f4exb 2021-05-10 22:17:07 +02:00
parent 7184ae925d
commit 4a523edc8b
5 changed files with 160 additions and 15 deletions

View File

@ -260,7 +260,7 @@ void PlutoSDRMIMO::stopRx()
}
m_plutoParams->getBox()->deleteRxBuffer();
m_plutoRxBuffer = nullptr;
m_plutoTxBuffer = nullptr;
}
void PlutoSDRMIMO::stopTx()
@ -790,14 +790,21 @@ bool PlutoSDRMIMO::applySettings(const PlutoSDRMIMOSettings& settings, bool forc
}
if (force || (m_settings.m_txCenterFrequency != settings.m_txCenterFrequency)
|| (m_settings.m_log2Interp != settings.m_log2Interp)
|| (m_settings.m_fcPosTx != settings.m_fcPosTx)
|| (m_settings.m_devSampleRate != settings.m_devSampleRate)
|| (m_settings.m_txTransverterMode != settings.m_txTransverterMode)
|| (m_settings.m_txTransverterDeltaFrequency != settings.m_txTransverterDeltaFrequency))
{
qint64 deviceCenterFrequency = settings.m_txCenterFrequency;
deviceCenterFrequency -= settings.m_txTransverterMode ? settings.m_txTransverterDeltaFrequency : 0;
deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
qint64 deviceCenterFrequency = DeviceSampleSink::calculateDeviceCenterFrequency(
settings.m_txCenterFrequency,
settings.m_txTransverterDeltaFrequency,
settings.m_log2Interp,
(DeviceSampleSink::fcPos_t) settings.m_fcPosTx,
settings.m_devSampleRate,
settings.m_txTransverterMode
);
params.push_back(QString(tr("out_altvoltage1_TX_LO_frequency=%1").arg(deviceCenterFrequency)).toStdString());
paramsToSet = true;
@ -1039,16 +1046,16 @@ void PlutoSDRMIMO::webapiUpdateDeviceSettings(
settings.m_tx1AntennaPath = static_cast<PlutoSDRMIMOSettings::RFPathTx>(response.getPlutoSdrMimoSettings()->getTx1AntennaPath());
}
if (deviceSettingsKeys.contains("useReverseAPI")) {
settings.m_useReverseAPI = response.getBladeRf2MimoSettings()->getUseReverseApi() != 0;
settings.m_useReverseAPI = response.getPlutoSdrMimoSettings()->getUseReverseApi() != 0;
}
if (deviceSettingsKeys.contains("reverseAPIAddress")) {
settings.m_reverseAPIAddress = *response.getBladeRf2MimoSettings()->getReverseApiAddress();
settings.m_reverseAPIAddress = *response.getPlutoSdrMimoSettings()->getReverseApiAddress();
}
if (deviceSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = response.getBladeRf2MimoSettings()->getReverseApiPort();
settings.m_reverseAPIPort = response.getPlutoSdrMimoSettings()->getReverseApiPort();
}
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getBladeRf2MimoSettings()->getReverseApiDeviceIndex();
settings.m_reverseAPIDeviceIndex = response.getPlutoSdrMimoSettings()->getReverseApiDeviceIndex();
}
}
@ -1071,6 +1078,7 @@ void PlutoSDRMIMO::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& re
response.getPlutoSdrMimoSettings()->setLpfRxFirbw(settings.m_lpfRxFIRBW);
response.getPlutoSdrMimoSettings()->setLpfRxFiRlog2Decim(settings.m_lpfRxFIRlog2Decim);
response.getPlutoSdrMimoSettings()->setLpfRxFirGain(settings.m_lpfRxFIRGain);
response.getPlutoSdrMimoSettings()->setLog2Decim(settings.m_log2Decim);
response.getPlutoSdrMimoSettings()->setRx0Gain(settings.m_rx0Gain);
response.getPlutoSdrMimoSettings()->setRx0GainMode((int) settings.m_rx0GainMode);
response.getPlutoSdrMimoSettings()->setRx0AntennaPath((int) settings.m_rx0AntennaPath);
@ -1091,16 +1099,16 @@ void PlutoSDRMIMO::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& re
response.getPlutoSdrMimoSettings()->setTx0AntennaPath((int) settings.m_tx0AntennaPath);
response.getPlutoSdrMimoSettings()->setTx1Att(settings.m_tx1Att);
response.getPlutoSdrMimoSettings()->setTx1AntennaPath((int) settings.m_tx1AntennaPath);
response.getBladeRf2MimoSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
response.getPlutoSdrMimoSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
if (response.getBladeRf2MimoSettings()->getReverseApiAddress()) {
*response.getBladeRf2MimoSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
if (response.getPlutoSdrMimoSettings()->getReverseApiAddress()) {
*response.getPlutoSdrMimoSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
} else {
response.getBladeRf2MimoSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
response.getPlutoSdrMimoSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
}
response.getBladeRf2MimoSettings()->setReverseApiPort(settings.m_reverseAPIPort);
response.getBladeRf2MimoSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
response.getPlutoSdrMimoSettings()->setReverseApiPort(settings.m_reverseAPIPort);
response.getPlutoSdrMimoSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
}
int PlutoSDRMIMO::webapiRunGet(

View File

@ -216,6 +216,15 @@ PlutoSdrMIMOSettings:
type: integer
tx1AntennaPath:
type: integer
useReverseAPI:
description: Synchronize with reverse API (1 for yes, 0 for no)
type: integer
reverseAPIAddress:
type: string
reverseAPIPort:
type: integer
reverseAPIDeviceIndex:
type: integer
PlutoSdrInputReport:
description: PlutoSDR

View File

@ -216,6 +216,15 @@ PlutoSdrMIMOSettings:
type: integer
tx1AntennaPath:
type: integer
useReverseAPI:
description: Synchronize with reverse API (1 for yes, 0 for no)
type: integer
reverseAPIAddress:
type: string
reverseAPIPort:
type: integer
reverseAPIDeviceIndex:
type: integer
PlutoSdrInputReport:
description: PlutoSDR

View File

@ -104,6 +104,14 @@ SWGPlutoSdrMIMOSettings::SWGPlutoSdrMIMOSettings() {
m_tx1_att_isSet = false;
tx1_antenna_path = 0;
m_tx1_antenna_path_isSet = false;
use_reverse_api = 0;
m_use_reverse_api_isSet = false;
reverse_api_address = nullptr;
m_reverse_api_address_isSet = false;
reverse_api_port = 0;
m_reverse_api_port_isSet = false;
reverse_api_device_index = 0;
m_reverse_api_device_index_isSet = false;
}
SWGPlutoSdrMIMOSettings::~SWGPlutoSdrMIMOSettings() {
@ -188,6 +196,14 @@ SWGPlutoSdrMIMOSettings::init() {
m_tx1_att_isSet = false;
tx1_antenna_path = 0;
m_tx1_antenna_path_isSet = false;
use_reverse_api = 0;
m_use_reverse_api_isSet = false;
reverse_api_address = new QString("");
m_reverse_api_address_isSet = false;
reverse_api_port = 0;
m_reverse_api_port_isSet = false;
reverse_api_device_index = 0;
m_reverse_api_device_index_isSet = false;
}
void
@ -228,6 +244,12 @@ SWGPlutoSdrMIMOSettings::cleanup() {
if(reverse_api_address != nullptr) {
delete reverse_api_address;
}
}
@ -319,6 +341,14 @@ SWGPlutoSdrMIMOSettings::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&tx1_antenna_path, pJson["tx1AntennaPath"], "qint32", "");
::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
}
QString
@ -449,6 +479,18 @@ SWGPlutoSdrMIMOSettings::asJsonObject() {
if(m_tx1_antenna_path_isSet){
obj->insert("tx1AntennaPath", QJsonValue(tx1_antenna_path));
}
if(m_use_reverse_api_isSet){
obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
}
if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
}
if(m_reverse_api_port_isSet){
obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
}
if(m_reverse_api_device_index_isSet){
obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
}
return obj;
}
@ -833,6 +875,46 @@ SWGPlutoSdrMIMOSettings::setTx1AntennaPath(qint32 tx1_antenna_path) {
this->m_tx1_antenna_path_isSet = true;
}
qint32
SWGPlutoSdrMIMOSettings::getUseReverseApi() {
return use_reverse_api;
}
void
SWGPlutoSdrMIMOSettings::setUseReverseApi(qint32 use_reverse_api) {
this->use_reverse_api = use_reverse_api;
this->m_use_reverse_api_isSet = true;
}
QString*
SWGPlutoSdrMIMOSettings::getReverseApiAddress() {
return reverse_api_address;
}
void
SWGPlutoSdrMIMOSettings::setReverseApiAddress(QString* reverse_api_address) {
this->reverse_api_address = reverse_api_address;
this->m_reverse_api_address_isSet = true;
}
qint32
SWGPlutoSdrMIMOSettings::getReverseApiPort() {
return reverse_api_port;
}
void
SWGPlutoSdrMIMOSettings::setReverseApiPort(qint32 reverse_api_port) {
this->reverse_api_port = reverse_api_port;
this->m_reverse_api_port_isSet = true;
}
qint32
SWGPlutoSdrMIMOSettings::getReverseApiDeviceIndex() {
return reverse_api_device_index;
}
void
SWGPlutoSdrMIMOSettings::setReverseApiDeviceIndex(qint32 reverse_api_device_index) {
this->reverse_api_device_index = reverse_api_device_index;
this->m_reverse_api_device_index_isSet = true;
}
bool
SWGPlutoSdrMIMOSettings::isSet(){
@ -952,6 +1034,18 @@ SWGPlutoSdrMIMOSettings::isSet(){
if(m_tx1_antenna_path_isSet){
isObjectUpdated = true; break;
}
if(m_use_reverse_api_isSet){
isObjectUpdated = true; break;
}
if(reverse_api_address && *reverse_api_address != QString("")){
isObjectUpdated = true; break;
}
if(m_reverse_api_port_isSet){
isObjectUpdated = true; break;
}
if(m_reverse_api_device_index_isSet){
isObjectUpdated = true; break;
}
}while(false);
return isObjectUpdated;
}

View File

@ -22,6 +22,7 @@
#include <QJsonObject>
#include <QString>
#include "SWGObject.h"
#include "export.h"
@ -155,6 +156,18 @@ public:
qint32 getTx1AntennaPath();
void setTx1AntennaPath(qint32 tx1_antenna_path);
qint32 getUseReverseApi();
void setUseReverseApi(qint32 use_reverse_api);
QString* getReverseApiAddress();
void setReverseApiAddress(QString* reverse_api_address);
qint32 getReverseApiPort();
void setReverseApiPort(qint32 reverse_api_port);
qint32 getReverseApiDeviceIndex();
void setReverseApiDeviceIndex(qint32 reverse_api_device_index);
virtual bool isSet() override;
@ -273,6 +286,18 @@ private:
qint32 tx1_antenna_path;
bool m_tx1_antenna_path_isSet;
qint32 use_reverse_api;
bool m_use_reverse_api_isSet;
QString* reverse_api_address;
bool m_reverse_api_address_isSet;
qint32 reverse_api_port;
bool m_reverse_api_port_isSet;
qint32 reverse_api_device_index;
bool m_reverse_api_device_index_isSet;
};
}