GNU Radio's LORA Package
demod_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2016 Bastille Networks.
4 *
5 * This 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; either version 3, or (at your option)
8 * any later version.
9 *
10 * This software 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 for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef INCLUDED_LORA_DEMOD_IMPL_H
22#define INCLUDED_LORA_DEMOD_IMPL_H
23
24#include <cmath>
25#include <cstdlib>
26#include <vector>
27#include <queue>
28#include <complex>
29#include <fstream>
30#include <gnuradio/fft/fft.h>
31#include <gnuradio/fft/window.h>
32#include <volk/volk.h>
33#include "lora/demod.h"
34
35namespace gr {
36 namespace lora {
37
38 class demod_impl : public demod
39 {
40 private:
41 pmt::pmt_t d_out_port;
42
43 demod_state_t d_state;
44 unsigned short d_sf;
45 bool d_ldr;
46
47 unsigned short d_num_symbols;
48 unsigned short d_fft_size_factor;
49 unsigned short d_fft_size;
50 unsigned short d_overlaps;
51 unsigned short d_offset;
52
53 float d_power;
54 float d_threshold;
55 bool d_squelched;
56
57 unsigned short d_preamble_idx;
58 unsigned short d_sfd_idx;
59 std::vector<unsigned short> d_argmax_history;
60 std::vector<unsigned short> d_sfd_history;
61 unsigned short d_sync_recovery_counter;
62
63 fft::fft_complex *d_fft;
64 std::vector<float> d_window;
65 float d_beta;
66
67 std::vector<gr_complex> d_upchirp;
68 std::vector<gr_complex> d_downchirp;
69
70 std::vector<unsigned short> d_symbols;
71
72 std::ofstream f_raw, f_up_windowless, f_up, f_down;
73
74 public:
75 demod_impl( unsigned short spreading_factor,
76 bool low_data_rate,
77 float beta,
78 unsigned short fft_factor);
80
81 unsigned short argmax(gr_complex *fft_result, bool update_squelch);
82
83 // Where all the action really happens
84 void forecast (int noutput_items, gr_vector_int &ninput_items_required);
85
86 int general_work(int noutput_items,
87 gr_vector_int &ninput_items,
88 gr_vector_const_void_star &input_items,
89 gr_vector_void_star &output_items);
90 };
91
92 } // namespace lora
93} // namespace gr
94
95#endif /* INCLUDED_LORA_DEMOD_IMPL_H */
96
Definition demod_impl.h:39
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
demod_impl(unsigned short spreading_factor, bool low_data_rate, float beta, unsigned short fft_factor)
unsigned short argmax(gr_complex *fft_result, bool update_squelch)
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
<+description of block+>
Definition demod.h:54
demod_state_t
Definition demod.h:38
Definition decode.h:31