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.
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
LoRaDemod Class Reference

#include <lorademod.h>

+ Inheritance diagram for LoRaDemod:
+ Collaboration diagram for LoRaDemod:

Classes

class  MsgConfigureChannelizer
 
class  MsgConfigureLoRaDemod
 

Public Member Functions

 LoRaDemod (DeviceAPI *deviceAPI)
 
virtual ~LoRaDemod ()
 
virtual void destroy ()
 
void setSpectrumSink (BasebandSampleSink *sampleSink)
 
virtual void feed (const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool pO)
 
virtual void start ()
 
virtual void stop ()
 
virtual bool handleMessage (const Message &cmd)
 Processing of a message. Returns true if message has actually been processed. More...
 
virtual void getIdentifier (QString &id)
 
virtual void getTitle (QString &title)
 
virtual qint64 getCenterFrequency () const
 Applies to a default stream. More...
 
virtual QByteArray serialize () const
 
virtual bool deserialize (const QByteArray &data)
 
virtual int getNbSinkStreams () const
 
virtual int getNbSourceStreams () const
 
virtual qint64 getStreamCenterFrequency (int streamIndex, bool sinkElseSource) const
 
- Public Member Functions inherited from BasebandSampleSink
 BasebandSampleSink ()
 
virtual ~BasebandSampleSink ()
 
MessageQueuegetInputMessageQueue ()
 Get the queue for asynchronous inbound communication. More...
 
virtual void setMessageQueueToGUI (MessageQueue *queue)
 
MessageQueuegetMessageQueueToGUI ()
 
- Public Member Functions inherited from ChannelAPI
 ChannelAPI (const QString &name, StreamType streamType)
 
virtual ~ChannelAPI ()
 
virtual void setName (const QString &name)
 
virtual const QString & getName () const
 
virtual int webapiSettingsGet (SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
 
virtual int webapiSettingsPutPatch (bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
 
virtual int webapiReportGet (SWGSDRangel::SWGChannelReport &response, QString &errorMessage)
 
int getIndexInDeviceSet () const
 
void setIndexInDeviceSet (int indexInDeviceSet)
 
int getDeviceSetIndex () const
 
void setDeviceSetIndex (int deviceSetIndex)
 
DeviceAPIgetDeviceAPI ()
 
void setDeviceAPI (DeviceAPI *deviceAPI)
 
uint64_t getUID () const
 
StreamType getStreamType () const
 

Static Public Attributes

static const QString m_channelIdURI = "sdrangel.channel.lorademod"
 
static const QString m_channelId = "LoRaDemod"
 

Private Member Functions

int detect (Complex sample, Complex angle)
 
void dumpRaw (void)
 
short synch (short bin)
 
short toGray (short bin)
 
void interleave6 (char *inout, int size)
 
void hamming6 (char *inout, int size)
 
void prng6 (char *inout, int size)
 

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSinkm_threadedChannelizer
 
DownChannelizerm_channelizer
 
LoRaDemodSettings m_settings
 
Real m_Bandwidth
 
int m_sampleRate
 
int m_frequency
 
int m_chirp
 
int m_angle
 
int m_bin
 
int m_result
 
int m_count
 
int m_header
 
int m_time
 
short m_tune
 
sfftloraFilter
 
sfftnegaFilter
 
float * mov
 
short * history
 
short * finetune
 
NCO m_nco
 
Interpolator m_interpolator
 
Real m_sampleDistanceRemain
 
BasebandSampleSinkm_sampleSink
 
SampleVector m_sampleBuffer
 
QMutex m_settingsMutex
 

Additional Inherited Members

- Public Types inherited from ChannelAPI
enum  StreamType { StreamSingleSink, StreamSingleSource, StreamMIMO }
 < This is the same enum as in PluginInterface More...
 
- Protected Slots inherited from BasebandSampleSink
void handleInputMessages ()
 
- Protected Attributes inherited from BasebandSampleSink
MessageQueue m_inputMessageQueue
 Queue for asynchronous inbound communication. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 44 of file lorademod.h.

Constructor & Destructor Documentation

◆ LoRaDemod()

LoRaDemod::LoRaDemod ( DeviceAPI deviceAPI)

Definition at line 39 of file lorademod.cpp.

References DeviceAPI::addChannelSink(), DeviceAPI::addChannelSinkAPI(), LoRaDemodSettings::bandwidths, Interpolator::create(), finetune, history, LORA_SFFT_LEN, loraFilter, m_angle, m_Bandwidth, m_bin, m_channelId, m_channelizer, m_chirp, m_count, m_deviceAPI, m_frequency, m_header, m_interpolator, m_nco, m_result, m_sampleDistanceRemain, m_sampleRate, m_threadedChannelizer, m_time, m_tune, mov, negaFilter, and NCO::setFreq().

Referenced by LoRaDemod::MsgConfigureChannelizer::MsgConfigureChannelizer().

39  :
41  m_deviceAPI(deviceAPI),
42  m_sampleSink(0),
43  m_settingsMutex(QMutex::Recursive)
44 {
45  setObjectName(m_channelId);
46 
48  m_sampleRate = 96000;
49  m_frequency = 0;
53 
54  m_chirp = 0;
55  m_angle = 0;
56  m_bin = 0;
57  m_result = 0;
58  m_count = 0;
59  m_header = 0;
60  m_time = 0;
61  m_tune = 0;
62 
65 
66  mov = new float[4*LORA_SFFT_LEN];
67  history = new short[1024];
68  finetune = new short[16];
69 
70  m_channelizer = new DownChannelizer(this);
74 }
short * finetune
Definition: lorademod.h:152
sfft * negaFilter
Definition: lorademod.h:149
NCO m_nco
Definition: lorademod.h:154
int m_angle
Definition: lorademod.h:140
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
float * mov
Definition: lorademod.h:150
int m_bin
Definition: lorademod.h:141
Real m_sampleDistanceRemain
Definition: lorademod.h:156
Definition: fftfilt.h:96
int m_result
Definition: lorademod.h:142
DownChannelizer * m_channelizer
Definition: lorademod.h:133
static const int bandwidths[]
sfft * loraFilter
Definition: lorademod.h:148
static const QString m_channelId
Definition: lorademod.h:120
BasebandSampleSink * m_sampleSink
Definition: lorademod.h:158
int m_chirp
Definition: lorademod.h:139
Interpolator m_interpolator
Definition: lorademod.h:155
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
QMutex m_settingsMutex
Definition: lorademod.h:160
int m_frequency
Definition: lorademod.h:138
short m_tune
Definition: lorademod.h:146
void setFreq(Real freq, Real sampleRate)
Definition: nco.cpp:49
int m_sampleRate
Definition: lorademod.h:137
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: lorademod.h:132
DeviceAPI * m_deviceAPI
Definition: lorademod.h:131
Exposes a single sink stream (input, Rx)
Definition: channelapi.h:41
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
int m_time
Definition: lorademod.h:145
static const QString m_channelIdURI
Definition: lorademod.h:119
int m_count
Definition: lorademod.h:143
Real m_Bandwidth
Definition: lorademod.h:136
int m_header
Definition: lorademod.h:144
#define LORA_SFFT_LEN
Definition: lorademod.h:37
short * history
Definition: lorademod.h:151
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~LoRaDemod()

LoRaDemod::~LoRaDemod ( )
virtual

Definition at line 76 of file lorademod.cpp.

References finetune, history, loraFilter, m_channelizer, m_deviceAPI, m_threadedChannelizer, mov, negaFilter, DeviceAPI::removeChannelSink(), and DeviceAPI::removeChannelSinkAPI().

Referenced by LoRaDemod::MsgConfigureChannelizer::MsgConfigureChannelizer().

77 {
78  if (loraFilter)
79  delete loraFilter;
80  if (negaFilter)
81  delete negaFilter;
82  if (mov)
83  delete [] mov;
84  if (history)
85  delete [] history;
86  if (finetune)
87  delete [] finetune;
88 
91  delete m_threadedChannelizer;
92  delete m_channelizer;
93 }
short * finetune
Definition: lorademod.h:152
sfft * negaFilter
Definition: lorademod.h:149
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
float * mov
Definition: lorademod.h:150
DownChannelizer * m_channelizer
Definition: lorademod.h:133
sfft * loraFilter
Definition: lorademod.h:148
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: lorademod.h:132
DeviceAPI * m_deviceAPI
Definition: lorademod.h:131
short * history
Definition: lorademod.h:151
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ deserialize()

bool LoRaDemod::deserialize ( const QByteArray &  data)
virtual

Implements ChannelAPI.

Definition at line 375 of file lorademod.cpp.

References LoRaDemod::MsgConfigureLoRaDemod::create(), LoRaDemodSettings::deserialize(), BasebandSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and LoRaDemodSettings::resetToDefaults().

Referenced by getCenterFrequency().

376 {
377  if (m_settings.deserialize(data))
378  {
379  MsgConfigureLoRaDemod *msg = MsgConfigureLoRaDemod::create(m_settings, true);
381  return true;
382  }
383  else
384  {
386  MsgConfigureLoRaDemod *msg = MsgConfigureLoRaDemod::create(m_settings, true);
388  return false;
389  }
390 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
bool deserialize(const QByteArray &data)
static MsgConfigureLoRaDemod * create(const LoRaDemodSettings &settings, bool force)
Definition: lorademod.h:53
LoRaDemodSettings m_settings
Definition: lorademod.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

virtual void LoRaDemod::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 94 of file lorademod.h.

94 { delete this; }

◆ detect()

int LoRaDemod::detect ( Complex  sample,
Complex  angle 
)
private

Definition at line 192 of file lorademod.cpp.

References DATA_BITS, sfft::fetch(), finetune, i, LORA_SFFT_LEN, LORA_SQUELCH, loraFilter, m_count, m_result, m_time, mov, negaFilter, sfft::run(), and synch().

Referenced by feed().

193 {
194  int p, q;
195  short i, result, negresult, movpoint;
196  float peak, negpeak, tfloat;
197  float mag[LORA_SFFT_LEN];
198  float rev[LORA_SFFT_LEN];
199 
200  loraFilter->run(c * a);
201  negaFilter->run(c * conj(a));
202 
203  // process spectrum twice in FFTLEN
204  if (++m_count & ((1 << DATA_BITS) - 1))
205  {
206  return m_result;
207  }
208 
209  movpoint = 3 & (m_count >> DATA_BITS);
210 
211  loraFilter->fetch(mag);
212  negaFilter->fetch(rev);
213  peak = negpeak = 0.0f;
214  result = negresult = 0;
215 
216  for (i = 0; i < LORA_SFFT_LEN; i++)
217  {
218  if (rev[i] > negpeak)
219  {
220  negpeak = rev[i];
221  negresult = i;
222  }
223 
224  tfloat = mov[i] + mov[LORA_SFFT_LEN + i] +mov[2 * LORA_SFFT_LEN + i]
225  + mov[3 * LORA_SFFT_LEN + i] + mag[i];
226 
227  if (tfloat > peak)
228  {
229  peak = tfloat;
230  result = i;
231  }
232 
233  mov[movpoint * LORA_SFFT_LEN + i] = mag[i];
234  }
235 
236  p = (result - 1 + LORA_SFFT_LEN) & (LORA_SFFT_LEN -1);
237  q = (result + 1) & (LORA_SFFT_LEN -1);
238  finetune[15 & m_time] = (mag[p] > mag[q]) ? -1 : 1;
239 
240  if (peak < negpeak * LORA_SQUELCH)
241  {
242  result = -1;
243  }
244 
245  result = synch(result);
246 
247  if (result >= 0)
248  {
249  m_result = result;
250  }
251 
252  return m_result;
253 }
short * finetune
Definition: lorademod.h:152
sfft * negaFilter
Definition: lorademod.h:149
float * mov
Definition: lorademod.h:150
#define LORA_SQUELCH
Definition: lorademod.h:38
int m_result
Definition: lorademod.h:142
sfft * loraFilter
Definition: lorademod.h:148
void fetch(float *result)
Definition: fftfilt.cpp:451
void run(const cmplx &input)
Definition: fftfilt.cpp:437
int32_t i
Definition: decimators.h:244
#define DATA_BITS
Definition: lorademod.h:34
int m_time
Definition: lorademod.h:145
int m_count
Definition: lorademod.h:143
#define LORA_SFFT_LEN
Definition: lorademod.h:37
short synch(short bin)
Definition: lorademod.cpp:138
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dumpRaw()

void LoRaDemod::dumpRaw ( void  )
private

Definition at line 95 of file lorademod.cpp.

References hamming6(), history, interleave6(), LORA_SFFT_LEN, m_time, m_tune, leansdr::max(), prng6(), and toGray().

Referenced by synch().

96 {
97  short bin, j, max;
98  char text[256];
99 
100  max = m_time / 4 - 3;
101 
102  if (max > 140)
103  {
104  max = 140; // about 2 symbols to each char
105  }
106 
107  for ( j=0; j < max; j++)
108  {
109  bin = (history[(j + 1) * 4] + m_tune ) & (LORA_SFFT_LEN - 1);
110  text[j] = toGray(bin >> 1);
111  }
112 
113  prng6(text, max);
114  // First block is always 8 symbols
115  interleave6(text, 6);
116  interleave6(&text[8], max);
117  hamming6(text, 6);
118  hamming6(&text[8], max);
119 
120  for ( j=0; j < max / 2; j++)
121  {
122  text[j] = (text[j * 2 + 1] << 4) | (0xf & text[j * 2 + 0]);
123 
124  if ((text[j] < 32 )||( text[j] > 126))
125  {
126  text[j] = 0x5f;
127  }
128  }
129 
130  text[3] = text[2];
131  text[2] = text[1];
132  text[1] = text[0];
133  text[j] = 0;
134 
135  printf("%s\n", &text[1]);
136 }
short toGray(short bin)
Definition: lorabits.h:36
void prng6(char *inout, int size)
Definition: lorabits.h:63
short m_tune
Definition: lorademod.h:146
void interleave6(char *inout, int size)
Definition: lorabits.h:14
int m_time
Definition: lorademod.h:145
#define LORA_SFFT_LEN
Definition: lorademod.h:37
short * history
Definition: lorademod.h:151
T max(const T &x, const T &y)
Definition: framework.h:446
void hamming6(char *inout, int size)
Definition: lorabits.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ feed()

void LoRaDemod::feed ( const SampleVector::const_iterator &  begin,
const SampleVector::const_iterator &  end,
bool  pO 
)
virtual

Implements BasebandSampleSink.

Definition at line 255 of file lorademod.cpp.

References cos(), Interpolator::decimate(), detect(), BasebandSampleSink::feed(), LORA_SFFT_LEN, m_angle, m_Bandwidth, m_bin, m_chirp, m_interpolator, m_nco, M_PI, m_sampleBuffer, m_sampleDistanceRemain, m_sampleRate, m_sampleSink, m_settingsMutex, NCO::nextIQ(), SDR_RX_SCALEF, sin(), and SPREADFACTOR.

Referenced by setSpectrumSink().

256 {
257  (void) pO;
258  int newangle;
259  Complex ci;
260 
261  m_sampleBuffer.clear();
262 
263  m_settingsMutex.lock();
264 
265  for(SampleVector::const_iterator it = begin; it < end; ++it)
266  {
267  Complex c(it->real() / SDR_RX_SCALEF, it->imag() / SDR_RX_SCALEF);
268  c *= m_nco.nextIQ();
269 
271  {
272  m_chirp = (m_chirp + 1) & (SPREADFACTOR - 1);
273  m_angle = (m_angle + m_chirp) & (SPREADFACTOR - 1);
275  newangle = detect(ci, cangle);
276 
277  m_bin = (m_bin + newangle) & (LORA_SFFT_LEN - 1);
279  m_sampleBuffer.push_back(Sample(nangle.real() * 100, nangle.imag() * 100));
281  }
282  }
283 
284  if(m_sampleSink != 0)
285  {
286  m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), false);
287  }
288 
289  m_settingsMutex.unlock();
290 }
int detect(Complex sample, Complex angle)
Definition: lorademod.cpp:192
Complex nextIQ()
Return next complex sample.
Definition: nco.cpp:61
bool decimate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:38
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
NCO m_nco
Definition: lorademod.h:154
int m_angle
Definition: lorademod.h:140
int m_bin
Definition: lorademod.h:141
Real m_sampleDistanceRemain
Definition: lorademod.h:156
#define M_PI
Definition: rdsdemod.cpp:27
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool positiveOnly)=0
#define SDR_RX_SCALEF
Definition: dsptypes.h:33
BasebandSampleSink * m_sampleSink
Definition: lorademod.h:158
int m_chirp
Definition: lorademod.h:139
#define SPREADFACTOR
Definition: lorademod.h:36
Interpolator m_interpolator
Definition: lorademod.h:155
Fixed< IntType, IntBits > sin(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2265
QMutex m_settingsMutex
Definition: lorademod.h:160
int m_sampleRate
Definition: lorademod.h:137
Real m_Bandwidth
Definition: lorademod.h:136
#define LORA_SFFT_LEN
Definition: lorademod.h:37
std::complex< Real > Complex
Definition: dsptypes.h:43
SampleVector m_sampleBuffer
Definition: lorademod.h:159
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCenterFrequency()

virtual qint64 LoRaDemod::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 104 of file lorademod.h.

References deserialize(), and serialize().

104 { return 0; }
+ Here is the call graph for this function:

◆ getIdentifier()

virtual void LoRaDemod::getIdentifier ( QString &  id)
inlinevirtual

Implements ChannelAPI.

Definition at line 102 of file lorademod.h.

102 { id = objectName(); }

◆ getNbSinkStreams()

virtual int LoRaDemod::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 109 of file lorademod.h.

109 { return 1; }

◆ getNbSourceStreams()

virtual int LoRaDemod::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 110 of file lorademod.h.

110 { return 0; }

◆ getStreamCenterFrequency()

virtual qint64 LoRaDemod::getStreamCenterFrequency ( int  streamIndex,
bool  sinkElseSource 
) const
inlinevirtual

Implements ChannelAPI.

Definition at line 112 of file lorademod.h.

113  {
114  (void) streamIndex;
115  (void) sinkElseSource;
116  return 0;
117  }

◆ getTitle()

virtual void LoRaDemod::getTitle ( QString &  title)
inlinevirtual

Implements ChannelAPI.

Definition at line 103 of file lorademod.h.

References LoRaDemod::MsgConfigureLoRaDemod::m_settings, and LoRaDemodSettings::m_title.

103 { title = m_settings.m_title; }
LoRaDemodSettings m_settings
Definition: lorademod.h:134

◆ hamming6()

void LoRaDemod::hamming6 ( char *  inout,
int  size 
)
private

Definition at line 42 of file lorabits.h.

References i.

Referenced by dumpRaw().

43 {
44  int i;
45 
46  for (i = 0; i < size; i++) {
47  c[i] = ((c[i] & 1)<<3) | ((c[i] & 2)<<0) | ((c[i] & 4)>>0) | ((c[i] & 8)>>3);
48  i++;
49  c[i] = ((c[i] & 1)<<2) | ((c[i] & 2)<<2) | ((c[i] & 4)>>1) | ((c[i] & 8)>>3);
50  i++;
51  c[i] = ((c[i] &32)>>2) | ((c[i] & 2)<<1) | ((c[i] & 4)>>1) | ((c[i] & 8)>>3);
52  i++;
53  c[i] = ((c[i] & 1)<<3) | ((c[i] & 2)<<1) | ((c[i] & 4)>>1) | ((c[i] & 8)>>3);
54  i++;
55  c[i] = ((c[i] & 1)<<3) | ((c[i] & 2)<<1) | ((c[i] & 4)>>1) | ((c[i] &16)>>4);
56  i++;
57  c[i] = ((c[i] & 1)<<3) | ((c[i] & 2)<<1) | ((c[i] & 4)>>2) | ((c[i] & 8)>>2);
58  }
59  c[i] = 0;
60 }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ handleMessage()

bool LoRaDemod::handleMessage ( const Message cmd)
virtual

Processing of a message. Returns true if message has actually been processed.

Implements BasebandSampleSink.

Definition at line 300 of file lorademod.cpp.

References LoRaDemodSettings::bandwidths, DownChannelizer::configure(), Interpolator::create(), LoRaDemod::MsgConfigureChannelizer::getCenterFrequency(), DownChannelizer::MsgChannelizerNotification::getFrequencyOffset(), BasebandSampleSink::getInputMessageQueue(), DownChannelizer::MsgChannelizerNotification::getSampleRate(), LoRaDemod::MsgConfigureChannelizer::getSampleRate(), LoRaDemod::MsgConfigureLoRaDemod::getSettings(), BasebandSampleSink::handleMessage(), m_Bandwidth, LoRaDemodSettings::m_bandwidthIndex, m_channelizer, m_interpolator, m_nco, m_sampleDistanceRemain, m_sampleRate, m_sampleSink, m_settings, m_settingsMutex, Message::match(), and NCO::setFreq().

Referenced by setSpectrumSink().

301 {
302  qDebug() << "LoRaDemod::handleMessage";
303 
305  {
307 
308  m_settingsMutex.lock();
309 
310  m_sampleRate = notif.getSampleRate();
314 
315  m_settingsMutex.unlock();
316 
317  qDebug() << "LoRaDemod::handleMessage: MsgChannelizerNotification: m_sampleRate: " << m_sampleRate
318  << " frequencyOffset: " << notif.getFrequencyOffset();
319 
320  return true;
321  }
322  else if (MsgConfigureChannelizer::match(cmd))
323  {
324  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
325 
327  cfg.getSampleRate(),
328  cfg.getCenterFrequency());
329 
330  qDebug() << "LoRaDemod::handleMessage: MsgConfigureChannelizer: sampleRate: " << cfg.getSampleRate()
331  << " centerFrequency: " << cfg.getCenterFrequency();
332 
333  return true;
334  }
335  else if (MsgConfigureLoRaDemod::match(cmd))
336  {
337  MsgConfigureLoRaDemod& cfg = (MsgConfigureLoRaDemod&) cmd;
338 
339  m_settingsMutex.lock();
340 
341  LoRaDemodSettings settings = cfg.getSettings();
342 
345 
346  m_settingsMutex.unlock();
347 
348  m_settings = settings;
349  qDebug() << "LoRaDemod::handleMessage: MsgConfigureLoRaDemod: m_Bandwidth: " << m_Bandwidth;
350 
351  return true;
352  }
353  else if (DSPSignalNotification::match(cmd))
354  {
355  return true;
356  }
357  else
358  {
359  if(m_sampleSink != 0)
360  {
361  return m_sampleSink->handleMessage(cmd);
362  }
363  else
364  {
365  return false;
366  }
367  }
368 }
void configure(MessageQueue *messageQueue, int sampleRate, int centerFrequency)
NCO m_nco
Definition: lorademod.h:154
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
Real m_sampleDistanceRemain
Definition: lorademod.h:156
DownChannelizer * m_channelizer
Definition: lorademod.h:133
static const int bandwidths[]
BasebandSampleSink * m_sampleSink
Definition: lorademod.h:158
virtual bool handleMessage(const Message &cmd)=0
Processing of a message. Returns true if message has actually been processed.
Interpolator m_interpolator
Definition: lorademod.h:155
QMutex m_settingsMutex
Definition: lorademod.h:160
static bool match(const Message *message)
Definition: message.cpp:45
void setFreq(Real freq, Real sampleRate)
Definition: nco.cpp:49
int m_sampleRate
Definition: lorademod.h:137
LoRaDemodSettings m_settings
Definition: lorademod.h:134
Real m_Bandwidth
Definition: lorademod.h:136
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ interleave6()

void LoRaDemod::interleave6 ( char *  inout,
int  size 
)
private

Definition at line 14 of file lorabits.h.

References i.

Referenced by dumpRaw().

15 {
16  int i, j;
17  char in[6 * 2];
18  short s;
19 
20  for (j = 0; j < size; j+=6) {
21  for (i = 0; i < 6; i++)
22  in[i] = in[i + 6] = inout[i + j];
23  // top bits are swapped
24  for (i = 0; i < 6; i++) {
25  s = (32 & in[2 + i]) | (16 & in[1 + i]) | (8 & in[3 + i])
26  | (4 & in[4 + i]) | (2 & in[5 + i]) | (1 & in[6 + i]);
27  // bits are also rotated
28  s = (s << 3) | (s >> 3);
29  s &= 63;
30  s = (s >> i) | (s << (6 - i));
31  inout[i + j] = s & 63;
32  }
33  }
34 }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ prng6()

void LoRaDemod::prng6 ( char *  inout,
int  size 
)
private

Definition at line 63 of file lorabits.h.

References i.

Referenced by dumpRaw().

64 {
65  const char otp[] = {
66  //explicit mode
67  "cOGGg7CM2=b5a?<`i;T2of5jDAB=2DoQ9ko?h_RLQR4@Z\\`9jY\\PX89lHX8h_R]c_^@OB<0`W08ik?Mg>dQZf3kn5Je5R=R4h[<Ph90HHh9j;h:mS^?f:lQ:GG;nU:b?WFU20Lf4@A?`hYJMnW\\QZ\\AMIZ<h:jQk[PP<`6[Z"
68 #if 0
69  // implicit mode (offset 2 symbols)
70  "5^ZSm0=cOGMgUB=bNcb<@a^T;_f=6DEB]2ImPIKg:j]RlYT4YZ<`9hZ\\PPb;@8X8i]Zmc_6B52\\8oUPHIcBOc>dY?d9[n5Lg]b]R8hR<0`T008h9c9QJm[c?a:lQEGa;nU=b_WfUV2?V4@c=8h9B9njlQZDC@9Z<Q8\\iiX\\Rb6k:iY"
71 #endif
72  };
73  int i, maxchars;
74 
75  maxchars = sizeof( otp );
76  if (size < maxchars)
77  maxchars = size;
78  for (i = 0; i < maxchars; i++)
79  inout[i] ^= (otp[i] - 48);
80 }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ serialize()

QByteArray LoRaDemod::serialize ( ) const
virtual

Implements ChannelAPI.

Definition at line 370 of file lorademod.cpp.

References m_settings, and LoRaDemodSettings::serialize().

Referenced by getCenterFrequency().

371 {
372  return m_settings.serialize();
373 }
LoRaDemodSettings m_settings
Definition: lorademod.h:134
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSpectrumSink()

void LoRaDemod::setSpectrumSink ( BasebandSampleSink sampleSink)
inline

Definition at line 95 of file lorademod.h.

References feed(), handleMessage(), m_sampleSink, start(), and stop().

Referenced by LoRaDemodGUI::LoRaDemodGUI().

95 { m_sampleSink = sampleSink; }
BasebandSampleSink * m_sampleSink
Definition: lorademod.h:158
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

void LoRaDemod::start ( )
virtual

Implements BasebandSampleSink.

Definition at line 292 of file lorademod.cpp.

Referenced by setSpectrumSink().

293 {
294 }
+ Here is the caller graph for this function:

◆ stop()

void LoRaDemod::stop ( )
virtual

Implements BasebandSampleSink.

Definition at line 296 of file lorademod.cpp.

Referenced by setSpectrumSink().

297 {
298 }
+ Here is the caller graph for this function:

◆ synch()

short LoRaDemod::synch ( short  bin)
private

Definition at line 138 of file lorademod.cpp.

References dumpRaw(), finetune, history, i, LORA_SFFT_LEN, m_time, and m_tune.

Referenced by detect().

139 {
140  short i, j;
141 
142  if (bin < 0)
143  {
144  if (m_time > 70)
145  {
146  dumpRaw();
147  }
148 
149  m_time = 0;
150  return -1;
151  }
152 
153  history[m_time] = bin;
154 
155  if (m_time > 12)
156  {
157  if (bin == history[m_time - 6])
158  {
159  if (bin == history[m_time - 12])
160  {
161  m_tune = LORA_SFFT_LEN - bin;
162  j = 0;
163 
164  for (i=0; i<12; i++)
165  {
166  j += finetune[15 & (m_time - i)];
167  }
168 
169  if (j < 0)
170  {
171  m_tune += 1;
172  }
173 
174  m_tune &= (LORA_SFFT_LEN - 1);
175  m_time = 0;
176  return -1;
177  }
178  }
179  }
180 
181  m_time++;
182  m_time &= 1023;
183 
184  if (m_time & 3)
185  {
186  return -1;
187  }
188 
189  return (bin + m_tune) & (LORA_SFFT_LEN - 1);
190 }
short * finetune
Definition: lorademod.h:152
int32_t i
Definition: decimators.h:244
short m_tune
Definition: lorademod.h:146
int m_time
Definition: lorademod.h:145
#define LORA_SFFT_LEN
Definition: lorademod.h:37
short * history
Definition: lorademod.h:151
void dumpRaw(void)
Definition: lorademod.cpp:95
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toGray()

short LoRaDemod::toGray ( short  bin)
private

Definition at line 36 of file lorabits.h.

Referenced by dumpRaw().

37 {
38  return (num >> 1) ^ num;
39 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ finetune

short* LoRaDemod::finetune
private

Definition at line 152 of file lorademod.h.

Referenced by detect(), LoRaDemod(), synch(), and ~LoRaDemod().

◆ history

short* LoRaDemod::history
private

Definition at line 151 of file lorademod.h.

Referenced by dumpRaw(), LoRaDemod(), synch(), and ~LoRaDemod().

◆ loraFilter

sfft* LoRaDemod::loraFilter
private

Definition at line 148 of file lorademod.h.

Referenced by detect(), LoRaDemod(), and ~LoRaDemod().

◆ m_angle

int LoRaDemod::m_angle
private

Definition at line 140 of file lorademod.h.

Referenced by feed(), and LoRaDemod().

◆ m_Bandwidth

Real LoRaDemod::m_Bandwidth
private

Definition at line 136 of file lorademod.h.

Referenced by feed(), handleMessage(), and LoRaDemod().

◆ m_bin

int LoRaDemod::m_bin
private

Definition at line 141 of file lorademod.h.

Referenced by feed(), and LoRaDemod().

◆ m_channelId

const QString LoRaDemod::m_channelId = "LoRaDemod"
static

Definition at line 120 of file lorademod.h.

Referenced by LoRaPlugin::initPlugin(), and LoRaDemod().

◆ m_channelIdURI

const QString LoRaDemod::m_channelIdURI = "sdrangel.channel.lorademod"
static

Definition at line 119 of file lorademod.h.

Referenced by LoRaPlugin::initPlugin(), and LoRaDemodGUI::LoRaDemodGUI().

◆ m_channelizer

DownChannelizer* LoRaDemod::m_channelizer
private

Definition at line 133 of file lorademod.h.

Referenced by handleMessage(), LoRaDemod(), and ~LoRaDemod().

◆ m_chirp

int LoRaDemod::m_chirp
private

Definition at line 139 of file lorademod.h.

Referenced by feed(), and LoRaDemod().

◆ m_count

int LoRaDemod::m_count
private

Definition at line 143 of file lorademod.h.

Referenced by detect(), and LoRaDemod().

◆ m_deviceAPI

DeviceAPI* LoRaDemod::m_deviceAPI
private

Definition at line 131 of file lorademod.h.

Referenced by LoRaDemod(), and ~LoRaDemod().

◆ m_frequency

int LoRaDemod::m_frequency
private

Definition at line 138 of file lorademod.h.

Referenced by LoRaDemod().

◆ m_header

int LoRaDemod::m_header
private

Definition at line 144 of file lorademod.h.

Referenced by LoRaDemod().

◆ m_interpolator

Interpolator LoRaDemod::m_interpolator
private

Definition at line 155 of file lorademod.h.

Referenced by feed(), handleMessage(), and LoRaDemod().

◆ m_nco

NCO LoRaDemod::m_nco
private

Definition at line 154 of file lorademod.h.

Referenced by feed(), handleMessage(), and LoRaDemod().

◆ m_result

int LoRaDemod::m_result
private

Definition at line 142 of file lorademod.h.

Referenced by detect(), and LoRaDemod().

◆ m_sampleBuffer

SampleVector LoRaDemod::m_sampleBuffer
private

Definition at line 159 of file lorademod.h.

Referenced by feed().

◆ m_sampleDistanceRemain

Real LoRaDemod::m_sampleDistanceRemain
private

Definition at line 156 of file lorademod.h.

Referenced by feed(), handleMessage(), and LoRaDemod().

◆ m_sampleRate

int LoRaDemod::m_sampleRate
private

◆ m_sampleSink

BasebandSampleSink* LoRaDemod::m_sampleSink
private

Definition at line 158 of file lorademod.h.

Referenced by feed(), handleMessage(), and setSpectrumSink().

◆ m_settings

LoRaDemodSettings LoRaDemod::m_settings
private

Definition at line 134 of file lorademod.h.

Referenced by deserialize(), handleMessage(), and serialize().

◆ m_settingsMutex

QMutex LoRaDemod::m_settingsMutex
private

Definition at line 160 of file lorademod.h.

Referenced by feed(), and handleMessage().

◆ m_threadedChannelizer

ThreadedBasebandSampleSink* LoRaDemod::m_threadedChannelizer
private

Definition at line 132 of file lorademod.h.

Referenced by LoRaDemod(), and ~LoRaDemod().

◆ m_time

int LoRaDemod::m_time
private

Definition at line 145 of file lorademod.h.

Referenced by detect(), dumpRaw(), LoRaDemod(), and synch().

◆ m_tune

short LoRaDemod::m_tune
private

Definition at line 146 of file lorademod.h.

Referenced by dumpRaw(), LoRaDemod(), and synch().

◆ mov

float* LoRaDemod::mov
private

Definition at line 150 of file lorademod.h.

Referenced by detect(), LoRaDemod(), and ~LoRaDemod().

◆ negaFilter

sfft* LoRaDemod::negaFilter
private

Definition at line 149 of file lorademod.h.

Referenced by detect(), LoRaDemod(), and ~LoRaDemod().


The documentation for this class was generated from the following files: