From 3cf8a2e826b5d538ec5277b28ae0843aa3afce62 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 28 Aug 2019 08:45:58 +0200 Subject: [PATCH] HackRF output: implemented transverter mode --- .../samplesink/hackrfoutput/hackrfoutput.cpp | 29 ++++++++++-- .../hackrfoutput/hackrfoutputgui.cpp | 25 ++++++++++ .../samplesink/hackrfoutput/hackrfoutputgui.h | 2 + .../hackrfoutput/hackrfoutputgui.ui | 21 +++++++++ .../hackrfoutput/hackrfoutputplugin.cpp | 2 +- .../hackrfoutput/hackrfoutputsettings.cpp | 6 +++ .../hackrfoutput/hackrfoutputsettings.h | 2 + .../hackrfinput/hackrfinputgui.ui | 3 ++ .../hackrfinput/hackrfinputplugin.cpp | 2 +- sdrbase/resources/webapi/doc/html2/index.html | 9 +++- .../webapi/doc/swagger/include/HackRF.yaml | 5 ++ .../sdrangel/api/swagger/include/HackRF.yaml | 5 ++ swagger/sdrangel/code/html2/index.html | 9 +++- .../qt5/client/SWGHackRFOutputSettings.cpp | 46 +++++++++++++++++++ .../code/qt5/client/SWGHackRFOutputSettings.h | 12 +++++ 15 files changed, 171 insertions(+), 7 deletions(-) diff --git a/plugins/samplesink/hackrfoutput/hackrfoutput.cpp b/plugins/samplesink/hackrfoutput/hackrfoutput.cpp index 70794d079..03b62c644 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutput.cpp +++ b/plugins/samplesink/hackrfoutput/hackrfoutput.cpp @@ -419,19 +419,28 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc if ((m_settings.m_fcPos != settings.m_fcPos) || force) { reverseAPIKeys.append("fcPos"); } + if ((m_settings.m_transverterMode != settings.m_transverterMode) || force) { + reverseAPIKeys.append("transverterMode"); + } + if ((m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || force) { + reverseAPIKeys.append("transverterDeltaFrequency"); + } if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || (m_settings.m_devSampleRate != settings.m_devSampleRate) || (m_settings.m_LOppmTenths != settings.m_LOppmTenths) || (m_settings.m_log2Interp != settings.m_log2Interp) || - (m_settings.m_fcPos != settings.m_fcPos) || force) + (m_settings.m_fcPos != settings.m_fcPos) || + (m_settings.m_transverterMode != settings.m_transverterMode) || + (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || force) { qint64 deviceCenterFrequency = DeviceSampleSink::calculateDeviceCenterFrequency( settings.m_centerFrequency, - 0, + settings.m_transverterDeltaFrequency, settings.m_log2Interp, (DeviceSampleSink::fcPos_t) settings.m_fcPos, - settings.m_devSampleRate); + settings.m_devSampleRate, + m_settings.m_transverterMode); setDeviceCenterFrequency(deviceCenterFrequency, settings.m_LOppmTenths); if (m_deviceAPI->getSourceBuddies().size() > 0) @@ -611,6 +620,12 @@ void HackRFOutput::webapiUpdateDeviceSettings( if (deviceSettingsKeys.contains("lnaExt")) { settings.m_lnaExt = response.getHackRfOutputSettings()->getLnaExt() != 0; } + if (deviceSettingsKeys.contains("transverterDeltaFrequency")) { + settings.m_transverterDeltaFrequency = response.getHackRfInputSettings()->getTransverterDeltaFrequency(); + } + if (deviceSettingsKeys.contains("transverterMode")) { + settings.m_transverterMode = response.getHackRfInputSettings()->getTransverterMode() != 0; + } if (deviceSettingsKeys.contains("useReverseAPI")) { settings.m_useReverseAPI = response.getHackRfOutputSettings()->getUseReverseApi() != 0; } @@ -636,6 +651,8 @@ void HackRFOutput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& re response.getHackRfOutputSettings()->setDevSampleRate(settings.m_devSampleRate); response.getHackRfOutputSettings()->setBiasT(settings.m_biasT ? 1 : 0); response.getHackRfOutputSettings()->setLnaExt(settings.m_lnaExt ? 1 : 0); + response.getHackRfOutputSettings()->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency); + response.getHackRfOutputSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0); response.getHackRfOutputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0); @@ -715,6 +732,12 @@ void HackRFOutput::webapiReverseSendSettings(QList& deviceSettingsKeys, if (deviceSettingsKeys.contains("lnaExt") || force) { swgHackRFOutputSettings->setLnaExt(settings.m_lnaExt ? 1 : 0); } + if (deviceSettingsKeys.contains("transverterDeltaFrequency") || force) { + swgHackRFOutputSettings->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency); + } + if (deviceSettingsKeys.contains("transverterMode") || force) { + swgHackRFOutputSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0); + } QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings") .arg(settings.m_reverseAPIAddress) diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp b/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp index 1ff296ccd..2baaa9cda 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp @@ -229,6 +229,21 @@ void HackRFOutputGui::displaySampleRate() ui->sampleRate->blockSignals(false); } +void HackRFOutputGui::updateFrequencyLimits() +{ + // values in kHz + qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0; + qint64 minLimit = (0U) + deltaFrequency; + qint64 maxLimit = (7250000U) + deltaFrequency; + + minLimit = minLimit < 0 ? 0 : minLimit > 9999999 ? 9999999 : minLimit; + maxLimit = maxLimit < 0 ? 0 : maxLimit > 9999999 ? 9999999 : maxLimit; + + qDebug("HackRFOutputGui::updateFrequencyLimits: delta: %lld min: %lld max: %lld", deltaFrequency, minLimit, maxLimit); + + ui->centerFrequency->setValueRange(7, minLimit, maxLimit); +} + void HackRFOutputGui::displayFcTooltip() { int32_t fShift = DeviceSampleSink::calculateFrequencyShift( @@ -386,6 +401,16 @@ void HackRFOutputGui::on_sampleRateMode_toggled(bool checked) displaySampleRate(); } +void HackRFOutputGui::on_transverter_clicked() +{ + m_settings.m_transverterMode = ui->transverter->getDeltaFrequencyAcive(); + m_settings.m_transverterDeltaFrequency = ui->transverter->getDeltaFrequency(); + qDebug("HackRFOutputGui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off"); + updateFrequencyLimits(); + m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000; + sendSettings(); +} + void HackRFOutputGui::updateHardware() { if (m_doApplySettings) diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputgui.h b/plugins/samplesink/hackrfoutput/hackrfoutputgui.h index 4777a148a..725764044 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.h +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.h @@ -84,6 +84,7 @@ private: void displayBandwidths(); void sendSettings(); void updateSampleRateAndFrequency(); + void updateFrequencyLimits(); void blockApplySettings(bool block); private slots: @@ -99,6 +100,7 @@ private slots: void on_txvga_valueChanged(int value); void on_startStop_toggled(bool checked); void on_sampleRateMode_toggled(bool checked); + void on_transverter_clicked(); void updateHardware(); void updateStatus(); void openDeviceSettingsDialog(const QPoint& p); diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui b/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui index 240dc59ec..8b9e1e455 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui @@ -277,6 +277,22 @@ + + + + + 24 + 24 + + + + Transverter frequency translation dialog + + + X + + + @@ -552,6 +568,11 @@ QToolButton
gui/buttonswitch.h
+ + TransverterButton + QPushButton +
gui/transverterbutton.h
+
diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputplugin.cpp b/plugins/samplesink/hackrfoutput/hackrfoutputplugin.cpp index 8bad14cb5..580417012 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputplugin.cpp +++ b/plugins/samplesink/hackrfoutput/hackrfoutputplugin.cpp @@ -31,7 +31,7 @@ const PluginDescriptor HackRFOutputPlugin::m_pluginDescriptor = { QString("HackRF Output"), - QString("4.11.6"), + QString("4.11.8"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputsettings.cpp b/plugins/samplesink/hackrfoutput/hackrfoutputsettings.cpp index 6335e486a..e876d4c66 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputsettings.cpp +++ b/plugins/samplesink/hackrfoutput/hackrfoutputsettings.cpp @@ -37,6 +37,8 @@ void HackRFOutputSettings::resetToDefaults() m_vgaGain = 22; m_bandwidth = 1750000; m_devSampleRate = 2400000; + m_transverterMode = false; + m_transverterDeltaFrequency = 0; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; m_reverseAPIPort = 8888; @@ -59,6 +61,8 @@ QByteArray HackRFOutputSettings::serialize() const s.writeString(10, m_reverseAPIAddress); s.writeU32(11, m_reverseAPIPort); s.writeU32(12, m_reverseAPIDeviceIndex); + s.writeBool(13, m_transverterMode); + s.writeS64(14, m_transverterDeltaFrequency); return s.final(); } @@ -99,6 +103,8 @@ bool HackRFOutputSettings::deserialize(const QByteArray& data) d.readU32(12, &uintval, 0); m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; + d.readBool(13, &m_transverterMode, false); + d.readS64(14, &m_transverterDeltaFrequency, 0); return true; } diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputsettings.h b/plugins/samplesink/hackrfoutput/hackrfoutputsettings.h index 260ce39d1..25ffe4c54 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputsettings.h +++ b/plugins/samplesink/hackrfoutput/hackrfoutputsettings.h @@ -37,6 +37,8 @@ struct HackRFOutputSettings { quint64 m_devSampleRate; bool m_biasT; bool m_lnaExt; + bool m_transverterMode; + qint64 m_transverterDeltaFrequency; bool m_useReverseAPI; QString m_reverseAPIAddress; uint16_t m_reverseAPIPort; diff --git a/plugins/samplesource/hackrfinput/hackrfinputgui.ui b/plugins/samplesource/hackrfinput/hackrfinputgui.ui index 5e5800385..e5929b93c 100644 --- a/plugins/samplesource/hackrfinput/hackrfinputgui.ui +++ b/plugins/samplesource/hackrfinput/hackrfinputgui.ui @@ -31,6 +31,9 @@ HackRF + + Transverter frequency translation dialog + 3 diff --git a/plugins/samplesource/hackrfinput/hackrfinputplugin.cpp b/plugins/samplesource/hackrfinput/hackrfinputplugin.cpp index 164bce832..12107be6c 100644 --- a/plugins/samplesource/hackrfinput/hackrfinputplugin.cpp +++ b/plugins/samplesource/hackrfinput/hackrfinputplugin.cpp @@ -32,7 +32,7 @@ const PluginDescriptor HackRFInputPlugin::m_pluginDescriptor = { QString("HackRF Input"), - QString("4.11.6"), + QString("4.11.8"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index 0188a3823..8bba9e91c 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -3599,6 +3599,13 @@ margin-bottom: 20px; "lnaExt" : { "type" : "integer" }, + "transverterMode" : { + "type" : "integer" + }, + "transverterDeltaFrequency" : { + "type" : "integer", + "format" : "int64" + }, "useReverseAPI" : { "type" : "integer", "description" : "Synchronize with reverse API (1 for yes, 0 for no)" @@ -28221,7 +28228,7 @@ except ApiException as e:
- Generated 2019-08-27T08:26:32.301+02:00 + Generated 2019-08-28T08:25:28.542+02:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/HackRF.yaml b/sdrbase/resources/webapi/doc/swagger/include/HackRF.yaml index 38f187ab9..21b221d06 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/HackRF.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/HackRF.yaml @@ -67,6 +67,11 @@ HackRFOutputSettings: type: integer lnaExt: type: integer + transverterMode: + type: integer + transverterDeltaFrequency: + type: integer + format: int64 useReverseAPI: description: Synchronize with reverse API (1 for yes, 0 for no) type: integer diff --git a/swagger/sdrangel/api/swagger/include/HackRF.yaml b/swagger/sdrangel/api/swagger/include/HackRF.yaml index 38f187ab9..21b221d06 100644 --- a/swagger/sdrangel/api/swagger/include/HackRF.yaml +++ b/swagger/sdrangel/api/swagger/include/HackRF.yaml @@ -67,6 +67,11 @@ HackRFOutputSettings: type: integer lnaExt: type: integer + transverterMode: + type: integer + transverterDeltaFrequency: + type: integer + format: int64 useReverseAPI: description: Synchronize with reverse API (1 for yes, 0 for no) type: integer diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index 0188a3823..8bba9e91c 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -3599,6 +3599,13 @@ margin-bottom: 20px; "lnaExt" : { "type" : "integer" }, + "transverterMode" : { + "type" : "integer" + }, + "transverterDeltaFrequency" : { + "type" : "integer", + "format" : "int64" + }, "useReverseAPI" : { "type" : "integer", "description" : "Synchronize with reverse API (1 for yes, 0 for no)" @@ -28221,7 +28228,7 @@ except ApiException as e:
- Generated 2019-08-27T08:26:32.301+02:00 + Generated 2019-08-28T08:25:28.542+02:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGHackRFOutputSettings.cpp b/swagger/sdrangel/code/qt5/client/SWGHackRFOutputSettings.cpp index 8bf44c449..904c0ffc1 100644 --- a/swagger/sdrangel/code/qt5/client/SWGHackRFOutputSettings.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGHackRFOutputSettings.cpp @@ -46,6 +46,10 @@ SWGHackRFOutputSettings::SWGHackRFOutputSettings() { m_bias_t_isSet = false; lna_ext = 0; m_lna_ext_isSet = false; + transverter_mode = 0; + m_transverter_mode_isSet = false; + transverter_delta_frequency = 0L; + m_transverter_delta_frequency_isSet = false; use_reverse_api = 0; m_use_reverse_api_isSet = false; reverse_api_address = nullptr; @@ -80,6 +84,10 @@ SWGHackRFOutputSettings::init() { m_bias_t_isSet = false; lna_ext = 0; m_lna_ext_isSet = false; + transverter_mode = 0; + m_transverter_mode_isSet = false; + transverter_delta_frequency = 0L; + m_transverter_delta_frequency_isSet = false; use_reverse_api = 0; m_use_reverse_api_isSet = false; reverse_api_address = new QString(""); @@ -102,6 +110,8 @@ SWGHackRFOutputSettings::cleanup() { + + if(reverse_api_address != nullptr) { delete reverse_api_address; } @@ -138,6 +148,10 @@ SWGHackRFOutputSettings::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&lna_ext, pJson["lnaExt"], "qint32", ""); + ::SWGSDRangel::setValue(&transverter_mode, pJson["transverterMode"], "qint32", ""); + + ::SWGSDRangel::setValue(&transverter_delta_frequency, pJson["transverterDeltaFrequency"], "qint64", ""); + ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", ""); ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString"); @@ -189,6 +203,12 @@ SWGHackRFOutputSettings::asJsonObject() { if(m_lna_ext_isSet){ obj->insert("lnaExt", QJsonValue(lna_ext)); } + if(m_transverter_mode_isSet){ + obj->insert("transverterMode", QJsonValue(transverter_mode)); + } + if(m_transverter_delta_frequency_isSet){ + obj->insert("transverterDeltaFrequency", QJsonValue(transverter_delta_frequency)); + } if(m_use_reverse_api_isSet){ obj->insert("useReverseAPI", QJsonValue(use_reverse_api)); } @@ -295,6 +315,26 @@ SWGHackRFOutputSettings::setLnaExt(qint32 lna_ext) { this->m_lna_ext_isSet = true; } +qint32 +SWGHackRFOutputSettings::getTransverterMode() { + return transverter_mode; +} +void +SWGHackRFOutputSettings::setTransverterMode(qint32 transverter_mode) { + this->transverter_mode = transverter_mode; + this->m_transverter_mode_isSet = true; +} + +qint64 +SWGHackRFOutputSettings::getTransverterDeltaFrequency() { + return transverter_delta_frequency; +} +void +SWGHackRFOutputSettings::setTransverterDeltaFrequency(qint64 transverter_delta_frequency) { + this->transverter_delta_frequency = transverter_delta_frequency; + this->m_transverter_delta_frequency_isSet = true; +} + qint32 SWGHackRFOutputSettings::getUseReverseApi() { return use_reverse_api; @@ -367,6 +407,12 @@ SWGHackRFOutputSettings::isSet(){ if(m_lna_ext_isSet){ isObjectUpdated = true; break; } + if(m_transverter_mode_isSet){ + isObjectUpdated = true; break; + } + if(m_transverter_delta_frequency_isSet){ + isObjectUpdated = true; break; + } if(m_use_reverse_api_isSet){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGHackRFOutputSettings.h b/swagger/sdrangel/code/qt5/client/SWGHackRFOutputSettings.h index 9bf48ea3a..cdfb6bf62 100644 --- a/swagger/sdrangel/code/qt5/client/SWGHackRFOutputSettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGHackRFOutputSettings.h @@ -69,6 +69,12 @@ public: qint32 getLnaExt(); void setLnaExt(qint32 lna_ext); + qint32 getTransverterMode(); + void setTransverterMode(qint32 transverter_mode); + + qint64 getTransverterDeltaFrequency(); + void setTransverterDeltaFrequency(qint64 transverter_delta_frequency); + qint32 getUseReverseApi(); void setUseReverseApi(qint32 use_reverse_api); @@ -112,6 +118,12 @@ private: qint32 lna_ext; bool m_lna_ext_isSet; + qint32 transverter_mode; + bool m_transverter_mode_isSet; + + qint64 transverter_delta_frequency; + bool m_transverter_delta_frequency_isSet; + qint32 use_reverse_api; bool m_use_reverse_api_isSet;