2017-10-07 20:18:33 +00:00
|
|
|
#include "lorademodsettings.h"
|
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "settings/serializable.h"
|
|
|
|
#include "lorademodsettings.h"
|
|
|
|
|
2017-10-07 22:28:42 +00:00
|
|
|
const int LoRaDemodSettings::bandwidths[] = {7813,15625,20833,31250,62500};
|
|
|
|
const int LoRaDemodSettings::nb_bandwidths = 5;
|
|
|
|
|
2017-10-07 20:18:33 +00:00
|
|
|
LoRaDemodSettings::LoRaDemodSettings() :
|
2018-02-22 02:04:42 +00:00
|
|
|
m_centerFrequency(0),
|
2017-10-07 20:18:33 +00:00
|
|
|
m_channelMarker(0),
|
|
|
|
m_spectrumGUI(0)
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoRaDemodSettings::resetToDefaults()
|
|
|
|
{
|
2017-10-07 22:28:42 +00:00
|
|
|
m_bandwidthIndex = 0;
|
2017-10-07 20:18:33 +00:00
|
|
|
m_spread = 0;
|
2017-10-07 23:42:18 +00:00
|
|
|
m_rgbColor = QColor(255, 0, 255).rgb();
|
2017-11-19 17:18:17 +00:00
|
|
|
m_title = "LoRa Demodulator";
|
2017-10-07 20:18:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray LoRaDemodSettings::serialize() const
|
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
|
|
|
s.writeS32(1, m_centerFrequency);
|
2017-10-07 22:28:42 +00:00
|
|
|
s.writeS32(2, m_bandwidthIndex);
|
2017-10-07 20:18:33 +00:00
|
|
|
s.writeS32(3, m_spread);
|
|
|
|
|
|
|
|
if (m_spectrumGUI) {
|
|
|
|
s.writeBlob(4, m_spectrumGUI->serialize());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_channelMarker) {
|
|
|
|
s.writeBlob(5, m_channelMarker->serialize());
|
|
|
|
}
|
|
|
|
|
2017-11-19 17:18:17 +00:00
|
|
|
s.writeString(6, m_title);
|
|
|
|
|
2017-10-07 20:18:33 +00:00
|
|
|
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);
|
2017-10-07 22:28:42 +00:00
|
|
|
d.readS32(2, &m_bandwidthIndex, 0);
|
2017-10-07 20:18:33 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-11-19 17:18:17 +00:00
|
|
|
d.readString(6, &m_title, "LoRa Demodulator");
|
|
|
|
|
2017-10-07 20:18:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|