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.
remoteinputsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 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 "util/simpleserializer.h"
19 #include "remoteinputsettings.h"
20 
22 {
24 }
25 
27 {
28  m_apiAddress = "127.0.0.1";
29  m_apiPort = 9091;
30  m_dataAddress = "127.0.0.1";
31  m_dataPort = 9090;
32  m_dcBlock = false;
33  m_iqCorrection = false;
34  m_fileRecordName = "";
35  m_useReverseAPI = false;
36  m_reverseAPIAddress = "127.0.0.1";
37  m_reverseAPIPort = 8888;
39 }
40 
42 {
43  SimpleSerializer s(1);
44 
46  s.writeU32(6, m_apiPort);
47  s.writeU32(7, m_dataPort);
49  s.writeBool(9, m_dcBlock);
55 
56  return s.final();
57 }
58 
59 bool RemoteInputSettings::deserialize(const QByteArray& data)
60 {
61  SimpleDeserializer d(data);
62 
63  if (!d.isValid())
64  {
66  return false;
67  }
68 
69  if (d.getVersion() == 1)
70  {
71  quint32 uintval;
72 
73  d.readString(5, &m_apiAddress, "127.0.0.1");
74  d.readU32(6, &uintval, 9090);
75  m_apiPort = uintval % (1<<16);
76  d.readU32(7, &uintval, 9091);
77  m_dataPort = uintval % (1<<16);
78  d.readString(8, &m_dataAddress, "127.0.0.1");
79  d.readBool(9, &m_dcBlock, false);
80  d.readBool(10, &m_iqCorrection, false);
81  d.readBool(11, &m_useReverseAPI, false);
82  d.readString(12, &m_reverseAPIAddress, "127.0.0.1");
83  d.readU32(13, &uintval, 0);
84 
85  if ((uintval > 1023) && (uintval < 65535)) {
86  m_reverseAPIPort = uintval;
87  } else {
88  m_reverseAPIPort = 8888;
89  }
90 
91  d.readU32(14, &uintval, 0);
92  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
93  return true;
94  }
95  else
96  {
98  return false;
99  }
100 }
101 
102 
103 
QByteArray serialize() 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
quint32 getVersion() const
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
bool deserialize(const QByteArray &data)
void writeString(quint32 id, const QString &value)
const QByteArray & final()