| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2017 Edouard Griffiths, F4EXB.                                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // Swagger server adapter interface                                              //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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 14:44:23 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01: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 <QCoreApplication>
 | 
					
						
							|  |  |  | #include <QList>
 | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  | #include <QTextStream>
 | 
					
						
							| 
									
										
										
										
											2018-01-07 01:33:57 +01:00
										 |  |  | #include <QSysInfo>
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | #include "SWGInstanceSummaryResponse.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-01 02:16:56 +02:00
										 |  |  | #include "SWGInstanceConfigResponse.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:31:53 +01:00
										 |  |  | #include "SWGInstanceDevicesResponse.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:36:27 +01:00
										 |  |  | #include "SWGInstanceChannelsResponse.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:39:31 +01:00
										 |  |  | #include "SWGLoggingInfo.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  | #include "SWGAudioDevices.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 22:35:48 +01:00
										 |  |  | #include "SWGLocationInformation.h"
 | 
					
						
							| 
									
										
										
										
											2019-07-21 09:47:11 +02:00
										 |  |  | #include "SWGDVSerialDevices.h"
 | 
					
						
							| 
									
										
										
										
											2019-07-21 01:57:51 +02:00
										 |  |  | #include "SWGAMBEDevices.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  | #include "SWGPresetImport.h"
 | 
					
						
							|  |  |  | #include "SWGPresetExport.h"
 | 
					
						
							|  |  |  | #include "SWGPresets.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  | #include "SWGPresetTransfer.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  | #include "SWGDeviceSettings.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  | #include "SWGDeviceActions.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  | #include "SWGChannelsDetail.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  | #include "SWGChannelSettings.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  | #include "SWGChannelReport.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  | #include "SWGChannelActions.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  | #include "SWGSuccessResponse.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | #include "SWGErrorResponse.h"
 | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  | #include "SWGDeviceState.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-28 10:06:17 +02:00
										 |  |  | #include "SWGDeviceReport.h"
 | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  | #include "SWGLimeRFEDevices.h"
 | 
					
						
							|  |  |  | #include "SWGLimeRFESettings.h"
 | 
					
						
							| 
									
										
										
										
											2020-01-14 15:26:49 +01:00
										 |  |  | #include "SWGLimeRFEPower.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | #include "maincore.h"
 | 
					
						
							|  |  |  | #include "loggerwithfile.h"
 | 
					
						
							|  |  |  | #include "device/deviceset.h"
 | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  | #include "device/deviceapi.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:31:53 +01:00
										 |  |  | #include "device/deviceenumerator.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | #include "dsp/devicesamplesink.h"
 | 
					
						
							|  |  |  | #include "dsp/devicesamplesource.h"
 | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  | #include "dsp/devicesamplemimo.h"
 | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  | #include "dsp/dspdevicesourceengine.h"
 | 
					
						
							|  |  |  | #include "dsp/dspdevicesinkengine.h"
 | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  | #include "dsp/dspdevicemimoengine.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  | #include "dsp/dspengine.h"
 | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  | #include "channel/channelapi.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:36:27 +01:00
										 |  |  | #include "plugin/pluginapi.h"
 | 
					
						
							|  |  |  | #include "plugin/pluginmanager.h"
 | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  | #include "util/serialutil.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-01 02:16:56 +02:00
										 |  |  | #include "webapi/webapiadapterbase.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | #include "webapiadaptersrv.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-24 23:05:16 +01:00
										 |  |  | #ifdef HAS_LIMERFEUSB
 | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  | #include "limerfe/limerfecontroller.h"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | WebAPIAdapterSrv::WebAPIAdapterSrv(MainCore& mainCore) : | 
					
						
							|  |  |  |     m_mainCore(mainCore) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | WebAPIAdapterSrv::~WebAPIAdapterSrv() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceSummary( | 
					
						
							|  |  |  |         SWGSDRangel::SWGInstanceSummaryResponse& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2018-01-22 23:29:09 +01:00
										 |  |  |     *response.getAppname() = QCoreApplication::applicationName(); | 
					
						
							|  |  |  |     *response.getVersion() = QCoreApplication::applicationVersion(); | 
					
						
							| 
									
										
										
										
											2017-12-18 13:19:20 +01:00
										 |  |  |     *response.getQtVersion() = QString(QT_VERSION_STR); | 
					
						
							| 
									
										
										
										
											2018-01-22 23:29:09 +01:00
										 |  |  |     response.setDspRxBits(SDR_RX_SAMP_SZ); | 
					
						
							|  |  |  |     response.setDspTxBits(SDR_TX_SAMP_SZ); | 
					
						
							|  |  |  |     response.setPid(QCoreApplication::applicationPid()); | 
					
						
							| 
									
										
										
										
											2018-01-07 01:33:57 +01:00
										 |  |  | #if QT_VERSION >= 0x050400
 | 
					
						
							|  |  |  |     *response.getArchitecture() = QString(QSysInfo::currentCpuArchitecture()); | 
					
						
							|  |  |  |     *response.getOs() = QString(QSysInfo::prettyProductName()); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     SWGSDRangel::SWGLoggingInfo *logging = response.getLogging(); | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     logging->init(); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |     logging->setDumpToFile(m_mainCore.m_logger->getUseFileLogger() ? 1 : 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (logging->getDumpToFile()) { | 
					
						
							|  |  |  |         m_mainCore.m_logger->getLogFileName(*logging->getFileName()); | 
					
						
							|  |  |  |         m_mainCore.m_logger->getFileMinMessageLevelStr(*logging->getFileLevel()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_logger->getConsoleMinMessageLevelStr(*logging->getConsoleLevel()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     SWGSDRangel::SWGDeviceSetList *deviceSetList = response.getDevicesetlist(); | 
					
						
							|  |  |  |     getDeviceSetList(deviceSetList); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceDelete( | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     MainCore::MsgDeleteInstance *msg = MainCore::MsgDeleteInstance::create(); | 
					
						
							|  |  |  |     m_mainCore.getInputMessageQueue()->push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-21 22:35:25 +01:00
										 |  |  |     *response.getMessage() = QString("Message to stop the SDRangel instance (MsgDeleteInstance) was submitted successfully"); | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return 202; | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 02:16:56 +02:00
										 |  |  | int WebAPIAdapterSrv::instanceConfigGet( | 
					
						
							|  |  |  |             SWGSDRangel::SWGInstanceConfigResponse& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  |     WebAPIAdapterBase webAPIAdapterBase; | 
					
						
							|  |  |  |     webAPIAdapterBase.setPluginManager(m_mainCore.getPluginManager()); | 
					
						
							| 
									
										
										
										
											2019-08-01 02:16:56 +02:00
										 |  |  |     SWGSDRangel::SWGPreferences *preferences = response.getPreferences(); | 
					
						
							|  |  |  |     WebAPIAdapterBase::webapiFormatPreferences(preferences, m_mainCore.getMainSettings().getPreferences()); | 
					
						
							|  |  |  |     SWGSDRangel::SWGPreset *workingPreset = response.getWorkingPreset(); | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  |     webAPIAdapterBase.webapiFormatPreset(workingPreset, m_mainCore.getMainSettings().getWorkingPresetConst()); | 
					
						
							| 
									
										
										
										
											2019-08-01 02:16:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     int nbPresets = m_mainCore.m_settings.getPresetCount(); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGPreset*> *swgPresets = response.getPresets(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < nbPresets; i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const Preset *preset = m_mainCore.m_settings.getPreset(i); | 
					
						
							|  |  |  |         swgPresets->append(new SWGSDRangel::SWGPreset); | 
					
						
							| 
									
										
										
										
											2019-08-01 18:50:21 +02:00
										 |  |  |         webAPIAdapterBase.webapiFormatPreset(swgPresets->back(), *preset); | 
					
						
							| 
									
										
										
										
											2019-08-01 02:16:56 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 10:54:45 +02:00
										 |  |  |     int nbCommands = m_mainCore.m_settings.getCommandCount(); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGCommand*> *swgCommands = response.getCommands(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < nbCommands; i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const Command *command = m_mainCore.m_settings.getCommand(i); | 
					
						
							|  |  |  |         swgCommands->append(new SWGSDRangel::SWGCommand); | 
					
						
							|  |  |  |         WebAPIAdapterBase::webapiFormatCommand(swgCommands->back(), *command); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 02:16:56 +02:00
										 |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-07 00:27:34 +02:00
										 |  |  | int WebAPIAdapterSrv::instanceConfigPutPatch( | 
					
						
							|  |  |  |         bool force, // PUT else PATCH
 | 
					
						
							|  |  |  |         SWGSDRangel::SWGInstanceConfigResponse& query, | 
					
						
							|  |  |  |         const ConfigKeys& configKeys, | 
					
						
							|  |  |  |         SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     WebAPIAdapterBase webAPIAdapterBase; | 
					
						
							|  |  |  |     webAPIAdapterBase.setPluginManager(m_mainCore.getPluginManager()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (force) { | 
					
						
							|  |  |  |         webAPIAdapterBase.webapiInitConfig(m_mainCore.m_settings); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 12:18:47 +02:00
										 |  |  |     Preferences newPreferences = m_mainCore.m_settings.getPreferences(); | 
					
						
							|  |  |  |     webAPIAdapterBase.webapiUpdatePreferences(query.getPreferences(), configKeys.m_preferencesKeys, newPreferences); | 
					
						
							|  |  |  |     m_mainCore.m_settings.setPreferences(newPreferences); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Preset *workingPreset = m_mainCore.m_settings.getWorkingPreset(); | 
					
						
							|  |  |  |     webAPIAdapterBase.webapiUpdatePreset(force, query.getWorkingPreset(), configKeys.m_workingPresetKeys, workingPreset); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<PresetKeys>::const_iterator presetKeysIt = configKeys.m_presetKeys.begin(); | 
					
						
							|  |  |  |     int i = 0; | 
					
						
							|  |  |  |     for (; presetKeysIt != configKeys.m_presetKeys.end(); ++presetKeysIt, i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         Preset *newPreset = new Preset(); // created with default values
 | 
					
						
							|  |  |  |         SWGSDRangel::SWGPreset *swgPreset = query.getPresets()->at(i); | 
					
						
							|  |  |  |         webAPIAdapterBase.webapiUpdatePreset(force, swgPreset, *presetKeysIt, newPreset); | 
					
						
							|  |  |  |         m_mainCore.m_settings.addPreset(newPreset); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<CommandKeys>::const_iterator commandKeysIt = configKeys.m_commandKeys.begin(); | 
					
						
							|  |  |  |     i = 0; | 
					
						
							|  |  |  |     for (; commandKeysIt != configKeys.m_commandKeys.end(); ++commandKeysIt, i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         Command *newCommand = new Command(); // created with default values
 | 
					
						
							|  |  |  |         SWGSDRangel::SWGCommand *swgCommand = query.getCommands()->at(i); | 
					
						
							|  |  |  |         webAPIAdapterBase.webapiUpdateCommand(swgCommand, *commandKeysIt, *newCommand); | 
					
						
							|  |  |  |         m_mainCore.m_settings.addCommand(newCommand); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MainCore::MsgApplySettings *msg = MainCore::MsgApplySettings::create(); | 
					
						
							|  |  |  |     m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-12 13:23:05 +02:00
										 |  |  |     return 200; | 
					
						
							| 
									
										
										
										
											2019-08-07 00:27:34 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:31:53 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceDevices( | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             int direction, | 
					
						
							| 
									
										
										
										
											2017-12-18 13:31:53 +01:00
										 |  |  |             SWGSDRangel::SWGInstanceDevicesResponse& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-18 13:31:53 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     int nbSamplingDevices; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (direction == 0) { // Single Rx stream device
 | 
					
						
							|  |  |  |         nbSamplingDevices = DeviceEnumerator::instance()->getNbRxSamplingDevices(); | 
					
						
							|  |  |  |     } else if (direction == 1) { // Single Tx stream device
 | 
					
						
							|  |  |  |         nbSamplingDevices = DeviceEnumerator::instance()->getNbTxSamplingDevices(); | 
					
						
							| 
									
										
										
										
											2019-12-24 19:08:11 +01:00
										 |  |  |     } else if (direction == 2) { // MIMO device
 | 
					
						
							|  |  |  |         nbSamplingDevices = DeviceEnumerator::instance()->getNbMIMOSamplingDevices(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |     } else { // not supported
 | 
					
						
							|  |  |  |         nbSamplingDevices = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:31:53 +01:00
										 |  |  |     response.setDevicecount(nbSamplingDevices); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGDeviceListItem*> *devices = response.getDevices(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < nbSamplingDevices; i++) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         const PluginInterface::SamplingDevice *samplingDevice = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (direction == 0) { | 
					
						
							|  |  |  |             samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(i); | 
					
						
							|  |  |  |         } else if (direction == 1) { | 
					
						
							|  |  |  |             samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(i); | 
					
						
							| 
									
										
										
										
											2019-12-24 19:08:11 +01:00
										 |  |  |         } else if (direction == 2) { | 
					
						
							|  |  |  |             samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(i); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:31:53 +01:00
										 |  |  |         devices->append(new SWGSDRangel::SWGDeviceListItem); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |         devices->back()->init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         *devices->back()->getDisplayedName() = samplingDevice->displayedName; | 
					
						
							|  |  |  |         *devices->back()->getHwType() = samplingDevice->hardwareId; | 
					
						
							|  |  |  |         *devices->back()->getSerial() = samplingDevice->serial; | 
					
						
							|  |  |  |         devices->back()->setSequence(samplingDevice->sequence); | 
					
						
							|  |  |  |         devices->back()->setDirection((int) samplingDevice->streamType); | 
					
						
							|  |  |  |         devices->back()->setDeviceNbStreams(samplingDevice->deviceNbItems); | 
					
						
							|  |  |  |         devices->back()->setDeviceSetIndex(samplingDevice->claimed); | 
					
						
							| 
									
										
										
										
											2017-12-18 13:31:53 +01:00
										 |  |  |         devices->back()->setIndex(i); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:36:27 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceChannels( | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             int direction, | 
					
						
							| 
									
										
										
										
											2017-12-18 13:36:27 +01:00
										 |  |  |             SWGSDRangel::SWGInstanceChannelsResponse& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-18 13:36:27 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |     PluginAPI::ChannelRegistrations *channelRegistrations; | 
					
						
							|  |  |  |     int nbChannelDevices; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (direction == 0) // Single sink (Rx) channel
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         channelRegistrations = m_mainCore.m_pluginManager->getRxChannelRegistrations(); | 
					
						
							|  |  |  |         nbChannelDevices = channelRegistrations->size(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (direction == 1) // Single source (Tx) channel
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         channelRegistrations = m_mainCore.m_pluginManager->getTxChannelRegistrations(); | 
					
						
							|  |  |  |         nbChannelDevices = channelRegistrations->size(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-12-23 23:00:11 +01:00
										 |  |  |     else if (direction == 2) // MIMO channel
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         channelRegistrations = m_mainCore.m_pluginManager->getMIMOChannelRegistrations(); | 
					
						
							|  |  |  |         nbChannelDevices = channelRegistrations->size(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |     else // not supported
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         channelRegistrations = nullptr; | 
					
						
							|  |  |  |         nbChannelDevices = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:36:27 +01:00
										 |  |  |     response.setChannelcount(nbChannelDevices); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGChannelListItem*> *channels = response.getChannels(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < nbChannelDevices; i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         channels->append(new SWGSDRangel::SWGChannelListItem); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |         channels->back()->init(); | 
					
						
							| 
									
										
										
										
											2017-12-18 13:36:27 +01:00
										 |  |  |         PluginInterface *channelInterface = channelRegistrations->at(i).m_plugin; | 
					
						
							|  |  |  |         const PluginDescriptor& pluginDescriptor = channelInterface->getPluginDescriptor(); | 
					
						
							|  |  |  |         *channels->back()->getVersion() = pluginDescriptor.version; | 
					
						
							|  |  |  |         *channels->back()->getName() = pluginDescriptor.displayedName; | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         channels->back()->setDirection(direction); | 
					
						
							| 
									
										
										
										
											2017-12-18 13:36:27 +01:00
										 |  |  |         *channels->back()->getIdUri() = channelRegistrations->at(i).m_channelIdURI; | 
					
						
							|  |  |  |         *channels->back()->getId() = channelRegistrations->at(i).m_channelId; | 
					
						
							|  |  |  |         channels->back()->setIndex(i); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:39:31 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceLoggingGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGLoggingInfo& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-18 13:39:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-18 13:39:31 +01:00
										 |  |  |     response.setDumpToFile(m_mainCore.m_logger->getUseFileLogger() ? 1 : 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (response.getDumpToFile()) { | 
					
						
							|  |  |  |     	m_mainCore.m_logger->getLogFileName(*response.getFileName()); | 
					
						
							|  |  |  |     	m_mainCore.m_logger->getFileMinMessageLevelStr(*response.getFileLevel()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_logger->getConsoleMinMessageLevelStr(*response.getConsoleLevel()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 14:50:58 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceLoggingPut( | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |         SWGSDRangel::SWGLoggingInfo& query, | 
					
						
							| 
									
										
										
										
											2017-12-18 14:50:58 +01:00
										 |  |  |         SWGSDRangel::SWGLoggingInfo& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-18 14:50:58 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     // response input is the query actually
 | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     bool dumpToFile = (query.getDumpToFile() != 0); | 
					
						
							|  |  |  |     QString* consoleLevel = query.getConsoleLevel(); | 
					
						
							|  |  |  |     QString* fileLevel = query.getFileLevel(); | 
					
						
							|  |  |  |     QString* fileName = query.getFileName(); | 
					
						
							| 
									
										
										
										
											2017-12-18 14:50:58 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // perform actions
 | 
					
						
							|  |  |  |     if (consoleLevel) { | 
					
						
							|  |  |  |     	m_mainCore.m_settings.setConsoleMinLogLevel(getMsgTypeFromString(*consoleLevel)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (fileLevel) { | 
					
						
							|  |  |  |     	m_mainCore.m_settings.setFileMinLogLevel(getMsgTypeFromString(*fileLevel)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_settings.setUseLogFile(dumpToFile); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (fileName) { | 
					
						
							|  |  |  |     	m_mainCore.m_settings.setLogFileName(*fileName); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.setLoggingOptions(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // build response
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-18 14:50:58 +01:00
										 |  |  |     getMsgTypeString(m_mainCore.m_settings.getConsoleMinLogLevel(), *response.getConsoleLevel()); | 
					
						
							|  |  |  |     response.setDumpToFile(m_mainCore.m_settings.getUseLogFile() ? 1 : 0); | 
					
						
							|  |  |  |     getMsgTypeString(m_mainCore.m_settings.getFileMinLogLevel(), *response.getFileLevel()); | 
					
						
							|  |  |  |     *response.getFileName() = m_mainCore.m_settings.getLogFileName(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceAudioGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGAudioDevices& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 18:08:38 +01:00
										 |  |  |     const QList<QAudioDeviceInfo>& audioInputDevices = m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDevices(); | 
					
						
							|  |  |  |     const QList<QAudioDeviceInfo>& audioOutputDevices = m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDevices(); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  |     int nbInputDevices = audioInputDevices.size(); | 
					
						
							|  |  |  |     int nbOutputDevices = audioOutputDevices.size(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  |     response.setNbInputDevices(nbInputDevices); | 
					
						
							|  |  |  |     response.setNbOutputDevices(nbOutputDevices); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     QList<SWGSDRangel::SWGAudioInputDevice*> *inputDevices = response.getInputDevices(); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGAudioOutputDevice*> *outputDevices = response.getOutputDevices(); | 
					
						
							|  |  |  |     AudioDeviceManager::InputDeviceInfo inputDeviceInfo; | 
					
						
							|  |  |  |     AudioDeviceManager::OutputDeviceInfo outputDeviceInfo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // system default input device
 | 
					
						
							|  |  |  |     inputDevices->append(new SWGSDRangel::SWGAudioInputDevice); | 
					
						
							|  |  |  |     inputDevices->back()->init(); | 
					
						
							|  |  |  |     bool found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, inputDeviceInfo); | 
					
						
							|  |  |  |     *inputDevices->back()->getName() = AudioDeviceManager::m_defaultDeviceName; | 
					
						
							|  |  |  |     inputDevices->back()->setIndex(-1); | 
					
						
							|  |  |  |     inputDevices->back()->setSampleRate(inputDeviceInfo.sampleRate); | 
					
						
							|  |  |  |     inputDevices->back()->setIsSystemDefault(0); | 
					
						
							|  |  |  |     inputDevices->back()->setDefaultUnregistered(found ? 0 : 1); | 
					
						
							|  |  |  |     inputDevices->back()->setVolume(inputDeviceInfo.volume); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // real input devices
 | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  |     for (int i = 0; i < nbInputDevices; i++) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         inputDevices->append(new SWGSDRangel::SWGAudioInputDevice); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |         inputDevices->back()->init(); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         inputDeviceInfo.resetToDefaults(); | 
					
						
							|  |  |  |         found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(audioInputDevices.at(i).deviceName(), inputDeviceInfo); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  |         *inputDevices->back()->getName() = audioInputDevices.at(i).deviceName(); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         inputDevices->back()->setIndex(i); | 
					
						
							|  |  |  |         inputDevices->back()->setSampleRate(inputDeviceInfo.sampleRate); | 
					
						
							|  |  |  |         inputDevices->back()->setIsSystemDefault(audioInputDevices.at(i).deviceName() == QAudioDeviceInfo::defaultInputDevice().deviceName() ? 1 : 0); | 
					
						
							|  |  |  |         inputDevices->back()->setDefaultUnregistered(found ? 0 : 1); | 
					
						
							|  |  |  |         inputDevices->back()->setVolume(inputDeviceInfo.volume); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     // system default output device
 | 
					
						
							|  |  |  |     outputDevices->append(new SWGSDRangel::SWGAudioOutputDevice); | 
					
						
							|  |  |  |     outputDevices->back()->init(); | 
					
						
							|  |  |  |     found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, outputDeviceInfo); | 
					
						
							|  |  |  |     *outputDevices->back()->getName() = AudioDeviceManager::m_defaultDeviceName; | 
					
						
							|  |  |  |     outputDevices->back()->setIndex(-1); | 
					
						
							|  |  |  |     outputDevices->back()->setSampleRate(outputDeviceInfo.sampleRate); | 
					
						
							|  |  |  |     inputDevices->back()->setIsSystemDefault(0); | 
					
						
							|  |  |  |     outputDevices->back()->setDefaultUnregistered(found ? 0 : 1); | 
					
						
							|  |  |  |     outputDevices->back()->setCopyToUdp(outputDeviceInfo.copyToUDP ? 1 : 0); | 
					
						
							|  |  |  |     outputDevices->back()->setUdpUsesRtp(outputDeviceInfo.udpUseRTP ? 1 : 0); | 
					
						
							|  |  |  |     outputDevices->back()->setUdpChannelMode((int) outputDeviceInfo.udpChannelMode); | 
					
						
							| 
									
										
										
										
											2019-02-15 12:10:01 +01:00
										 |  |  |     outputDevices->back()->setUdpChannelCodec((int) outputDeviceInfo.udpChannelCodec); | 
					
						
							|  |  |  |     outputDevices->back()->setUdpDecimationFactor(outputDeviceInfo.udpDecimationFactor); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     *outputDevices->back()->getUdpAddress() = outputDeviceInfo.udpAddress; | 
					
						
							|  |  |  |     outputDevices->back()->setUdpPort(outputDeviceInfo.udpPort); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // real output devices
 | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  |     for (int i = 0; i < nbOutputDevices; i++) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         outputDevices->append(new SWGSDRangel::SWGAudioOutputDevice); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |         outputDevices->back()->init(); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         outputDeviceInfo.resetToDefaults(); | 
					
						
							|  |  |  |         found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(audioOutputDevices.at(i).deviceName(), outputDeviceInfo); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  |         *outputDevices->back()->getName() = audioOutputDevices.at(i).deviceName(); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         outputDevices->back()->setIndex(i); | 
					
						
							|  |  |  |         outputDevices->back()->setSampleRate(outputDeviceInfo.sampleRate); | 
					
						
							|  |  |  |         outputDevices->back()->setIsSystemDefault(audioOutputDevices.at(i).deviceName() == QAudioDeviceInfo::defaultOutputDevice().deviceName() ? 1 : 0); | 
					
						
							|  |  |  |         outputDevices->back()->setDefaultUnregistered(found ? 0 : 1); | 
					
						
							|  |  |  |         outputDevices->back()->setCopyToUdp(outputDeviceInfo.copyToUDP ? 1 : 0); | 
					
						
							|  |  |  |         outputDevices->back()->setUdpUsesRtp(outputDeviceInfo.udpUseRTP ? 1 : 0); | 
					
						
							|  |  |  |         outputDevices->back()->setUdpChannelMode((int) outputDeviceInfo.udpChannelMode); | 
					
						
							| 
									
										
										
										
											2019-02-15 12:10:01 +01:00
										 |  |  |         outputDevices->back()->setUdpChannelCodec((int) outputDeviceInfo.udpChannelCodec); | 
					
						
							|  |  |  |         outputDevices->back()->setUdpDecimationFactor(outputDeviceInfo.udpDecimationFactor); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         *outputDevices->back()->getUdpAddress() = outputDeviceInfo.udpAddress; | 
					
						
							|  |  |  |         outputDevices->back()->setUdpPort(outputDeviceInfo.udpPort); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  | int WebAPIAdapterSrv::instanceAudioInputPatch( | 
					
						
							|  |  |  |         SWGSDRangel::SWGAudioInputDevice& response, | 
					
						
							|  |  |  |         const QStringList& audioInputKeys, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     // TODO
 | 
					
						
							|  |  |  |     AudioDeviceManager::InputDeviceInfo inputDeviceInfo; | 
					
						
							|  |  |  |     QString deviceName; | 
					
						
							|  |  |  |     int deviceIndex = response.getIndex(); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceName(deviceIndex, deviceName)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no input audio device at index %1").arg(deviceIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (audioInputKeys.contains("sampleRate")) { | 
					
						
							|  |  |  |         inputDeviceInfo.sampleRate = response.getSampleRate(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (audioInputKeys.contains("volume")) { | 
					
						
							|  |  |  |         inputDeviceInfo.volume = response.getVolume(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->setInputDeviceInfo(deviceIndex, inputDeviceInfo); | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.setSampleRate(inputDeviceInfo.sampleRate); | 
					
						
							|  |  |  |     response.setVolume(inputDeviceInfo.volume); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceAudioOutputPatch( | 
					
						
							|  |  |  |         SWGSDRangel::SWGAudioOutputDevice& response, | 
					
						
							|  |  |  |         const QStringList& audioOutputKeys, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     AudioDeviceManager::OutputDeviceInfo outputDeviceInfo; | 
					
						
							|  |  |  |     QString deviceName; | 
					
						
							|  |  |  |     int deviceIndex = response.getIndex(); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceName(deviceIndex, deviceName)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no output audio device at index %1").arg(deviceIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (audioOutputKeys.contains("sampleRate")) { | 
					
						
							|  |  |  |         outputDeviceInfo.sampleRate = response.getSampleRate(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (audioOutputKeys.contains("copyToUDP")) { | 
					
						
							|  |  |  |         outputDeviceInfo.copyToUDP = response.getCopyToUdp() == 0 ? 0 : 1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (audioOutputKeys.contains("udpUsesRTP")) { | 
					
						
							|  |  |  |         outputDeviceInfo.udpUseRTP = response.getUdpUsesRtp() == 0 ? 0 : 1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (audioOutputKeys.contains("udpChannelMode")) { | 
					
						
							|  |  |  |         outputDeviceInfo.udpChannelMode = static_cast<AudioOutput::UDPChannelMode>(response.getUdpChannelMode() % 4); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (audioOutputKeys.contains("udpAddress")) { | 
					
						
							|  |  |  |         outputDeviceInfo.udpAddress = *response.getUdpAddress(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (audioOutputKeys.contains("udpPort")) { | 
					
						
							|  |  |  |         outputDeviceInfo.udpPort = response.getUdpPort() % (1<<16); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->setOutputDeviceInfo(deviceIndex, outputDeviceInfo); | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.setSampleRate(outputDeviceInfo.sampleRate); | 
					
						
							|  |  |  |     response.setCopyToUdp(outputDeviceInfo.copyToUDP == 0 ? 0 : 1); | 
					
						
							|  |  |  |     response.setUdpUsesRtp(outputDeviceInfo.udpUseRTP == 0 ? 0 : 1); | 
					
						
							| 
									
										
										
										
											2019-02-15 12:10:01 +01:00
										 |  |  |     response.setUdpChannelMode(outputDeviceInfo.udpChannelMode); | 
					
						
							|  |  |  |     response.setUdpChannelCodec(outputDeviceInfo.udpChannelCodec); | 
					
						
							|  |  |  |     response.setUdpDecimationFactor(outputDeviceInfo.udpDecimationFactor); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (response.getUdpAddress()) { | 
					
						
							|  |  |  |         *response.getUdpAddress() = outputDeviceInfo.udpAddress; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         response.setUdpAddress(new QString(outputDeviceInfo.udpAddress)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     response.setUdpPort(outputDeviceInfo.udpPort % (1<<16)); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceAudioInputDelete( | 
					
						
							|  |  |  |             SWGSDRangel::SWGAudioInputDevice& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     AudioDeviceManager::InputDeviceInfo inputDeviceInfo; | 
					
						
							|  |  |  |     QString deviceName; | 
					
						
							|  |  |  |     int deviceIndex = response.getIndex(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceName(deviceIndex, deviceName)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no audio input device at index %1").arg(deviceIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->unsetInputDeviceInfo(deviceIndex); | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.setSampleRate(inputDeviceInfo.sampleRate); | 
					
						
							|  |  |  |     response.setVolume(inputDeviceInfo.volume); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceAudioOutputDelete( | 
					
						
							|  |  |  |             SWGSDRangel::SWGAudioOutputDevice& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     AudioDeviceManager::OutputDeviceInfo outputDeviceInfo; | 
					
						
							|  |  |  |     QString deviceName; | 
					
						
							|  |  |  |     int deviceIndex = response.getIndex(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceName(deviceIndex, deviceName)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no audio output device at index %1").arg(deviceIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->unsetInputDeviceInfo(deviceIndex); | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.setSampleRate(outputDeviceInfo.sampleRate); | 
					
						
							|  |  |  |     response.setCopyToUdp(outputDeviceInfo.copyToUDP == 0 ? 0 : 1); | 
					
						
							|  |  |  |     response.setUdpUsesRtp(outputDeviceInfo.udpUseRTP == 0 ? 0 : 1); | 
					
						
							| 
									
										
										
										
											2019-02-15 12:10:01 +01:00
										 |  |  |     response.setUdpChannelMode(outputDeviceInfo.udpChannelMode); | 
					
						
							|  |  |  |     response.setUdpChannelCodec(outputDeviceInfo.udpChannelCodec); | 
					
						
							|  |  |  |     response.setUdpDecimationFactor(outputDeviceInfo.udpDecimationFactor); | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (response.getUdpAddress()) { | 
					
						
							|  |  |  |         *response.getUdpAddress() = outputDeviceInfo.udpAddress; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         response.setUdpAddress(new QString(outputDeviceInfo.udpAddress)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.setUdpPort(outputDeviceInfo.udpPort % (1<<16)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceAudioInputCleanupPatch( | 
					
						
							|  |  |  |             SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->inputInfosCleanup(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.init(); | 
					
						
							|  |  |  |     *response.getMessage() = QString("Unregistered parameters for devices not in list of available input devices for this instance"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceAudioOutputCleanupPatch( | 
					
						
							|  |  |  |             SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAudioDeviceManager()->outputInfosCleanup(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.init(); | 
					
						
							|  |  |  |     *response.getMessage() = QString("Unregistered parameters for devices not in list of available output devices for this instance"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 22:05:43 +01:00
										 |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 22:35:48 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceLocationGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGLocationInformation& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-18 22:35:48 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:35:48 +01:00
										 |  |  |     response.setLatitude(m_mainCore.m_settings.getLatitude()); | 
					
						
							|  |  |  |     response.setLongitude(m_mainCore.m_settings.getLongitude()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceLocationPut( | 
					
						
							|  |  |  |         SWGSDRangel::SWGLocationInformation& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-18 22:35:48 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     float latitude = response.getLatitude(); | 
					
						
							|  |  |  |     float longitude = response.getLongitude(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     latitude = latitude < -90.0 ? -90.0 : latitude > 90.0 ? 90.0 : latitude; | 
					
						
							|  |  |  |     longitude = longitude < -180.0 ? -180.0 : longitude > 180.0 ? 180.0 : longitude; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_mainCore.m_settings.setLatitude(latitude); | 
					
						
							|  |  |  |     m_mainCore.m_settings.setLongitude(longitude); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.setLatitude(m_mainCore.m_settings.getLatitude()); | 
					
						
							|  |  |  |     response.setLongitude(m_mainCore.m_settings.getLongitude()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-02 23:05:53 +02:00
										 |  |  | int WebAPIAdapterSrv::instanceDVSerialGet( | 
					
						
							| 
									
										
										
										
											2019-07-21 09:47:11 +02:00
										 |  |  |             SWGSDRangel::SWGDVSerialDevices& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2018-08-02 23:05:53 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     response.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<std::string> deviceNames; | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getDVSerialNames(deviceNames); | 
					
						
							|  |  |  |     response.setNbDevices((int) deviceNames.size()); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<std::string>::iterator it = deviceNames.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while (it != deviceNames.end()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         deviceNamesList->append(new SWGSDRangel::SWGDVSerialDevice); | 
					
						
							|  |  |  |         deviceNamesList->back()->init(); | 
					
						
							|  |  |  |         *deviceNamesList->back()->getDeviceName() = QString::fromStdString(*it); | 
					
						
							|  |  |  |         ++it; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 22:39:32 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceDVSerialPatch( | 
					
						
							|  |  |  |             bool dvserial, | 
					
						
							| 
									
										
										
										
											2019-07-21 09:47:11 +02:00
										 |  |  |             SWGSDRangel::SWGDVSerialDevices& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-18 22:39:32 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->setDVSerialSupport(dvserial); | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:39:32 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (dvserial) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         std::vector<std::string> deviceNames; | 
					
						
							|  |  |  |         m_mainCore.m_dspEngine->getDVSerialNames(deviceNames); | 
					
						
							|  |  |  |         response.setNbDevices((int) deviceNames.size()); | 
					
						
							|  |  |  |         QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         std::vector<std::string>::iterator it = deviceNames.begin(); | 
					
						
							|  |  |  |         std::string deviceNamesStr = "DV Serial devices found: "; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         while (it != deviceNames.end()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             deviceNamesList->append(new SWGSDRangel::SWGDVSerialDevice); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |             deviceNamesList->back()->init(); | 
					
						
							| 
									
										
										
										
											2017-12-18 22:39:32 +01:00
										 |  |  |             *deviceNamesList->back()->getDeviceName() = QString::fromStdString(*it); | 
					
						
							|  |  |  |             ++it; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setNbDevices(0); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-21 01:57:51 +02:00
										 |  |  | int WebAPIAdapterSrv::instanceAMBESerialGet( | 
					
						
							| 
									
										
										
										
											2019-07-21 09:47:11 +02:00
										 |  |  |         SWGSDRangel::SWGDVSerialDevices& response, | 
					
						
							| 
									
										
										
										
											2019-07-21 01:57:51 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     (void) error; | 
					
						
							|  |  |  |     response.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<std::string> deviceNames; | 
					
						
							|  |  |  |     std::vector<QString> qDeviceNames; | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAMBEEngine()->scan(qDeviceNames); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (std::vector<QString>::const_iterator it = qDeviceNames.begin(); it != qDeviceNames.end(); ++it) { | 
					
						
							|  |  |  |         deviceNames.push_back(it->toStdString()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.setNbDevices((int) deviceNames.size()); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<std::string>::iterator it = deviceNames.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while (it != deviceNames.end()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         deviceNamesList->append(new SWGSDRangel::SWGDVSerialDevice); | 
					
						
							|  |  |  |         deviceNamesList->back()->init(); | 
					
						
							|  |  |  |         *deviceNamesList->back()->getDeviceName() = QString::fromStdString(*it); | 
					
						
							|  |  |  |         ++it; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceAMBEDevicesGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGAMBEDevices& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     (void) error; | 
					
						
							|  |  |  |     response.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<std::string> deviceNames; | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getDVSerialNames(deviceNames); | 
					
						
							|  |  |  |     response.setNbDevices((int) deviceNames.size()); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGAMBEDevice*> *deviceNamesList = response.getAmbeDevices(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<std::string>::iterator it = deviceNames.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while (it != deviceNames.end()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         deviceNamesList->append(new SWGSDRangel::SWGAMBEDevice); | 
					
						
							|  |  |  |         deviceNamesList->back()->init(); | 
					
						
							|  |  |  |         *deviceNamesList->back()->getDeviceRef() = QString::fromStdString(*it); | 
					
						
							|  |  |  |         deviceNamesList->back()->setDelete(0); | 
					
						
							|  |  |  |         ++it; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceAMBEDevicesDelete( | 
					
						
							|  |  |  |             SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     (void) error; | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAMBEEngine()->releaseAll(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.init(); | 
					
						
							|  |  |  |     *response.getMessage() = QString("All AMBE devices released"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceAMBEDevicesPut( | 
					
						
							|  |  |  |         SWGSDRangel::SWGAMBEDevices& query, | 
					
						
							|  |  |  |         SWGSDRangel::SWGAMBEDevices& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_mainCore.m_dspEngine->getAMBEEngine()->releaseAll(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it) { | 
					
						
							|  |  |  |         m_mainCore.m_dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     instanceAMBEDevicesGet(response, error); | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceAMBEDevicesPatch( | 
					
						
							|  |  |  |         SWGSDRangel::SWGAMBEDevices& query, | 
					
						
							|  |  |  |         SWGSDRangel::SWGAMBEDevices& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if ((*it)->getDelete()) { | 
					
						
							|  |  |  |             m_mainCore.m_dspEngine->getAMBEEngine()->releaseController((*it)->getDeviceRef()->toStdString()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             m_mainCore.m_dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     instanceAMBEDevicesGet(response, error); | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-24 23:05:16 +01:00
										 |  |  | #ifdef HAS_LIMERFEUSB
 | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceLimeRFESerialGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGLimeRFEDevices& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     (void) error; | 
					
						
							|  |  |  |     std::vector<std::string> comPorts; | 
					
						
							|  |  |  |     SerialUtil::getComPorts(comPorts, "ttyUSB[0-9]+"); // regex is for Linux only
 | 
					
						
							|  |  |  |     response.setNbDevices((int) comPorts.size()); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGLimeRFEDevice*> *deviceNamesList = response.getLimeRfeDevices(); | 
					
						
							|  |  |  |     std::vector<std::string>::iterator it = comPorts.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while (it != comPorts.end()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         deviceNamesList->append(new SWGSDRangel::SWGLimeRFEDevice); | 
					
						
							|  |  |  |         deviceNamesList->back()->init(); | 
					
						
							|  |  |  |         *deviceNamesList->back()->getDeviceRef() = QString::fromStdString(*it); | 
					
						
							|  |  |  |         ++it; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceLimeRFEConfigGet( | 
					
						
							|  |  |  |         const QString& serial, | 
					
						
							|  |  |  |         SWGSDRangel::SWGLimeRFESettings& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     LimeRFEController controller; | 
					
						
							|  |  |  |     int rc = controller.openDevice(serial.toStdString()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Error opening LimeRFE device %1: %2") | 
					
						
							|  |  |  |             .arg(serial).arg(controller.getError(rc).c_str()); | 
					
						
							|  |  |  |         return 400; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rc = controller.getState(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Error getting config from LimeRFE device %1: %2") | 
					
						
							|  |  |  |             .arg(serial).arg(controller.getError(rc).c_str()); | 
					
						
							|  |  |  |         return 500; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     controller.closeDevice(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LimeRFEController::LimeRFESettings settings; | 
					
						
							|  |  |  |     controller.stateToSettings(settings); | 
					
						
							|  |  |  |     response.init(); | 
					
						
							|  |  |  |     response.setDevicePath(new QString(serial)); | 
					
						
							|  |  |  |     response.setRxChannels((int) settings.m_rxChannels); | 
					
						
							|  |  |  |     response.setRxWidebandChannel((int) settings.m_rxWidebandChannel); | 
					
						
							|  |  |  |     response.setRxHamChannel((int) settings.m_rxHAMChannel); | 
					
						
							|  |  |  |     response.setRxCellularChannel((int) settings.m_rxCellularChannel); | 
					
						
							|  |  |  |     response.setRxPort((int) settings.m_rxPort); | 
					
						
							|  |  |  |     response.setRxOn(settings.m_rxOn ? 1 : 0); | 
					
						
							|  |  |  |     response.setAmfmNotch(settings.m_amfmNotch ? 1 : 0); | 
					
						
							|  |  |  |     response.setAttenuationFactor(settings.m_attenuationFactor); | 
					
						
							|  |  |  |     response.setTxChannels((int) settings.m_txChannels); | 
					
						
							|  |  |  |     response.setTxWidebandChannel((int) settings.m_txWidebandChannel); | 
					
						
							|  |  |  |     response.setTxHamChannel((int) settings.m_txHAMChannel); | 
					
						
							|  |  |  |     response.setTxCellularChannel((int) settings.m_txCellularChannel); | 
					
						
							|  |  |  |     response.setTxPort((int) settings.m_txPort); | 
					
						
							|  |  |  |     response.setTxOn(settings.m_txOn ? 1 : 0); | 
					
						
							| 
									
										
										
										
											2020-01-15 00:28:25 +01:00
										 |  |  |     response.setSwrEnable(settings.m_swrEnable ? 1 : 0); | 
					
						
							|  |  |  |     response.setSwrSource((int) settings.m_swrSource); | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceLimeRFEConfigPut( | 
					
						
							|  |  |  |         SWGSDRangel::SWGLimeRFESettings& query, | 
					
						
							| 
									
										
										
										
											2020-01-14 01:11:31 +01:00
										 |  |  |         SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     LimeRFEController controller; | 
					
						
							|  |  |  |     int rc = controller.openDevice(query.getDevicePath()->toStdString()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Error opening LimeRFE device %1: %2") | 
					
						
							|  |  |  |             .arg(*query.getDevicePath()).arg(controller.getError(rc).c_str()); | 
					
						
							|  |  |  |         return 400; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LimeRFEController::LimeRFESettings settings; | 
					
						
							|  |  |  |     settings.m_rxChannels = (LimeRFEController::ChannelGroups) query.getRxChannels(); | 
					
						
							|  |  |  |     settings.m_rxWidebandChannel = (LimeRFEController::WidebandChannel) query.getRxWidebandChannel(); | 
					
						
							|  |  |  |     settings.m_rxHAMChannel = (LimeRFEController::HAMChannel) query.getRxHamChannel(); | 
					
						
							|  |  |  |     settings.m_rxCellularChannel = (LimeRFEController::CellularChannel) query.getRxCellularChannel(); | 
					
						
							|  |  |  |     settings.m_rxPort = (LimeRFEController::RxPort) query.getRxPort(); | 
					
						
							| 
									
										
										
										
											2020-01-14 01:11:31 +01:00
										 |  |  |     settings.m_rxOn = query.getRxOn() != 0; | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  |     settings.m_amfmNotch = query.getAmfmNotch() != 0; | 
					
						
							|  |  |  |     settings.m_attenuationFactor = query.getAttenuationFactor(); | 
					
						
							|  |  |  |     settings.m_txChannels = (LimeRFEController::ChannelGroups) query.getTxChannels(); | 
					
						
							|  |  |  |     settings.m_txWidebandChannel = (LimeRFEController::WidebandChannel) query.getTxWidebandChannel(); | 
					
						
							|  |  |  |     settings.m_txHAMChannel = (LimeRFEController::HAMChannel) query.getTxHamChannel(); | 
					
						
							|  |  |  |     settings.m_txCellularChannel = (LimeRFEController::CellularChannel) query.getTxCellularChannel(); | 
					
						
							|  |  |  |     settings.m_txPort = (LimeRFEController::TxPort) query.getTxPort(); | 
					
						
							| 
									
										
										
										
											2020-01-14 01:11:31 +01:00
										 |  |  |     settings.m_txOn = query.getTxOn() != 0; | 
					
						
							| 
									
										
										
										
											2020-01-15 00:28:25 +01:00
										 |  |  |     settings.m_swrEnable = query.getSwrEnable() != 0; | 
					
						
							|  |  |  |     settings.m_swrSource = (LimeRFEController::SWRSource) query.getSwrSource(); | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     controller.settingsToState(settings); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rc = controller.configure(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Error configuring LimeRFE device %1: %2") | 
					
						
							|  |  |  |             .arg(*query.getDevicePath()).arg(controller.getError(rc).c_str()); | 
					
						
							|  |  |  |         return 500; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-14 01:11:31 +01:00
										 |  |  |     response.init(); | 
					
						
							|  |  |  |     *response.getMessage() = QString("LimeRFE device at %1 configuration updated successfully").arg(*query.getDevicePath()); | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceLimeRFERunPut( | 
					
						
							|  |  |  |         SWGSDRangel::SWGLimeRFESettings& query, | 
					
						
							|  |  |  |         SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     LimeRFEController controller; | 
					
						
							|  |  |  |     int rc = controller.openDevice(query.getDevicePath()->toStdString()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Error opening LimeRFE device %1: %2") | 
					
						
							|  |  |  |             .arg(*query.getDevicePath()).arg(controller.getError(rc).c_str()); | 
					
						
							|  |  |  |         return 400; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LimeRFEController::LimeRFESettings settings; | 
					
						
							|  |  |  |     settings.m_rxOn = query.getRxOn() != 0; | 
					
						
							|  |  |  |     settings.m_txOn = query.getTxOn() != 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rc = controller.setRx(settings, settings.m_rxOn); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Error setting Rx/Tx LimeRFE device %1: %2") | 
					
						
							|  |  |  |             .arg(*query.getDevicePath()).arg(controller.getError(rc).c_str()); | 
					
						
							|  |  |  |         return 400; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2020-01-14 01:11:31 +01:00
										 |  |  |     *response.getMessage() = QString("LimeRFE device at %1 mode updated successfully").arg(*query.getDevicePath()); | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-01-14 15:26:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instanceLimeRFEPowerGet( | 
					
						
							|  |  |  |         const QString& serial, | 
					
						
							|  |  |  |         SWGSDRangel::SWGLimeRFEPower& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     LimeRFEController controller; | 
					
						
							|  |  |  |     int rc = controller.openDevice(serial.toStdString()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Error opening LimeRFE device %1: %2") | 
					
						
							|  |  |  |             .arg(serial).arg(controller.getError(rc).c_str()); | 
					
						
							|  |  |  |         return 400; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int fwdPower; | 
					
						
							|  |  |  |     rc = controller.getFwdPower(fwdPower); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Error getting forward power from LimeRFE device %1: %2") | 
					
						
							|  |  |  |             .arg(serial).arg(controller.getError(rc).c_str()); | 
					
						
							|  |  |  |         return 500; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int refPower; | 
					
						
							|  |  |  |     rc = controller.getRefPower(refPower); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Error getting reflected power from LimeRFE device %1: %2") | 
					
						
							|  |  |  |             .arg(serial).arg(controller.getError(rc).c_str()); | 
					
						
							|  |  |  |         return 500; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     controller.closeDevice(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.init(); | 
					
						
							|  |  |  |     response.setForward(fwdPower); | 
					
						
							|  |  |  |     response.setReflected(refPower); | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-01-13 01:57:39 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  | int WebAPIAdapterSrv::instancePresetFilePut( | 
					
						
							|  |  |  |             SWGSDRangel::SWGPresetImport& query, | 
					
						
							|  |  |  |             SWGSDRangel::SWGPresetIdentifier& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const QString& fileName = *query.getFilePath(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (fileName != "") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QFile exportFile(fileName); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (exportFile.open(QIODevice::ReadOnly | QIODevice::Text)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QByteArray base64Str; | 
					
						
							|  |  |  |             QTextStream instream(&exportFile); | 
					
						
							|  |  |  |             instream >> base64Str; | 
					
						
							|  |  |  |             exportFile.close(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             Preset* preset = m_mainCore.m_settings.newPreset("", ""); | 
					
						
							|  |  |  |             preset->deserialize(QByteArray::fromBase64(base64Str)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (query.getGroupName() && (query.getGroupName()->size() > 0)) { | 
					
						
							|  |  |  |                 preset->setGroup(*query.getGroupName()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (query.getDescription() && (query.getDescription()->size() > 0)) { | 
					
						
							|  |  |  |                 preset->setDescription(*query.getDescription()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             response.setCenterFrequency(preset->getCenterFrequency()); | 
					
						
							|  |  |  |             *response.getGroupName() = preset->getGroup(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |             *response.getType() = preset->isSourcePreset() ? "R" : preset->isSinkPreset() ? "T" : preset->isMIMOPreset() ? "M" : "X"; | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             *response.getName() = preset->getDescription(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return 200; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |             error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             *error.getMessage() = QString("File %1 not found or not readable").arg(fileName); | 
					
						
							|  |  |  |             return 404; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         *error.getMessage() = QString("Empty file path"); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instancePresetFilePost( | 
					
						
							|  |  |  |             SWGSDRangel::SWGPresetExport& query, | 
					
						
							|  |  |  |             SWGSDRangel::SWGPresetIdentifier& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString filePath = *query.getFilePath(); | 
					
						
							|  |  |  |     SWGSDRangel::SWGPresetIdentifier *presetIdentifier = query.getPreset(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*presetIdentifier->getGroupName(), | 
					
						
							|  |  |  |             presetIdentifier->getCenterFrequency(), | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             *presetIdentifier->getName(), | 
					
						
							|  |  |  |             *presetIdentifier->getType()); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (selectedPreset == 0) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         *error.getMessage() = QString("There is no preset [%1, %2, %3, %4]") | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |                 .arg(*presetIdentifier->getGroupName()) | 
					
						
							|  |  |  |                 .arg(presetIdentifier->getCenterFrequency()) | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |                 .arg(*presetIdentifier->getName()) | 
					
						
							|  |  |  |                 .arg(*presetIdentifier->getType()); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QString base64Str = selectedPreset->serialize().toBase64(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (filePath != "") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QFileInfo fileInfo(filePath); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (fileInfo.suffix() != "prex") { | 
					
						
							|  |  |  |             filePath += ".prex"; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         QFile exportFile(filePath); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (exportFile.open(QIODevice::WriteOnly | QIODevice::Text)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QTextStream outstream(&exportFile); | 
					
						
							|  |  |  |             outstream << base64Str; | 
					
						
							|  |  |  |             exportFile.close(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             response.setCenterFrequency(selectedPreset->getCenterFrequency()); | 
					
						
							|  |  |  |             *response.getGroupName() = selectedPreset->getGroup(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |             *response.getType() = selectedPreset->isSourcePreset() ? "R" : selectedPreset->isSinkPreset() ? "T" : selectedPreset->isMIMOPreset() ? "M" : "X"; | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             *response.getName() = selectedPreset->getDescription(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return 200; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |             error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             *error.getMessage() = QString("File %1 cannot be written").arg(filePath); | 
					
						
							|  |  |  |             return 404; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         *error.getMessage() = QString("Empty file path"); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 00:50:58 +01:00
										 |  |  | int WebAPIAdapterSrv::instancePresetsGet( | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         SWGSDRangel::SWGPresets& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     int nbPresets = m_mainCore.m_settings.getPresetCount(); | 
					
						
							|  |  |  |     int nbGroups = 0; | 
					
						
							|  |  |  |     int nbPresetsThisGroup = 0; | 
					
						
							|  |  |  |     QString groupName; | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |     QList<SWGSDRangel::SWGPresetGroup*> *groups = response.getGroups(); | 
					
						
							|  |  |  |     QList<SWGSDRangel::SWGPresetItem*> *swgPresets = 0; | 
					
						
							|  |  |  |     int i = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Presets are sorted by group first
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (; i < nbPresets; i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const Preset *preset = m_mainCore.m_settings.getPreset(i); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ((i == 0) || (groupName != preset->getGroup())) // new group
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (i > 0) { groups->back()->setNbPresets(nbPresetsThisGroup); } | 
					
						
							|  |  |  |             groups->append(new SWGSDRangel::SWGPresetGroup); | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |             groups->back()->init(); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             groupName = preset->getGroup(); | 
					
						
							|  |  |  |             *groups->back()->getGroupName() = groupName; | 
					
						
							|  |  |  |             swgPresets = groups->back()->getPresets(); | 
					
						
							|  |  |  |             nbGroups++; | 
					
						
							|  |  |  |             nbPresetsThisGroup = 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         swgPresets->append(new SWGSDRangel::SWGPresetItem); | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         swgPresets->back()->init(); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         swgPresets->back()->setCenterFrequency(preset->getCenterFrequency()); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |         *swgPresets->back()->getType() = preset->isSourcePreset() ? "R" : preset->isSinkPreset() ? "T" : preset->isMIMOPreset() ? "M" : "X"; | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         *swgPresets->back()->getName() = preset->getDescription(); | 
					
						
							|  |  |  |         nbPresetsThisGroup++; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (i > 0) { groups->back()->setNbPresets(nbPresetsThisGroup); } | 
					
						
							|  |  |  |     response.setNbGroups(nbGroups); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  | int WebAPIAdapterSrv::instancePresetPatch( | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetTransfer& query, | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetIdentifier& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int deviceSetIndex = query.getDeviceSetIndex(); | 
					
						
							|  |  |  |     SWGSDRangel::SWGPresetIdentifier *presetIdentifier = query.getPreset(); | 
					
						
							|  |  |  |     int nbDeviceSets = m_mainCore.m_deviceSets.size(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (deviceSetIndex >= nbDeviceSets) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  |         *error.getMessage() = QString("There is no device set at index %1. Number of device sets is %2").arg(deviceSetIndex).arg(nbDeviceSets); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*presetIdentifier->getGroupName(), | 
					
						
							|  |  |  |             presetIdentifier->getCenterFrequency(), | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             *presetIdentifier->getName(), | 
					
						
							|  |  |  |             *presetIdentifier->getType()); | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (selectedPreset == 0) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         *error.getMessage() = QString("There is no preset [%1, %2, %3 %4]") | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  |                 .arg(*presetIdentifier->getGroupName()) | 
					
						
							|  |  |  |                 .arg(presetIdentifier->getCenterFrequency()) | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |                 .arg(*presetIdentifier->getName()) | 
					
						
							|  |  |  |                 .arg(*presetIdentifier->getType()); | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (deviceSet->m_deviceSourceEngine && !selectedPreset->isSourcePreset()) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |         *error.getMessage() = QString("Preset type and device set type (Rx) mismatch"); | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |     if (deviceSet->m_deviceSinkEngine && !selectedPreset->isSinkPreset()) | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |         *error.getMessage() = QString("Preset type and device set type (Tx) mismatch"); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (deviceSet->m_deviceMIMOEngine && !selectedPreset->isMIMOPreset()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("Preset type and device set type (MIMO) mismatch"); | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MainCore::MsgLoadPreset *msg = MainCore::MsgLoadPreset::create(selectedPreset, deviceSetIndex); | 
					
						
							|  |  |  |     m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  |     response.setCenterFrequency(selectedPreset->getCenterFrequency()); | 
					
						
							|  |  |  |     *response.getGroupName() = selectedPreset->getGroup(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |     *response.getType() = selectedPreset->isSourcePreset() ? "R" : selectedPreset->isSinkPreset() ? "T" : selectedPreset->isMIMOPreset() ? "M" : "X"; | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |     *response.getName() = selectedPreset->getDescription(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |     return 202; | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instancePresetPut( | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetTransfer& query, | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetIdentifier& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int deviceSetIndex = query.getDeviceSetIndex(); | 
					
						
							|  |  |  |     SWGSDRangel::SWGPresetIdentifier *presetIdentifier = query.getPreset(); | 
					
						
							|  |  |  |     int nbDeviceSets = m_mainCore.m_deviceSets.size(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  |     if (deviceSetIndex >= nbDeviceSets) | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |         *error.getMessage() = QString("There is no device set at index %1. Number of device sets is %2").arg(deviceSetIndex).arg(nbDeviceSets); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*presetIdentifier->getGroupName(), | 
					
						
							|  |  |  |             presetIdentifier->getCenterFrequency(), | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             *presetIdentifier->getName(), | 
					
						
							|  |  |  |             *presetIdentifier->getType()); | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (selectedPreset == 0) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         *error.getMessage() = QString("There is no preset [%1, %2, %3 %4]") | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |                 .arg(*presetIdentifier->getGroupName()) | 
					
						
							|  |  |  |                 .arg(presetIdentifier->getCenterFrequency()) | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |                 .arg(*presetIdentifier->getName()) | 
					
						
							|  |  |  |                 .arg(*presetIdentifier->getType()); | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else // update existing preset
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceSourceEngine && !selectedPreset->isSourcePreset()) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |             error.init(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |             *error.getMessage() = QString("Preset type and device set type (Rx) mismatch"); | 
					
						
							|  |  |  |             return 404; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceSinkEngine && !selectedPreset->isSinkPreset()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             error.init(); | 
					
						
							|  |  |  |             *error.getMessage() = QString("Preset type and device set type (Tx) mismatch"); | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |             return 404; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |         if (deviceSet->m_deviceSinkEngine && !selectedPreset->isMIMOPreset()) | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |             error.init(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |             *error.getMessage() = QString("Preset type and device set type (MIMO) mismatch"); | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |             return 404; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MainCore::MsgSavePreset *msg = MainCore::MsgSavePreset::create(const_cast<Preset*>(selectedPreset), deviceSetIndex, false); | 
					
						
							|  |  |  |     m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |     response.setCenterFrequency(selectedPreset->getCenterFrequency()); | 
					
						
							|  |  |  |     *response.getGroupName() = selectedPreset->getGroup(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |     *response.getType() = selectedPreset->isSourcePreset() ? "R" : selectedPreset->isSinkPreset() ? "T": selectedPreset->isMIMOPreset() ? "M" : "X"; | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  |     *response.getName() = selectedPreset->getDescription(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |     return 202; | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::instancePresetPost( | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetTransfer& query, | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetIdentifier& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int deviceSetIndex = query.getDeviceSetIndex(); | 
					
						
							|  |  |  |     SWGSDRangel::SWGPresetIdentifier *presetIdentifier = query.getPreset(); | 
					
						
							|  |  |  |     int nbDeviceSets = m_mainCore.m_deviceSets.size(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (deviceSetIndex >= nbDeviceSets) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  |         *error.getMessage() = QString("There is no device set at index %1. Number of device sets is %2").arg(deviceSetIndex).arg(nbDeviceSets); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  |     int deviceCenterFrequency = 0; | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |     int presetTypeCode; | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (deviceSet->m_deviceSourceEngine) { // Rx
 | 
					
						
							|  |  |  |         deviceCenterFrequency = deviceSet->m_deviceSourceEngine->getSource()->getCenterFrequency(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |         presetTypeCode = 0; | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  |     } else if (deviceSet->m_deviceSinkEngine) { // Tx
 | 
					
						
							|  |  |  |         deviceCenterFrequency = deviceSet->m_deviceSinkEngine->getSink()->getCenterFrequency(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |         presetTypeCode = 1; | 
					
						
							|  |  |  |     } else if (deviceSet->m_deviceMIMOEngine) { // MIMO
 | 
					
						
							|  |  |  |         deviceCenterFrequency = deviceSet->m_deviceMIMOEngine->getMIMO()->getMIMOCenterFrequency(); | 
					
						
							|  |  |  |         presetTypeCode = 2; | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  |         *error.getMessage() = QString("Device set error"); | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  |         return 500; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*presetIdentifier->getGroupName(), | 
					
						
							|  |  |  |             deviceCenterFrequency, | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             *presetIdentifier->getName(), | 
					
						
							|  |  |  |             *presetIdentifier->getType()); | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (selectedPreset == 0) // save on a new preset
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         selectedPreset = m_mainCore.m_settings.newPreset(*presetIdentifier->getGroupName(), *presetIdentifier->getName()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         *error.getMessage() = QString("Preset already exists [%1, %2, %3 %4]") | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  |                 .arg(*presetIdentifier->getGroupName()) | 
					
						
							|  |  |  |                 .arg(deviceCenterFrequency) | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |                 .arg(*presetIdentifier->getName()) | 
					
						
							|  |  |  |                 .arg(*presetIdentifier->getType()); | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  |         return 409; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MainCore::MsgSavePreset *msg = MainCore::MsgSavePreset::create(const_cast<Preset*>(selectedPreset), deviceSetIndex, true); | 
					
						
							|  |  |  |     m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2018-02-14 22:33:41 +01:00
										 |  |  |     response.setCenterFrequency(deviceCenterFrequency); | 
					
						
							| 
									
										
										
										
											2017-12-21 00:23:36 +01:00
										 |  |  |     *response.getGroupName() = selectedPreset->getGroup(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |     *response.getType() = presetTypeCode == 0 ? "R" : presetTypeCode == 1 ? "T" : presetTypeCode == 2 ? "M" : "X"; | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  |     *response.getName() = selectedPreset->getDescription(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |     return 202; | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 00:31:38 +01:00
										 |  |  | int WebAPIAdapterSrv::instancePresetDelete( | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetIdentifier& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*response.getGroupName(), | 
					
						
							|  |  |  |             response.getCenterFrequency(), | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             *response.getName(), | 
					
						
							|  |  |  |             *response.getType()); | 
					
						
							| 
									
										
										
										
											2017-12-21 00:31:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (selectedPreset == 0) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         *error.getMessage() = QString("There is no preset [%1, %2, %3 %4]") | 
					
						
							| 
									
										
										
										
											2017-12-21 00:31:38 +01:00
										 |  |  |                 .arg(*response.getGroupName()) | 
					
						
							|  |  |  |                 .arg(response.getCenterFrequency()) | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |                 .arg(*response.getName()) | 
					
						
							|  |  |  |                 .arg(*response.getType()); | 
					
						
							| 
									
										
										
										
											2017-12-21 00:31:38 +01:00
										 |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     response.setCenterFrequency(selectedPreset->getCenterFrequency()); | 
					
						
							|  |  |  |     *response.getGroupName() = selectedPreset->getGroup(); | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |     *response.getType() = selectedPreset->isSourcePreset() ? "R" : selectedPreset->isSinkPreset() ? "T" : selectedPreset->isMIMOPreset() ? "M" : "X"; | 
					
						
							| 
									
										
										
										
											2017-12-21 00:31:38 +01:00
										 |  |  |     *response.getName() = selectedPreset->getDescription(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MainCore::MsgDeletePreset *msg = MainCore::MsgDeletePreset::create(const_cast<Preset*>(selectedPreset)); | 
					
						
							|  |  |  |     m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |     return 202; | 
					
						
							| 
									
										
										
										
											2017-12-21 00:31:38 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 00:39:57 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceDeviceSetsGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceSetList& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-21 00:39:57 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     getDeviceSetList(&response); | 
					
						
							|  |  |  |     return 200; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 01:07:03 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceDeviceSetPost( | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         int direction, | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |         SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |     MainCore::MsgAddDeviceSet *msg = MainCore::MsgAddDeviceSet::create(direction); | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |     m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-21 22:35:25 +01:00
										 |  |  |     *response.getMessage() = QString("Message to add a new device set (MsgAddDeviceSet) was submitted successfully"); | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |     return 202; | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 01:07:03 +01:00
										 |  |  | int WebAPIAdapterSrv::instanceDeviceSetDelete( | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |         SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_mainCore.m_deviceSets.size() > 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         MainCore::MsgRemoveLastDeviceSet *msg = MainCore::MsgRemoveLastDeviceSet::create(); | 
					
						
							|  |  |  |         m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |         response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-21 22:35:25 +01:00
										 |  |  |         *response.getMessage() = QString("Message to remove last device set (MsgRemoveLastDeviceSet) was submitted successfully"); | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         return 202; | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |         *error.getMessage() = "No more device sets to be removed"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetGet( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceSet& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  |         getDeviceSet(&response, deviceSet, deviceSetIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return 200; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-06 03:46:53 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetFocusPatch( | 
					
						
							| 
									
										
										
										
											2019-05-24 09:37:13 +02:00
										 |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							| 
									
										
										
										
											2018-01-06 03:46:53 +01:00
										 |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     *error.getMessage() = QString("Not supported in server instance"); | 
					
						
							|  |  |  |     return 400; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetDevicePut( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							| 
									
										
										
										
											2018-02-14 13:40:34 +01:00
										 |  |  |         SWGSDRangel::SWGDeviceListItem& query, | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         SWGSDRangel::SWGDeviceListItem& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         if ((query.getDirection() != 1) && (deviceSet->m_deviceSinkEngine)) | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-02-14 13:40:34 +01:00
										 |  |  |             error.init(); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |             *error.getMessage() = QString("Device type and device set type (Tx) mismatch"); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |             return 404; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         if ((query.getDirection() != 0) && (deviceSet->m_deviceSourceEngine)) | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-02-14 13:40:34 +01:00
										 |  |  |             error.init(); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |             *error.getMessage() = QString("Device type and device set type (Rx) mismatch"); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |             return 404; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         if ((query.getDirection() != 2) && (deviceSet->m_deviceMIMOEngine)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             error.init(); | 
					
						
							|  |  |  |             *error.getMessage() = QString("Device type and device set type (MIMO) mismatch"); | 
					
						
							|  |  |  |             return 404; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         int nbSamplingDevices; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (query.getDirection() == 0) { | 
					
						
							|  |  |  |             nbSamplingDevices = DeviceEnumerator::instance()->getNbRxSamplingDevices(); | 
					
						
							|  |  |  |         } else if (query.getDirection() == 1) { | 
					
						
							|  |  |  |             nbSamplingDevices = DeviceEnumerator::instance()->getNbTxSamplingDevices(); | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         } else if (query.getDirection() == 2) { | 
					
						
							|  |  |  |             nbSamplingDevices = DeviceEnumerator::instance()->getNbMIMOSamplingDevices(); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             nbSamplingDevices = 0; // TODO: not implemented yet
 | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i < nbSamplingDevices; i++) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             int direction; | 
					
						
							|  |  |  |             const PluginInterface::SamplingDevice *samplingDevice; | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             if (query.getDirection() == 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 direction = 0; | 
					
						
							|  |  |  |                 samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(i); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (query.getDirection() == 1) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 direction = 1; | 
					
						
							|  |  |  |                 samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(i); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |             else if (query.getDirection() == 2) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 direction = 2; | 
					
						
							|  |  |  |                 samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(i); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |                 continue; // device not supported
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             if (query.getDisplayedName() && (*query.getDisplayedName() != samplingDevice->displayedName)) { | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             if (query.getHwType() && (*query.getHwType() != samplingDevice->hardwareId)) { | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             if ((query.getSequence() >= 0) && (query.getSequence() != samplingDevice->sequence)) { | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             if (query.getSerial() && (*query.getSerial() != samplingDevice->serial)) { | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             if ((query.getDeviceStreamIndex() >= 0) && (query.getDeviceStreamIndex() != samplingDevice->deviceItemIndex)) { | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  |             MainCore::MsgSetDevice *msg = MainCore::MsgSetDevice::create(deviceSetIndex, i, query.getDirection()); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |             m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             *response.getDisplayedName() = samplingDevice->displayedName; | 
					
						
							|  |  |  |             *response.getHwType() = samplingDevice->hardwareId; | 
					
						
							|  |  |  |             *response.getSerial() = samplingDevice->serial; | 
					
						
							|  |  |  |             response.setSequence(samplingDevice->sequence); | 
					
						
							|  |  |  |             response.setDirection(direction); | 
					
						
							|  |  |  |             response.setDeviceNbStreams(samplingDevice->deviceNbItems); | 
					
						
							|  |  |  |             response.setDeviceStreamIndex(samplingDevice->deviceItemIndex); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |             response.setDeviceSetIndex(deviceSetIndex); | 
					
						
							|  |  |  |             response.setIndex(i); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return 202; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-14 13:40:34 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         *error.getMessage() = QString("Device not found"); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::devicesetDeviceSettingsGet( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceSettings& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-21 13:27:10 +01:00
										 |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         if (deviceSet->m_deviceSourceEngine) // Single Rx
 | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             response.setDeviceHwType(new QString(deviceSet->m_deviceAPI->getHardwareId())); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |             response.setDirection(0); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSource *source = deviceSet->m_deviceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |             return source->webapiSettingsGet(response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         else if (deviceSet->m_deviceSinkEngine) // Single Tx
 | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             response.setDeviceHwType(new QString(deviceSet->m_deviceAPI->getHardwareId())); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |             response.setDirection(1); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSink *sink = deviceSet->m_deviceAPI->getSampleSink(); | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |             return sink->webapiSettingsGet(response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         else if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setDeviceHwType(new QString(deviceSet->m_deviceAPI->getHardwareId())); | 
					
						
							|  |  |  |             response.setDirection(2); | 
					
						
							|  |  |  |             DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getSampleMIMO(); | 
					
						
							|  |  |  |             return mimo->webapiSettingsGet(response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetDeviceActionsPost( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |         const QStringList& deviceActionsKeys, | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  |         SWGSDRangel::SWGDeviceActions& query, | 
					
						
							|  |  |  |         SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceSourceEngine) // Single Rx
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (query.getDirection() != 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Single Rx device found but other type of device requested"); | 
					
						
							|  |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if (deviceSet->m_deviceAPI->getHardwareId() != *query.getDeviceHwType()) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Device mismatch. Found %1 input").arg(deviceSet->m_deviceAPI->getHardwareId()); | 
					
						
							|  |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 DeviceSampleSource *source = deviceSet->m_deviceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |                 int res = source->webapiActionsPost(deviceActionsKeys, query, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 if (res/100 == 2) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     response.init(); | 
					
						
							|  |  |  |                     *response.getMessage() = QString("Message to post action was submitted successfully"); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 return res; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else if (deviceSet->m_deviceSinkEngine) // Single Tx
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (query.getDirection() != 1) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Single Tx device found but other type of device requested"); | 
					
						
							|  |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (deviceSet->m_deviceAPI->getHardwareId() != *query.getDeviceHwType()) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Device mismatch. Found %1 output").arg(deviceSet->m_deviceAPI->getHardwareId()); | 
					
						
							|  |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 DeviceSampleSink *sink = deviceSet->m_deviceAPI->getSampleSink(); | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |                 int res = sink->webapiActionsPost(deviceActionsKeys, query, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 if (res/100 == 2) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     response.init(); | 
					
						
							|  |  |  |                     *response.getMessage() = QString("Message to post action was submitted successfully"); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 return res; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (query.getDirection() != 2) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("MIMO device found but other type of device requested"); | 
					
						
							|  |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (deviceSet->m_deviceAPI->getHardwareId() != *query.getDeviceHwType()) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Device mismatch. Found %1 output").arg(deviceSet->m_deviceAPI->getHardwareId()); | 
					
						
							|  |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getSampleMIMO(); | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |                 int res = mimo->webapiActionsPost(deviceActionsKeys, query, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 if (res/100 == 2) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     response.init(); | 
					
						
							|  |  |  |                     *response.getMessage() = QString("Message to post action was submitted successfully"); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 return res; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetDeviceSettingsPutPatch( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         bool force, | 
					
						
							| 
									
										
										
										
											2017-12-27 01:46:33 +01:00
										 |  |  |         const QStringList& deviceSettingsKeys, | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |         SWGSDRangel::SWGDeviceSettings& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-21 13:27:10 +01:00
										 |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         if (deviceSet->m_deviceSourceEngine) // Single Rx
 | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |             if (response.getDirection() != 0) | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |                 *error.getMessage() = QString("Single Rx device found but other type of device requested"); | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             if (deviceSet->m_deviceAPI->getHardwareId() != *response.getDeviceHwType()) | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |                 *error.getMessage() = QString("Device mismatch. Found %1 input").arg(deviceSet->m_deviceAPI->getHardwareId()); | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |                 DeviceSampleSource *source = deviceSet->m_deviceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2017-12-27 01:46:33 +01:00
										 |  |  |                 return source->webapiSettingsPutPatch(force, deviceSettingsKeys, response, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         else if (deviceSet->m_deviceSinkEngine) // Single Tx
 | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |             if (response.getDirection() != 1) | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |                 *error.getMessage() = QString("Single Tx device found but other type of device requested"); | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             else if (deviceSet->m_deviceAPI->getHardwareId() != *response.getDeviceHwType()) | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |                 *error.getMessage() = QString("Device mismatch. Found %1 output").arg(deviceSet->m_deviceAPI->getHardwareId()); | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |                 DeviceSampleSink *sink = deviceSet->m_deviceAPI->getSampleSink(); | 
					
						
							| 
									
										
										
										
											2017-12-27 01:46:33 +01:00
										 |  |  |                 return sink->webapiSettingsPutPatch(force, deviceSettingsKeys, response, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         else if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (response.getDirection() != 2) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("MIMO device found but other type of device requested"); | 
					
						
							|  |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (deviceSet->m_deviceAPI->getHardwareId() != *response.getDeviceHwType()) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Device mismatch. Found %1 output").arg(deviceSet->m_deviceAPI->getHardwareId()); | 
					
						
							|  |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getSampleMIMO(); | 
					
						
							|  |  |  |                 return mimo->webapiSettingsPutPatch(force, deviceSettingsKeys, response, *error.getMessage()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-22 16:41:37 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-27 22:00:35 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetDeviceRunGet( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-27 22:00:35 +01:00
										 |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceSourceEngine) // Rx
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSource *source = deviceSet->m_deviceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-27 22:00:35 +01:00
										 |  |  |             return source->webapiRunGet(response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else if (deviceSet->m_deviceSinkEngine) // Tx
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSink *sink = deviceSet->m_deviceAPI->getSampleSink(); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-27 22:00:35 +01:00
										 |  |  |             return sink->webapiRunGet(response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-24 19:08:11 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::devicesetDeviceSubsystemRunGet( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         int subsystemIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getSampleMIMO(); | 
					
						
							|  |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2019-12-24 19:08:11 +01:00
										 |  |  |             return mimo->webapiRunGet(subsystemIndex, response, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-27 22:00:35 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-27 11:10:47 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetDeviceRunPost( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-27 11:10:47 +01:00
										 |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceSourceEngine) // Rx
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSource *source = deviceSet->m_deviceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-27 11:10:47 +01:00
										 |  |  |             return source->webapiRun(true, response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else if (deviceSet->m_deviceSinkEngine) // Tx
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSink *sink = deviceSet->m_deviceAPI->getSampleSink(); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-27 11:10:47 +01:00
										 |  |  |             return sink->webapiRun(true, response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-24 19:08:11 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::devicesetDeviceSubsystemRunPost( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         int subsystemIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getSampleMIMO(); | 
					
						
							|  |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2019-12-24 19:08:11 +01:00
										 |  |  |             return mimo->webapiRun(true, subsystemIndex, response, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-27 11:10:47 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::devicesetDeviceRunDelete( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-27 11:10:47 +01:00
										 |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceSourceEngine) // Rx
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSource *source = deviceSet->m_deviceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-27 11:10:47 +01:00
										 |  |  |             return source->webapiRun(false, response, *error.getMessage()); | 
					
						
							|  |  |  |        } | 
					
						
							|  |  |  |         else if (deviceSet->m_deviceSinkEngine) // Tx
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSink *sink = deviceSet->m_deviceAPI->getSampleSink(); | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-27 11:10:47 +01:00
										 |  |  |             return sink->webapiRun(false, response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-24 19:08:11 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::devicesetDeviceSubsystemRunDelete( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         int subsystemIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getSampleMIMO(); | 
					
						
							|  |  |  |             response.init(); | 
					
						
							| 
									
										
										
										
											2019-12-24 19:08:11 +01:00
										 |  |  |             return mimo->webapiRun(false, subsystemIndex, response, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-27 11:10:47 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-28 10:06:17 +02:00
										 |  |  | int WebAPIAdapterSrv::devicesetDeviceReportGet( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceReport& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         if (deviceSet->m_deviceSourceEngine) // Single Rx
 | 
					
						
							| 
									
										
										
										
											2018-05-28 10:06:17 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             response.setDeviceHwType(new QString(deviceSet->m_deviceAPI->getHardwareId())); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |             response.setDirection(0); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSource *source = deviceSet->m_deviceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2018-05-28 10:06:17 +02:00
										 |  |  |             return source->webapiReportGet(response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         else if (deviceSet->m_deviceSinkEngine) // Single Tx
 | 
					
						
							| 
									
										
										
										
											2018-05-28 10:06:17 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             response.setDeviceHwType(new QString(deviceSet->m_deviceAPI->getHardwareId())); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |             response.setDirection(1); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             DeviceSampleSink *sink = deviceSet->m_deviceAPI->getSampleSink(); | 
					
						
							| 
									
										
										
										
											2018-05-28 10:06:17 +02:00
										 |  |  |             return sink->webapiReportGet(response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         else if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setDeviceHwType(new QString(deviceSet->m_deviceAPI->getHardwareId())); | 
					
						
							|  |  |  |             response.setDirection(2); | 
					
						
							|  |  |  |             DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getSampleMIMO(); | 
					
						
							|  |  |  |             return mimo->webapiReportGet(response, *error.getMessage()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-05-28 10:06:17 +02:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetChannelsReportGet( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         SWGSDRangel::SWGChannelsDetail& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  |         getChannelsDetail(&response, deviceSet); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return 200; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         error.init(); | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetChannelPost( | 
					
						
							|  |  |  |             int deviceSetIndex, | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelSettings& query, | 
					
						
							|  |  |  | 			SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         if (query.getDirection() == 0) // Single Rx
 | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-01-02 20:10:01 +01:00
										 |  |  |             if (!deviceSet->m_deviceSourceEngine && !deviceSet->m_deviceMIMOEngine) | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |                 error.init(); | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |                 *error.getMessage() = QString("Device set at %1 is not a receive capable device set").arg(deviceSetIndex); | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             PluginAPI::ChannelRegistrations *channelRegistrations = m_mainCore.m_pluginManager->getRxChannelRegistrations(); | 
					
						
							|  |  |  |             int nbRegistrations = channelRegistrations->size(); | 
					
						
							|  |  |  |             int index = 0; | 
					
						
							|  |  |  |             for (; index < nbRegistrations; index++) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 if (channelRegistrations->at(index).m_channelId == *query.getChannelType()) { | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (index < nbRegistrations) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, false); | 
					
						
							|  |  |  |                 m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |                 response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |                 *response.getMessage() = QString("Message to add a channel (MsgAddChannel) was submitted successfully"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 return 202; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |                 error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |                 *error.getMessage() = QString("There is no receive channel with id %1").arg(*query.getChannelType()); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         else if (query.getDirection() == 1) // single Tx
 | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-01-02 20:10:01 +01:00
										 |  |  |             if (!deviceSet->m_deviceSinkEngine && !deviceSet->m_deviceMIMOEngine) | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |                 error.init(); | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |                 *error.getMessage() = QString("Device set at %1 is not a transmit capable device set").arg(deviceSetIndex); | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             PluginAPI::ChannelRegistrations *channelRegistrations = m_mainCore.m_pluginManager->getTxChannelRegistrations(); | 
					
						
							|  |  |  |             int nbRegistrations = channelRegistrations->size(); | 
					
						
							|  |  |  |             int index = 0; | 
					
						
							|  |  |  |             for (; index < nbRegistrations; index++) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 if (channelRegistrations->at(index).m_channelId == *query.getChannelType()) { | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (index < nbRegistrations) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |             	MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, true); | 
					
						
							|  |  |  |                 m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |                 response.init(); | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |                 *response.getMessage() = QString("Message to add a channel (MsgAddChannel) was submitted successfully"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 return 202; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |                 error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |                 *error.getMessage() = QString("There is no transmit channel with id %1").arg(*query.getChannelType()); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-23 20:06:10 +01:00
										 |  |  |         else if (query.getDirection() == 2) // MIMO
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (!deviceSet->m_deviceMIMOEngine) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 error.init(); | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Device set at %1 is not a MIMO capable device set").arg(deviceSetIndex); | 
					
						
							|  |  |  |                 return 400; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             PluginAPI::ChannelRegistrations *channelRegistrations = m_mainCore.m_pluginManager->getMIMOChannelRegistrations(); | 
					
						
							|  |  |  |             int nbRegistrations = channelRegistrations->size(); | 
					
						
							|  |  |  |             int index = 0; | 
					
						
							|  |  |  |             for (; index < nbRegistrations; index++) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 if (channelRegistrations->at(index).m_channelId == *query.getChannelType()) { | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (index < nbRegistrations) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |             	MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, true); | 
					
						
							|  |  |  |                 m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 response.init(); | 
					
						
							|  |  |  |                 *response.getMessage() = QString("Message to add a channel (MsgAddChannel) was submitted successfully"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 return 202; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 error.init(); | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no MIMO channel with id %1").arg(*query.getChannelType()); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             error.init(); | 
					
						
							|  |  |  |             *error.getMessage() = QString("This type of device is not implemented yet"); | 
					
						
							|  |  |  |             return 400; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::devicesetChannelDelete( | 
					
						
							|  |  |  |             int deviceSetIndex, | 
					
						
							|  |  |  |             int channelIndex, | 
					
						
							|  |  |  |             SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |         if (channelIndex < deviceSet->getNumberOfChannels()) | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |             MainCore::MsgDeleteChannel *msg = MainCore::MsgDeleteChannel::create(deviceSetIndex, channelIndex); | 
					
						
							|  |  |  |             m_mainCore.m_inputMessageQueue.push(msg); | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |             response.init(); | 
					
						
							|  |  |  |             *response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully"); | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |             return 202; | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |             error.init(); | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |             *error.getMessage() = QString("There is no channel at index %1. There are %2 channels") | 
					
						
							|  |  |  |                     .arg(channelIndex) | 
					
						
							|  |  |  |                     .arg(channelIndex < deviceSet->getNumberOfChannels()); | 
					
						
							|  |  |  |             return 400; | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |         error.init(); | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetChannelSettingsGet( | 
					
						
							|  |  |  |             int deviceSetIndex, | 
					
						
							|  |  |  |             int channelIndex, | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelSettings& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-21 13:50:05 +01:00
										 |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         if (deviceSet->m_deviceSourceEngine) // Single Rx
 | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI == 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setChannelType(new QString()); | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(*response.getChannelType()); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |                 response.setDirection(0); | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |                 return channelAPI->webapiSettingsGet(response, *error.getMessage()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         else if (deviceSet->m_deviceSinkEngine) // Single Tx
 | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex); | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI == 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setChannelType(new QString()); | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(*response.getChannelType()); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |                 response.setDirection(1); | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |                 return channelAPI->webapiSettingsGet(response, *error.getMessage()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-23 23:00:11 +01:00
										 |  |  |         else if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); | 
					
						
							|  |  |  |             int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); | 
					
						
							|  |  |  |             int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); | 
					
						
							|  |  |  |             ChannelAPI *channelAPI = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelIndex < nbSinkChannels) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); | 
					
						
							|  |  |  |                 response.setDirection(0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (channelIndex < nbSinkChannels + nbSourceChannels) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); | 
					
						
							|  |  |  |                 response.setDirection(1); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); | 
					
						
							|  |  |  |                 response.setDirection(2); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setChannelType(new QString()); | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(*response.getChannelType()); | 
					
						
							|  |  |  |                 return channelAPI->webapiSettingsGet(response, *error.getMessage()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetChannelReportGet( | 
					
						
							|  |  |  |             int deviceSetIndex, | 
					
						
							|  |  |  |             int channelIndex, | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelReport& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         if (deviceSet->m_deviceSourceEngine) // Single Rx
 | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI == 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setChannelType(new QString()); | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(*response.getChannelType()); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |                 response.setDirection(0); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |                 return channelAPI->webapiReportGet(response, *error.getMessage()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         else if (deviceSet->m_deviceSinkEngine) // Single Tx
 | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI == 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setChannelType(new QString()); | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(*response.getChannelType()); | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |                 response.setDirection(1); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |                 return channelAPI->webapiReportGet(response, *error.getMessage()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-23 23:00:11 +01:00
										 |  |  |         else if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); | 
					
						
							|  |  |  |             int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); | 
					
						
							|  |  |  |             int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); | 
					
						
							|  |  |  |             ChannelAPI *channelAPI = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelIndex < nbSinkChannels) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); | 
					
						
							|  |  |  |                 response.setDirection(0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (channelIndex < nbSinkChannels + nbSourceChannels) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); | 
					
						
							|  |  |  |                 response.setDirection(1); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); | 
					
						
							|  |  |  |                 response.setDirection(2); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setChannelType(new QString()); | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(*response.getChannelType()); | 
					
						
							|  |  |  |                 return channelAPI->webapiReportGet(response, *error.getMessage()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("Ther is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WebAPIAdapterSrv::devicesetChannelActionsPost( | 
					
						
							|  |  |  |         int deviceSetIndex, | 
					
						
							|  |  |  |         int channelIndex, | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |         const QStringList& channelActionsKeys, | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  |         SWGSDRangel::SWGChannelActions& query, | 
					
						
							|  |  |  |         SWGSDRangel::SWGSuccessResponse& response, | 
					
						
							|  |  |  |         SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceSourceEngine) // Single Rx
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             ChannelAPI *channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI == 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QString channelType; | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(channelType); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (channelType == *query.getChannelType()) | 
					
						
							|  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |                     int res = channelAPI->webapiActionsPost(channelActionsKeys, query, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     if (res/100 == 2) | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                         response.init(); | 
					
						
							|  |  |  |                         *response.getMessage() = QString("Message to post action was submitted successfully"); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     return res; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") | 
					
						
							|  |  |  |                             .arg(*query.getChannelType()) | 
					
						
							|  |  |  |                             .arg(channelIndex) | 
					
						
							|  |  |  |                             .arg(channelType); | 
					
						
							|  |  |  |                     return 404; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else if (deviceSet->m_deviceSinkEngine) // Single Tx
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             ChannelAPI *channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI == 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QString channelType; | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(channelType); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (channelType == *query.getChannelType()) | 
					
						
							|  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |                     int res = channelAPI->webapiActionsPost(channelActionsKeys, query, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     if (res/100 == 2) | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                         response.init(); | 
					
						
							|  |  |  |                         *response.getMessage() = QString("Message to post action was submitted successfully"); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     return res; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") | 
					
						
							|  |  |  |                             .arg(*query.getChannelType()) | 
					
						
							|  |  |  |                             .arg(channelIndex) | 
					
						
							|  |  |  |                             .arg(channelType); | 
					
						
							|  |  |  |                     return 404; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); | 
					
						
							|  |  |  |             int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); | 
					
						
							|  |  |  |             int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); | 
					
						
							|  |  |  |             ChannelAPI *channelAPI = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if ((query.getDirection() == 0) && (channelIndex < nbSinkChannels)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if ((query.getDirection() == 1) && (channelIndex < nbSinkChannels + nbSourceChannels)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if ((query.getDirection() == 2) && (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("here is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QString channelType; | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(channelType); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (channelType == *query.getChannelType()) | 
					
						
							|  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |                     int res = channelAPI->webapiActionsPost(channelActionsKeys, query, *error.getMessage()); | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  |                     if (res/100 == 2) | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                         response.init(); | 
					
						
							|  |  |  |                         *response.getMessage() = QString("Message to post action was submitted successfully"); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     return res; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") | 
					
						
							|  |  |  |                             .arg(*query.getChannelType()) | 
					
						
							|  |  |  |                             .arg(channelIndex) | 
					
						
							|  |  |  |                             .arg(channelType); | 
					
						
							|  |  |  |                     return 404; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  | int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch( | 
					
						
							|  |  |  |             int deviceSetIndex, | 
					
						
							|  |  |  |             int channelIndex, | 
					
						
							|  |  |  |             bool force, | 
					
						
							|  |  |  |             const QStringList& channelSettingsKeys, | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelSettings& response, | 
					
						
							|  |  |  |             SWGSDRangel::SWGErrorResponse& error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-21 13:50:05 +01:00
										 |  |  |     error.init(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSet->m_deviceSourceEngine) // Rx
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI == 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QString channelType; | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(channelType); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (channelType == *response.getChannelType()) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") | 
					
						
							|  |  |  |                             .arg(*response.getChannelType()) | 
					
						
							|  |  |  |                             .arg(channelIndex) | 
					
						
							|  |  |  |                             .arg(channelType); | 
					
						
							|  |  |  |                     return 404; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else if (deviceSet->m_deviceSinkEngine) // Tx
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex); | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI == 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QString channelType; | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(channelType); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (channelType == *response.getChannelType()) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") | 
					
						
							|  |  |  |                             .arg(*response.getChannelType()) | 
					
						
							|  |  |  |                             .arg(channelIndex) | 
					
						
							|  |  |  |                             .arg(channelType); | 
					
						
							|  |  |  |                     return 404; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-12-23 23:00:11 +01:00
										 |  |  |         else if (deviceSet->m_deviceMIMOEngine) // MIMO
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); | 
					
						
							|  |  |  |             int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); | 
					
						
							|  |  |  |             int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); | 
					
						
							|  |  |  |             ChannelAPI *channelAPI = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelIndex < nbSinkChannels) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getChanelSinkAPIAt(channelIndex); | 
					
						
							|  |  |  |                 response.setDirection(0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (channelIndex < nbSinkChannels + nbSourceChannels) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getChanelSourceAPIAt(channelIndex - nbSinkChannels); | 
					
						
							|  |  |  |                 response.setDirection(1); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else if (channelIndex < nbSinkChannels + nbSourceChannels + nbMIMOChannels) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 channelAPI = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(channelIndex - nbSinkChannels - nbSourceChannels); | 
					
						
							|  |  |  |                 response.setDirection(2); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("here is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelAPI) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QString channelType; | 
					
						
							|  |  |  |                 channelAPI->getIdentifier(channelType); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (channelType == *response.getChannelType()) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") | 
					
						
							|  |  |  |                             .arg(*response.getChannelType()) | 
					
						
							|  |  |  |                             .arg(channelIndex) | 
					
						
							|  |  |  |                             .arg(channelType); | 
					
						
							|  |  |  |                     return 404; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); | 
					
						
							|  |  |  |                 return 404; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             *error.getMessage() = QString("DeviceSet error"); | 
					
						
							|  |  |  |             return 500; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); | 
					
						
							|  |  |  |         return 404; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     deviceSetList->init(); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |     deviceSetList->setDevicesetcount((int) m_mainCore.m_deviceSets.size()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<DeviceSet*>::const_iterator it = m_mainCore.m_deviceSets.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; it != m_mainCore.m_deviceSets.end(); ++it, i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QList<SWGSDRangel::SWGDeviceSet*> *deviceSets = deviceSetList->getDeviceSets(); | 
					
						
							|  |  |  |         deviceSets->append(new SWGSDRangel::SWGDeviceSet()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         getDeviceSet(deviceSets->back(), *it, i); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIAdapterSrv::getDeviceSet(SWGSDRangel::SWGDeviceSet *swgDeviceSet, const DeviceSet* deviceSet, int deviceUISetIndex) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |     swgDeviceSet->init(); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |     SWGSDRangel::SWGSamplingDevice *samplingDevice = swgDeviceSet->getSamplingDevice(); | 
					
						
							| 
									
										
										
										
											2018-02-13 20:12:54 +01:00
										 |  |  |     samplingDevice->init(); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |     samplingDevice->setIndex(deviceUISetIndex); | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |     if (deviceSet->m_deviceSinkEngine) // Single Tx data
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |         samplingDevice->setDirection(1); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         *samplingDevice->getHwType() = deviceSet->m_deviceAPI->getHardwareId(); | 
					
						
							|  |  |  |         *samplingDevice->getSerial() = deviceSet->m_deviceAPI->getSamplingDeviceSerial(); | 
					
						
							|  |  |  |         samplingDevice->setSequence(deviceSet->m_deviceAPI->getSamplingDeviceSequence()); | 
					
						
							| 
									
										
										
										
											2019-05-21 00:27:08 +02:00
										 |  |  |         samplingDevice->setDeviceNbStreams(deviceSet->m_deviceAPI->getDeviceNbItems()); | 
					
						
							|  |  |  |         samplingDevice->setDeviceStreamIndex(deviceSet->m_deviceAPI->getDeviceItemIndex()); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         deviceSet->m_deviceAPI->getDeviceEngineStateStr(*samplingDevice->getState()); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |         DeviceSampleSink *sampleSink = deviceSet->m_deviceSinkEngine->getSink(); | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |         if (sampleSink) { | 
					
						
							|  |  |  |             samplingDevice->setCenterFrequency(sampleSink->getCenterFrequency()); | 
					
						
							|  |  |  |             samplingDevice->setBandwidth(sampleSink->getSampleRate()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         swgDeviceSet->setChannelcount(deviceSet->m_deviceAPI->getNbSourceChannels()); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |         QList<SWGSDRangel::SWGChannel*> *channels = swgDeviceSet->getChannels(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i <  swgDeviceSet->getChannelcount(); i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |             channels->back()->init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSourceAPIAt(i); | 
					
						
							| 
									
										
										
										
											2017-12-29 05:22:26 +01:00
										 |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							| 
									
										
										
										
											2019-12-23 18:49:06 +01:00
										 |  |  |             channels->back()->setDirection(1); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 15:25:20 +02:00
										 |  |  |     if (deviceSet->m_deviceSourceEngine) // Single Rx data
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-09 11:11:31 +02:00
										 |  |  |         samplingDevice->setDirection(0); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         *samplingDevice->getHwType() = deviceSet->m_deviceAPI->getHardwareId(); | 
					
						
							|  |  |  |         *samplingDevice->getSerial() = deviceSet->m_deviceAPI->getSamplingDeviceSerial(); | 
					
						
							|  |  |  |         samplingDevice->setSequence(deviceSet->m_deviceAPI->getSamplingDeviceSequence()); | 
					
						
							| 
									
										
										
										
											2019-05-21 00:27:08 +02:00
										 |  |  |         samplingDevice->setDeviceNbStreams(deviceSet->m_deviceAPI->getDeviceNbItems()); | 
					
						
							|  |  |  |         samplingDevice->setDeviceStreamIndex(deviceSet->m_deviceAPI->getDeviceItemIndex()); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         deviceSet->m_deviceAPI->getDeviceEngineStateStr(*samplingDevice->getState()); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |         DeviceSampleSource *sampleSource = deviceSet->m_deviceSourceEngine->getSource(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (sampleSource) { | 
					
						
							|  |  |  |             samplingDevice->setCenterFrequency(sampleSource->getCenterFrequency()); | 
					
						
							|  |  |  |             samplingDevice->setBandwidth(sampleSource->getSampleRate()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         swgDeviceSet->setChannelcount(deviceSet->m_deviceAPI->getNbSinkChannels()); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |         QList<SWGSDRangel::SWGChannel*> *channels = swgDeviceSet->getChannels(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i <  swgDeviceSet->getChannelcount(); i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							| 
									
										
										
										
											2018-02-14 11:27:57 +01:00
										 |  |  |             channels->back()->init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSinkAPIAt(i); | 
					
						
							| 
									
										
										
										
											2017-12-29 05:22:26 +01:00
										 |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							| 
									
										
										
										
											2019-12-23 18:49:06 +01:00
										 |  |  |             channels->back()->setDirection(0); | 
					
						
							|  |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (deviceSet->m_deviceMIMOEngine) // MIMO data
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         samplingDevice->setDirection(2); | 
					
						
							|  |  |  |         *samplingDevice->getHwType() = deviceSet->m_deviceAPI->getHardwareId(); | 
					
						
							|  |  |  |         *samplingDevice->getSerial() = deviceSet->m_deviceAPI->getSamplingDeviceSerial(); | 
					
						
							|  |  |  |         samplingDevice->setSequence(deviceSet->m_deviceAPI->getSamplingDeviceSequence()); | 
					
						
							|  |  |  |         samplingDevice->setDeviceNbStreams(deviceSet->m_deviceAPI->getDeviceNbItems()); | 
					
						
							|  |  |  |         samplingDevice->setDeviceStreamIndex(deviceSet->m_deviceAPI->getDeviceItemIndex()); | 
					
						
							|  |  |  |         samplingDevice->setState(new QString("notStarted")); | 
					
						
							|  |  |  |         deviceSet->m_deviceAPI->getDeviceEngineStateStr(*samplingDevice->getStateRx(), 0); | 
					
						
							|  |  |  |         deviceSet->m_deviceAPI->getDeviceEngineStateStr(*samplingDevice->getStateTx(), 1); | 
					
						
							|  |  |  |         DeviceSampleMIMO *sampleMIMO = deviceSet->m_deviceMIMOEngine->getMIMO(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (sampleMIMO) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             samplingDevice->setCenterFrequency(sampleMIMO->getMIMOCenterFrequency()); | 
					
						
							|  |  |  |             samplingDevice->setBandwidth(sampleMIMO->getMIMOSampleRate()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); | 
					
						
							|  |  |  |         int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); | 
					
						
							|  |  |  |         int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); | 
					
						
							|  |  |  |         swgDeviceSet->setChannelcount(nbSinkChannels + nbSourceChannels + nbMIMOChannels); | 
					
						
							|  |  |  |         QList<SWGSDRangel::SWGChannel*> *channels = swgDeviceSet->getChannels(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i < nbSinkChannels; i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							|  |  |  |             channels->back()->init(); | 
					
						
							|  |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSinkAPIAt(i); | 
					
						
							|  |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							|  |  |  |             channels->back()->setDirection(0); | 
					
						
							|  |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i < nbSourceChannels; i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							|  |  |  |             channels->back()->init(); | 
					
						
							|  |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSourceAPIAt(i); | 
					
						
							|  |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							|  |  |  |             channels->back()->setDirection(1); | 
					
						
							|  |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i < nbMIMOChannels; i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							|  |  |  |             channels->back()->init(); | 
					
						
							|  |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(i); | 
					
						
							|  |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							|  |  |  |             channels->back()->setDirection(2); | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-12-18 14:50:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  | void WebAPIAdapterSrv::getChannelsDetail(SWGSDRangel::SWGChannelsDetail *channelsDetail, const DeviceSet* deviceSet) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     channelsDetail->init(); | 
					
						
							|  |  |  |     SWGSDRangel::SWGChannelReport *channelReport; | 
					
						
							|  |  |  |     QString channelReportError; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (deviceSet->m_deviceSinkEngine) // Tx data
 | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         channelsDetail->setChannelcount(deviceSet->m_deviceAPI->getNbSourceChannels()); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |         QList<SWGSDRangel::SWGChannel*> *channels = channelsDetail->getChannels(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i <  channelsDetail->getChannelcount(); i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							|  |  |  |             channels->back()->init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSourceAPIAt(i); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							| 
									
										
										
										
											2019-12-23 18:49:06 +01:00
										 |  |  |             channels->back()->setDirection(1); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             channelReport = new SWGSDRangel::SWGChannelReport(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channel->webapiReportGet(*channelReport, channelReportError) != 501) { | 
					
						
							|  |  |  |                 channels->back()->setReport(channelReport); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 delete channelReport; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (deviceSet->m_deviceSourceEngine) // Rx data
 | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         channelsDetail->setChannelcount(deviceSet->m_deviceAPI->getNbSinkChannels()); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |         QList<SWGSDRangel::SWGChannel*> *channels = channelsDetail->getChannels(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i <  channelsDetail->getChannelcount(); i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							|  |  |  |             channels->back()->init(); | 
					
						
							| 
									
										
										
										
											2019-05-09 17:27:12 +02:00
										 |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSinkAPIAt(i); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							| 
									
										
										
										
											2019-12-23 18:49:06 +01:00
										 |  |  |             channels->back()->setDirection(0); | 
					
						
							|  |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             channelReport = new SWGSDRangel::SWGChannelReport(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channel->webapiReportGet(*channelReport, channelReportError) != 501) { | 
					
						
							|  |  |  |                 channels->back()->setReport(channelReport); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 delete channelReport; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (deviceSet->m_deviceMIMOEngine) // MIMO data
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int nbSinkChannels = deviceSet->m_deviceAPI->getNbSinkChannels(); | 
					
						
							|  |  |  |         int nbSourceChannels = deviceSet->m_deviceAPI->getNbSourceChannels(); | 
					
						
							|  |  |  |         int nbMIMOChannels = deviceSet->m_deviceAPI->getNbMIMOChannels(); | 
					
						
							|  |  |  |         QList<SWGSDRangel::SWGChannel*> *channels = channelsDetail->getChannels(); | 
					
						
							|  |  |  |         channelsDetail->setChannelcount(nbSinkChannels + nbSourceChannels + nbMIMOChannels); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i < nbSinkChannels; i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							|  |  |  |             channels->back()->init(); | 
					
						
							|  |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSinkAPIAt(i); | 
					
						
							|  |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							|  |  |  |             channels->back()->setDirection(0); | 
					
						
							|  |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             channelReport = new SWGSDRangel::SWGChannelReport(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channel->webapiReportGet(*channelReport, channelReportError) != 501) { | 
					
						
							|  |  |  |                 channels->back()->setReport(channelReport); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 delete channelReport; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i <  nbSourceChannels; i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							|  |  |  |             channels->back()->init(); | 
					
						
							|  |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getChanelSourceAPIAt(i); | 
					
						
							|  |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							|  |  |  |             channels->back()->setDirection(1); | 
					
						
							|  |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             channelReport = new SWGSDRangel::SWGChannelReport(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channel->webapiReportGet(*channelReport, channelReportError) != 501) { | 
					
						
							|  |  |  |                 channels->back()->setReport(channelReport); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 delete channelReport; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i <  nbMIMOChannels; i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             channels->append(new SWGSDRangel::SWGChannel); | 
					
						
							|  |  |  |             channels->back()->init(); | 
					
						
							|  |  |  |             ChannelAPI *channel = deviceSet->m_deviceAPI->getMIMOChannelAPIAt(i); | 
					
						
							|  |  |  |             channels->back()->setDeltaFrequency(channel->getCenterFrequency()); | 
					
						
							|  |  |  |             channels->back()->setDirection(2); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:20:54 +01:00
										 |  |  |             channels->back()->setIndex(channel->getIndexInDeviceSet()); | 
					
						
							|  |  |  |             channels->back()->setUid(channel->getUID()); | 
					
						
							|  |  |  |             channel->getIdentifier(*channels->back()->getId()); | 
					
						
							|  |  |  |             channel->getTitle(*channels->back()->getTitle()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             channelReport = new SWGSDRangel::SWGChannelReport(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channel->webapiReportGet(*channelReport, channelReportError) != 501) { | 
					
						
							|  |  |  |                 channels->back()->setReport(channelReport); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 delete channelReport; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 14:50:58 +01:00
										 |  |  | QtMsgType WebAPIAdapterSrv::getMsgTypeFromString(const QString& msgTypeString) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (msgTypeString == "debug") { | 
					
						
							|  |  |  |         return QtDebugMsg; | 
					
						
							|  |  |  |     } else if (msgTypeString == "info") { | 
					
						
							|  |  |  |         return QtInfoMsg; | 
					
						
							|  |  |  |     } else if (msgTypeString == "warning") { | 
					
						
							|  |  |  |         return QtWarningMsg; | 
					
						
							|  |  |  |     } else if (msgTypeString == "error") { | 
					
						
							|  |  |  |         return QtCriticalMsg; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return QtDebugMsg; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIAdapterSrv::getMsgTypeString(const QtMsgType& msgType, QString& levelStr) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     switch (msgType) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     case QtDebugMsg: | 
					
						
							|  |  |  |         levelStr = "debug"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case QtInfoMsg: | 
					
						
							|  |  |  |         levelStr = "info"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case QtWarningMsg: | 
					
						
							|  |  |  |         levelStr = "warning"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case QtCriticalMsg: | 
					
						
							|  |  |  |     case QtFatalMsg: | 
					
						
							|  |  |  |         levelStr = "error"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         levelStr = "debug"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |