1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-05 08:21:16 -05:00
sdrangel/plugins/channelrx/demodlora/lorademodsettings.cpp
2017-10-07 22:18:33 +02:00

77 lines
1.4 KiB
C++

#include "lorademodsettings.h"
#include <QColor>
#include "dsp/dspengine.h"
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "lorademodsettings.h"
LoRaDemodSettings::LoRaDemodSettings() :
m_channelMarker(0),
m_spectrumGUI(0)
{
resetToDefaults();
}
void LoRaDemodSettings::resetToDefaults()
{
m_bandwidth = 0;
m_spread = 0;
}
QByteArray LoRaDemodSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_centerFrequency);
s.writeS32(2, m_bandwidth);
s.writeS32(3, m_spread);
if (m_spectrumGUI) {
s.writeBlob(4, m_spectrumGUI->serialize());
}
if (m_channelMarker) {
s.writeBlob(5, m_channelMarker->serialize());
}
return s.final();
}
bool LoRaDemodSettings::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid())
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1)
{
QByteArray bytetmp;
d.readS32(1, &m_centerFrequency, 0);
d.readS32(2, &m_bandwidth, 0);
d.readS32(3, &m_spread, 0);
if (m_spectrumGUI) {
d.readBlob(4, &bytetmp);
m_spectrumGUI->deserialize(bytetmp);
}
if (m_channelMarker) {
d.readBlob(5, &bytetmp);
m_channelMarker->deserialize(bytetmp);
}
return true;
}
else
{
resetToDefaults();
return false;
}
}