2015-01-10 19:12:58 -05: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
|
|
|
|
|
2015-08-24 17:23:45 -04:00
|
|
|
#include <QMutex>
|
2015-01-10 19:12:58 -05:00
|
|
|
#include <vector>
|
|
|
|
#include "dsp/samplesink.h"
|
|
|
|
#include "dsp/nco.h"
|
|
|
|
#include "dsp/interpolator.h"
|
|
|
|
#include "util/message.h"
|
2015-01-11 14:30:48 -05:00
|
|
|
#include "dsp/fftfilt.h"
|
2015-01-10 19:12:58 -05:00
|
|
|
|
2015-01-17 10:59:44 -05:00
|
|
|
#define DATA_BITS (6)
|
|
|
|
#define SAMPLEBITS (DATA_BITS + 2)
|
|
|
|
#define SPREADFACTOR (1 << SAMPLEBITS)
|
|
|
|
#define LORA_SFFT_LEN (SPREADFACTOR / 2)
|
2015-02-12 04:37:08 -05:00
|
|
|
#define LORA_SQUELCH (3)
|
2015-01-11 14:30:48 -05:00
|
|
|
|
2015-01-10 19:12:58 -05:00
|
|
|
class LoRaDemod : public SampleSink {
|
|
|
|
public:
|
|
|
|
LoRaDemod(SampleSink* sampleSink);
|
2015-08-17 02:29:34 -04:00
|
|
|
virtual ~LoRaDemod();
|
2015-01-10 19:12:58 -05:00
|
|
|
|
|
|
|
void configure(MessageQueue* messageQueue, Real Bandwidth);
|
|
|
|
|
2015-08-25 02:24:23 -04:00
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool pO);
|
2015-08-17 02:29:34 -04:00
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& cmd);
|
2015-01-10 19:12:58 -05:00
|
|
|
|
|
|
|
private:
|
2015-01-20 19:53:00 -05:00
|
|
|
int detect(Complex sample, Complex angle);
|
2015-01-25 12:27:20 -05:00
|
|
|
void dumpRaw(void);
|
2015-01-22 17:30:55 -05:00
|
|
|
short synch (short bin);
|
|
|
|
short toGray(short bin);
|
2015-02-12 04:37:08 -05:00
|
|
|
void interleave6(char* inout, int size);
|
|
|
|
void hamming6(char* inout, int size);
|
|
|
|
void prng6(char* inout, int size);
|
2015-02-05 14:38:46 -05:00
|
|
|
|
2015-01-10 19:12:58 -05: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 07:27:11 -05:00
|
|
|
int m_chirp;
|
2015-01-10 19:12:58 -05:00
|
|
|
int m_angle;
|
2015-01-12 14:59:45 -05:00
|
|
|
int m_bin;
|
2015-01-13 14:14:36 -05:00
|
|
|
int m_result;
|
|
|
|
int m_count;
|
2015-01-17 10:59:44 -05:00
|
|
|
int m_header;
|
2015-01-22 17:30:55 -05:00
|
|
|
int m_time;
|
|
|
|
short m_tune;
|
2015-01-10 19:12:58 -05:00
|
|
|
|
2015-01-11 14:30:48 -05:00
|
|
|
sfft* loraFilter;
|
2015-01-13 19:48:48 -05:00
|
|
|
sfft* negaFilter;
|
2015-01-20 19:53:00 -05:00
|
|
|
float* mov;
|
2015-01-22 17:30:55 -05:00
|
|
|
short* history;
|
2015-01-27 19:02:49 -05:00
|
|
|
short* finetune;
|
2015-01-11 14:30:48 -05:00
|
|
|
|
2015-01-10 19:12:58 -05:00
|
|
|
NCO m_nco;
|
|
|
|
Interpolator m_interpolator;
|
|
|
|
Real m_sampleDistanceRemain;
|
|
|
|
|
|
|
|
SampleSink* m_sampleSink;
|
|
|
|
SampleVector m_sampleBuffer;
|
2015-08-24 17:23:45 -04:00
|
|
|
QMutex m_settingsMutex;
|
2015-01-10 19:12:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_LoRaDEMOD_H
|