| 
									
										
										
										
											2017-04-15 04:52:12 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2017 Edouard Griffiths, F4EXB                                   //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | #include "util/simpleserializer.h"
 | 
					
						
							| 
									
										
										
										
											2017-04-15 04:52:12 +02:00
										 |  |  | #include "limesdrinputsettings.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LimeSDRInputSettings::LimeSDRInputSettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     resetToDefaults(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputSettings::resetToDefaults() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_centerFrequency = 435000*1000; | 
					
						
							| 
									
										
										
										
											2017-04-18 23:26:30 +02:00
										 |  |  |     m_devSampleRate = 5000000; | 
					
						
							|  |  |  |     m_log2HardDecim = 3; | 
					
						
							| 
									
										
										
										
											2017-04-15 04:52:12 +02:00
										 |  |  |     m_dcBlock = false; | 
					
						
							|  |  |  |     m_iqCorrection = false; | 
					
						
							|  |  |  |     m_log2SoftDecim = 0; | 
					
						
							| 
									
										
										
										
											2017-04-18 23:26:30 +02:00
										 |  |  |     m_lpfBW = 4.5e6f; | 
					
						
							| 
									
										
										
										
											2017-04-15 04:52:12 +02:00
										 |  |  |     m_lpfFIREnable = false; | 
					
						
							| 
									
										
										
										
											2017-04-18 23:26:30 +02:00
										 |  |  |     m_lpfFIRBW = 2.5e6f; | 
					
						
							| 
									
										
										
										
											2017-05-08 11:03:05 +02:00
										 |  |  |     m_gain = 50; | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  |     m_ncoEnable = false; | 
					
						
							|  |  |  |     m_ncoFrequency = 0; | 
					
						
							| 
									
										
										
										
											2017-04-23 16:23:01 +02:00
										 |  |  |     m_antennaPath = PATH_RFE_NONE; | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |     m_gainMode = GAIN_AUTO; | 
					
						
							|  |  |  |     m_lnaGain = 15; | 
					
						
							|  |  |  |     m_tiaGain = 2; | 
					
						
							|  |  |  |     m_pgaGain = 16; | 
					
						
							| 
									
										
										
										
											2017-11-04 02:18:16 +01:00
										 |  |  |     m_extClock = false; | 
					
						
							|  |  |  |     m_extClockFreq = 10000000; // 10 MHz
 | 
					
						
							| 
									
										
										
										
											2018-04-17 00:25:19 +02:00
										 |  |  |     m_transverterMode = false; | 
					
						
							|  |  |  |     m_transverterDeltaFrequency = 0; | 
					
						
							| 
									
										
										
										
											2018-05-09 17:39:48 +02:00
										 |  |  |     m_fileRecordName = ""; | 
					
						
							| 
									
										
										
										
											2018-11-29 01:21:44 +01:00
										 |  |  |     m_gpioDir = 0; | 
					
						
							|  |  |  |     m_gpioPins = 0; | 
					
						
							| 
									
										
										
										
											2018-12-18 23:37:26 +01:00
										 |  |  |     m_useReverseAPI = false; | 
					
						
							|  |  |  |     m_reverseAPIAddress = "127.0.0.1"; | 
					
						
							|  |  |  |     m_reverseAPIPort = 8888; | 
					
						
							|  |  |  |     m_reverseAPIDeviceIndex = 0; | 
					
						
							| 
									
										
										
										
											2017-04-15 04:52:12 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QByteArray LimeSDRInputSettings::serialize() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SimpleSerializer s(1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     s.writeS32(1, m_devSampleRate); | 
					
						
							|  |  |  |     s.writeU32(2, m_log2HardDecim); | 
					
						
							|  |  |  |     s.writeBool(3, m_dcBlock); | 
					
						
							|  |  |  |     s.writeBool(4, m_iqCorrection); | 
					
						
							|  |  |  |     s.writeU32(5, m_log2SoftDecim); | 
					
						
							|  |  |  |     s.writeFloat(7, m_lpfBW); | 
					
						
							|  |  |  |     s.writeBool(8, m_lpfFIREnable); | 
					
						
							|  |  |  |     s.writeFloat(9, m_lpfFIRBW); | 
					
						
							|  |  |  |     s.writeU32(10, m_gain); | 
					
						
							| 
									
										
										
										
											2017-04-21 16:46:09 +02:00
										 |  |  |     s.writeBool(11, m_ncoEnable); | 
					
						
							|  |  |  |     s.writeS32(12, m_ncoFrequency); | 
					
						
							| 
									
										
										
										
											2017-05-07 01:47:31 +02:00
										 |  |  |     s.writeS32(13, (int) m_antennaPath); | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |     s.writeS32(14, (int) m_gainMode); | 
					
						
							|  |  |  |     s.writeU32(15, m_lnaGain); | 
					
						
							|  |  |  |     s.writeU32(16, m_tiaGain); | 
					
						
							|  |  |  |     s.writeU32(17, m_pgaGain); | 
					
						
							| 
									
										
										
										
											2017-11-04 02:18:16 +01:00
										 |  |  |     s.writeBool(18, m_extClock); | 
					
						
							|  |  |  |     s.writeU32(19, m_extClockFreq); | 
					
						
							| 
									
										
										
										
											2018-04-17 00:25:19 +02:00
										 |  |  |     s.writeBool(20, m_transverterMode); | 
					
						
							|  |  |  |     s.writeS64(21, m_transverterDeltaFrequency); | 
					
						
							| 
									
										
										
										
											2018-11-29 01:21:44 +01:00
										 |  |  |     s.writeU32(22, m_gpioDir); | 
					
						
							|  |  |  |     s.writeU32(23, m_gpioPins); | 
					
						
							| 
									
										
										
										
											2018-12-18 23:37:26 +01:00
										 |  |  |     s.writeBool(24, m_useReverseAPI); | 
					
						
							|  |  |  |     s.writeString(25, m_reverseAPIAddress); | 
					
						
							|  |  |  |     s.writeU32(26, m_reverseAPIPort); | 
					
						
							|  |  |  |     s.writeU32(27, m_reverseAPIDeviceIndex); | 
					
						
							| 
									
										
										
										
											2017-04-15 04:52:12 +02:00
										 |  |  |     return s.final(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool LimeSDRInputSettings::deserialize(const QByteArray& data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SimpleDeserializer d(data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!d.isValid()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         resetToDefaults(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (d.getVersion() == 1) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int intval; | 
					
						
							| 
									
										
										
										
											2018-11-29 01:21:44 +01:00
										 |  |  |         uint32_t uintval; | 
					
						
							| 
									
										
										
										
											2017-04-15 04:52:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 16:46:09 +02:00
										 |  |  |         d.readS32(1, &m_devSampleRate, 5000000); | 
					
						
							| 
									
										
										
										
											2017-04-15 04:52:12 +02:00
										 |  |  |         d.readU32(2, &m_log2HardDecim, 2); | 
					
						
							|  |  |  |         d.readBool(3, &m_dcBlock, false); | 
					
						
							|  |  |  |         d.readBool(4, &m_iqCorrection, false); | 
					
						
							|  |  |  |         d.readU32(5, &m_log2SoftDecim, 0); | 
					
						
							|  |  |  |         d.readFloat(7, &m_lpfBW, 1.5e6); | 
					
						
							|  |  |  |         d.readBool(8, &m_lpfFIREnable, false); | 
					
						
							|  |  |  |         d.readFloat(9, &m_lpfFIRBW, 1.5e6); | 
					
						
							| 
									
										
										
										
											2017-05-08 11:03:05 +02:00
										 |  |  |         d.readU32(10, &m_gain, 50); | 
					
						
							| 
									
										
										
										
											2017-04-21 16:46:09 +02:00
										 |  |  |         d.readBool(11, &m_ncoEnable, false); | 
					
						
							|  |  |  |         d.readS32(12, &m_ncoFrequency, 0); | 
					
						
							| 
									
										
										
										
											2017-05-07 01:47:31 +02:00
										 |  |  |         d.readS32(13, &intval, 0); | 
					
						
							|  |  |  |         m_antennaPath = (PathRFE) intval; | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |         d.readS32(14, &intval, 0); | 
					
						
							|  |  |  |         m_gainMode = (GainMode) intval; | 
					
						
							|  |  |  |         d.readU32(15, &m_lnaGain, 15); | 
					
						
							|  |  |  |         d.readU32(16, &m_tiaGain, 2); | 
					
						
							|  |  |  |         d.readU32(17, &m_pgaGain, 16); | 
					
						
							| 
									
										
										
										
											2017-11-04 02:18:16 +01:00
										 |  |  |         d.readBool(18, &m_extClock, false); | 
					
						
							|  |  |  |         d.readU32(19, &m_extClockFreq, 10000000); | 
					
						
							| 
									
										
										
										
											2018-04-17 00:25:19 +02:00
										 |  |  |         d.readBool(20, &m_transverterMode, false); | 
					
						
							|  |  |  |         d.readS64(21, &m_transverterDeltaFrequency, 0); | 
					
						
							| 
									
										
										
										
											2018-11-29 01:21:44 +01:00
										 |  |  |         d.readU32(22, &uintval, 0); | 
					
						
							|  |  |  |         m_gpioDir = uintval & 0xFF; | 
					
						
							|  |  |  |         d.readU32(23, &uintval, 0); | 
					
						
							|  |  |  |         m_gpioPins = uintval & 0xFF; | 
					
						
							| 
									
										
										
										
											2018-12-18 23:37:26 +01:00
										 |  |  |         d.readBool(24, &m_useReverseAPI, false); | 
					
						
							|  |  |  |         d.readString(25, &m_reverseAPIAddress, "127.0.0.1"); | 
					
						
							|  |  |  |         d.readU32(26, &uintval, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ((uintval > 1023) && (uintval < 65535)) { | 
					
						
							|  |  |  |             m_reverseAPIPort = uintval; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             m_reverseAPIPort = 8888; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         d.readU32(27, &uintval, 0); | 
					
						
							|  |  |  |         m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval; | 
					
						
							| 
									
										
										
										
											2017-04-15 04:52:12 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         resetToDefaults(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 |