diff --git a/plugins/samplemimo/bladerf2mimo/bladerf2mimo.cpp b/plugins/samplemimo/bladerf2mimo/bladerf2mimo.cpp index 61d4b28c5..09708f084 100644 --- a/plugins/samplemimo/bladerf2mimo/bladerf2mimo.cpp +++ b/plugins/samplemimo/bladerf2mimo/bladerf2mimo.cpp @@ -140,7 +140,7 @@ void BladeRF2MIMO::closeDevice() void BladeRF2MIMO::init() { - applySettings(m_settings, true); + applySettings(m_settings, QList(), true); } bool BladeRF2MIMO::startRx() @@ -271,12 +271,12 @@ bool BladeRF2MIMO::deserialize(const QByteArray& data) success = false; } - MsgConfigureBladeRF2MIMO* message = MsgConfigureBladeRF2MIMO::create(m_settings, true); + MsgConfigureBladeRF2MIMO* message = MsgConfigureBladeRF2MIMO::create(m_settings, QList(), true); m_inputMessageQueue.push(message); if (m_guiMessageQueue) { - MsgConfigureBladeRF2MIMO* messageToGUI = MsgConfigureBladeRF2MIMO::create(m_settings, true); + MsgConfigureBladeRF2MIMO* messageToGUI = MsgConfigureBladeRF2MIMO::create(m_settings, QList(), true); m_guiMessageQueue->push(messageToGUI); } @@ -314,12 +314,12 @@ void BladeRF2MIMO::setSourceCenterFrequency(qint64 centerFrequency, int index) BladeRF2MIMOSettings settings = m_settings; settings.m_rxCenterFrequency = centerFrequency; - MsgConfigureBladeRF2MIMO* message = MsgConfigureBladeRF2MIMO::create(settings, false); + MsgConfigureBladeRF2MIMO* message = MsgConfigureBladeRF2MIMO::create(settings, QList{"rxCenterFrequency"}, false); m_inputMessageQueue.push(message); if (m_guiMessageQueue) { - MsgConfigureBladeRF2MIMO* messageToGUI = MsgConfigureBladeRF2MIMO::create(settings, false); + MsgConfigureBladeRF2MIMO* messageToGUI = MsgConfigureBladeRF2MIMO::create(settings, QList{"rxCenterFrequency"}, false); m_guiMessageQueue->push(messageToGUI); } } @@ -336,12 +336,12 @@ void BladeRF2MIMO::setSinkCenterFrequency(qint64 centerFrequency, int index) BladeRF2MIMOSettings settings = m_settings; settings.m_txCenterFrequency = centerFrequency; - MsgConfigureBladeRF2MIMO* message = MsgConfigureBladeRF2MIMO::create(settings, false); + MsgConfigureBladeRF2MIMO* message = MsgConfigureBladeRF2MIMO::create(settings, QList{"txCenterFrequency"}, false); m_inputMessageQueue.push(message); if (m_guiMessageQueue) { - MsgConfigureBladeRF2MIMO* messageToGUI = MsgConfigureBladeRF2MIMO::create(settings, false); + MsgConfigureBladeRF2MIMO* messageToGUI = MsgConfigureBladeRF2MIMO::create(settings, QList{"txCenterFrequency"}, false); m_guiMessageQueue->push(messageToGUI); } } @@ -353,7 +353,7 @@ bool BladeRF2MIMO::handleMessage(const Message& message) MsgConfigureBladeRF2MIMO& conf = (MsgConfigureBladeRF2MIMO&) message; qDebug() << "BladeRF2MIMO::handleMessage: MsgConfigureBladeRF2MIMO"; - bool success = applySettings(conf.getSettings(), conf.getForce()); + bool success = applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce()); if (!success) { qDebug("BladeRF2MIMO::handleMessage: config error"); @@ -393,43 +393,12 @@ bool BladeRF2MIMO::handleMessage(const Message& message) } } -bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool force) +bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, const QList& settingsKeys, bool force) { - QList reverseAPIKeys; bool forwardChangeRxDSP = false; bool forwardChangeTxDSP = false; - qDebug() << "BladeRF2MIMO::applySettings: common: " - << " m_devSampleRate: " << settings.m_devSampleRate - << " m_LOppmTenths: " << settings.m_LOppmTenths - << " m_rxCenterFrequency: " << settings.m_rxCenterFrequency - << " m_log2Decim: " << settings.m_log2Decim - << " m_iqOrder: " << settings.m_iqOrder - << " m_fcPosRx: " << settings.m_fcPosRx - << " m_rxBandwidth: " << settings.m_rxBandwidth - << " m_rx0GainMode: " << settings.m_rx0GainMode - << " m_rx0GlobalGain: " << settings.m_rx0GlobalGain - << " m_rx1GainMode: " << settings.m_rx1GainMode - << " m_rx1GlobalGain: " << settings.m_rx1GlobalGain - << " m_rxBiasTee: " << settings.m_rxBiasTee - << " m_dcBlock: " << settings.m_dcBlock - << " m_iqCorrection: " << settings.m_iqCorrection - << " m_rxTransverterMode: " << settings.m_rxTransverterMode - << " m_rxTransverterDeltaFrequency: " << settings.m_rxTransverterDeltaFrequency - << " m_txCenterFrequency: " << settings.m_txCenterFrequency - << " m_log2Interp: " << settings.m_log2Interp - << " m_fcPosTx: " << settings.m_fcPosTx - << " m_txBandwidth: " << settings.m_txBandwidth - << " m_tx0GlobalGain: " << settings.m_tx0GlobalGain - << " m_tx1GlobalGain: " << settings.m_tx1GlobalGain - << " m_txBiasTee: " << settings.m_txBiasTee - << " m_txTransverterMode: " << settings.m_txTransverterMode - << " m_txTransverterDeltaFrequency: " << settings.m_txTransverterDeltaFrequency - << " m_useReverseAPI: " << settings.m_useReverseAPI - << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress - << " m_reverseAPIPort: " << settings.m_reverseAPIPort - << " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex - << " force: " << force; + qDebug() << "BladeRF2MIMO::applySettings: force:" << force << settings.getDebugString(settingsKeys, force); struct bladerf *dev = m_dev ? m_dev->getDev() : nullptr; @@ -442,10 +411,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc txXlatedDeviceCenterFrequency -= settings.m_txTransverterMode ? settings.m_txTransverterDeltaFrequency : 0; txXlatedDeviceCenterFrequency = txXlatedDeviceCenterFrequency < 0 ? 0 : txXlatedDeviceCenterFrequency; - if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) + if (settingsKeys.contains("devSampleRate") || force) { - reverseAPIKeys.append("devSampleRate"); - if (dev) { unsigned int actualSamplerate; @@ -466,24 +433,15 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc // Rx settings - if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) { - reverseAPIKeys.append("dcBlock"); - } - if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) { - reverseAPIKeys.append("iqCorrection"); - } - - if ((m_settings.m_dcBlock != settings.m_dcBlock) || - (m_settings.m_iqCorrection != settings.m_iqCorrection) || force) + if (settingsKeys.contains("dcBlock") || + settingsKeys.contains("iqCorrection") || force) { m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection, 0); m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection, 1); } - if ((m_settings.m_rxBandwidth != settings.m_rxBandwidth) || force) + if (settingsKeys.contains("rxBandwidth") || force) { - reverseAPIKeys.append("rxBandwidth"); - if (dev) { unsigned int actualBandwidth; @@ -505,10 +463,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_fcPosRx != settings.m_fcPosRx) || force) + if (settingsKeys.contains("fcPosRx") || force) { - reverseAPIKeys.append("fcPosRx"); - if (m_sourceThread) { m_sourceThread->setFcPos((int) settings.m_fcPosRx); @@ -516,10 +472,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) + if (settingsKeys.contains("log2Decim") || force) { - reverseAPIKeys.append("log2Decim"); - if (m_sourceThread) { m_sourceThread->setLog2Decimation(settings.m_log2Decim); @@ -527,10 +481,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_iqOrder != settings.m_iqOrder) || force) + if (settingsKeys.contains("iqOrder") || force) { - reverseAPIKeys.append("iqOrder"); - if (m_sourceThread) { m_sourceThread->setIQOrder(settings.m_iqOrder); @@ -538,10 +490,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_fcPosTx != settings.m_fcPosTx) || force) + if (settingsKeys.contains("fcPosTx") || force) { - reverseAPIKeys.append("fcPosTx"); - if (m_sourceThread) { m_sourceThread->setFcPos((int) settings.m_fcPosTx); @@ -549,10 +499,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_log2Interp != settings.m_log2Interp) || force) + if (settingsKeys.contains("log2Interp") || force) { - reverseAPIKeys.append("log2Interp"); - if (m_sinkThread) { m_sinkThread->setLog2Interpolation(settings.m_log2Interp); @@ -560,26 +508,20 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_rxCenterFrequency != settings.m_rxCenterFrequency) || force) { - reverseAPIKeys.append("rxCenterFrequency"); - } - if ((m_settings.m_rxTransverterMode != settings.m_rxTransverterMode) || force) { - reverseAPIKeys.append("rxTransverterMode"); - } - if ((m_settings.m_rxTransverterDeltaFrequency != settings.m_rxTransverterDeltaFrequency) || force) { - reverseAPIKeys.append("rxTransverterDeltaFrequency"); - } - if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) { - reverseAPIKeys.append("LOppmTenths"); - } - - if ((m_settings.m_rxCenterFrequency != settings.m_rxCenterFrequency) - || (m_settings.m_rxTransverterMode != settings.m_rxTransverterMode) - || (m_settings.m_rxTransverterDeltaFrequency != settings.m_rxTransverterDeltaFrequency) - || (m_settings.m_LOppmTenths != settings.m_LOppmTenths) - || (m_settings.m_devSampleRate != settings.m_devSampleRate) - || (m_settings.m_fcPosRx != settings.m_fcPosRx) - || (m_settings.m_log2Decim != settings.m_log2Decim) || force) + // if ((m_settings.m_rxCenterFrequency != settings.m_rxCenterFrequency) + // || (m_settings.m_rxTransverterMode != settings.m_rxTransverterMode) + // || (m_settings.m_rxTransverterDeltaFrequency != settings.m_rxTransverterDeltaFrequency) + // || (m_settings.m_LOppmTenths != settings.m_LOppmTenths) + // || (m_settings.m_devSampleRate != settings.m_devSampleRate) + // || (m_settings.m_fcPosRx != settings.m_fcPosRx) + // || (m_settings.m_log2Decim != settings.m_log2Decim) || force) + if (settingsKeys.contains("rxCenterFrequency") + || settingsKeys.contains("rxTransverterMode") + || settingsKeys.contains("rxTransverterDeltaFrequency") + || settingsKeys.contains("LOppmTenths") + || settingsKeys.contains("devSampleRate") + || settingsKeys.contains("fcPosRx") + || settingsKeys.contains("log2Decim") || force) { if (dev) { @@ -597,19 +539,15 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc forwardChangeRxDSP = true; } - if ((m_settings.m_rxBiasTee != settings.m_rxBiasTee) || force) + if (settingsKeys.contains("rxBiasTee") || force) { - reverseAPIKeys.append("rxBiasTee"); - if (m_dev) { m_dev->setBiasTeeRx(settings.m_rxBiasTee); } } - if ((m_settings.m_rx0GainMode != settings.m_rx0GainMode) || force) + if (settingsKeys.contains("rx0GainMode") || force) { - reverseAPIKeys.append("rx0GainMode"); - if (dev) { int status = bladerf_set_gain_mode(dev, BLADERF_CHANNEL_RX(0), (bladerf_gain_mode) settings.m_rx0GainMode); @@ -623,10 +561,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_rx1GainMode != settings.m_rx1GainMode) || force) + if (settingsKeys.contains("rx1GainMode") || force) { - reverseAPIKeys.append("rx1GainMode"); - if (dev) { int status = bladerf_set_gain_mode(dev, BLADERF_CHANNEL_RX(1), (bladerf_gain_mode) settings.m_rx1GainMode); @@ -640,15 +576,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_rx0GlobalGain != settings.m_rx0GlobalGain) || force) { - reverseAPIKeys.append("rx0GlobalGain"); - } - if ((m_settings.m_rx1GlobalGain != settings.m_rx1GlobalGain) || force) { - reverseAPIKeys.append("rx1GlobalGain"); - } - - if ((m_settings.m_rx0GlobalGain != settings.m_rx0GlobalGain) - || ((m_settings.m_rx0GlobalGain != settings.m_rx0GlobalGain) && (settings.m_rx0GlobalGain == BLADERF_GAIN_MANUAL)) || force) + if (settingsKeys.contains("rx0GlobalGain") + || (settingsKeys.contains("rx0GlobalGain") && (settings.m_rx0GlobalGain == BLADERF_GAIN_MANUAL)) || force) { if (dev) { @@ -663,8 +592,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_rx1GlobalGain != settings.m_rx1GlobalGain) - || ((m_settings.m_rx1GlobalGain != settings.m_rx1GlobalGain) && (settings.m_rx1GlobalGain == BLADERF_GAIN_MANUAL)) || force) + if (settingsKeys.contains("rx1GlobalGain") + || (settingsKeys.contains("rx1GlobalGain") && (settings.m_rx1GlobalGain == BLADERF_GAIN_MANUAL)) || force) { if (dev) { @@ -681,23 +610,13 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc // Tx settings - if ((m_settings.m_txCenterFrequency != settings.m_txCenterFrequency) || force) { - reverseAPIKeys.append("txCenterFrequency"); - } - if ((m_settings.m_txTransverterMode != settings.m_txTransverterMode) || force) { - reverseAPIKeys.append("txTransverterMode"); - } - if ((m_settings.m_txTransverterDeltaFrequency != settings.m_txTransverterDeltaFrequency) || force) { - reverseAPIKeys.append("txTransverterDeltaFrequency"); - } - - if ((m_settings.m_txCenterFrequency != settings.m_txCenterFrequency) - || (m_settings.m_txTransverterMode != settings.m_txTransverterMode) - || (m_settings.m_txTransverterDeltaFrequency != settings.m_txTransverterDeltaFrequency) - || (m_settings.m_fcPosTx != settings.m_fcPosTx) - || (m_settings.m_log2Interp != settings.m_log2Interp) - || (m_settings.m_LOppmTenths != settings.m_LOppmTenths) - || (m_settings.m_devSampleRate != settings.m_devSampleRate) || force) + if (settingsKeys.contains("txCenterFrequency") + || settingsKeys.contains("txTransverterMode") + || settingsKeys.contains("txTransverterDeltaFrequency") + || settingsKeys.contains("fcPosTx") + || settingsKeys.contains("log2Interp") + || settingsKeys.contains("LOppmTenths") + || settingsKeys.contains("devSampleRate") || force) { if (dev) { @@ -714,10 +633,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc forwardChangeTxDSP = true; } - if ((m_settings.m_txBandwidth != settings.m_txBandwidth) || force) + if (settingsKeys.contains("txBandwidth") || force) { - reverseAPIKeys.append("txBandwidth"); - if (dev) { unsigned int actualBandwidth; @@ -747,10 +664,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_log2Interp != settings.m_log2Interp) || force) + if (settingsKeys.contains("log2Interp") || force) { - reverseAPIKeys.append("log2Interp"); - if (m_sinkThread) { m_sinkThread->setLog2Interpolation(settings.m_log2Interp); @@ -758,19 +673,15 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_txBiasTee != settings.m_txBiasTee) || force) + if (settingsKeys.contains("txBiasTee") || force) { - reverseAPIKeys.append("txBiasTee"); - if (m_dev) { m_dev->setBiasTeeTx(settings.m_txBiasTee); } } - if ((m_settings.m_tx0GlobalGain != settings.m_tx0GlobalGain) || force) + if (settingsKeys.contains("tx0GlobalGain") || force) { - reverseAPIKeys.append("tx0GlobalGain"); - if (dev) { int status = bladerf_set_gain(dev, BLADERF_CHANNEL_TX(0), settings.m_tx0GlobalGain); @@ -784,10 +695,8 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc } } - if ((m_settings.m_tx1GlobalGain != settings.m_tx1GlobalGain) || force) + if (settingsKeys.contains("tx1GlobalGain") || force) { - reverseAPIKeys.append("tx1GlobalGain"); - if (dev) { int status = bladerf_set_gain(dev, BLADERF_CHANNEL_TX(1), settings.m_tx1GlobalGain); @@ -821,13 +730,13 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc // Reverse API settings - if (settings.m_useReverseAPI) + if (settingsKeys.contains("useReverseAPI")) { - bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) || - (m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) || - (m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) || - (m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex); - webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force); + bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) || + settingsKeys.contains("reverseAPIAddress") || + settingsKeys.contains("reverseAPIPort") || + settingsKeys.contains("reverseAPIDeviceIndex"); + webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force); } m_settings = settings; @@ -977,12 +886,12 @@ int BladeRF2MIMO::webapiSettingsPutPatch( BladeRF2MIMOSettings settings = m_settings; webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response); - MsgConfigureBladeRF2MIMO *msg = MsgConfigureBladeRF2MIMO::create(settings, force); + MsgConfigureBladeRF2MIMO *msg = MsgConfigureBladeRF2MIMO::create(settings, deviceSettingsKeys, force); m_inputMessageQueue.push(msg); if (m_guiMessageQueue) // forward to GUI if any { - MsgConfigureBladeRF2MIMO *msgToGUI = MsgConfigureBladeRF2MIMO::create(settings, force); + MsgConfigureBladeRF2MIMO *msgToGUI = MsgConfigureBladeRF2MIMO::create(settings, deviceSettingsKeys, force); m_guiMessageQueue->push(msgToGUI); } @@ -1174,7 +1083,7 @@ int BladeRF2MIMO::webapiRun( } } -void BladeRF2MIMO::webapiReverseSendSettings(QList& deviceSettingsKeys, const BladeRF2MIMOSettings& settings, bool force) +void BladeRF2MIMO::webapiReverseSendSettings(const QList& deviceSettingsKeys, const BladeRF2MIMOSettings& settings, bool force) { SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); swgDeviceSettings->setDirection(2); // MIMO diff --git a/plugins/samplemimo/bladerf2mimo/bladerf2mimo.h b/plugins/samplemimo/bladerf2mimo/bladerf2mimo.h index 9cbf613cf..95f4aebbc 100644 --- a/plugins/samplemimo/bladerf2mimo/bladerf2mimo.h +++ b/plugins/samplemimo/bladerf2mimo/bladerf2mimo.h @@ -46,20 +46,22 @@ public: public: const BladeRF2MIMOSettings& getSettings() const { return m_settings; } + const QList& getSettingsKeys() const { return m_settingsKeys; } bool getForce() const { return m_force; } - static MsgConfigureBladeRF2MIMO* create(const BladeRF2MIMOSettings& settings, bool force) - { - return new MsgConfigureBladeRF2MIMO(settings, force); + static MsgConfigureBladeRF2MIMO* create(const BladeRF2MIMOSettings& settings, const QList& settingsKeys, bool force) { + return new MsgConfigureBladeRF2MIMO(settings, settingsKeys, force); } private: BladeRF2MIMOSettings m_settings; + QList m_settingsKeys; bool m_force; - MsgConfigureBladeRF2MIMO(const BladeRF2MIMOSettings& settings, bool force) : + MsgConfigureBladeRF2MIMO(const BladeRF2MIMOSettings& settings, const QList& settingsKeys, bool force) : Message(), m_settings(settings), + m_settingsKeys(settingsKeys), m_force(force) { } }; @@ -192,10 +194,10 @@ private: bool openDevice(); void closeDevice(); - bool applySettings(const BladeRF2MIMOSettings& settings, bool force); + bool applySettings(const BladeRF2MIMOSettings& settings, const QList& settingsKeys, bool force); bool setRxDeviceCenterFrequency(struct bladerf *dev, quint64 freq_hz, int loPpmTenths); bool setTxDeviceCenterFrequency(struct bladerf *dev, quint64 freq_hz, int loPpmTenths); - void webapiReverseSendSettings(QList& deviceSettingsKeys, const BladeRF2MIMOSettings& settings, bool force); + void webapiReverseSendSettings(const QList& deviceSettingsKeys, const BladeRF2MIMOSettings& settings, bool force); void webapiReverseSendStartStop(bool start); void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); diff --git a/plugins/samplemimo/bladerf2mimo/bladerf2mimogui.cpp b/plugins/samplemimo/bladerf2mimo/bladerf2mimogui.cpp index f65a25933..f69e6b199 100644 --- a/plugins/samplemimo/bladerf2mimo/bladerf2mimogui.cpp +++ b/plugins/samplemimo/bladerf2mimo/bladerf2mimogui.cpp @@ -120,6 +120,7 @@ void BladeRF2MIMOGui::resetToDefaults() { m_settings.resetToDefaults(); displaySettings(); + m_forceSettings = true; sendSettings(); } @@ -358,7 +359,13 @@ bool BladeRF2MIMOGui::handleMessage(const Message& message) else if (BladeRF2MIMO::MsgConfigureBladeRF2MIMO::match(message)) { const BladeRF2MIMO::MsgConfigureBladeRF2MIMO& notif = (const BladeRF2MIMO::MsgConfigureBladeRF2MIMO&) message; - m_settings = notif.getSettings(); + + if (notif.getForce()) { + m_settings = notif.getSettings(); + } else { + m_settings.applySettings(notif.getSettingsKeys(), notif.getSettings()); + } + displaySettings(); return true; @@ -383,7 +390,7 @@ void BladeRF2MIMOGui::handleInputMessages() void BladeRF2MIMOGui::sendSettings() { - if(!m_updateTimer.isActive()) { + if (!m_updateTimer.isActive()) { m_updateTimer.start(100); } } @@ -392,9 +399,10 @@ void BladeRF2MIMOGui::updateHardware() { if (m_doApplySettings) { - BladeRF2MIMO::MsgConfigureBladeRF2MIMO* message = BladeRF2MIMO::MsgConfigureBladeRF2MIMO::create(m_settings, m_forceSettings); + BladeRF2MIMO::MsgConfigureBladeRF2MIMO* message = BladeRF2MIMO::MsgConfigureBladeRF2MIMO::create(m_settings, m_settingsKeys, m_forceSettings); m_sampleMIMO->getInputMessageQueue()->push(message); m_forceSettings = false; + m_settingsKeys.clear(); m_updateTimer.stop(); } } @@ -463,10 +471,15 @@ void BladeRF2MIMOGui::on_startStopTx_toggled(bool checked) void BladeRF2MIMOGui::on_centerFrequency_changed(quint64 value) { - if (m_rxElseTx) { + if (m_rxElseTx) + { m_settings.m_rxCenterFrequency = value * 1000; - } else { + m_settingsKeys.append("rxCenterFrequency"); + } + else + { m_settings.m_txCenterFrequency = value * 1000; + m_settingsKeys.append("txCenterFrequency"); } sendSettings(); @@ -476,27 +489,35 @@ void BladeRF2MIMOGui::on_LOppm_valueChanged(int value) { ui->LOppmText->setText(QString("%1").arg(QString::number(value/10.0, 'f', 1))); m_settings.m_LOppmTenths = value; + m_settingsKeys.append("LOppmTenths"); sendSettings(); } void BladeRF2MIMOGui::on_dcOffset_toggled(bool checked) { m_settings.m_dcBlock = checked; + m_settingsKeys.append("dcBlock"); sendSettings(); } void BladeRF2MIMOGui::on_iqImbalance_toggled(bool checked) { m_settings.m_iqCorrection = checked; + m_settingsKeys.append("iqCorrection"); sendSettings(); } void BladeRF2MIMOGui::on_bandwidth_changed(quint64 value) { - if (m_rxElseTx) { + if (m_rxElseTx) + { m_settings.m_rxBandwidth = value * 1000; - } else { + m_settingsKeys.append("rxBandwidth"); + } + else + { m_settings.m_txBandwidth = value * 1000; + m_settingsKeys.append("txBandwidth"); } sendSettings(); @@ -519,15 +540,21 @@ void BladeRF2MIMOGui::on_sampleRate_changed(quint64 value) displaySampleRate(); displayFcTooltip(); + m_settingsKeys.append("devSampleRate"); sendSettings(); } void BladeRF2MIMOGui::on_fcPos_currentIndexChanged(int index) { - if (m_rxElseTx) { + if (m_rxElseTx) + { m_settings.m_fcPosRx = (BladeRF2MIMOSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index); - } else { + m_settingsKeys.append("fcPosRx"); + } + else + { m_settings.m_fcPosTx = (BladeRF2MIMOSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index); + m_settingsKeys.append("fcPosTx"); } displayFcTooltip(); @@ -540,10 +567,15 @@ void BladeRF2MIMOGui::on_decim_currentIndexChanged(int index) return; } - if (m_rxElseTx) { + if (m_rxElseTx) + { m_settings.m_log2Decim = index; - } else { + m_settingsKeys.append("log2Decim"); + } + else + { m_settings.m_log2Interp = index; + m_settingsKeys.append("log2Interp"); } displaySampleRate(); @@ -554,6 +586,7 @@ void BladeRF2MIMOGui::on_decim_currentIndexChanged(int index) m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << (m_rxElseTx ? m_settings.m_log2Decim : m_settings.m_log2Interp)); } + m_settingsKeys.append("devSampleRate"); sendSettings(); } @@ -564,6 +597,9 @@ void BladeRF2MIMOGui::on_gainLock_toggled(bool checked) m_settings.m_rx1GlobalGain = m_settings.m_rx0GlobalGain; m_settings.m_rx1GainMode = m_settings.m_rx0GainMode; m_settings.m_tx1GlobalGain = m_settings.m_tx0GlobalGain; + m_settingsKeys.append("rx1GlobalGain"); + m_settingsKeys.append("rx1GainMode"); + m_settingsKeys.append("tx1GlobalGain"); sendSettings(); } @@ -597,6 +633,7 @@ void BladeRF2MIMOGui::on_gainMode_currentIndexChanged(int index) } m_settings.m_rx0GainMode = mode.m_value; + m_settingsKeys.append("rx0GainMode"); } if (m_streamIndex == 1 || m_gainLock) @@ -613,6 +650,7 @@ void BladeRF2MIMOGui::on_gainMode_currentIndexChanged(int index) } m_settings.m_rx1GainMode = mode.m_value; + m_settingsKeys.append("rx1GainMode"); } sendSettings(); @@ -636,11 +674,15 @@ float BladeRF2MIMOGui::setGainFromValue(int value) m_sampleMIMO->getRxGlobalGainRange(min, max, step, scale); gainDB = getGainDB(value, min, max, step, scale); - if (m_streamIndex == 0 || m_gainLock) { + if (m_streamIndex == 0 || m_gainLock) + { m_settings.m_rx0GlobalGain = (int) gainDB; + m_settingsKeys.append("rx0GlobalGain"); } - if (m_streamIndex == 1 || m_gainLock) { + if (m_streamIndex == 1 || m_gainLock) + { m_settings.m_rx1GlobalGain = (int) gainDB; + m_settingsKeys.append("rx1GlobalGain"); } } else @@ -648,11 +690,15 @@ float BladeRF2MIMOGui::setGainFromValue(int value) m_sampleMIMO->getTxGlobalGainRange(min, max, step, scale); gainDB = getGainDB(value, min, max, step, scale); - if (m_streamIndex == 0 || m_gainLock) { + if (m_streamIndex == 0 || m_gainLock) + { m_settings.m_tx0GlobalGain = (int) gainDB; + m_settingsKeys.append("tx0GlobalGain"); } - if (m_streamIndex == 1 || m_gainLock) { + if (m_streamIndex == 1 || m_gainLock) + { m_settings.m_tx1GlobalGain = (int) gainDB; + m_settingsKeys.append("tx1GlobalGain"); } } @@ -661,10 +707,15 @@ float BladeRF2MIMOGui::setGainFromValue(int value) void BladeRF2MIMOGui::on_biasTee_toggled(bool checked) { - if (m_rxElseTx) { + if (m_rxElseTx) + { m_settings.m_rxBiasTee = checked; - } else { + m_settingsKeys.append("rxBiasTee"); + } + else + { m_settings.m_txBiasTee = checked; + m_settingsKeys.append("txBiasTee"); } sendSettings(); @@ -677,12 +728,19 @@ void BladeRF2MIMOGui::on_transverter_clicked() m_settings.m_rxTransverterMode = ui->transverter->getDeltaFrequencyAcive(); m_settings.m_rxTransverterDeltaFrequency = ui->transverter->getDeltaFrequency(); m_settings.m_iqOrder = ui->transverter->getIQOrder(); + m_settingsKeys.append("rxTransverterMode"); + m_settingsKeys.append("rxTransverterDeltaFrequency"); + m_settingsKeys.append("iqOrder"); + m_settingsKeys.append("rxCenterFrequency"); qDebug("BladeRF2InputGui::on_transverter_clicked: Rx: %lld Hz %s", m_settings.m_rxTransverterDeltaFrequency, m_settings.m_rxTransverterMode ? "on" : "off"); } else { m_settings.m_txTransverterMode = ui->transverter->getDeltaFrequencyAcive(); m_settings.m_txTransverterDeltaFrequency = ui->transverter->getDeltaFrequency(); + m_settingsKeys.append("txTransverterMode"); + m_settingsKeys.append("txTransverterDeltaFrequency"); + m_settingsKeys.append("txCenterFrequency"); qDebug("BladeRF2InputGui::on_transverter_clicked: Tx: %lld Hz %s", m_settings.m_txTransverterDeltaFrequency, m_settings.m_txTransverterMode ? "on" : "off"); } @@ -746,10 +804,15 @@ void BladeRF2MIMOGui::setCenterFrequencySetting(uint64_t kHzValue) { int64_t centerFrequency = kHzValue*1000; - if (m_rxElseTx) { + if (m_rxElseTx) + { m_settings.m_rxCenterFrequency = centerFrequency < 0 ? 0 : (uint64_t) centerFrequency; - } else { + m_settingsKeys.append("rxCenterFrequency"); + } + else + { m_settings.m_txCenterFrequency = centerFrequency < 0 ? 0 : (uint64_t) centerFrequency; + m_settingsKeys.append("txCenterFrequency"); } ui->centerFrequency->setToolTip(QString("Main center frequency in kHz (LO: %1 kHz)").arg(centerFrequency/1000)); @@ -828,6 +891,10 @@ void BladeRF2MIMOGui::openDeviceSettingsDialog(const QPoint& p) m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex(); + m_settingsKeys.append("useReverseAPI"); + m_settingsKeys.append("reverseAPIAddress"); + m_settingsKeys.append("reverseAPIPort"); + m_settingsKeys.append("reverseAPIDeviceIndex"); sendSettings(); } diff --git a/plugins/samplemimo/bladerf2mimo/bladerf2mimogui.h b/plugins/samplemimo/bladerf2mimo/bladerf2mimogui.h index ad0b150be..53b1f05f2 100644 --- a/plugins/samplemimo/bladerf2mimo/bladerf2mimogui.h +++ b/plugins/samplemimo/bladerf2mimo/bladerf2mimogui.h @@ -52,6 +52,7 @@ private: Ui::BladeRF2MIMOGui* ui; BladeRF2MIMOSettings m_settings; + QList m_settingsKeys; bool m_rxElseTx; //!< Which side is being dealt with int m_streamIndex; //!< Current stream index being dealt with bool m_spectrumRxElseTx; diff --git a/plugins/samplemimo/bladerf2mimo/bladerf2mimosettings.cpp b/plugins/samplemimo/bladerf2mimo/bladerf2mimosettings.cpp index 650dd62f1..f9812c88a 100644 --- a/plugins/samplemimo/bladerf2mimo/bladerf2mimosettings.cpp +++ b/plugins/samplemimo/bladerf2mimo/bladerf2mimosettings.cpp @@ -167,4 +167,191 @@ bool BladeRF2MIMOSettings::deserialize(const QByteArray& data) } } +void BladeRF2MIMOSettings::applySettings(const QStringList& settingsKeys, const BladeRF2MIMOSettings& settings) +{ + if (settingsKeys.contains("devSampleRate")) { + m_devSampleRate = settings.m_devSampleRate; + } + if (settingsKeys.contains("LOppmTenths")) { + m_LOppmTenths = settings.m_LOppmTenths; + } + if (settingsKeys.contains("rxCenterFrequency")) { + m_rxCenterFrequency = settings.m_rxCenterFrequency; + } + if (settingsKeys.contains("log2Decim")) { + m_log2Decim = settings.m_log2Decim; + } + if (settingsKeys.contains("fcPosRx")) { + m_fcPosRx = settings.m_fcPosRx; + } + if (settingsKeys.contains("rxBandwidth")) { + m_rxBandwidth = settings.m_rxBandwidth; + } + if (settingsKeys.contains("rx0GainMode")) { + m_rx0GainMode = settings.m_rx0GainMode; + } + if (settingsKeys.contains("rx0GlobalGain")) { + m_rx0GlobalGain = settings.m_rx0GlobalGain; + } + if (settingsKeys.contains("rx1GainMode")) { + m_rx1GainMode = settings.m_rx1GainMode; + } + if (settingsKeys.contains("rx1GlobalGain")) { + m_rx1GlobalGain = settings.m_rx1GlobalGain; + } + if (settingsKeys.contains("rxBiasTee")) { + m_rxBiasTee = settings.m_rxBiasTee; + } + if (settingsKeys.contains("dcBlock")) { + m_dcBlock = settings.m_dcBlock; + } + if (settingsKeys.contains("iqCorrection")) { + m_iqCorrection = settings.m_iqCorrection; + } + if (settingsKeys.contains("rxTransverterMode")) { + m_rxTransverterMode = settings.m_rxTransverterMode; + } + if (settingsKeys.contains("rxTransverterDeltaFrequency")) { + m_rxTransverterDeltaFrequency = settings.m_rxTransverterDeltaFrequency; + } + if (settingsKeys.contains("iqOrder")) { + m_iqOrder = settings.m_iqOrder; + } + if (settingsKeys.contains("txCenterFrequency")) { + m_txCenterFrequency = settings.m_txCenterFrequency; + } + if (settingsKeys.contains("log2Interp")) { + m_log2Interp = settings.m_log2Interp; + } + if (settingsKeys.contains("fcPosTx")) { + m_fcPosTx = settings.m_fcPosTx; + } + if (settingsKeys.contains("txBandwidth")) { + m_txBandwidth = settings.m_txBandwidth; + } + if (settingsKeys.contains("tx0GlobalGain")) { + m_tx0GlobalGain = settings.m_tx0GlobalGain; + } + if (settingsKeys.contains("tx1GlobalGain")) { + m_tx1GlobalGain = settings.m_tx1GlobalGain; + } + if (settingsKeys.contains("txBiasTee")) { + m_txBiasTee = settings.m_txBiasTee; + } + if (settingsKeys.contains("txTransverterMode")) { + m_txTransverterMode = settings.m_txTransverterMode; + } + if (settingsKeys.contains("txTransverterDeltaFrequency")) { + m_txTransverterDeltaFrequency = settings.m_txTransverterDeltaFrequency; + } + if (settingsKeys.contains("useReverseAPI")) { + m_useReverseAPI = settings.m_useReverseAPI; + } + if (settingsKeys.contains("reverseAPIAddress")) { + m_reverseAPIAddress = settings.m_reverseAPIAddress; + } + if (settingsKeys.contains("reverseAPIPort")) { + m_reverseAPIPort = settings.m_reverseAPIPort; + } + if (settingsKeys.contains("reverseAPIDeviceIndex")) { + m_reverseAPIDeviceIndex = settings.m_reverseAPIDeviceIndex; + } +} + +QString BladeRF2MIMOSettings::getDebugString(const QStringList& settingsKeys, bool force) const +{ + std::ostringstream ostr; + + if (settingsKeys.contains("devSampleRate") || force) { + ostr << " m_devSampleRate: " << m_devSampleRate; + } + if (settingsKeys.contains("LOppmTenths") || force) { + ostr << " m_LOppmTenths: " << m_LOppmTenths; + } + if (settingsKeys.contains("rxCenterFrequency") || force) { + ostr << " m_rxCenterFrequency: " << m_rxCenterFrequency; + } + if (settingsKeys.contains("log2Decim") || force) { + ostr << " m_log2Decim: " << m_log2Decim; + } + if (settingsKeys.contains("fcPosRx") || force) { + ostr << " m_fcPosRx: " << m_fcPosRx; + } + if (settingsKeys.contains("rxBandwidth") || force) { + ostr << " m_rxBandwidth: " << m_rxBandwidth; + } + if (settingsKeys.contains("rx0GainMode") || force) { + ostr << " m_rx0GainMode: " << m_rx0GainMode; + } + if (settingsKeys.contains("rx0GlobalGain") || force) { + ostr << " m_rx0GlobalGain: " << m_rx0GlobalGain; + } + if (settingsKeys.contains("rx1GainMode") || force) { + ostr << " m_rx1GainMode: " << m_rx1GainMode; + } + if (settingsKeys.contains("rx1GlobalGain") || force) { + ostr << " m_rx1GlobalGain: " << m_rx1GlobalGain; + } + if (settingsKeys.contains("rxBiasTee") || force) { + ostr << " m_rxBiasTee: " << m_rxBiasTee; + } + if (settingsKeys.contains("dcBlock") || force) { + ostr << " m_dcBlock: " << m_dcBlock; + } + if (settingsKeys.contains("iqCorrection") || force) { + ostr << " m_iqCorrection: " << m_iqCorrection; + } + if (settingsKeys.contains("rxTransverterMode") || force) { + ostr << " m_rxTransverterMode: " << m_rxTransverterMode; + } + if (settingsKeys.contains("rxTransverterDeltaFrequency") || force) { + ostr << " m_rxTransverterDeltaFrequency: " << m_rxTransverterDeltaFrequency; + } + if (settingsKeys.contains("iqOrder") || force) { + ostr << " m_iqOrder: " << m_iqOrder; + } + if (settingsKeys.contains("txCenterFrequency") || force) { + ostr << " m_txCenterFrequency: " << m_txCenterFrequency; + } + if (settingsKeys.contains("log2Interp") || force) { + ostr << " m_log2Interp: " << m_log2Interp; + } + if (settingsKeys.contains("fcPosTx") || force) { + ostr << " m_fcPosTx: " << m_fcPosTx; + } + if (settingsKeys.contains("txBandwidth") || force) { + ostr << " m_txBandwidth: " << m_txBandwidth; + } + if (settingsKeys.contains("tx0GlobalGain") || force) { + ostr << " m_tx0GlobalGain: " << m_tx0GlobalGain; + } + if (settingsKeys.contains("tx1GlobalGain") || force) { + ostr << " m_tx1GlobalGain: " << m_tx1GlobalGain; + } + if (settingsKeys.contains("txBiasTee") || force) { + ostr << " m_txBiasTee: " << m_txBiasTee; + } + if (settingsKeys.contains("txTransverterMode") || force) { + ostr << " m_txTransverterMode: " << m_txTransverterMode; + } + if (settingsKeys.contains("txTransverterDeltaFrequency") || force) { + ostr << " m_txTransverterDeltaFrequency: " << m_txTransverterDeltaFrequency; + } + if (settingsKeys.contains("useReverseAPI") || force) { + ostr << " m_useReverseAPI: " << m_useReverseAPI; + } + if (settingsKeys.contains("reverseAPIAddress") || force) { + ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString(); + } + if (settingsKeys.contains("reverseAPIPort") || force) { + ostr << " m_reverseAPIPort: " << m_reverseAPIPort; + } + if (settingsKeys.contains("reverseAPIDeviceIndex") || force) { + ostr << " m_reverseAPIDeviceIndex: " << m_reverseAPIDeviceIndex; + } + + return QString(ostr.str().c_str()); +} + + diff --git a/plugins/samplemimo/bladerf2mimo/bladerf2mimosettings.h b/plugins/samplemimo/bladerf2mimo/bladerf2mimosettings.h index 2f2104630..c7fe94240 100644 --- a/plugins/samplemimo/bladerf2mimo/bladerf2mimosettings.h +++ b/plugins/samplemimo/bladerf2mimo/bladerf2mimosettings.h @@ -65,6 +65,8 @@ struct BladeRF2MIMOSettings { void resetToDefaults(); QByteArray serialize() const; bool deserialize(const QByteArray& data); + void applySettings(const QStringList& settingsKeys, const BladeRF2MIMOSettings& settings); + QString getDebugString(const QStringList& settingsKeys, bool force=false) const; };