/////////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2019-2020 Edouard Griffiths, F4EXB // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation as version 3 of the License, or // // (at your option) any later version. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License V3 for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// #include "lorademodsettings.h" #include #include "dsp/dspengine.h" #include "util/simpleserializer.h" #include "settings/serializable.h" #include "lorademodsettings.h" const int LoRaDemodSettings::bandwidths[] = {7813, 10417, 15625, 20833, 31250, 41667, 62500, 125000, 250000, 500000}; const int LoRaDemodSettings::nbBandwidths = 10; LoRaDemodSettings::LoRaDemodSettings() : m_inputFrequencyOffset(0), m_channelMarker(0), m_spectrumGUI(0) { resetToDefaults(); } void LoRaDemodSettings::resetToDefaults() { m_bandwidthIndex = 5; m_spreadFactor = 7; m_deBits = 0; m_rgbColor = QColor(255, 0, 255).rgb(); m_title = "LoRa Demodulator"; } QByteArray LoRaDemodSettings::serialize() const { SimpleSerializer s(1); s.writeS32(1, m_inputFrequencyOffset); s.writeS32(2, m_bandwidthIndex); s.writeS32(3, m_spreadFactor); if (m_spectrumGUI) { s.writeBlob(4, m_spectrumGUI->serialize()); } if (m_channelMarker) { s.writeBlob(5, m_channelMarker->serialize()); } s.writeString(6, m_title); s.writeS32(7, m_deBits); 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_inputFrequencyOffset, 0); d.readS32(2, &m_bandwidthIndex, 0); d.readS32(3, &m_spreadFactor, 0); if (m_spectrumGUI) { d.readBlob(4, &bytetmp); m_spectrumGUI->deserialize(bytetmp); } if (m_channelMarker) { d.readBlob(5, &bytetmp); m_channelMarker->deserialize(bytetmp); } d.readString(6, &m_title, "LoRa Demodulator"); d.readS32(7, &m_deBits, 0); return true; } else { resetToDefaults(); return false; } }