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.
airspyhfsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 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 <QtGlobal>
19 #include "util/simpleserializer.h"
20 
21 #include "airspyhfsettings.h"
22 
24 {
26 }
27 
29 {
30  m_centerFrequency = 7150*1000;
31  m_LOppmTenths = 0;
33  m_log2Decim = 0;
34  m_transverterMode = false;
36  m_bandIndex = 0;
37  m_fileRecordName = "";
38  m_useReverseAPI = false;
39  m_reverseAPIAddress = "127.0.0.1";
40  m_reverseAPIPort = 8888;
42  m_useDSP = true;
43  m_useAGC = false;
44  m_agcHigh = false;
45  m_useLNA = false;
47  m_dcBlock = false;
48  m_iqCorrection = false;
49 }
50 
51 QByteArray AirspyHFSettings::serialize() const
52 {
53  SimpleSerializer s(1);
54 
56  s.writeS32(2, m_LOppmTenths);
57  s.writeU32(3, m_log2Decim);
60  s.writeU32(9, m_bandIndex);
65  s.writeBool(14, m_useDSP);
66  s.writeBool(15, m_useAGC);
67  s.writeBool(16, m_agcHigh);
68  s.writeBool(17, m_useLNA);
70  s.writeBool(19, m_dcBlock);
72 
73  return s.final();
74 }
75 
76 bool AirspyHFSettings::deserialize(const QByteArray& data)
77 {
78  SimpleDeserializer d(data);
79 
80  if (!d.isValid())
81  {
83  return false;
84  }
85 
86  if (d.getVersion() == 1)
87  {
88  int intval;
89  quint32 uintval;
90 
91  d.readU32(1, &m_devSampleRateIndex, 0);
92  d.readS32(2, &m_LOppmTenths, 0);
93  d.readU32(3, &m_log2Decim, 0);
94  d.readS32(4, &intval, 0);
95  d.readBool(7, &m_transverterMode, false);
97  d.readU32(9, &uintval, 0);
98  m_bandIndex = uintval > 1 ? 1 : uintval;
99  d.readBool(10, &m_useReverseAPI, false);
100  d.readString(11, &m_reverseAPIAddress, "127.0.0.1");
101  d.readU32(12, &uintval, 0);
102 
103  if ((uintval > 1023) && (uintval < 65535)) {
104  m_reverseAPIPort = uintval;
105  } else {
106  m_reverseAPIPort = 8888;
107  }
108 
109  d.readU32(13, &uintval, 0);
110  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
111  d.readBool(14, &m_useDSP, true);
112  d.readBool(15, &m_useAGC, false);
113  d.readBool(16, &m_agcHigh, false);
114  d.readBool(17, &m_useLNA, false);
115  d.readU32(18, &m_attenuatorSteps, 0);
116  d.readBool(19, &m_dcBlock, false);
117  d.readBool(20, &m_iqCorrection, false);
118 
119  return true;
120  }
121  else
122  {
123  resetToDefaults();
124  return false;
125  }
126 }
bool deserialize(const QByteArray &data)
bool readS64(quint32 id, qint64 *result, qint64 def=0) const
uint16_t m_reverseAPIDeviceIndex
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
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
qint64 m_transverterDeltaFrequency
QString m_reverseAPIAddress
void writeS32(quint32 id, qint32 value)
quint32 m_devSampleRateIndex
quint32 getVersion() const
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
void writeS64(quint32 id, qint64 value)
QByteArray serialize() const
void writeString(quint32 id, const QString &value)
const QByteArray & final()