SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
lorademod.h
Go to the documentation of this file.
1 // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
3 // (C) 2015 John Greb //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef INCLUDE_LoRaDEMOD_H
20 #define INCLUDE_LoRaDEMOD_H
21 
22 #include <QMutex>
23 #include <vector>
24 
25 #include "dsp/basebandsamplesink.h"
26 #include "channel/channelapi.h"
27 #include "dsp/nco.h"
28 #include "dsp/interpolator.h"
29 #include "util/message.h"
30 #include "dsp/fftfilt.h"
31 
32 #include "lorademodsettings.h"
33 
34 #define DATA_BITS (6)
35 #define SAMPLEBITS (DATA_BITS + 2)
36 #define SPREADFACTOR (1 << SAMPLEBITS)
37 #define LORA_SFFT_LEN (SPREADFACTOR / 2)
38 #define LORA_SQUELCH (3)
39 
40 class DeviceAPI;
42 class DownChannelizer;
43 
44 class LoRaDemod : public BasebandSampleSink, public ChannelAPI {
45 public:
46  class MsgConfigureLoRaDemod : public Message {
48 
49  public:
50  const LoRaDemodSettings& getSettings() const { return m_settings; }
51  bool getForce() const { return m_force; }
52 
53  static MsgConfigureLoRaDemod* create(const LoRaDemodSettings& settings, bool force)
54  {
55  return new MsgConfigureLoRaDemod(settings, force);
56  }
57 
58  private:
60  bool m_force;
61 
62  MsgConfigureLoRaDemod(const LoRaDemodSettings& settings, bool force) :
63  Message(),
64  m_settings(settings),
65  m_force(force)
66  { }
67  };
68 
71 
72  public:
73  int getSampleRate() const { return m_sampleRate; }
74  int getCenterFrequency() const { return m_centerFrequency; }
75 
76  static MsgConfigureChannelizer* create(int sampleRate, int centerFrequency)
77  {
78  return new MsgConfigureChannelizer(sampleRate, centerFrequency);
79  }
80 
81  private:
84 
85  MsgConfigureChannelizer(int sampleRate, int centerFrequency) :
86  Message(),
87  m_sampleRate(sampleRate),
88  m_centerFrequency(centerFrequency)
89  { }
90  };
91 
92  LoRaDemod(DeviceAPI* deviceAPI);
93  virtual ~LoRaDemod();
94  virtual void destroy() { delete this; }
95  void setSpectrumSink(BasebandSampleSink* sampleSink) { m_sampleSink = sampleSink; }
96 
97  virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool pO);
98  virtual void start();
99  virtual void stop();
100  virtual bool handleMessage(const Message& cmd);
101 
102  virtual void getIdentifier(QString& id) { id = objectName(); }
103  virtual void getTitle(QString& title) { title = m_settings.m_title; }
104  virtual qint64 getCenterFrequency() const { return 0; }
105 
106  virtual QByteArray serialize() const;
107  virtual bool deserialize(const QByteArray& data);
108 
109  virtual int getNbSinkStreams() const { return 1; }
110  virtual int getNbSourceStreams() const { return 0; }
111 
112  virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
113  {
114  (void) streamIndex;
115  (void) sinkElseSource;
116  return 0;
117  }
118 
119  static const QString m_channelIdURI;
120  static const QString m_channelId;
121 
122 private:
123  int detect(Complex sample, Complex angle);
124  void dumpRaw(void);
125  short synch (short bin);
126  short toGray(short bin);
127  void interleave6(char* inout, int size);
128  void hamming6(char* inout, int size);
129  void prng6(char* inout, int size);
130 
135 
139  int m_chirp;
140  int m_angle;
141  int m_bin;
142  int m_result;
143  int m_count;
144  int m_header;
145  int m_time;
146  short m_tune;
147 
150  float* mov;
151  short* history;
152  short* finetune;
153 
157 
161 };
162 
163 #endif // INCLUDE_LoRaDEMOD_H
short * finetune
Definition: lorademod.h:152
std::vector< Sample > SampleVector
Definition: dsptypes.h:96
virtual qint64 getCenterFrequency() const
Applies to a default stream.
Definition: lorademod.h:104
int detect(Complex sample, Complex angle)
Definition: lorademod.cpp:192
short toGray(short bin)
Definition: lorabits.h:36
sfft * negaFilter
Definition: lorademod.h:149
NCO m_nco
Definition: lorademod.h:154
int m_angle
Definition: lorademod.h:140
float * mov
Definition: lorademod.h:150
virtual bool deserialize(const QByteArray &data)
Definition: lorademod.cpp:375
int m_bin
Definition: lorademod.h:141
virtual ~LoRaDemod()
Definition: lorademod.cpp:76
void prng6(char *inout, int size)
Definition: lorabits.h:63
Real m_sampleDistanceRemain
Definition: lorademod.h:156
virtual void getIdentifier(QString &id)
Definition: lorademod.h:102
Definition: fftfilt.h:96
int m_result
Definition: lorademod.h:142
DownChannelizer * m_channelizer
Definition: lorademod.h:133
sfft * loraFilter
Definition: lorademod.h:148
static MsgConfigureLoRaDemod * create(const LoRaDemodSettings &settings, bool force)
Definition: lorademod.h:53
virtual void stop()
Definition: lorademod.cpp:296
static const QString m_channelId
Definition: lorademod.h:120
LoRaDemodSettings m_settings
Definition: lorademod.h:59
BasebandSampleSink * m_sampleSink
Definition: lorademod.h:158
int m_chirp
Definition: lorademod.h:139
Definition: nco.h:25
virtual void destroy()
Definition: lorademod.h:94
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
Interpolator m_interpolator
Definition: lorademod.h:155
MsgConfigureChannelizer(int sampleRate, int centerFrequency)
Definition: lorademod.h:85
MsgConfigureLoRaDemod(const LoRaDemodSettings &settings, bool force)
Definition: lorademod.h:62
virtual void getTitle(QString &title)
Definition: lorademod.h:103
QMutex m_settingsMutex
Definition: lorademod.h:160
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
Definition: lorademod.h:112
int m_frequency
Definition: lorademod.h:138
short m_tune
Definition: lorademod.h:146
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: lorademod.h:76
void setSpectrumSink(BasebandSampleSink *sampleSink)
Definition: lorademod.h:95
int m_sampleRate
Definition: lorademod.h:137
LoRaDemod(DeviceAPI *deviceAPI)
Definition: lorademod.cpp:39
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: lorademod.h:132
DeviceAPI * m_deviceAPI
Definition: lorademod.h:131
void interleave6(char *inout, int size)
Definition: lorabits.h:14
virtual void start()
Definition: lorademod.cpp:292
virtual int getNbSinkStreams() const
Definition: lorademod.h:109
virtual bool handleMessage(const Message &cmd)
Processing of a message. Returns true if message has actually been processed.
Definition: lorademod.cpp:300
int m_time
Definition: lorademod.h:145
LoRaDemodSettings m_settings
Definition: lorademod.h:134
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool pO)
Definition: lorademod.cpp:255
static const QString m_channelIdURI
Definition: lorademod.h:119
const LoRaDemodSettings & getSettings() const
Definition: lorademod.h:50
virtual int getNbSourceStreams() const
Definition: lorademod.h:110
int m_count
Definition: lorademod.h:143
Real m_Bandwidth
Definition: lorademod.h:136
int m_header
Definition: lorademod.h:144
short synch(short bin)
Definition: lorademod.cpp:138
virtual QByteArray serialize() const
Definition: lorademod.cpp:370
std::complex< Real > Complex
Definition: dsptypes.h:43
short * history
Definition: lorademod.h:151
SampleVector m_sampleBuffer
Definition: lorademod.h:159
float Real
Definition: dsptypes.h:42
void dumpRaw(void)
Definition: lorademod.cpp:95
void hamming6(char *inout, int size)
Definition: lorabits.h:42