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.
bladerf2outputsettings.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 "bladerf2outputsettings.h"
19 
20 #include <QtGlobal>
21 #include "util/simpleserializer.h"
22 
23 
25 {
27 }
28 
30 {
31  m_centerFrequency = 435000*1000;
32  m_LOppmTenths = 0;
33  m_devSampleRate = 3072000;
34  m_bandwidth = 1500000;
35  m_globalGain = -3;
36  m_biasTee = false;
37  m_log2Interp = 0;
38  m_transverterMode = false;
40  m_useReverseAPI = false;
41  m_reverseAPIAddress = "127.0.0.1";
42  m_reverseAPIPort = 8888;
44 }
45 
47 {
48  SimpleSerializer s(1);
49 
51  s.writeS32(2, m_bandwidth);
52  s.writeS32(3, m_LOppmTenths);
53  s.writeS32(4, m_globalGain);
54  s.writeBool(5, m_biasTee);
55  s.writeU32(6, m_log2Interp);
62 
63  return s.final();
64 }
65 
66 bool BladeRF2OutputSettings::deserialize(const QByteArray& data)
67 {
68  SimpleDeserializer d(data);
69 
70  if (!d.isValid())
71  {
73  return false;
74  }
75 
76  if (d.getVersion() == 1)
77  {
78  uint32_t uintval;
79 
80  d.readS32(1, &m_devSampleRate);
81  d.readS32(2, &m_bandwidth);
82  d.readS32(3, &m_LOppmTenths);
83  d.readS32(4, &m_globalGain);
84  d.readBool(5, &m_biasTee);
85  d.readU32(6, &m_log2Interp);
86  d.readBool(7, &m_transverterMode, false);
88  d.readBool(9, &m_useReverseAPI, false);
89  d.readString(10, &m_reverseAPIAddress, "127.0.0.1");
90  d.readU32(11, &uintval, 0);
91 
92  if ((uintval > 1023) && (uintval < 65535)) {
93  m_reverseAPIPort = uintval;
94  } else {
95  m_reverseAPIPort = 8888;
96  }
97 
98  d.readU32(12, &uintval, 0);
99  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
100 
101  return true;
102  }
103  else
104  {
105  resetToDefaults();
106  return false;
107  }
108 }
109 
110 
111 
112 
bool readS64(quint32 id, qint64 *result, qint64 def=0) const
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
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
void writeS64(quint32 id, qint64 value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
bool deserialize(const QByteArray &data)