mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-02-26 03:10:08 -05:00
REST API: MIMO device plugins implementations and fixes
This commit is contained in:
parent
c9219ec8ea
commit
884f83c82a
@ -43,7 +43,6 @@
|
||||
MESSAGE_CLASS_DEFINITION(BladeRF2MIMO::MsgConfigureBladeRF2MIMO, Message)
|
||||
MESSAGE_CLASS_DEFINITION(BladeRF2MIMO::MsgFileRecord, Message)
|
||||
MESSAGE_CLASS_DEFINITION(BladeRF2MIMO::MsgStartStop, Message)
|
||||
MESSAGE_CLASS_DEFINITION(BladeRF2MIMO::MsgReportGainRange, Message)
|
||||
|
||||
BladeRF2MIMO::BladeRF2MIMO(DeviceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
@ -598,28 +597,17 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc
|
||||
|| (m_settings.m_fcPosRx != settings.m_fcPosRx)
|
||||
|| (m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
||||
{
|
||||
qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
|
||||
rxXlatedDeviceCenterFrequency,
|
||||
0,
|
||||
settings.m_log2Decim,
|
||||
(DeviceSampleSource::fcPos_t) settings.m_fcPosRx,
|
||||
settings.m_devSampleRate,
|
||||
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
|
||||
false);
|
||||
|
||||
if (dev)
|
||||
{
|
||||
if (setRxDeviceCenterFrequency(dev, deviceCenterFrequency, settings.m_LOppmTenths))
|
||||
{
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
int min, max, step;
|
||||
getRxGlobalGainRange(min, max, step);
|
||||
MsgReportGainRange *msg = MsgReportGainRange::create(min, max, step, true);
|
||||
getMessageQueueToGUI()->push(msg);
|
||||
}
|
||||
|
||||
}
|
||||
qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
|
||||
rxXlatedDeviceCenterFrequency,
|
||||
0,
|
||||
settings.m_log2Decim,
|
||||
(DeviceSampleSource::fcPos_t) settings.m_fcPosRx,
|
||||
settings.m_devSampleRate,
|
||||
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
|
||||
false);
|
||||
setRxDeviceCenterFrequency(dev, deviceCenterFrequency, settings.m_LOppmTenths);
|
||||
}
|
||||
|
||||
forwardChangeRxDSP = true;
|
||||
@ -736,17 +724,7 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc
|
||||
(DeviceSampleSink::fcPos_t) settings.m_fcPosTx,
|
||||
settings.m_devSampleRate,
|
||||
settings.m_txTransverterMode);
|
||||
|
||||
if (setTxDeviceCenterFrequency(dev, deviceCenterFrequency, settings.m_LOppmTenths))
|
||||
{
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
int min, max, step;
|
||||
getTxGlobalGainRange(min, max, step);
|
||||
MsgReportGainRange *msg = MsgReportGainRange::create(min, max, step, false);
|
||||
getMessageQueueToGUI()->push(msg);
|
||||
}
|
||||
}
|
||||
setTxDeviceCenterFrequency(dev, deviceCenterFrequency, settings.m_LOppmTenths);
|
||||
}
|
||||
|
||||
forwardChangeTxDSP = true;
|
||||
@ -1116,16 +1094,16 @@ void BladeRF2MIMO::webapiUpdateDeviceSettings(
|
||||
settings.m_fileRecordName = *response.getBladeRf2MimoSettings()->getFileRecordName();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("useReverseAPI")) {
|
||||
settings.m_useReverseAPI = response.getBladeRf2OutputSettings()->getUseReverseApi() != 0;
|
||||
settings.m_useReverseAPI = response.getBladeRf2MimoSettings()->getUseReverseApi() != 0;
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIAddress")) {
|
||||
settings.m_reverseAPIAddress = *response.getBladeRf2OutputSettings()->getReverseApiAddress();
|
||||
settings.m_reverseAPIAddress = *response.getBladeRf2MimoSettings()->getReverseApiAddress();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIPort")) {
|
||||
settings.m_reverseAPIPort = response.getBladeRf2OutputSettings()->getReverseApiPort();
|
||||
settings.m_reverseAPIPort = response.getBladeRf2MimoSettings()->getReverseApiPort();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
||||
settings.m_reverseAPIDeviceIndex = response.getBladeRf2OutputSettings()->getReverseApiDeviceIndex();
|
||||
settings.m_reverseAPIDeviceIndex = response.getBladeRf2MimoSettings()->getReverseApiDeviceIndex();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -115,34 +115,6 @@ public:
|
||||
int m_value;
|
||||
};
|
||||
|
||||
class MsgReportGainRange : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
int getMin() const { return m_min; }
|
||||
int getMax() const { return m_max; }
|
||||
int getStep() const { return m_step; }
|
||||
bool getRxElseTx() const { return m_rxElseTx; }
|
||||
|
||||
static MsgReportGainRange* create(int min, int max, int step, bool rxElseTx) {
|
||||
return new MsgReportGainRange(min, max, step, rxElseTx);
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_min;
|
||||
int m_max;
|
||||
int m_step;
|
||||
bool m_rxElseTx;
|
||||
|
||||
MsgReportGainRange(int min, int max, int step, bool rxElseTx) :
|
||||
Message(),
|
||||
m_min(min),
|
||||
m_max(max),
|
||||
m_step(step),
|
||||
m_rxElseTx(rxElseTx)
|
||||
{}
|
||||
};
|
||||
|
||||
BladeRF2MIMO(DeviceAPI *deviceAPI);
|
||||
virtual ~BladeRF2MIMO();
|
||||
virtual void destroy();
|
||||
|
||||
@ -344,6 +344,14 @@ bool BladeRF2MIMOGui::handleMessage(const Message& message)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (BladeRF2MIMO::MsgConfigureBladeRF2MIMO::match(message))
|
||||
{
|
||||
const BladeRF2MIMO::MsgConfigureBladeRF2MIMO& notif = (const BladeRF2MIMO::MsgConfigureBladeRF2MIMO&) message;
|
||||
m_settings = notif.getSettings();
|
||||
displaySettings();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -348,3 +348,66 @@ int TestMOSync::webapiRun(
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
||||
int TestMOSync::webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setTestMoSyncSettings(new SWGSDRangel::SWGTestMOSyncSettings());
|
||||
response.getTestMoSyncSettings()->init();
|
||||
webapiFormatDeviceSettings(response, m_settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int TestMOSync::webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
TestMOSyncSettings settings = m_settings;
|
||||
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
|
||||
|
||||
MsgConfigureTestMOSync *msg = MsgConfigureTestMOSync::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureTestMOSync *msgToGUI = MsgConfigureTestMOSync::create(settings, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
webapiFormatDeviceSettings(response, settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
void TestMOSync::webapiFormatDeviceSettings(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
const TestMOSyncSettings& settings)
|
||||
{
|
||||
response.getTestMoSyncSettings()->setCenterFrequency(settings.m_centerFrequency);
|
||||
response.getTestMoSyncSettings()->setFcPosTx((int) settings.m_fcPosTx);
|
||||
response.getTestMoSyncSettings()->setLog2Interp(settings.m_log2Interp);
|
||||
response.getTestMoSyncSettings()->setSampleRate(settings.m_sampleRate);
|
||||
}
|
||||
|
||||
void TestMOSync::webapiUpdateDeviceSettings(
|
||||
TestMOSyncSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response)
|
||||
{
|
||||
if (deviceSettingsKeys.contains("centerFrequency")) {
|
||||
settings.m_centerFrequency = response.getTestMoSyncSettings()->getCenterFrequency();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("fcPosTx")) {
|
||||
settings.m_fcPosTx = (TestMOSyncSettings::fcPos_t) response.getTestMoSyncSettings()->getFcPosTx();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("log2Interp")) {
|
||||
settings.m_log2Interp = response.getTestMoSyncSettings()->getLog2Interp();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("sampleRate")) {
|
||||
settings.m_sampleRate = response.getTestMoSyncSettings()->getSampleRate();
|
||||
}
|
||||
}
|
||||
@ -111,6 +111,16 @@ public:
|
||||
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
virtual int webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiRunGet(
|
||||
int subsystemIndex,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
@ -122,6 +132,15 @@ public:
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
|
||||
static void webapiFormatDeviceSettings(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
const TestMOSyncSettings& settings);
|
||||
|
||||
static void webapiUpdateDeviceSettings(
|
||||
TestMOSyncSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response);
|
||||
|
||||
bool getRxRunning() const { return false; }
|
||||
bool getTxRunning() const { return m_runningTx; }
|
||||
void setSpectrumSink(BasebandSampleSink* spectrumSink) { m_spectrumSink = spectrumSink; }
|
||||
|
||||
@ -120,8 +120,8 @@ const QMap<QString, QString> WebAPIRequestMapper::m_deviceIdToSettingsKey = {
|
||||
{"sdrangel.samplesource.testsource", "testSourceSettings"},
|
||||
{"sdrangel.samplemimo.testmi", "testMISettings"},
|
||||
{"sdrangel.samplemimo.testmosync", "testMOSyncSettings"},
|
||||
{"sdrangel.samplesource.xtrx", "XtrxInputSettings"},
|
||||
{"sdrangel.samplesink.xtrx", "XtrxOutputSettings"}
|
||||
{"sdrangel.samplesource.xtrx", "xtrxInputSettings"},
|
||||
{"sdrangel.samplesink.xtrx", "xtrxOutputSettings"}
|
||||
};
|
||||
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_channelTypeToSettingsKey = {
|
||||
@ -170,7 +170,7 @@ const QMap<QString, QString> WebAPIRequestMapper::m_sourceDeviceHwIdToSettingsKe
|
||||
{"SDRplay1", "sdrPlaySettings"},
|
||||
{"SoapySDR", "soapySDRInputSettings"},
|
||||
{"TestSource", "testSourceSettings"},
|
||||
{"XTRX", "XtrxInputSettings"}
|
||||
{"XTRX", "xtrxInputSettings"}
|
||||
};
|
||||
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_sinkDeviceHwIdToSettingsKey = {
|
||||
@ -182,13 +182,13 @@ const QMap<QString, QString> WebAPIRequestMapper::m_sinkDeviceHwIdToSettingsKey
|
||||
{"PlutoSDR", "plutoSdrOutputSettings"},
|
||||
{"RemoteOutput", "remoteOutputSettings"},
|
||||
{"SoapySDR", "soapySDROutputSettings"},
|
||||
{"XTRX", "XtrxOutputSettings"}
|
||||
{"XTRX", "xtrxOutputSettings"}
|
||||
};
|
||||
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_mimoDeviceHwIdToSettingsKey= {
|
||||
{"BladeRF2", "BladeRF2MIMOSettings"},
|
||||
{"BladeRF2", "bladeRF2MIMOSettings"},
|
||||
{"TestMI", "testMISettings"},
|
||||
{"TestMOSync", "TestMOSyncSettings"}
|
||||
{"TestMOSync", "testMOSyncSettings"}
|
||||
};
|
||||
|
||||
WebAPIRequestMapper::WebAPIRequestMapper(QObject* parent) :
|
||||
@ -2839,7 +2839,7 @@ bool WebAPIRequestMapper::getDevice(
|
||||
deviceSettings->setTestSourceSettings(new SWGSDRangel::SWGTestSourceSettings());
|
||||
deviceSettings->getTestSourceSettings()->fromJsonObject(settingsJsonObject);
|
||||
}
|
||||
else if (deviceSettingsKey == "TestMISettings")
|
||||
else if (deviceSettingsKey == "testMISettings")
|
||||
{
|
||||
if (deviceSettingsKeys.contains("streams") && settingsJsonObject["streams"].isArray()) {
|
||||
appendSettingsArrayKeys(settingsJsonObject, "streams", deviceSettingsKeys);
|
||||
@ -2848,7 +2848,7 @@ bool WebAPIRequestMapper::getDevice(
|
||||
deviceSettings->setTestMiSettings(new SWGSDRangel::SWGTestMISettings());
|
||||
deviceSettings->getTestMiSettings()->fromJsonObject(settingsJsonObject);
|
||||
}
|
||||
else if (deviceSettingsKey == "TestMOSyncSettings")
|
||||
else if (deviceSettingsKey == "testMOSyncSettings")
|
||||
{
|
||||
if (deviceSettingsKeys.contains("streams") && settingsJsonObject["streams"].isArray()) {
|
||||
appendSettingsArrayKeys(settingsJsonObject, "streams", deviceSettingsKeys);
|
||||
@ -2857,12 +2857,12 @@ bool WebAPIRequestMapper::getDevice(
|
||||
deviceSettings->setTestMoSyncSettings(new SWGSDRangel::SWGTestMOSyncSettings());
|
||||
deviceSettings->getTestMoSyncSettings()->fromJsonObject(settingsJsonObject);
|
||||
}
|
||||
else if (deviceSettingsKey == "XtrxInputSettings")
|
||||
else if (deviceSettingsKey == "xtrxInputSettings")
|
||||
{
|
||||
deviceSettings->setXtrxInputSettings(new SWGSDRangel::SWGXtrxInputSettings());
|
||||
deviceSettings->getXtrxInputSettings()->fromJsonObject(settingsJsonObject);
|
||||
}
|
||||
else if (deviceSettingsKey == "XtrxOutputSettings")
|
||||
else if (deviceSettingsKey == "xtrxOutputSettings")
|
||||
{
|
||||
deviceSettings->setXtrxOutputSettings(new SWGSDRangel::SWGXtrxOutputSettings());
|
||||
deviceSettings->getXtrxOutputSettings()->fromJsonObject(settingsJsonObject);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user