SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
sdrplaysettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2015 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include "sdrplaysettings.h"
19 
20 #include <QtGlobal>
21 #include "util/simpleserializer.h"
22 
24 {
26 }
27 
29 {
30  m_centerFrequency = 7040*1000;
31  m_tunerGain = 0;
32  m_LOppmTenths = 0;
35  m_bandwidthIndex = 0;
37  m_log2Decim = 0;
39  m_dcBlock = false;
40  m_iqCorrection = false;
41  m_tunerGainMode = true;
42  m_lnaOn = false;
43  m_mixerAmpOn = false;
44  m_basebandGain = 29;
45  m_fileRecordName = "";
46  m_useReverseAPI = false;
47  m_reverseAPIAddress = "127.0.0.1";
48  m_reverseAPIPort = 8888;
50 }
51 
52 QByteArray SDRPlaySettings::serialize() const
53 {
54  SimpleSerializer s(1);
55 
56  s.writeS32(1, m_LOppmTenths);
59  s.writeS32(4, m_tunerGain);
62  s.writeU32(7, m_log2Decim);
63  s.writeS32(8, (int) m_fcPos);
64  s.writeBool(9, m_dcBlock);
67  s.writeBool(12, m_lnaOn);
68  s.writeBool(13, m_mixerAmpOn);
69  s.writeS32(14, m_basebandGain);
74 
75  return s.final();
76 }
77 
78 bool SDRPlaySettings::deserialize(const QByteArray& data)
79 {
80  SimpleDeserializer d(data);
81 
82  if (!d.isValid())
83  {
85  return false;
86  }
87 
88  if (d.getVersion() == 1)
89  {
90  int intval;
91  uint32_t uintval;
92 
93  d.readS32(1, &m_LOppmTenths, 0);
94  d.readU32(2, &m_frequencyBandIndex, 0);
95  d.readU32(3, &m_ifFrequencyIndex, 0);
96  d.readS32(4, &m_tunerGain, 0);
97  d.readU32(5, &m_bandwidthIndex, 0);
98  d.readU32(6, &m_devSampleRateIndex, 0);
99  d.readU32(7, &m_log2Decim, 0);
100  d.readS32(8, &intval, 0);
101  m_fcPos = (fcPos_t) intval;
102  d.readBool(9, &m_dcBlock, false);
103  d.readBool(10, &m_iqCorrection, false);
104  d.readBool(11, &m_tunerGainMode, true);
105  d.readBool(12, &m_lnaOn, false);
106  d.readBool(13, &m_mixerAmpOn, false);
107  d.readS32(14, &m_basebandGain, 29);
108  d.readBool(15, &m_useReverseAPI, false);
109  d.readString(16, &m_reverseAPIAddress, "127.0.0.1");
110  d.readU32(17, &uintval, 0);
111 
112  if ((uintval > 1023) && (uintval < 65535)) {
113  m_reverseAPIPort = uintval;
114  } else {
115  m_reverseAPIPort = 8888;
116  }
117 
118  d.readU32(18, &uintval, 0);
119  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
120 
121  return true;
122  }
123  else
124  {
125  resetToDefaults();
126  return false;
127  }
128 }
uint32_t m_ifFrequencyIndex
uint16_t m_reverseAPIPort
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
bool readBool(quint32 id, bool *result, bool def=false) const
bool isValid() const
unsigned int uint32_t
Definition: rtptypes_win.h:46
QString m_reverseAPIAddress
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
QByteArray serialize() const
QString m_fileRecordName
uint64_t m_centerFrequency
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
uint32_t m_frequencyBandIndex
void writeU32(quint32 id, quint32 value)
uint32_t m_log2Decim
uint32_t m_bandwidthIndex
bool deserialize(const QByteArray &data)
void writeBool(quint32 id, bool value)
void writeString(quint32 id, const QString &value)
uint16_t m_reverseAPIDeviceIndex
uint32_t m_devSampleRateIndex
const QByteArray & final()