mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 04:50:29 -04:00 
			
		
		
		
	Reverse API: LimeSDR output changes
This commit is contained in:
		
							parent
							
								
									2945f7302f
								
							
						
					
					
						commit
						0a7e8378df
					
				| @ -14,10 +14,14 @@ | ||||
| // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #include <QMutexLocker> | ||||
| #include <QDebug> | ||||
| #include <cstddef> | ||||
| #include <string.h> | ||||
| 
 | ||||
| #include <QMutexLocker> | ||||
| #include <QDebug> | ||||
| #include <QNetworkReply> | ||||
| #include <QBuffer> | ||||
| 
 | ||||
| #include "lime/LimeSuite.h" | ||||
| 
 | ||||
| #include "SWGDeviceSettings.h" | ||||
| @ -57,11 +61,19 @@ LimeSDROutput::LimeSDROutput(DeviceSinkAPI *deviceAPI) : | ||||
|     openDevice(); | ||||
|     resumeTxBuddies(); | ||||
|     resumeRxBuddies(); | ||||
|     m_networkManager = new QNetworkAccessManager(); | ||||
|     connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); | ||||
| } | ||||
| 
 | ||||
| LimeSDROutput::~LimeSDROutput() | ||||
| { | ||||
|     if (m_running) stop(); | ||||
|     disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); | ||||
|     delete m_networkManager; | ||||
| 
 | ||||
|     if (m_running) { | ||||
|         stop(); | ||||
|     } | ||||
| 
 | ||||
|     suspendRxBuddies(); | ||||
|     suspendTxBuddies(); | ||||
|     closeDevice(); | ||||
| @ -524,6 +536,10 @@ bool LimeSDROutput::handleMessage(const Message& message) | ||||
|             m_deviceAPI->stopGeneration(); | ||||
|         } | ||||
| 
 | ||||
|         if (m_settings.m_useReverseAPI) { | ||||
|             webapiReverseSendStartStop(cmd.getStartStop()); | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
|     else if (DeviceLimeSDRShared::MsgReportBuddyChange::match(message)) | ||||
| @ -721,6 +737,7 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
|     bool doCalibration       = false; | ||||
|     bool doLPCalibration     = false; | ||||
|     double clockGenFreq      = 0.0; | ||||
|     QList<QString> reverseAPIKeys; | ||||
| //  QMutexLocker mutexLocker(&m_mutex);
 | ||||
| 
 | ||||
|     qint64 deviceCenterFrequency = settings.m_centerFrequency; | ||||
| @ -740,6 +757,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
| 
 | ||||
|     if ((m_settings.m_gain != settings.m_gain) || force) | ||||
|     { | ||||
|         reverseAPIKeys.append("gain"); | ||||
| 
 | ||||
|         if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired) | ||||
|         { | ||||
|             if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(), | ||||
| @ -760,6 +779,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
|     if ((m_settings.m_devSampleRate != settings.m_devSampleRate) | ||||
|        || (m_settings.m_log2HardInterp != settings.m_log2HardInterp) || force) | ||||
|     { | ||||
|         reverseAPIKeys.append("devSampleRate"); | ||||
|         reverseAPIKeys.append("log2HardInterp"); | ||||
|         forwardChangeAllDSP = true; //m_settings.m_devSampleRate != settings.m_devSampleRate;
 | ||||
| 
 | ||||
|         if (m_deviceShared.m_deviceParams->getDevice() != 0) | ||||
| @ -789,6 +810,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
|     if ((m_settings.m_devSampleRate != settings.m_devSampleRate) | ||||
|        || (m_settings.m_log2SoftInterp != settings.m_log2SoftInterp) || force) | ||||
|     { | ||||
|         reverseAPIKeys.append("devSampleRate"); | ||||
|         reverseAPIKeys.append("log2SoftInterp"); | ||||
| 
 | ||||
|         int fifoSize = (std::max)( | ||||
|                 (int) ((settings.m_devSampleRate/(1<<settings.m_log2SoftInterp)) * DeviceLimeSDRShared::m_sampleFifoLengthInSeconds), | ||||
|                 DeviceLimeSDRShared::m_sampleFifoMinSize); | ||||
| @ -798,6 +822,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
| 
 | ||||
|     if ((m_settings.m_lpfBW != settings.m_lpfBW) || force) | ||||
|     { | ||||
|         reverseAPIKeys.append("lpfBW"); | ||||
| 
 | ||||
|         if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired) | ||||
|         { | ||||
|             doLPCalibration = true; | ||||
| @ -807,6 +833,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
|     if ((m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) || | ||||
|         (m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || force) | ||||
|     { | ||||
|         reverseAPIKeys.append("lpfFIRBW"); | ||||
|         reverseAPIKeys.append("lpfFIREnable"); | ||||
| 
 | ||||
|         if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired) | ||||
|         { | ||||
|             if (LMS_SetGFIRLPF(m_deviceShared.m_deviceParams->getDevice(), | ||||
| @ -832,6 +861,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
|     if ((m_settings.m_ncoFrequency != settings.m_ncoFrequency) || | ||||
|         (m_settings.m_ncoEnable != settings.m_ncoEnable) || force || forceNCOFrequency) | ||||
|     { | ||||
|         reverseAPIKeys.append("ncoFrequency"); | ||||
|         reverseAPIKeys.append("ncoEnable"); | ||||
|         forwardChangeOwnDSP = true; | ||||
| 
 | ||||
|         if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired) | ||||
| @ -859,6 +890,7 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
| 
 | ||||
|     if ((m_settings.m_log2SoftInterp != settings.m_log2SoftInterp) || force) | ||||
|     { | ||||
|         reverseAPIKeys.append("log2SoftInterp"); | ||||
|         forwardChangeOwnDSP = true; | ||||
|         m_deviceShared.m_log2Soft = settings.m_log2SoftInterp; // for buddies
 | ||||
| 
 | ||||
| @ -871,6 +903,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
| 
 | ||||
|     if ((m_settings.m_antennaPath != settings.m_antennaPath) || force) | ||||
|     { | ||||
|         reverseAPIKeys.append("antennaPath"); | ||||
| 
 | ||||
|         if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired) | ||||
|         { | ||||
|             if (DeviceLimeSDR::setTxAntennaPath(m_deviceShared.m_deviceParams->getDevice(), | ||||
| @ -894,6 +928,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
|         || (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) | ||||
|         || force) | ||||
|     { | ||||
|         reverseAPIKeys.append("centerFrequency"); | ||||
|         reverseAPIKeys.append("transverterMode"); | ||||
|         reverseAPIKeys.append("transverterDeltaFrequency"); | ||||
|         forwardChangeTxDSP = true; | ||||
| 
 | ||||
|         if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired) | ||||
| @ -914,6 +951,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
|     if ((m_settings.m_extClock != settings.m_extClock) || | ||||
|         (settings.m_extClock && (m_settings.m_extClockFreq != settings.m_extClockFreq)) || force) | ||||
|     { | ||||
|         reverseAPIKeys.append("extClock"); | ||||
|         reverseAPIKeys.append("extClockFreq"); | ||||
| 
 | ||||
|         if (DeviceLimeSDR::setClockSource(m_deviceShared.m_deviceParams->getDevice(), | ||||
|                 settings.m_extClock, | ||||
| @ -938,6 +977,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
|     { | ||||
|         if ((m_settings.m_gpioDir != settings.m_gpioDir) || force) | ||||
|         { | ||||
|             reverseAPIKeys.append("gpioDir"); | ||||
| 
 | ||||
|             if (LMS_GPIODirWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioDir, 1) != 0) | ||||
|             { | ||||
|                 qCritical("LimeSDROutput::applySettings: could not set GPIO directions to %u", settings.m_gpioDir); | ||||
| @ -951,6 +992,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
| 
 | ||||
|         if ((m_settings.m_gpioPins != settings.m_gpioPins) || force) | ||||
|         { | ||||
|             reverseAPIKeys.append("gpioPins"); | ||||
| 
 | ||||
|             if (LMS_GPIOWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioPins, 1) != 0) | ||||
|             { | ||||
|                 qCritical("LimeSDROutput::applySettings: could not set GPIO pins to %u", settings.m_gpioPins); | ||||
| @ -963,6 +1006,15 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (settings.m_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); | ||||
|     } | ||||
| 
 | ||||
|     m_settings = settings; | ||||
|     double clockGenFreqAfter; | ||||
| 
 | ||||
| @ -1244,6 +1296,18 @@ int LimeSDROutput::webapiSettingsPutPatch( | ||||
|     if (deviceSettingsKeys.contains("gpioPins")) { | ||||
|         settings.m_gpioPins = response.getLimeSdrOutputSettings()->getGpioPins() & 0xFF; | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("useReverseAPI")) { | ||||
|         settings.m_useReverseAPI = response.getLimeSdrOutputSettings()->getUseReverseApi() != 0; | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("reverseAPIAddress")) { | ||||
|         settings.m_reverseAPIAddress = *response.getLimeSdrOutputSettings()->getReverseApiAddress() != 0; | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("reverseAPIPort")) { | ||||
|         settings.m_reverseAPIPort = response.getLimeSdrOutputSettings()->getReverseApiPort(); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) { | ||||
|         settings.m_reverseAPIDeviceIndex = response.getLimeSdrOutputSettings()->getReverseApiDeviceIndex(); | ||||
|     } | ||||
| 
 | ||||
|     MsgConfigureLimeSDR *msg = MsgConfigureLimeSDR::create(settings, force); | ||||
|     m_inputMessageQueue.push(msg); | ||||
| @ -1287,6 +1351,16 @@ void LimeSDROutput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& r | ||||
|     response.getLimeSdrOutputSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0); | ||||
|     response.getLimeSdrOutputSettings()->setGpioDir(settings.m_gpioDir); | ||||
|     response.getLimeSdrOutputSettings()->setGpioPins(settings.m_gpioPins); | ||||
|     response.getLimeSdrOutputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0); | ||||
| 
 | ||||
|     if (response.getLimeSdrOutputSettings()->getReverseApiAddress()) { | ||||
|         *response.getLimeSdrOutputSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress; | ||||
|     } else { | ||||
|         response.getLimeSdrOutputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress)); | ||||
|     } | ||||
| 
 | ||||
|     response.getLimeSdrOutputSettings()->setReverseApiPort(settings.m_reverseAPIPort); | ||||
|     response.getLimeSdrOutputSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex); | ||||
| } | ||||
| 
 | ||||
| int LimeSDROutput::webapiRunGet( | ||||
| @ -1356,3 +1430,114 @@ void LimeSDROutput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respo | ||||
|     response.getLimeSdrOutputReport()->setGpioDir(gpioDir); | ||||
|     response.getLimeSdrOutputReport()->setGpioPins(gpioPins); | ||||
| } | ||||
| 
 | ||||
| void LimeSDROutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const LimeSDROutputSettings& settings, bool force) | ||||
| { | ||||
|     SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); | ||||
|     swgDeviceSettings->setTx(1); | ||||
|     swgDeviceSettings->setDeviceHwType(new QString("LimeSDR")); | ||||
|     swgDeviceSettings->setLimeSdrOutputSettings(new SWGSDRangel::SWGLimeSdrOutputSettings()); | ||||
|     SWGSDRangel::SWGLimeSdrOutputSettings *swgLimeSdrOutputSettings = swgDeviceSettings->getLimeSdrOutputSettings(); | ||||
| 
 | ||||
|     // transfer data that has been modified. When force is on transfer all data except reverse API data
 | ||||
| 
 | ||||
|     if (deviceSettingsKeys.contains("antennaPath") || force) { | ||||
|         swgLimeSdrOutputSettings->setAntennaPath((int) settings.m_antennaPath); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("centerFrequency")) { | ||||
|         swgLimeSdrOutputSettings->setCenterFrequency(settings.m_centerFrequency); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("devSampleRate")) { | ||||
|         swgLimeSdrOutputSettings->setDevSampleRate(settings.m_devSampleRate); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("extClock")) { | ||||
|         swgLimeSdrOutputSettings->setExtClock(settings.m_extClock ? 1 : 0); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("extClockFreq")) { | ||||
|         swgLimeSdrOutputSettings->setExtClockFreq(settings.m_extClockFreq); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("gain")) { | ||||
|         swgLimeSdrOutputSettings->setGain(settings.m_gain); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("log2HardInterp")) { | ||||
|         swgLimeSdrOutputSettings->setLog2HardInterp(settings.m_log2HardInterp); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("log2SoftInterp")) { | ||||
|         swgLimeSdrOutputSettings->setLog2SoftInterp(settings.m_log2SoftInterp); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("lpfBW")) { | ||||
|         swgLimeSdrOutputSettings->setLpfBw(settings.m_lpfBW); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("lpfFIREnable")) { | ||||
|         swgLimeSdrOutputSettings->setLpfFirEnable(settings.m_lpfFIREnable ? 1 : 0); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("lpfFIRBW")) { | ||||
|         swgLimeSdrOutputSettings->setLpfFirbw(settings.m_lpfFIRBW); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("ncoEnable")) { | ||||
|         swgLimeSdrOutputSettings->setNcoEnable(settings.m_ncoEnable ? 1 : 0); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("ncoFrequency")) { | ||||
|         swgLimeSdrOutputSettings->setNcoFrequency(settings.m_ncoFrequency); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("transverterDeltaFrequency")) { | ||||
|         swgLimeSdrOutputSettings->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("transverterMode")) { | ||||
|         swgLimeSdrOutputSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("gpioDir")) { | ||||
|         swgLimeSdrOutputSettings->setGpioDir(settings.m_gpioDir & 0xFF); | ||||
|     } | ||||
|     if (deviceSettingsKeys.contains("gpioPins")) { | ||||
|         swgLimeSdrOutputSettings->setGpioPins(settings.m_gpioPins & 0xFF); | ||||
|     } | ||||
| 
 | ||||
|     QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings") | ||||
|             .arg(settings.m_reverseAPIAddress) | ||||
|             .arg(settings.m_reverseAPIPort) | ||||
|             .arg(settings.m_reverseAPIDeviceIndex); | ||||
|     m_networkRequest.setUrl(QUrl(deviceSettingsURL)); | ||||
| 
 | ||||
|     QBuffer *buffer=new QBuffer(); | ||||
|     buffer->open((QBuffer::ReadWrite)); | ||||
|     buffer->write(swgDeviceSettings->asJson().toUtf8()); | ||||
|     buffer->seek(0); | ||||
| 
 | ||||
|     // Always use PATCH to avoid passing reverse API settings
 | ||||
|     m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer); | ||||
| 
 | ||||
|     delete swgDeviceSettings; | ||||
| } | ||||
| 
 | ||||
| void LimeSDROutput::webapiReverseSendStartStop(bool start) | ||||
| { | ||||
|     QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") | ||||
|             .arg(m_settings.m_reverseAPIAddress) | ||||
|             .arg(m_settings.m_reverseAPIPort) | ||||
|             .arg(m_settings.m_reverseAPIDeviceIndex); | ||||
|     m_networkRequest.setUrl(QUrl(deviceSettingsURL)); | ||||
| 
 | ||||
|     if (start) { | ||||
|         m_networkManager->sendCustomRequest(m_networkRequest, "POST"); | ||||
|     } else { | ||||
|         m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void LimeSDROutput::networkManagerFinished(QNetworkReply *reply) | ||||
| { | ||||
|     QNetworkReply::NetworkError replyError = reply->error(); | ||||
| 
 | ||||
|     if (replyError) | ||||
|     { | ||||
|         qWarning() << "LimeSDROutput::networkManagerFinished:" | ||||
|                 << " error(" << (int) replyError | ||||
|                 << "): " << replyError | ||||
|                 << ": " << reply->errorString(); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     QString answer = reply->readAll(); | ||||
|     qDebug("LimeSDROutput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str()); | ||||
| } | ||||
|  | ||||
| @ -17,9 +17,11 @@ | ||||
| #ifndef PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUT_H_ | ||||
| #define PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUT_H_ | ||||
| 
 | ||||
| #include <QString> | ||||
| #include <stdint.h> | ||||
| 
 | ||||
| #include <QString> | ||||
| #include <QNetworkRequest> | ||||
| 
 | ||||
| #include "dsp/devicesamplesink.h" | ||||
| #include "limesdr/devicelimesdrshared.h" | ||||
| #include "limesdroutputsettings.h" | ||||
| @ -27,9 +29,12 @@ | ||||
| class DeviceSinkAPI; | ||||
| class LimeSDROutputThread; | ||||
| struct DeviceLimeSDRParams; | ||||
| class QNetworkAccessManager; | ||||
| class QNetworkReply; | ||||
| 
 | ||||
| class LimeSDROutput : public DeviceSampleSink | ||||
| { | ||||
|     Q_OBJECT | ||||
| public: | ||||
|     class MsgConfigureLimeSDR : public Message { | ||||
|         MESSAGE_CLASS_DECLARATION | ||||
| @ -235,8 +240,9 @@ private: | ||||
|     bool m_running; | ||||
|     DeviceLimeSDRShared m_deviceShared; | ||||
|     bool m_channelAcquired; | ||||
| 
 | ||||
|     lms_stream_t m_streamId; | ||||
|     QNetworkAccessManager *m_networkManager; | ||||
|     QNetworkRequest m_networkRequest; | ||||
| 
 | ||||
|     bool openDevice(); | ||||
|     void closeDevice(); | ||||
| @ -249,6 +255,11 @@ private: | ||||
|     bool applySettings(const LimeSDROutputSettings& settings, bool force = false, bool forceNCOFrequency = false); | ||||
|     void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const LimeSDROutputSettings& settings); | ||||
|     void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); | ||||
|     void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const LimeSDROutputSettings& settings, bool force); | ||||
|     void webapiReverseSendStartStop(bool start); | ||||
| 
 | ||||
| private slots: | ||||
|     void networkManagerFinished(QNetworkReply *reply); | ||||
| }; | ||||
| 
 | ||||
| #endif /* PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUT_H_ */ | ||||
|  | ||||
| @ -20,6 +20,8 @@ | ||||
| #include "ui_limesdroutputgui.h" | ||||
| #include "gui/colormapper.h" | ||||
| #include "gui/glspectrum.h" | ||||
| #include "gui/crightclickenabler.h" | ||||
| #include "gui/basicdevicesettingsdialog.h" | ||||
| #include "dsp/dspengine.h" | ||||
| #include "dsp/dspcommands.h" | ||||
| #include "device/devicesinkapi.h" | ||||
| @ -77,6 +79,9 @@ LimeSDROutputGUI::LimeSDROutputGUI(DeviceUISet *deviceUISet, QWidget* parent) : | ||||
| 
 | ||||
|     connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); | ||||
| 
 | ||||
|     CRightClickEnabler *startStopRightClickEnabler = new CRightClickEnabler(ui->startStop); | ||||
|     connect(startStopRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &))); | ||||
| 
 | ||||
|     sendSettings(); | ||||
| } | ||||
| 
 | ||||
| @ -561,4 +566,21 @@ void LimeSDROutputGUI::on_transverter_clicked() | ||||
|     sendSettings(); | ||||
| } | ||||
| 
 | ||||
| void LimeSDROutputGUI::openDeviceSettingsDialog(const QPoint& p) | ||||
| { | ||||
|     BasicDeviceSettingsDialog dialog(this); | ||||
|     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.move(p); | ||||
|     dialog.exec(); | ||||
| 
 | ||||
|     m_settings.m_useReverseAPI = dialog.useReverseAPI(); | ||||
|     m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); | ||||
|     m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); | ||||
|     m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex(); | ||||
| 
 | ||||
|     sendSettings(); | ||||
| } | ||||
|  | ||||
| @ -94,6 +94,7 @@ private slots: | ||||
|     void on_antenna_currentIndexChanged(int index); | ||||
|     void on_extClock_clicked(); | ||||
|     void on_transverter_clicked(); | ||||
|     void openDeviceSettingsDialog(const QPoint& p); | ||||
| 
 | ||||
|     void updateHardware(); | ||||
|     void updateStatus(); | ||||
|  | ||||
| @ -34,7 +34,7 @@ | ||||
| 
 | ||||
| const PluginDescriptor LimeSDROutputPlugin::m_pluginDescriptor = { | ||||
|     QString("LimeSDR Output"), | ||||
|     QString("4.3.1"), | ||||
|     QString("4.3.2"), | ||||
|     QString("(c) Edouard Griffiths, F4EXB"), | ||||
|     QString("https://github.com/f4exb/sdrangel"), | ||||
|     true, | ||||
|  | ||||
| @ -42,6 +42,10 @@ void LimeSDROutputSettings::resetToDefaults() | ||||
|     m_transverterDeltaFrequency = 0; | ||||
|     m_gpioDir = 0; | ||||
|     m_gpioPins = 0; | ||||
|     m_useReverseAPI = false; | ||||
|     m_reverseAPIAddress = "127.0.0.1"; | ||||
|     m_reverseAPIPort = 8888; | ||||
|     m_reverseAPIDeviceIndex = 0; | ||||
| } | ||||
| 
 | ||||
| QByteArray LimeSDROutputSettings::serialize() const | ||||
| @ -64,6 +68,10 @@ QByteArray LimeSDROutputSettings::serialize() const | ||||
|     s.writeS64(17, m_transverterDeltaFrequency); | ||||
|     s.writeU32(18, m_gpioDir); | ||||
|     s.writeU32(19, m_gpioPins); | ||||
|     s.writeBool(20, m_useReverseAPI); | ||||
|     s.writeString(21, m_reverseAPIAddress); | ||||
|     s.writeU32(22, m_reverseAPIPort); | ||||
|     s.writeU32(23, m_reverseAPIDeviceIndex); | ||||
| 
 | ||||
|     return s.final(); | ||||
| } | ||||
| @ -102,6 +110,18 @@ bool LimeSDROutputSettings::deserialize(const QByteArray& data) | ||||
|         m_gpioDir = uintval & 0xFF; | ||||
|         d.readU32(19, &uintval, 0); | ||||
|         m_gpioPins = uintval & 0xFF; | ||||
|         d.readBool(20, &m_useReverseAPI, false); | ||||
|         d.readString(21, &m_reverseAPIAddress, "127.0.0.1"); | ||||
|         d.readU32(22, &uintval, 0); | ||||
| 
 | ||||
|         if ((uintval > 1023) && (uintval < 65535)) { | ||||
|             m_reverseAPIPort = uintval; | ||||
|         } else { | ||||
|             m_reverseAPIPort = 8888; | ||||
|         } | ||||
| 
 | ||||
|         d.readU32(23, &uintval, 0); | ||||
|         m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
| @ -58,6 +58,10 @@ struct LimeSDROutputSettings | ||||
|     qint64   m_transverterDeltaFrequency; | ||||
|     uint8_t  m_gpioDir;      //!< GPIO pin direction LSB first; 0 input, 1 output
 | ||||
|     uint8_t  m_gpioPins;     //!< GPIO pins to write; LSB first
 | ||||
|     bool     m_useReverseAPI; | ||||
|     QString  m_reverseAPIAddress; | ||||
|     uint16_t m_reverseAPIPort; | ||||
|     uint16_t m_reverseAPIDeviceIndex; | ||||
| 
 | ||||
|     LimeSDROutputSettings(); | ||||
|     void resetToDefaults(); | ||||
|  | ||||
| @ -33,7 +33,7 @@ | ||||
| 
 | ||||
| const PluginDescriptor LimeSDRInputPlugin::m_pluginDescriptor = { | ||||
|     QString("LimeSDR Input"), | ||||
|     QString("4.3.1"), | ||||
|     QString("4.3.2"), | ||||
|     QString("(c) Edouard Griffiths, F4EXB"), | ||||
|     QString("https://github.com/f4exb/sdrangel"), | ||||
|     true, | ||||
|  | ||||
| @ -2853,6 +2853,19 @@ margin-bottom: 20px; | ||||
|     "gpioPins" : { | ||||
|       "type" : "integer", | ||||
|       "format" : "int8" | ||||
|     }, | ||||
|     "useReverseAPI" : { | ||||
|       "type" : "integer", | ||||
|       "description" : "Synchronize with reverse API (1 for yes, 0 for no)" | ||||
|     }, | ||||
|     "reverseAPIAddress" : { | ||||
|       "type" : "string" | ||||
|     }, | ||||
|     "reverseAPIPort" : { | ||||
|       "type" : "integer" | ||||
|     }, | ||||
|     "reverseAPIDeviceIndex" : { | ||||
|       "type" : "integer" | ||||
|     } | ||||
|   }, | ||||
|   "description" : "LimeSDR" | ||||
| @ -23704,7 +23717,7 @@ except ApiException as e: | ||||
|           </div> | ||||
|           <div id="generator"> | ||||
|             <div class="content"> | ||||
|               Generated 2018-12-18T22:18:01.691+01:00 | ||||
|               Generated 2018-12-18T23:38:18.118+01:00 | ||||
|             </div> | ||||
|           </div> | ||||
|       </div> | ||||
|  | ||||
| @ -104,6 +104,15 @@ LimeSdrOutputSettings: | ||||
|     gpioPins: | ||||
|       type: integer | ||||
|       format: int8 | ||||
|     useReverseAPI: | ||||
|       description: Synchronize with reverse API (1 for yes, 0 for no) | ||||
|       type: integer | ||||
|     reverseAPIAddress: | ||||
|       type: string | ||||
|     reverseAPIPort: | ||||
|       type: integer | ||||
|     reverseAPIDeviceIndex: | ||||
|       type: integer   | ||||
| 
 | ||||
| LimeSdrInputReport: | ||||
|   description: LimeSDR | ||||
|  | ||||
| @ -104,6 +104,15 @@ LimeSdrOutputSettings: | ||||
|     gpioPins: | ||||
|       type: integer | ||||
|       format: int8 | ||||
|     useReverseAPI: | ||||
|       description: Synchronize with reverse API (1 for yes, 0 for no) | ||||
|       type: integer | ||||
|     reverseAPIAddress: | ||||
|       type: string | ||||
|     reverseAPIPort: | ||||
|       type: integer | ||||
|     reverseAPIDeviceIndex: | ||||
|       type: integer   | ||||
| 
 | ||||
| LimeSdrInputReport: | ||||
|   description: LimeSDR | ||||
|  | ||||
| @ -2853,6 +2853,19 @@ margin-bottom: 20px; | ||||
|     "gpioPins" : { | ||||
|       "type" : "integer", | ||||
|       "format" : "int8" | ||||
|     }, | ||||
|     "useReverseAPI" : { | ||||
|       "type" : "integer", | ||||
|       "description" : "Synchronize with reverse API (1 for yes, 0 for no)" | ||||
|     }, | ||||
|     "reverseAPIAddress" : { | ||||
|       "type" : "string" | ||||
|     }, | ||||
|     "reverseAPIPort" : { | ||||
|       "type" : "integer" | ||||
|     }, | ||||
|     "reverseAPIDeviceIndex" : { | ||||
|       "type" : "integer" | ||||
|     } | ||||
|   }, | ||||
|   "description" : "LimeSDR" | ||||
| @ -23704,7 +23717,7 @@ except ApiException as e: | ||||
|           </div> | ||||
|           <div id="generator"> | ||||
|             <div class="content"> | ||||
|               Generated 2018-12-18T22:18:01.691+01:00 | ||||
|               Generated 2018-12-18T23:38:18.118+01:00 | ||||
|             </div> | ||||
|           </div> | ||||
|       </div> | ||||
|  | ||||
| @ -62,6 +62,14 @@ SWGLimeSdrOutputSettings::SWGLimeSdrOutputSettings() { | ||||
|     m_gpio_dir_isSet = false; | ||||
|     gpio_pins = 0; | ||||
|     m_gpio_pins_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; | ||||
| } | ||||
| 
 | ||||
| SWGLimeSdrOutputSettings::~SWGLimeSdrOutputSettings() { | ||||
| @ -104,6 +112,14 @@ SWGLimeSdrOutputSettings::init() { | ||||
|     m_gpio_dir_isSet = false; | ||||
|     gpio_pins = 0; | ||||
|     m_gpio_pins_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 | ||||
| @ -125,6 +141,12 @@ SWGLimeSdrOutputSettings::cleanup() { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     if(reverse_api_address != nullptr) {  | ||||
|         delete reverse_api_address; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| SWGLimeSdrOutputSettings* | ||||
| @ -172,6 +194,14 @@ SWGLimeSdrOutputSettings::fromJsonObject(QJsonObject &pJson) { | ||||
|      | ||||
|     ::SWGSDRangel::setValue(&gpio_pins, pJson["gpioPins"], "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 | ||||
| @ -239,6 +269,18 @@ SWGLimeSdrOutputSettings::asJsonObject() { | ||||
|     if(m_gpio_pins_isSet){ | ||||
|         obj->insert("gpioPins", QJsonValue(gpio_pins)); | ||||
|     } | ||||
|     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; | ||||
| } | ||||
| @ -413,6 +455,46 @@ SWGLimeSdrOutputSettings::setGpioPins(qint32 gpio_pins) { | ||||
|     this->m_gpio_pins_isSet = true; | ||||
| } | ||||
| 
 | ||||
| qint32 | ||||
| SWGLimeSdrOutputSettings::getUseReverseApi() { | ||||
|     return use_reverse_api; | ||||
| } | ||||
| void | ||||
| SWGLimeSdrOutputSettings::setUseReverseApi(qint32 use_reverse_api) { | ||||
|     this->use_reverse_api = use_reverse_api; | ||||
|     this->m_use_reverse_api_isSet = true; | ||||
| } | ||||
| 
 | ||||
| QString* | ||||
| SWGLimeSdrOutputSettings::getReverseApiAddress() { | ||||
|     return reverse_api_address; | ||||
| } | ||||
| void | ||||
| SWGLimeSdrOutputSettings::setReverseApiAddress(QString* reverse_api_address) { | ||||
|     this->reverse_api_address = reverse_api_address; | ||||
|     this->m_reverse_api_address_isSet = true; | ||||
| } | ||||
| 
 | ||||
| qint32 | ||||
| SWGLimeSdrOutputSettings::getReverseApiPort() { | ||||
|     return reverse_api_port; | ||||
| } | ||||
| void | ||||
| SWGLimeSdrOutputSettings::setReverseApiPort(qint32 reverse_api_port) { | ||||
|     this->reverse_api_port = reverse_api_port; | ||||
|     this->m_reverse_api_port_isSet = true; | ||||
| } | ||||
| 
 | ||||
| qint32 | ||||
| SWGLimeSdrOutputSettings::getReverseApiDeviceIndex() { | ||||
|     return reverse_api_device_index; | ||||
| } | ||||
| void | ||||
| SWGLimeSdrOutputSettings::setReverseApiDeviceIndex(qint32 reverse_api_device_index) { | ||||
|     this->reverse_api_device_index = reverse_api_device_index; | ||||
|     this->m_reverse_api_device_index_isSet = true; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| bool | ||||
| SWGLimeSdrOutputSettings::isSet(){ | ||||
| @ -435,6 +517,10 @@ SWGLimeSdrOutputSettings::isSet(){ | ||||
|         if(m_transverter_delta_frequency_isSet){ isObjectUpdated = true; break;} | ||||
|         if(m_gpio_dir_isSet){ isObjectUpdated = true; break;} | ||||
|         if(m_gpio_pins_isSet){ isObjectUpdated = true; break;} | ||||
|         if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;} | ||||
|         if(reverse_api_address != nullptr && *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; | ||||
| } | ||||
|  | ||||
| @ -22,6 +22,7 @@ | ||||
| #include <QJsonObject> | ||||
| 
 | ||||
| 
 | ||||
| #include <QString> | ||||
| 
 | ||||
| #include "SWGObject.h" | ||||
| #include "export.h" | ||||
| @ -92,6 +93,18 @@ public: | ||||
|     qint32 getGpioPins(); | ||||
|     void setGpioPins(qint32 gpio_pins); | ||||
| 
 | ||||
|     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; | ||||
| 
 | ||||
| @ -147,6 +160,18 @@ private: | ||||
|     qint32 gpio_pins; | ||||
|     bool m_gpio_pins_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; | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user