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.
kiwisdrsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2019 Vort //
3 // Copyright (C) 2019 Edouard Griffiths, F4EXB //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #include "util/simpleserializer.h"
20 #include "kiwisdrsettings.h"
21 
23 {
25 }
26 
28 {
29  m_centerFrequency = 1450000;
30 
31  m_gain = 20;
32  m_useAGC = true;
33  m_dcBlock = false;
34 
35  m_serverAddress = "127.0.0.1:8073";
36 
37  m_fileRecordName = "";
38  m_useReverseAPI = false;
39  m_reverseAPIAddress = "127.0.0.1";
40  m_reverseAPIPort = 8888;
42 }
43 
44 QByteArray KiwiSDRSettings::serialize() const
45 {
46  SimpleSerializer s(2);
47 
49  s.writeU32(3, m_gain);
50  s.writeBool(4, m_useAGC);
51 
52  s.writeBool(100, m_useReverseAPI);
54  s.writeU32(102, m_reverseAPIPort);
56 
57  return s.final();
58 }
59 
60 bool KiwiSDRSettings::deserialize(const QByteArray& data)
61 {
62  SimpleDeserializer d(data);
63 
64  if (!d.isValid())
65  {
67  return false;
68  }
69 
70  if (d.getVersion() == 2)
71  {
72  uint32_t utmp;
73 
74  d.readString(2, &m_serverAddress, "127.0.0.1:8073");
75  d.readU32(3, &m_gain, 20);
76  d.readBool(4, &m_useAGC, true);
77 
78  d.readBool(100, &m_useReverseAPI, false);
79  d.readString(101, &m_reverseAPIAddress, "127.0.0.1");
80  d.readU32(102, &utmp, 0);
81 
82  if ((utmp > 1023) && (utmp < 65535)) {
83  m_reverseAPIPort = utmp;
84  }
85  else {
86  m_reverseAPIPort = 8888;
87  }
88 
89  d.readU32(103, &utmp, 0);
90  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
91 
92  return true;
93  }
94  else
95  {
97  return false;
98  }
99 }
100 
101 
102 
103 
104 
105 
QString m_serverAddress
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
QString m_reverseAPIAddress
unsigned int uint32_t
Definition: rtptypes_win.h:46
uint16_t m_reverseAPIDeviceIndex
QString m_fileRecordName
quint32 getVersion() const
void writeU32(quint32 id, quint32 value)
bool deserialize(const QByteArray &data)
void writeBool(quint32 id, bool value)
uint16_t m_reverseAPIPort
quint64 m_centerFrequency
void writeString(quint32 id, const QString &value)
const QByteArray & final()
QByteArray serialize() const