GNU Radio's LORA Package
decode_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_DECODE_IMPL_H
22 #define INCLUDED_LORA_DECODE_IMPL_H
23 
24 #include <iostream>
25 #include <bitset>
26 #include <lora/decode.h>
27 
28 namespace gr {
29  namespace lora {
30 
31  class decode_impl : public decode
32  {
33  private:
34  pmt::pmt_t d_in_port;
35  pmt::pmt_t d_out_port;
36 
37  const unsigned short *d_whitening_sequence;
38 
39  unsigned char d_sf;
40  unsigned char d_cr;
41  bool d_ldr;
42  bool d_header;
43 
44  unsigned short d_fft_size;
45  unsigned char d_interleaver_size;
46 
47  std::vector<unsigned short> d_symbols;
48  std::vector<unsigned char> d_codewords;
49  std::vector<unsigned char> d_bytes;
50 
51  public:
52  decode_impl( short spreading_factor,
53  short code_rate,
54  bool low_data_rate,
55  bool header);
56  ~decode_impl();
57 
58  void to_gray(std::vector<unsigned short> &symbols);
59  void from_gray(std::vector<unsigned short> &symbols);
60  void whiten(std::vector<unsigned short> &symbols);
61  void deinterleave(std::vector<unsigned short> &symbols, std::vector<unsigned char> &codewords, unsigned char ppm, unsigned char rdd);
62  void hamming_decode(std::vector<unsigned char> &codewords, std::vector<unsigned char> &bytes, unsigned char rdd);
63  unsigned char parity(unsigned char c, unsigned char bitmask);
64  void print_payload(std::vector<unsigned char> &payload);
65 
66  void print_bitwise_u8 (std::vector<unsigned char> &buffer);
67  void print_bitwise_u16(std::vector<unsigned short> &buffer);
68 
69  void decode(pmt::pmt_t msg);
70 
71  };
72 
73  } // namespace lora
74 } // namespace gr
75 
76 #endif /* INCLUDED_LORA_DECODE_IMPL_H */
void decode(pmt::pmt_t msg)
void hamming_decode(std::vector< unsigned char > &codewords, std::vector< unsigned char > &bytes, unsigned char rdd)
unsigned char parity(unsigned char c, unsigned char bitmask)
decode_impl(short spreading_factor, short code_rate, bool low_data_rate, bool header)
void whiten(std::vector< unsigned short > &symbols)
void print_bitwise_u8(std::vector< unsigned char > &buffer)
<+description of block+>
Definition: decode.h:39
Definition: decode_impl.h:31
void deinterleave(std::vector< unsigned short > &symbols, std::vector< unsigned char > &codewords, unsigned char ppm, unsigned char rdd)
void print_payload(std::vector< unsigned char > &payload)
Definition: decode.h:31
void to_gray(std::vector< unsigned short > &symbols)
void print_bitwise_u16(std::vector< unsigned short > &buffer)
void from_gray(std::vector< unsigned short > &symbols)