sdrangel/plugins/channelrx/demodlora/lorademod.h

105 wiersze
3.1 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 <dsp/basebandsamplesink.h>
#include <QMutex>
2015-01-11 00:12:58 +00:00
#include <vector>
#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
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
class LoRaDemod : public BasebandSampleSink {
2015-01-11 00:12:58 +00:00
public:
LoRaDemod(BasebandSampleSink* sampleSink);
2015-08-17 06:29:34 +00:00
virtual ~LoRaDemod();
2015-01-11 00:12:58 +00:00
void configure(MessageQueue* messageQueue, Real Bandwidth);
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
2015-01-11 00:12:58 +00:00
class MsgConfigureLoRaDemod : public Message {
MESSAGE_CLASS_DECLARATION
public:
Real getBandwidth() const { return m_Bandwidth; }
static MsgConfigureLoRaDemod* create(Real Bandwidth)
{
return new MsgConfigureLoRaDemod(Bandwidth);
}
private:
Real m_Bandwidth;
MsgConfigureLoRaDemod(Real Bandwidth) :
Message(),
m_Bandwidth(Bandwidth)
{
}
};
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