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.
rtlsdrsettings.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 <QtGlobal>
19 #include "util/simpleserializer.h"
20 #include "rtlsdrsettings.h"
21 
23 {
25 }
26 
28 {
29  m_devSampleRate = 1024*1000;
30  m_lowSampleRate = false;
31  m_centerFrequency = 435000*1000;
32  m_gain = 0;
34  m_log2Decim = 4;
36  m_dcBlock = false;
37  m_iqImbalance = false;
38  m_agc = false;
39  m_noModMode = false;
40  m_transverterMode = false;
42  m_rfBandwidth = 2500 * 1000; // Hz
43  m_fileRecordName = "";
44  m_offsetTuning = false;
45  m_useReverseAPI = false;
46  m_reverseAPIAddress = "127.0.0.1";
47  m_reverseAPIPort = 8888;
49 }
50 
51 QByteArray RTLSDRSettings::serialize() const
52 {
53  SimpleSerializer s(1);
54 
55  s.writeS32(2, m_gain);
57  s.writeU32(4, m_log2Decim);
58  s.writeBool(5, m_dcBlock);
60  s.writeS32(7, (int) m_fcPos);
63  s.writeBool(10, m_agc);
64  s.writeBool(11, m_noModMode);
67  s.writeU32(14, m_rfBandwidth);
73 
74  return s.final();
75 }
76 
77 bool RTLSDRSettings::deserialize(const QByteArray& data)
78 {
79  SimpleDeserializer d(data);
80 
81  if (!d.isValid())
82  {
84  return false;
85  }
86 
87  if (d.getVersion() == 1)
88  {
89  int intval;
90  uint32_t utmp;
91 
92  d.readS32(2, &m_gain, 0);
93  d.readS32(3, &m_loPpmCorrection, 0);
94  d.readU32(4, &m_log2Decim, 4);
95  d.readBool(5, &m_dcBlock, false);
96  d.readBool(6, &m_iqImbalance, false);
97  d.readS32(7, &intval, 0);
98  m_fcPos = (fcPos_t) intval;
99  d.readS32(8, &m_devSampleRate, 1024*1000);
100  d.readBool(9, &m_lowSampleRate, false);
101  d.readBool(10, &m_agc, false);
102  d.readBool(11, &m_noModMode, false);
103  d.readBool(12, &m_transverterMode, false);
105  d.readU32(4, &m_rfBandwidth, 2500 * 1000);
106  d.readBool(15, &m_offsetTuning, false);
107  d.readBool(16, &m_useReverseAPI, false);
108  d.readString(17, &m_reverseAPIAddress, "127.0.0.1");
109  d.readU32(18, &utmp, 0);
110 
111  if ((utmp > 1023) && (utmp < 65535)) {
112  m_reverseAPIPort = utmp;
113  } else {
114  m_reverseAPIPort = 8888;
115  }
116 
117  d.readU32(19, &utmp, 0);
118  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
119 
120  return true;
121  }
122  else
123  {
124  resetToDefaults();
125  return false;
126  }
127 }
128 
129 
QByteArray serialize() const
bool readS64(quint32 id, qint64 *result, qint64 def=0) const
QString m_fileRecordName
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
uint16_t m_reverseAPIDeviceIndex
uint16_t m_reverseAPIPort
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
quint32 m_log2Decim
quint32 m_rfBandwidth
RF filter bandwidth in Hz.
qint32 m_loPpmCorrection
void writeU32(quint32 id, quint32 value)
QString m_reverseAPIAddress
void writeBool(quint32 id, bool value)
void writeS64(quint32 id, qint64 value)
qint64 m_transverterDeltaFrequency
void writeString(quint32 id, const QString &value)
quint64 m_centerFrequency
bool deserialize(const QByteArray &data)
const QByteArray & final()