From 31123dacce0a204c547e7dc9eb388114331c2186 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 14 Dec 2018 08:51:01 +0100 Subject: [PATCH] Reverse API: AM demod changes (1) --- plugins/channelrx/demodam/amdemod.cpp | 31 +++++++- plugins/channelrx/demodam/amdemod.h | 1 + plugins/channelrx/demodam/amdemodgui.cpp | 4 + plugins/channelrx/demodam/amdemodsettings.cpp | 9 +++ plugins/channelrx/demodam/amdemodsettings.h | 2 + sdrgui/gui/basicchannelsettingsdialog.cpp | 12 +++ sdrgui/gui/basicchannelsettingsdialog.h | 6 ++ sdrgui/gui/basicchannelsettingsdialog.ui | 78 ++++++++++++++++++- 8 files changed, 141 insertions(+), 2 deletions(-) diff --git a/plugins/channelrx/demodam/amdemod.cpp b/plugins/channelrx/demodam/amdemod.cpp index f0f48d562..1171a2981 100644 --- a/plugins/channelrx/demodam/amdemod.cpp +++ b/plugins/channelrx/demodam/amdemod.cpp @@ -427,8 +427,11 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force) << " m_audioDeviceName: " << settings.m_audioDeviceName << " m_pll: " << settings.m_pll << " m_syncAMOperation: " << (int) settings.m_syncAMOperation + << " m_useReverseAPI" << settings.m_useReverseAPI << " force: " << force; + QList reverseAPIKeys; + if((m_settings.m_rfBandwidth != settings.m_rfBandwidth) || (m_settings.m_bandpassEnable != settings.m_bandpassEnable) || force) { @@ -439,11 +442,19 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force) m_bandpass.create(301, m_audioSampleRate, 300.0, settings.m_rfBandwidth / 2.0f); DSBFilter->create_dsb_filter((2.0f * settings.m_rfBandwidth) / (float) m_audioSampleRate); m_settingsMutex.unlock(); + + if ((m_settings.m_rfBandwidth != settings.m_rfBandwidth) || force) { + reverseAPIKeys.append("rfBandwidth"); + } + if ((m_settings.m_bandpassEnable != settings.m_bandpassEnable) || force) { + reverseAPIKeys.append("bandpassEnable"); + } } if ((m_settings.m_squelch != settings.m_squelch) || force) { m_squelchLevel = CalcDb::powerFromdB(settings.m_squelch); + reverseAPIKeys.append("squelchLevel"); } if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) @@ -457,6 +468,8 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force) if (m_audioSampleRate != audioSampleRate) { applyAudioSampleRate(audioSampleRate); } + + reverseAPIKeys.append("audioDeviceName"); } if ((m_settings.m_pll != settings.m_pll) || force) @@ -470,13 +483,21 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force) { m_volumeAGC.resizeNew(m_audioSampleRate/10, 0.003); } + + reverseAPIKeys.append("pll"); } - if ((m_settings.m_syncAMOperation != settings.m_syncAMOperation) || force) { + if ((m_settings.m_syncAMOperation != settings.m_syncAMOperation) || force) + { m_syncAMBuffIndex = 0; + reverseAPIKeys.append("syncAMOperation"); } m_settings = settings; + + if (m_settings.m_useReverseAPI) { + webapiReverseSendSettings(reverseAPIKeys, m_settings, force); + } } QByteArray AMDemod::serialize() const @@ -634,3 +655,11 @@ void AMDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) response.getAmDemodReport()->setChannelSampleRate(m_inputSampleRate); } +void AMDemod::webapiReverseSendSettings(QList& channelSettingsKeys, AMDemodSettings& settings, bool force) +{ + (void) channelSettingsKeys; + (void) settings; + (void) force; + // TODO +} + diff --git a/plugins/channelrx/demodam/amdemod.h b/plugins/channelrx/demodam/amdemod.h index f08ed6451..3d64034b2 100644 --- a/plugins/channelrx/demodam/amdemod.h +++ b/plugins/channelrx/demodam/amdemod.h @@ -211,6 +211,7 @@ private: void applyAudioSampleRate(int sampleRate); void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const AMDemodSettings& settings); void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response); + void webapiReverseSendSettings(QList& channelSettingsKeys, AMDemodSettings& settings, bool force); void processOneSample(Complex &ci); }; diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index 91c248146..c071f1951 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -209,6 +209,8 @@ void AMDemodGUI::onMenuDialogCalled(const QPoint &p) dialog.setUseReverseAPI(m_settings.m_useReverseAPI); dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress); dialog.setReverseAPIPort(m_settings.m_reverseAPIPort); + dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex); + dialog.setReverseAPIChannelIndex(m_settings.m_reverseAPIChannelIndex); dialog.move(p); dialog.exec(); @@ -218,6 +220,8 @@ void AMDemodGUI::onMenuDialogCalled(const QPoint &p) m_settings.m_useReverseAPI = dialog.useReverseAPI(); m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); + m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex(); + m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex(); setWindowTitle(m_settings.m_title); setTitleColor(m_settings.m_rgbColor); diff --git a/plugins/channelrx/demodam/amdemodsettings.cpp b/plugins/channelrx/demodam/amdemodsettings.cpp index 0a421e7a8..14d9eeb1f 100644 --- a/plugins/channelrx/demodam/amdemodsettings.cpp +++ b/plugins/channelrx/demodam/amdemodsettings.cpp @@ -43,6 +43,8 @@ void AMDemodSettings::resetToDefaults() m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; m_reverseAPIPort = 8888; + m_reverseAPIDeviceIndex = 0; + m_reverseAPIChannelIndex = 0; } QByteArray AMDemodSettings::serialize() const @@ -66,6 +68,8 @@ QByteArray AMDemodSettings::serialize() const s.writeBool(14, m_useReverseAPI); s.writeString(15, m_reverseAPIAddress); s.writeU32(16, m_reverseAPIPort); + s.writeU32(17, m_reverseAPIDeviceIndex); + s.writeU32(18, m_reverseAPIChannelIndex); return s.final(); } @@ -117,6 +121,11 @@ bool AMDemodSettings::deserialize(const QByteArray& data) m_reverseAPIPort = 8888; } + d.readU32(17, &utmp, 0); + m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp; + d.readU32(18, &utmp, 0); + m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp; + return true; } else diff --git a/plugins/channelrx/demodam/amdemodsettings.h b/plugins/channelrx/demodam/amdemodsettings.h index 0f2fd2cee..1e551f4d6 100644 --- a/plugins/channelrx/demodam/amdemodsettings.h +++ b/plugins/channelrx/demodam/amdemodsettings.h @@ -45,6 +45,8 @@ struct AMDemodSettings bool m_useReverseAPI; QString m_reverseAPIAddress; uint16_t m_reverseAPIPort; + uint16_t m_reverseAPIDeviceIndex; + uint16_t m_reverseAPIChannelIndex; AMDemodSettings(); void resetToDefaults(); diff --git a/sdrgui/gui/basicchannelsettingsdialog.cpp b/sdrgui/gui/basicchannelsettingsdialog.cpp index d66112333..7e5fd13c7 100644 --- a/sdrgui/gui/basicchannelsettingsdialog.cpp +++ b/sdrgui/gui/basicchannelsettingsdialog.cpp @@ -49,6 +49,18 @@ void BasicChannelSettingsDialog::setReverseAPIPort(uint16_t port) ui->reverseAPIPort->setText(tr("%1").arg(m_reverseAPIPort)); } +void BasicChannelSettingsDialog::setReverseAPIDeviceIndex(uint16_t deviceIndex) +{ + m_reverseAPIDeviceIndex = deviceIndex > 99 ? 99 : deviceIndex; + ui->reverseAPIDeviceIndex->setText(tr("%1").arg(m_reverseAPIDeviceIndex)); +} + +void BasicChannelSettingsDialog::setReverseAPIChannelIndex(uint16_t channelIndex) +{ + m_reverseAPIChannelIndex = channelIndex > 99 ? 99 : channelIndex; + ui->reverseAPIDeviceIndex->setText(tr("%1").arg(m_reverseAPIChannelIndex)); +} + void BasicChannelSettingsDialog::paintColor() { QPixmap pm(24, 24); diff --git a/sdrgui/gui/basicchannelsettingsdialog.h b/sdrgui/gui/basicchannelsettingsdialog.h index 8cc67ce63..7769d55d8 100644 --- a/sdrgui/gui/basicchannelsettingsdialog.h +++ b/sdrgui/gui/basicchannelsettingsdialog.h @@ -22,9 +22,13 @@ public: bool useReverseAPI() const { return m_useReverseAPI; } const QString& getReverseAPIAddress() const { return m_reverseAPIAddress; } uint16_t getReverseAPIPort() const { return m_reverseAPIPort; } + uint16_t getReverseAPIDeviceIndex() const { return m_reverseAPIDeviceIndex; } + uint16_t getReverseAPIChannelIndex() const { return m_reverseAPIChannelIndex; } void setUseReverseAPI(bool useReverseAPI); void setReverseAPIAddress(const QString& address); void setReverseAPIPort(uint16_t port); + void setReverseAPIDeviceIndex(uint16_t deviceIndex); + void setReverseAPIChannelIndex(uint16_t channelIndex); private slots: void on_colorBtn_clicked(); @@ -40,6 +44,8 @@ private: bool m_useReverseAPI; QString m_reverseAPIAddress; uint16_t m_reverseAPIPort; + uint16_t m_reverseAPIDeviceIndex; + uint16_t m_reverseAPIChannelIndex; bool m_hasChanged; void paintColor(); diff --git a/sdrgui/gui/basicchannelsettingsdialog.ui b/sdrgui/gui/basicchannelsettingsdialog.ui index 6d2e02f89..51d5e6116 100644 --- a/sdrgui/gui/basicchannelsettingsdialog.ui +++ b/sdrgui/gui/basicchannelsettingsdialog.ui @@ -152,9 +152,15 @@ + + + 45 + 0 + + - 50 + 45 16777215 @@ -169,6 +175,76 @@ + + + + D + + + + + + + + 22 + 0 + + + + + 22 + 16777215 + + + + Reverse API destination device index + + + 00 + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + C + + + + + + + + 22 + 0 + + + + + 22 + 16777215 + + + + Reverse API destination channel index + + + 00 + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + +