sdrangel/plugins/channelrx/demodlora/lorademod.h

141 wiersze
4.4 KiB
C
Czysty Zwykły widok Historia

2015-01-11 00:12:58 +00:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// (C) 2015 John Greb //
// //
// 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 //
// //
// 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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_LoRaDEMOD_H
#define INCLUDE_LoRaDEMOD_H
#include <QMutex>
2015-01-11 00:12:58 +00:00
#include <vector>
2017-10-07 23:42:18 +00:00
#include <dsp/basebandsamplesink.h>
2015-01-11 00:12:58 +00:00
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "util/message.h"
2015-01-11 19:30:48 +00:00
#include "dsp/fftfilt.h"
2015-01-11 00:12:58 +00:00
2017-10-07 23:42:18 +00:00
#include "lorademodsettings.h"
2015-01-17 15:59:44 +00:00
#define DATA_BITS (6)
#define SAMPLEBITS (DATA_BITS + 2)
#define SPREADFACTOR (1 << SAMPLEBITS)
#define LORA_SFFT_LEN (SPREADFACTOR / 2)
2015-02-12 09:37:08 +00:00
#define LORA_SQUELCH (3)
2015-01-11 19:30:48 +00:00
2017-10-07 23:42:18 +00:00
class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class LoRaDemod : public BasebandSampleSink {
2015-01-11 00:12:58 +00:00
public:
2017-10-07 23:42:18 +00:00
class MsgConfigureLoRaDemod : public Message {
MESSAGE_CLASS_DECLARATION
public:
const LoRaDemodSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureLoRaDemod* create(const LoRaDemodSettings& settings, bool force)
{
return new MsgConfigureLoRaDemod(settings, force);
}
private:
LoRaDemodSettings m_settings;
bool m_force;
MsgConfigureLoRaDemod(const LoRaDemodSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
{ }
};
class MsgConfigureChannelizer : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getSampleRate() const { return m_sampleRate; }
int getCenterFrequency() const { return m_centerFrequency; }
static MsgConfigureChannelizer* create(int sampleRate, int centerFrequency)
{
return new MsgConfigureChannelizer(sampleRate, centerFrequency);
}
private:
int m_sampleRate;
int m_centerFrequency;
MsgConfigureChannelizer(int sampleRate, int centerFrequency) :
Message(),
m_sampleRate(sampleRate),
m_centerFrequency(centerFrequency)
{ }
};
LoRaDemod(DeviceSourceAPI* deviceAPI);
2015-08-17 06:29:34 +00:00
virtual ~LoRaDemod();
2017-10-07 23:42:18 +00:00
void setSpectrumSink(BasebandSampleSink* sampleSink) { m_sampleSink = sampleSink; }
2015-01-11 00:12:58 +00:00
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool pO);
2015-08-17 06:29:34 +00:00
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& cmd);
2015-01-11 00:12:58 +00:00
private:
2015-01-21 00:53:00 +00:00
int detect(Complex sample, Complex angle);
2015-01-25 17:27:20 +00:00
void dumpRaw(void);
2015-01-22 22:30:55 +00:00
short synch (short bin);
short toGray(short bin);
2015-02-12 09:37:08 +00:00
void interleave6(char* inout, int size);
void hamming6(char* inout, int size);
void prng6(char* inout, int size);
2015-02-05 19:38:46 +00:00
2017-10-07 23:42:18 +00:00
DeviceSourceAPI *m_deviceAPI;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
LoRaDemodSettings m_settings;
2015-01-11 00:12:58 +00:00
Real m_Bandwidth;
int m_sampleRate;
int m_frequency;
2015-01-11 12:27:11 +00:00
int m_chirp;
2015-01-11 00:12:58 +00:00
int m_angle;
2015-01-12 19:59:45 +00:00
int m_bin;
2015-01-13 19:14:36 +00:00
int m_result;
int m_count;
2015-01-17 15:59:44 +00:00
int m_header;
2015-01-22 22:30:55 +00:00
int m_time;
short m_tune;
2015-01-11 00:12:58 +00:00
2015-01-11 19:30:48 +00:00
sfft* loraFilter;
2015-01-14 00:48:48 +00:00
sfft* negaFilter;
2015-01-21 00:53:00 +00:00
float* mov;
2015-01-22 22:30:55 +00:00
short* history;
2015-01-28 00:02:49 +00:00
short* finetune;
2015-01-11 19:30:48 +00:00
2015-01-11 00:12:58 +00:00
NCO m_nco;
Interpolator m_interpolator;
Real m_sampleDistanceRemain;
BasebandSampleSink* m_sampleSink;
2015-01-11 00:12:58 +00:00
SampleVector m_sampleBuffer;
QMutex m_settingsMutex;
2015-01-11 00:12:58 +00:00
};
#endif // INCLUDE_LoRaDEMOD_H