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.
remoteoutputsettings.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 "remoteoutputsettings.h"
20 
22 {
24 }
25 
27 {
28  m_centerFrequency = 435000*1000;
29  m_sampleRate = 48000;
30  m_txDelay = 0.35;
31  m_nbFECBlocks = 0;
32  m_apiAddress = "127.0.0.1";
33  m_apiPort = 9091;
34  m_dataAddress = "127.0.0.1";
35  m_dataPort = 9090;
36  m_deviceIndex = 0;
37  m_channelIndex = 0;
38  m_useReverseAPI = false;
39  m_reverseAPIAddress = "127.0.0.1";
40  m_reverseAPIPort = 8888;
42 }
43 
45 {
46  SimpleSerializer s(1);
47 
49  s.writeU32(2, m_sampleRate);
50  s.writeFloat(3, m_txDelay);
51  s.writeU32(4, m_nbFECBlocks);
53  s.writeU32(6, m_apiPort);
55  s.writeU32(8, m_dataPort);
56  s.writeU32(10, m_deviceIndex);
57  s.writeU32(11, m_channelIndex);
62 
63  return s.final();
64 }
65 
66 bool RemoteOutputSettings::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  quint32 uintval;
79 
80  d.readU64(1, &m_centerFrequency, 435000*1000);
81  d.readU32(2, &m_sampleRate, 48000);
82  d.readFloat(3, &m_txDelay, 0.5);
83  d.readU32(4, &m_nbFECBlocks, 0);
84  d.readString(5, &m_apiAddress, "127.0.0.1");
85  d.readU32(6, &uintval, 9090);
86  m_apiPort = uintval % (1<<16);
87  d.readString(7, &m_dataAddress, "127.0.0.1");
88  d.readU32(8, &uintval, 9090);
89  m_dataPort = uintval % (1<<16);
90  d.readU32(10, &m_deviceIndex, 0);
91  d.readU32(11, &m_channelIndex, 0);
92  d.readBool(12, &m_useReverseAPI, false);
93  d.readString(13, &m_reverseAPIAddress, "127.0.0.1");
94  d.readU32(14, &uintval, 0);
95 
96  if ((uintval > 1023) && (uintval < 65535)) {
97  m_reverseAPIPort = uintval;
98  } else {
99  m_reverseAPIPort = 8888;
100  }
101 
102  d.readU32(15, &uintval, 0);
103  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
104 
105  return true;
106  }
107  else
108  {
109  resetToDefaults();
110  return false;
111  }
112 }
bool readFloat(quint32 id, float *result, float def=0) const
void writeFloat(quint32 id, float value)
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
bool readU64(quint32 id, quint64 *result, quint64 def=0) const
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
QByteArray serialize() const
void writeString(quint32 id, const QString &value)
bool deserialize(const QByteArray &data)
const QByteArray & final()
void writeU64(quint32 id, quint64 value)