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.
remotesinksettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB. //
3 // //
4 // Remote sink channel (Rx) UDP sender thread //
5 // //
6 // SDRangel can work as a detached SDR front end. With this plugin it can //
7 // sends the I/Q samples stream to another SDRangel instance via UDP. //
8 // It is controlled via a Web REST API. //
9 // //
10 // This program is free software; you can redistribute it and/or modify //
11 // it under the terms of the GNU General Public License as published by //
12 // the Free Software Foundation as version 3 of the License, or //
13 // (at your option) any later version. //
14 // //
15 // This program is distributed in the hope that it will be useful, //
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
18 // GNU General Public License V3 for more details. //
19 // //
20 // You should have received a copy of the GNU General Public License //
21 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
23 
24 #include "remotesinksettings.h"
25 
26 #include <QColor>
27 
28 #include "util/simpleserializer.h"
29 #include "settings/serializable.h"
30 
31 
33 {
35 }
36 
38 {
39  m_nbFECBlocks = 0;
40  m_txDelay = 35;
41  m_dataAddress = "127.0.0.1";
42  m_dataPort = 9090;
43  m_rgbColor = QColor(140, 4, 4).rgb();
44  m_title = "Remote sink";
45  m_log2Decim = 0;
47  m_channelMarker = nullptr;
48  m_useReverseAPI = false;
49  m_reverseAPIAddress = "127.0.0.1";
50  m_reverseAPIPort = 8888;
53 }
54 
56 {
57  SimpleSerializer s(1);
58  s.writeU32(1, m_nbFECBlocks);
59  s.writeU32(2, m_txDelay);
61  s.writeU32(4, m_dataPort);
62  s.writeU32(5, m_rgbColor);
63  s.writeString(6, m_title);
69  s.writeU32(12, m_log2Decim);
71 
72  return s.final();
73 }
74 
75 bool RemoteSinkSettings::deserialize(const QByteArray& data)
76 {
77  SimpleDeserializer d(data);
78 
79  if(!d.isValid())
80  {
82  return false;
83  }
84 
85  if(d.getVersion() == 1)
86  {
87  uint32_t tmp;
88  QString strtmp;
89 
90  d.readU32(1, &tmp, 0);
91 
92  if (tmp < 128) {
93  m_nbFECBlocks = tmp;
94  } else {
95  m_nbFECBlocks = 0;
96  }
97 
98  d.readU32(2, &m_txDelay, 35);
99  d.readString(3, &m_dataAddress, "127.0.0.1");
100  d.readU32(4, &tmp, 0);
101 
102  if ((tmp > 1023) && (tmp < 65535)) {
103  m_dataPort = tmp;
104  } else {
105  m_dataPort = 9090;
106  }
107 
108  d.readU32(5, &m_rgbColor, QColor(0, 255, 255).rgb());
109  d.readString(6, &m_title, "Remote sink");
110  d.readBool(7, &m_useReverseAPI, false);
111  d.readString(8, &m_reverseAPIAddress, "127.0.0.1");
112  d.readU32(9, &tmp, 0);
113 
114  if ((tmp > 1023) && (tmp < 65535)) {
115  m_reverseAPIPort = tmp;
116  } else {
117  m_reverseAPIPort = 8888;
118  }
119 
120  d.readU32(10, &tmp, 0);
121  m_reverseAPIDeviceIndex = tmp > 99 ? 99 : tmp;
122  d.readU32(11, &tmp, 0);
123  m_reverseAPIChannelIndex = tmp > 99 ? 99 : tmp;
124  d.readU32(12, &tmp, 0);
125  m_log2Decim = tmp > 6 ? 6 : tmp;
126  d.readU32(13, &m_filterChainHash, 0);
127 
128  return true;
129  }
130  else
131  {
132  resetToDefaults();
133  return false;
134  }
135 }
136 
137 
138 
139 
140 
uint16_t m_reverseAPIDeviceIndex
bool deserialize(const QByteArray &data)
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_reverseAPIChannelIndex
quint32 getVersion() const
void writeU32(quint32 id, quint32 value)
Serializable * m_channelMarker
QByteArray serialize() const
void writeBool(quint32 id, bool value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()