| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-18 06:36:53 +01:00
										 |  |  | // Copyright (C) 2017-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>          //
 | 
					
						
							|  |  |  | // Copyright (C) 2020 Kacper Michajłow <kasper93@gmail.com>                      //
 | 
					
						
							|  |  |  | // Copyright (C) 2022 Jiří Pinkava <jiri.pinkava@rossum.ai>                      //
 | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is free software; you can redistribute it and/or modify          //
 | 
					
						
							|  |  |  | // it under the terms of the GNU General Public License as published by          //
 | 
					
						
							|  |  |  | // the Free Software Foundation as version 3 of the License, or                  //
 | 
					
						
							| 
									
										
										
										
											2019-04-11 06:39:30 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful,               //
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
					
						
							|  |  |  | // GNU General Public License V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  | #include <QNetworkAccessManager>
 | 
					
						
							|  |  |  | #include <QNetworkReply>
 | 
					
						
							|  |  |  | #include <QBuffer>
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | #include <QThread>
 | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | #include "SWGChannelSettings.h"
 | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  | #include "SWGWorkspaceInfo.h"
 | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | #include "SWGChannelReport.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  | #include "SWGUDPSourceReport.h"
 | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  | #include "device/deviceapi.h"
 | 
					
						
							| 
									
										
										
										
											2018-02-14 20:11:36 +01:00
										 |  |  | #include "dsp/dspcommands.h"
 | 
					
						
							| 
									
										
										
										
											2017-08-17 04:23:36 +02:00
										 |  |  | #include "util/db.h"
 | 
					
						
							| 
									
										
										
										
											2020-10-23 00:11:18 +02:00
										 |  |  | #include "maincore.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-17 23:45:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | #include "udpsourcebaseband.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | #include "udpsource.h"
 | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 15:46:42 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(UDPSource::MsgConfigureUDPSource, Message) | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(UDPSource::MsgConfigureChannelizer, Message) | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-21 20:24:18 +01:00
										 |  |  | const char* const UDPSource::m_channelIdURI = "sdrangel.channeltx.udpsource"; | 
					
						
							|  |  |  | const char* const UDPSource::m_channelId = "UDPSource"; | 
					
						
							| 
									
										
										
										
											2017-11-08 17:09:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  | UDPSource::UDPSource(DeviceAPI *deviceAPI) : | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |     ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource), | 
					
						
							| 
									
										
										
										
											2017-10-17 21:08:54 +02:00
										 |  |  |     m_deviceAPI(deviceAPI), | 
					
						
							| 
									
										
										
										
											2022-09-15 21:59:42 +02:00
										 |  |  |     m_spectrumVis(SDR_TX_SCALEF) | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  |     setObjectName(m_channelId); | 
					
						
							| 
									
										
										
										
											2017-10-17 23:45:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     m_thread = new QThread(this); | 
					
						
							|  |  |  |     m_basebandSource = new UDPSourceBaseband(); | 
					
						
							| 
									
										
										
										
											2020-04-30 09:57:05 +02:00
										 |  |  |     m_basebandSource->setSpectrumSink(&m_spectrumVis); | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     m_basebandSource->moveToThread(m_thread); | 
					
						
							| 
									
										
										
										
											2017-11-06 01:39:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-16 10:26:49 +01:00
										 |  |  |     applySettings(m_settings, true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     m_deviceAPI->addChannelSource(this); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |     m_deviceAPI->addChannelSourceAPI(this); | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_networkManager = new QNetworkAccessManager(); | 
					
						
							| 
									
										
										
										
											2022-03-23 22:32:23 +01:00
										 |  |  |     QObject::connect( | 
					
						
							|  |  |  |         m_networkManager, | 
					
						
							|  |  |  |         &QNetworkAccessManager::finished, | 
					
						
							|  |  |  |         this, | 
					
						
							|  |  |  |         &UDPSource::networkManagerFinished | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | UDPSource::~UDPSource() | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-23 22:32:23 +01:00
										 |  |  |     QObject::disconnect( | 
					
						
							|  |  |  |         m_networkManager, | 
					
						
							|  |  |  |         &QNetworkAccessManager::finished, | 
					
						
							|  |  |  |         this, | 
					
						
							|  |  |  |         &UDPSource::networkManagerFinished | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     delete m_networkManager; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |     m_deviceAPI->removeChannelSourceAPI(this); | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     m_deviceAPI->removeChannelSource(this); | 
					
						
							|  |  |  |     delete m_basebandSource; | 
					
						
							|  |  |  |     delete m_thread; | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-16 16:45:53 +02:00
										 |  |  | void UDPSource::setDeviceAPI(DeviceAPI *deviceAPI) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (deviceAPI != m_deviceAPI) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_deviceAPI->removeChannelSourceAPI(this); | 
					
						
							|  |  |  |         m_deviceAPI->removeChannelSource(this); | 
					
						
							|  |  |  |         m_deviceAPI = deviceAPI; | 
					
						
							|  |  |  |         m_deviceAPI->addChannelSource(this); | 
					
						
							|  |  |  |         m_deviceAPI->addChannelSinkAPI(this); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | void UDPSource::start() | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | 	qDebug("UDPSource::start"); | 
					
						
							|  |  |  |     m_basebandSource->reset(); | 
					
						
							|  |  |  |     m_thread->start(); | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | void UDPSource::stop() | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     qDebug("UDPSource::stop"); | 
					
						
							|  |  |  | 	m_thread->exit(); | 
					
						
							|  |  |  | 	m_thread->wait(); | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | void UDPSource::pull(SampleVector::iterator& begin, unsigned int nbSamples) | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     m_basebandSource->pull(begin, nbSamples); | 
					
						
							| 
									
										
										
										
											2017-08-16 23:37:01 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-06 22:47:41 +01:00
										 |  |  | void UDPSource::setCenterFrequency(qint64 frequency) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     UDPSourceSettings settings = m_settings; | 
					
						
							|  |  |  |     settings.m_inputFrequencyOffset = frequency; | 
					
						
							|  |  |  |     applySettings(settings, false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_guiMessageQueue) // forward to GUI if any
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         MsgConfigureUDPSource *msgToGUI = MsgConfigureUDPSource::create(settings, false); | 
					
						
							|  |  |  |         m_guiMessageQueue->push(msgToGUI); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | bool UDPSource::handleMessage(const Message& cmd) | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     if (MsgConfigureChannelizer::match(cmd)) | 
					
						
							| 
									
										
										
										
											2017-10-16 23:04:53 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd; | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |         qDebug() << "AMMod::handleMessage: MsgConfigureChannelizer:" | 
					
						
							|  |  |  |                 << " getSourceSampleRate: " << cfg.getSourceSampleRate() | 
					
						
							|  |  |  |                 << " getSourceCenterFrequency: " << cfg.getSourceCenterFrequency(); | 
					
						
							| 
									
										
										
										
											2017-10-16 23:04:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |         UDPSourceBaseband::MsgConfigureChannelizer *msg | 
					
						
							|  |  |  |             = UDPSourceBaseband::MsgConfigureChannelizer::create(cfg.getSourceSampleRate(), cfg.getSourceCenterFrequency()); | 
					
						
							|  |  |  |         m_basebandSource->getInputMessageQueue()->push(msg); | 
					
						
							| 
									
										
										
										
											2017-10-16 23:04:53 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-09-12 15:46:42 +02:00
										 |  |  |     else if (MsgConfigureUDPSource::match(cmd)) | 
					
						
							| 
									
										
										
										
											2017-10-16 23:04:53 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-09-12 15:46:42 +02:00
										 |  |  |         MsgConfigureUDPSource& cfg = (MsgConfigureUDPSource&) cmd; | 
					
						
							|  |  |  |         qDebug() << "UDPSource::handleMessage: MsgConfigureUDPSource"; | 
					
						
							| 
									
										
										
										
											2017-10-16 23:04:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-30 00:30:41 +01:00
										 |  |  |         applySettings(cfg.getSettings(), cfg.getForce()); | 
					
						
							| 
									
										
										
										
											2017-10-16 23:04:53 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-02-14 20:11:36 +01:00
										 |  |  |     else if (DSPSignalNotification::match(cmd)) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |         // Forward to the source
 | 
					
						
							|  |  |  |         DSPSignalNotification& notif = (DSPSignalNotification&) cmd; | 
					
						
							|  |  |  |         DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy
 | 
					
						
							|  |  |  |         qDebug() << "UDPSource::handleMessage: DSPSignalNotification"; | 
					
						
							|  |  |  |         m_basebandSource->getInputMessageQueue()->push(rep); | 
					
						
							| 
									
										
										
										
											2022-04-13 11:08:21 +02:00
										 |  |  |         // Forward to GUI if any
 | 
					
						
							|  |  |  |         if (getMessageQueueToGUI()) { | 
					
						
							|  |  |  |             getMessageQueueToGUI()->push(new DSPSignalNotification(notif)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-14 20:11:36 +01:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |         return false; | 
					
						
							| 
									
										
										
										
											2017-08-14 01:39:26 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | void UDPSource::setSpectrum(bool enabled) | 
					
						
							| 
									
										
										
										
											2017-08-18 17:51:11 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     Message* cmd = UDPSourceBaseband::MsgUDPSourceSpectrum::create(enabled); | 
					
						
							|  |  |  |     m_basebandSource->getInputMessageQueue()->push(cmd); | 
					
						
							| 
									
										
										
										
											2017-08-18 17:51:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | void UDPSource::resetReadIndex() | 
					
						
							| 
									
										
										
										
											2017-10-16 22:22:29 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     Message* cmd = UDPSourceBaseband::MsgResetReadIndex::create(); | 
					
						
							|  |  |  |     m_basebandSource->getInputMessageQueue()->push(cmd); | 
					
						
							| 
									
										
										
										
											2017-12-30 00:30:41 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | void UDPSource::applySettings(const UDPSourceSettings& settings, bool force) | 
					
						
							| 
									
										
										
										
											2017-12-30 00:30:41 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  |     qDebug() << "UDPSource::applySettings:" | 
					
						
							| 
									
										
										
										
											2017-12-30 00:30:41 +01:00
										 |  |  |             << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset | 
					
						
							|  |  |  |             << " m_sampleFormat: " << settings.m_sampleFormat | 
					
						
							|  |  |  |             << " m_inputSampleRate: " << settings.m_inputSampleRate | 
					
						
							|  |  |  |             << " m_rfBandwidth: " << settings.m_rfBandwidth | 
					
						
							| 
									
										
										
										
											2018-08-16 01:05:19 +02:00
										 |  |  |             << " m_lowCutoff: " << settings.m_lowCutoff | 
					
						
							| 
									
										
										
										
											2017-12-30 00:30:41 +01:00
										 |  |  |             << " m_fmDeviation: " << settings.m_fmDeviation | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |             << " m_amModFactor: " << settings.m_amModFactor | 
					
						
							| 
									
										
										
										
											2017-12-30 00:30:41 +01:00
										 |  |  |             << " m_udpAddressStr: " << settings.m_udpAddress | 
					
						
							|  |  |  |             << " m_udpPort: " << settings.m_udpPort | 
					
						
							| 
									
										
										
										
											2020-08-24 19:56:04 +02:00
										 |  |  |             << " m_multicastAddress: " << settings.m_multicastAddress | 
					
						
							|  |  |  |             << " m_multicastJoin: " << settings.m_multicastJoin | 
					
						
							| 
									
										
										
										
											2017-12-30 00:30:41 +01:00
										 |  |  |             << " m_channelMute: " << settings.m_channelMute | 
					
						
							|  |  |  |             << " m_gainIn: " << settings.m_gainIn | 
					
						
							|  |  |  |             << " m_gainOut: " << settings.m_gainOut | 
					
						
							|  |  |  |             << " m_squelchGate: " << settings.m_squelchGate | 
					
						
							|  |  |  |             << " m_squelch: " << settings.m_squelch << "dB" | 
					
						
							|  |  |  |             << " m_squelchEnabled: " << settings.m_squelchEnabled | 
					
						
							|  |  |  |             << " m_autoRWBalance: " << settings.m_autoRWBalance | 
					
						
							|  |  |  |             << " m_stereoInput: " << settings.m_stereoInput | 
					
						
							|  |  |  |             << " force: " << force; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     QList<QString> reverseAPIKeys; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("inputFrequencyOffset"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_sampleFormat != m_settings.m_sampleFormat) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("sampleFormat"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-05-05 03:24:10 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |         reverseAPIKeys.append("inputSampleRate"); | 
					
						
							| 
									
										
										
										
											2020-05-05 03:24:10 +02:00
										 |  |  |         DSPSignalNotification *msg = new DSPSignalNotification(settings.m_inputSampleRate, 0); | 
					
						
							|  |  |  |         m_spectrumVis.getInputMessageQueue()->push(msg); | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-05-05 03:24:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("rfBandwidth"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_lowCutoff != m_settings.m_lowCutoff) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("lowCutoff"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_fmDeviation != m_settings.m_fmDeviation) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("fmDeviation"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_amModFactor != m_settings.m_amModFactor) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("amModFactor"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_udpAddress != m_settings.m_udpAddress) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("udpAddress"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_udpPort != m_settings.m_udpPort) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("udpPort"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-24 19:56:04 +02:00
										 |  |  |     if ((settings.m_multicastAddress != m_settings.m_multicastAddress) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("multicastAddress"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_multicastJoin != m_settings.m_multicastJoin) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("multicastJoin"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     if ((settings.m_channelMute != m_settings.m_channelMute) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("channelMute"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_gainIn != m_settings.m_gainIn) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("gainIn"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_gainOut != m_settings.m_gainOut) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("gainOut"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_squelchGate != m_settings.m_squelchGate) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("squelchGate"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_squelch != m_settings.m_squelch) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("squelch"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_squelchEnabled != m_settings.m_squelchEnabled) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("squelchEnabled"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_autoRWBalance != m_settings.m_autoRWBalance) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("autoRWBalance"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if ((settings.m_stereoInput != m_settings.m_stereoInput) || force) { | 
					
						
							|  |  |  |         reverseAPIKeys.append("stereoInput"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-19 01:22:55 +01:00
										 |  |  |     if (m_settings.m_streamIndex != settings.m_streamIndex) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-12-23 23:41:35 +01:00
										 |  |  |             m_deviceAPI->removeChannelSourceAPI(this); | 
					
						
							| 
									
										
										
										
											2019-11-19 01:22:55 +01:00
										 |  |  |             m_deviceAPI->removeChannelSource(this, m_settings.m_streamIndex); | 
					
						
							|  |  |  |             m_deviceAPI->addChannelSource(this, settings.m_streamIndex); | 
					
						
							| 
									
										
										
										
											2019-12-23 23:41:35 +01:00
										 |  |  |             m_deviceAPI->addChannelSourceAPI(this); | 
					
						
							| 
									
										
										
										
											2023-12-14 21:57:10 +01:00
										 |  |  |             m_settings.m_streamIndex = settings.m_streamIndex; // make sure ChannelAPI::getStreamIndex() is consistent
 | 
					
						
							|  |  |  |             emit streamIndexChanged(settings.m_streamIndex); | 
					
						
							| 
									
										
										
										
											2019-11-19 01:22:55 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         reverseAPIKeys.append("streamIndex"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     UDPSourceBaseband::MsgConfigureUDPSourceBaseband *msg = UDPSourceBaseband::MsgConfigureUDPSourceBaseband::create(settings, force); | 
					
						
							|  |  |  |     m_basebandSource->getInputMessageQueue()->push(msg); | 
					
						
							| 
									
										
										
										
											2017-10-16 22:22:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     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) || | 
					
						
							|  |  |  |                 (m_settings.m_reverseAPIChannelIndex != settings.m_reverseAPIChannelIndex); | 
					
						
							|  |  |  |         webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-02 23:07:15 +01:00
										 |  |  |     QList<ObjectPipe*> pipes; | 
					
						
							| 
									
										
										
										
											2022-03-02 23:57:35 +01:00
										 |  |  |     MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes); | 
					
						
							| 
									
										
										
										
											2020-12-13 13:04:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-02 23:07:15 +01:00
										 |  |  |     if (pipes.size() > 0) { | 
					
						
							|  |  |  |         sendChannelSettings(pipes, reverseAPIKeys, settings, force); | 
					
						
							| 
									
										
										
										
											2020-10-23 00:11:18 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-16 22:22:29 +02:00
										 |  |  |     m_settings = settings; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | QByteArray UDPSource::serialize() const | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return m_settings.serialize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | bool UDPSource::deserialize(const QByteArray& data) | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (m_settings.deserialize(data)) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-09-12 15:46:42 +02:00
										 |  |  |         MsgConfigureUDPSource *msg = MsgConfigureUDPSource::create(m_settings, true); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |         m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.resetToDefaults(); | 
					
						
							| 
									
										
										
										
											2018-09-12 15:46:42 +02:00
										 |  |  |         MsgConfigureUDPSource *msg = MsgConfigureUDPSource::create(m_settings, true); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |         m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | int UDPSource::webapiSettingsGet( | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |         SWGSDRangel::SWGChannelSettings& response, | 
					
						
							| 
									
										
										
										
											2018-11-13 08:51:14 +01:00
										 |  |  |         QString& errorMessage) | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-13 08:51:14 +01:00
										 |  |  |     (void) errorMessage; | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |     response.setUdpSourceSettings(new SWGSDRangel::SWGUDPSourceSettings()); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->init(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     webapiFormatChannelSettings(response, m_settings); | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  | int UDPSource::webapiWorkspaceGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGWorkspaceInfo& response, | 
					
						
							|  |  |  |         QString& errorMessage) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     (void) errorMessage; | 
					
						
							|  |  |  |     response.setIndex(m_settings.m_workspaceIndex); | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | int UDPSource::webapiSettingsPutPatch( | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |                 bool force, | 
					
						
							|  |  |  |                 const QStringList& channelSettingsKeys, | 
					
						
							|  |  |  |                 SWGSDRangel::SWGChannelSettings& response, | 
					
						
							| 
									
										
										
										
											2018-11-13 08:51:14 +01:00
										 |  |  |                 QString& errorMessage) | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-13 08:51:14 +01:00
										 |  |  |     (void) errorMessage; | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  |     UDPSourceSettings settings = m_settings; | 
					
						
							| 
									
										
										
										
											2019-08-01 23:21:57 +02:00
										 |  |  |     webapiUpdateChannelSettings(settings, channelSettingsKeys, response); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 23:21:57 +02:00
										 |  |  |     if (m_settings.m_inputFrequencyOffset != settings.m_inputFrequencyOffset) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         UDPSource::MsgConfigureChannelizer *msgChan = UDPSource::MsgConfigureChannelizer::create( | 
					
						
							|  |  |  |                 settings.m_inputSampleRate, | 
					
						
							|  |  |  |                 settings.m_inputFrequencyOffset); | 
					
						
							|  |  |  |         m_inputMessageQueue.push(msgChan); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MsgConfigureUDPSource *msg = MsgConfigureUDPSource::create(settings, force); | 
					
						
							|  |  |  |     m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_guiMessageQueue) // forward to GUI if any
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         MsgConfigureUDPSource *msgToGUI = MsgConfigureUDPSource::create(settings, force); | 
					
						
							|  |  |  |         m_guiMessageQueue->push(msgToGUI); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     webapiFormatChannelSettings(response, settings); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void UDPSource::webapiUpdateChannelSettings( | 
					
						
							|  |  |  |         UDPSourceSettings& settings, | 
					
						
							|  |  |  |         const QStringList& channelSettingsKeys, | 
					
						
							|  |  |  |         SWGSDRangel::SWGChannelSettings& response) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     if (channelSettingsKeys.contains("sampleFormat")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_sampleFormat = (UDPSourceSettings::SampleFormat) response.getUdpSourceSettings()->getSampleFormat(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("inputSampleRate")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_inputSampleRate = response.getUdpSourceSettings()->getInputSampleRate(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-08-01 23:21:57 +02:00
										 |  |  |     if (channelSettingsKeys.contains("inputFrequencyOffset")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_inputFrequencyOffset = response.getUdpSourceSettings()->getInputFrequencyOffset(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("rfBandwidth")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_rfBandwidth = response.getUdpSourceSettings()->getRfBandwidth(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("lowCutoff")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_lowCutoff = response.getUdpSourceSettings()->getLowCutoff(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("fmDeviation")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_fmDeviation = response.getUdpSourceSettings()->getFmDeviation(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("amModFactor")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_amModFactor = response.getUdpSourceSettings()->getAmModFactor(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("channelMute")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_channelMute = response.getUdpSourceSettings()->getChannelMute() != 0; | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("gainIn")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_gainIn = response.getUdpSourceSettings()->getGainIn(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("gainOut")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_gainOut = response.getUdpSourceSettings()->getGainOut(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("squelch")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_squelch = response.getUdpSourceSettings()->getSquelch(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("squelchGate")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_squelchGate = response.getUdpSourceSettings()->getSquelchGate(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("squelchEnabled")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_squelchEnabled = response.getUdpSourceSettings()->getSquelchEnabled() != 0; | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("autoRWBalance")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_autoRWBalance = response.getUdpSourceSettings()->getAutoRwBalance() != 0; | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("stereoInput")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_stereoInput = response.getUdpSourceSettings()->getStereoInput() != 0; | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("rgbColor")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_rgbColor = response.getUdpSourceSettings()->getRgbColor(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("udpAddress")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_udpAddress = *response.getUdpSourceSettings()->getUdpAddress(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("udpPort")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_udpPort = response.getUdpSourceSettings()->getUdpPort(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-24 23:55:26 +02:00
										 |  |  |     if (channelSettingsKeys.contains("multicastAddress")) { | 
					
						
							|  |  |  |         settings.m_multicastAddress = *response.getUdpSourceSettings()->getMulticastAddress(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("multicastJoin")) { | 
					
						
							|  |  |  |         settings.m_multicastJoin = response.getUdpSourceSettings()->getMulticastJoin() != 0; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     if (channelSettingsKeys.contains("title")) { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         settings.m_title = *response.getUdpSourceSettings()->getTitle(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-11-17 11:09:07 +01:00
										 |  |  |     if (channelSettingsKeys.contains("streamIndex")) { | 
					
						
							|  |  |  |         settings.m_streamIndex = response.getUdpSourceSettings()->getStreamIndex(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     if (channelSettingsKeys.contains("useReverseAPI")) { | 
					
						
							|  |  |  |         settings.m_useReverseAPI = response.getUdpSourceSettings()->getUseReverseApi() != 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("reverseAPIAddress")) { | 
					
						
							| 
									
										
										
										
											2019-04-20 19:53:16 +02:00
										 |  |  |         settings.m_reverseAPIAddress = *response.getUdpSourceSettings()->getReverseApiAddress(); | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("reverseAPIPort")) { | 
					
						
							|  |  |  |         settings.m_reverseAPIPort = response.getUdpSourceSettings()->getReverseApiPort(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) { | 
					
						
							|  |  |  |         settings.m_reverseAPIDeviceIndex = response.getUdpSourceSettings()->getReverseApiDeviceIndex(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("reverseAPIChannelIndex")) { | 
					
						
							|  |  |  |         settings.m_reverseAPIChannelIndex = response.getUdpSourceSettings()->getReverseApiChannelIndex(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-12-01 00:20:14 +01:00
										 |  |  |     if (settings.m_spectrumGUI && channelSettingsKeys.contains("spectrumConfig")) { | 
					
						
							|  |  |  |         settings.m_spectrumGUI->updateFrom(channelSettingsKeys, response.getUdpSourceSettings()->getSpectrumConfig()); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-12-03 22:32:54 +01:00
										 |  |  |     if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker")) { | 
					
						
							|  |  |  |         settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getUdpSourceSettings()->getChannelMarker()); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-09 05:27:12 +01:00
										 |  |  |     if (settings.m_rollupState && channelSettingsKeys.contains("rollupState")) { | 
					
						
							|  |  |  |         settings.m_rollupState->updateFrom(channelSettingsKeys, response.getUdpSourceSettings()->getRollupState()); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | int UDPSource::webapiReportGet( | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |         SWGSDRangel::SWGChannelReport& response, | 
					
						
							| 
									
										
										
										
											2018-11-13 08:51:14 +01:00
										 |  |  |         QString& errorMessage) | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-13 08:51:14 +01:00
										 |  |  |     (void) errorMessage; | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |     response.setUdpSourceReport(new SWGSDRangel::SWGUDPSourceReport()); | 
					
						
							|  |  |  |     response.getUdpSourceReport()->init(); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     webapiFormatChannelReport(response); | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | void UDPSource::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const UDPSourceSettings& settings) | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |     response.getUdpSourceSettings()->setSampleFormat((int) settings.m_sampleFormat); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setInputSampleRate(settings.m_inputSampleRate); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setRfBandwidth(settings.m_rfBandwidth); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setLowCutoff(settings.m_lowCutoff); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setFmDeviation(settings.m_fmDeviation); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setAmModFactor(settings.m_amModFactor); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setChannelMute(settings.m_channelMute ? 1 : 0); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setGainIn(settings.m_gainIn); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setGainOut(settings.m_gainOut); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setSquelch(settings.m_squelch); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setSquelchGate(settings.m_squelchGate); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setSquelchEnabled(settings.m_squelchEnabled ? 1 : 0); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setAutoRwBalance(settings.m_autoRWBalance ? 1 : 0); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setStereoInput(settings.m_stereoInput ? 1 : 0); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setRgbColor(settings.m_rgbColor); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (response.getUdpSourceSettings()->getUdpAddress()) { | 
					
						
							|  |  |  |         *response.getUdpSourceSettings()->getUdpAddress() = settings.m_udpAddress; | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         response.getUdpSourceSettings()->setUdpAddress(new QString(settings.m_udpAddress)); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |     response.getUdpSourceSettings()->setUdpPort(settings.m_udpPort); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-24 23:55:26 +02:00
										 |  |  |     if (response.getUdpSourceSettings()->getMulticastAddress()) { | 
					
						
							|  |  |  |         *response.getUdpSourceSettings()->getMulticastAddress() = settings.m_multicastAddress; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         response.getUdpSourceSettings()->setMulticastAddress(new QString(settings.m_multicastAddress)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setMulticastJoin(settings.m_multicastJoin ? 1 : 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |     if (response.getUdpSourceSettings()->getTitle()) { | 
					
						
							|  |  |  |         *response.getUdpSourceSettings()->getTitle() = settings.m_title; | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |         response.getUdpSourceSettings()->setTitle(new QString(settings.m_title)); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (response.getUdpSourceSettings()->getReverseApiAddress()) { | 
					
						
							|  |  |  |         *response.getUdpSourceSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         response.getUdpSourceSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setReverseApiPort(settings.m_reverseAPIPort); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex); | 
					
						
							|  |  |  |     response.getUdpSourceSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex); | 
					
						
							| 
									
										
										
										
											2021-12-01 00:20:14 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (settings.m_spectrumGUI) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (response.getUdpSourceSettings()->getSpectrumConfig()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             settings.m_spectrumGUI->formatTo(response.getUdpSourceSettings()->getSpectrumConfig()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum(); | 
					
						
							|  |  |  |             settings.m_spectrumGUI->formatTo(swgGLSpectrum); | 
					
						
							|  |  |  |             response.getUdpSourceSettings()->setSpectrumConfig(swgGLSpectrum); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-12-03 22:32:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (settings.m_channelMarker) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (response.getUdpSourceSettings()->getChannelMarker()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             settings.m_channelMarker->formatTo(response.getUdpSourceSettings()->getChannelMarker()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker(); | 
					
						
							|  |  |  |             settings.m_channelMarker->formatTo(swgChannelMarker); | 
					
						
							|  |  |  |             response.getUdpSourceSettings()->setChannelMarker(swgChannelMarker); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-09 05:27:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (settings.m_rollupState) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (response.getUdpSourceSettings()->getRollupState()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             settings.m_rollupState->formatTo(response.getUdpSourceSettings()->getRollupState()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState(); | 
					
						
							|  |  |  |             settings.m_rollupState->formatTo(swgRollupState); | 
					
						
							|  |  |  |             response.getUdpSourceSettings()->setRollupState(swgRollupState); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  | void UDPSource::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |     response.getUdpSourceReport()->setInputPowerDb(CalcDb::dbPower(getInMagSq())); | 
					
						
							|  |  |  |     response.getUdpSourceReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq())); | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     response.getUdpSourceReport()->setSquelch(m_basebandSource->isSquelchOpen() ? 1 : 0); | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |     response.getUdpSourceReport()->setBufferGauge(getBufferGauge()); | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     response.getUdpSourceReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate()); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void UDPSource::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const UDPSourceSettings& settings, bool force) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); | 
					
						
							| 
									
										
										
										
											2020-10-23 00:11:18 +02:00
										 |  |  |     webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") | 
					
						
							|  |  |  |             .arg(settings.m_reverseAPIAddress) | 
					
						
							|  |  |  |             .arg(settings.m_reverseAPIPort) | 
					
						
							|  |  |  |             .arg(settings.m_reverseAPIDeviceIndex) | 
					
						
							|  |  |  |             .arg(settings.m_reverseAPIChannelIndex); | 
					
						
							|  |  |  |     m_networkRequest.setUrl(QUrl(channelSettingsURL)); | 
					
						
							|  |  |  |     m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QBuffer *buffer = new QBuffer(); | 
					
						
							|  |  |  |     buffer->open((QBuffer::ReadWrite)); | 
					
						
							|  |  |  |     buffer->write(swgChannelSettings->asJson().toUtf8()); | 
					
						
							|  |  |  |     buffer->seek(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Always use PATCH to avoid passing reverse API settings
 | 
					
						
							|  |  |  |     QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer); | 
					
						
							|  |  |  |     buffer->setParent(reply); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     delete swgChannelSettings; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-13 13:04:36 +01:00
										 |  |  | void UDPSource::sendChannelSettings( | 
					
						
							| 
									
										
										
										
											2022-03-02 23:07:15 +01:00
										 |  |  |     const QList<ObjectPipe*>& pipes, | 
					
						
							| 
									
										
										
										
											2020-12-13 13:04:36 +01:00
										 |  |  |     QList<QString>& channelSettingsKeys, | 
					
						
							|  |  |  |     const UDPSourceSettings& settings, | 
					
						
							|  |  |  |     bool force) | 
					
						
							| 
									
										
										
										
											2020-10-23 00:11:18 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-02 23:07:15 +01:00
										 |  |  |     for (const auto& pipe : pipes) | 
					
						
							| 
									
										
										
										
											2020-10-23 00:11:18 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-02 23:07:15 +01:00
										 |  |  |         MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (messageQueue) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); | 
					
						
							|  |  |  |             webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force); | 
					
						
							|  |  |  |             MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create( | 
					
						
							|  |  |  |                 this, | 
					
						
							|  |  |  |                 channelSettingsKeys, | 
					
						
							|  |  |  |                 swgChannelSettings, | 
					
						
							|  |  |  |                 force | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |             messageQueue->push(msg); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-10-23 00:11:18 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void UDPSource::webapiFormatChannelSettings( | 
					
						
							|  |  |  |         QList<QString>& channelSettingsKeys, | 
					
						
							|  |  |  |         SWGSDRangel::SWGChannelSettings *swgChannelSettings, | 
					
						
							|  |  |  |         const UDPSourceSettings& settings, | 
					
						
							|  |  |  |         bool force | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-07 14:43:38 +02:00
										 |  |  |     swgChannelSettings->setDirection(1); // single source (Tx)
 | 
					
						
							| 
									
										
										
										
											2019-03-25 13:57:59 +01:00
										 |  |  |     swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet()); | 
					
						
							|  |  |  |     swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex()); | 
					
						
							| 
									
										
										
										
											2020-10-23 00:11:18 +02:00
										 |  |  |     swgChannelSettings->setChannelType(new QString(m_channelId)); | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     swgChannelSettings->setUdpSourceSettings(new SWGSDRangel::SWGUDPSourceSettings()); | 
					
						
							|  |  |  |     SWGSDRangel::SWGUDPSourceSettings *swgUDPSourceSettings = swgChannelSettings->getUdpSourceSettings(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // transfer data that has been modified. When force is on transfer all data except reverse API data
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("sampleFormat") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setSampleFormat((int) settings.m_sampleFormat); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("inputSampleRate") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setInputSampleRate(settings.m_inputSampleRate); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("inputFrequencyOffset") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("rfBandwidth") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setRfBandwidth(settings.m_rfBandwidth); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("lowCutoff") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setLowCutoff(settings.m_lowCutoff); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("fmDeviation") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setFmDeviation(settings.m_fmDeviation); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("amModFactor") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setAmModFactor(settings.m_amModFactor); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("channelMute") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setChannelMute(settings.m_channelMute ? 1 : 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("gainIn") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setGainIn(settings.m_gainIn); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("gainOut") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setGainOut(settings.m_gainOut); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("squelch") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setSquelch(settings.m_squelch); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("squelchGate") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setSquelchGate(settings.m_squelchGate); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("squelchEnabled") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setSquelchEnabled(settings.m_squelchEnabled ? 1 : 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("autoRWBalance") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setAutoRwBalance(settings.m_autoRWBalance ? 1 : 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("stereoInput") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setStereoInput(settings.m_stereoInput ? 1 : 0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("rgbColor") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setRgbColor(settings.m_rgbColor); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("udpAddress") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setUdpAddress(new QString(settings.m_udpAddress)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("udpPort") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setUdpPort(settings.m_udpPort); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-24 23:55:26 +02:00
										 |  |  |     if (channelSettingsKeys.contains("multicastAddress") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setMulticastAddress(new QString(settings.m_multicastAddress)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (channelSettingsKeys.contains("multicastJoin") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setMulticastJoin(settings.m_multicastJoin ? 1 : 0); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     if (channelSettingsKeys.contains("title") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setTitle(new QString(settings.m_title)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-11-17 11:09:07 +01:00
										 |  |  |     if (channelSettingsKeys.contains("streamIndex") || force) { | 
					
						
							|  |  |  |         swgUDPSourceSettings->setStreamIndex(settings.m_streamIndex); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-12-03 22:32:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 00:20:14 +01:00
										 |  |  |     if (settings.m_spectrumGUI && (channelSettingsKeys.contains("spectrunConfig") || force)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum(); | 
					
						
							|  |  |  |         settings.m_spectrumGUI->formatTo(swgGLSpectrum); | 
					
						
							|  |  |  |         swgUDPSourceSettings->setSpectrumConfig(swgGLSpectrum); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-12-03 22:32:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker(); | 
					
						
							|  |  |  |         settings.m_channelMarker->formatTo(swgChannelMarker); | 
					
						
							|  |  |  |         swgUDPSourceSettings->setChannelMarker(swgChannelMarker); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-09 05:27:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (settings.m_rollupState && (channelSettingsKeys.contains("rollupState") || force)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState(); | 
					
						
							|  |  |  |         settings.m_rollupState->formatTo(swgRollupState); | 
					
						
							|  |  |  |         swgUDPSourceSettings->setRollupState(swgRollupState); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void UDPSource::networkManagerFinished(QNetworkReply *reply) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QNetworkReply::NetworkError replyError = reply->error(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (replyError) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qWarning() << "UDPSource::networkManagerFinished:" | 
					
						
							|  |  |  |                 << " error(" << (int) replyError | 
					
						
							|  |  |  |                 << "): " << replyError | 
					
						
							|  |  |  |                 << ": " << reply->errorString(); | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QString answer = reply->readAll(); | 
					
						
							|  |  |  |         answer.chop(1); // remove last \n
 | 
					
						
							|  |  |  |         qDebug("UDPSource::networkManagerFinished: reply:\n%s", answer.toStdString().c_str()); | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  |     reply->deleteLater(); | 
					
						
							| 
									
										
										
										
											2018-12-21 17:10:55 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void UDPSource::setLevelMeter(QObject *levelMeter) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), levelMeter, SLOT(levelChanged(qreal, qreal, int))); | 
					
						
							| 
									
										
										
										
											2019-11-15 02:20:03 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | double UDPSource::getMagSq() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_basebandSource->getMagSq(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | double UDPSource::getInMagSq() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_basebandSource->getInMagSq(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int32_t UDPSource::getBufferGauge() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_basebandSource->getBufferGauge(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool UDPSource::getSquelchOpen() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_basebandSource->getSquelchOpen(); | 
					
						
							| 
									
										
										
										
											2019-11-17 11:09:07 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | uint32_t UDPSource::getNumberOfDeviceStreams() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_deviceAPI->getNbSinkStreams(); | 
					
						
							| 
									
										
										
										
											2020-10-23 00:11:18 +02:00
										 |  |  | } |