Merging OFDM features branch r5661:5759 into trunk. OFDM works over the air with...
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_ofdm_insert_preamble.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2007 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef INCLUDED_GR_OFDM_INSERT_PREAMBLE_H
23 #define INCLUDED_GR_OFDM_INSERT_PREAMBLE_H
24
25 #include <gr_block.h>
26 #include <vector>
27
28 class gr_ofdm_insert_preamble;
29 typedef boost::shared_ptr<gr_ofdm_insert_preamble> gr_ofdm_insert_preamble_sptr;
30
31 gr_ofdm_insert_preamble_sptr
32 gr_make_ofdm_insert_preamble(int fft_length,
33                              const std::vector<std::vector<gr_complex> > &preamble);
34
35 /*!
36  * \brief insert "pre-modulated" preamble symbols before each payload.
37  *
38  * <pre>
39  * input 1: stream of vectors of gr_complex [fft_length]
40  *          These are the modulated symbols of the payload.
41  *
42  * input 2: stream of char.  The LSB indicates whether the corresponding
43  *          symbol on input 1 is the first symbol of the payload or not.
44  *          It's a 1 if the corresponding symbol is the first symbol,
45  *          otherwise 0.
46  *
47  * N.B., this implies that there must be at least 1 symbol in the payload.
48  *
49  *
50  * output 1: stream of vectors of gr_complex [fft_length]
51  *           These include the preamble symbols and the payload symbols.
52  *
53  * output 2: stream of char.  The LSB indicates whether the corresponding
54  *           symbol on input 1 is the first symbol of a packet (i.e., the
55  *           first symbol of the preamble.)   It's a 1 if the corresponding
56  *           symbol is the first symbol, otherwise 0.
57  * </pre>
58  *
59  * \param fft_length length of each symbol in samples.
60  * \param preamble   vector of symbols that represent the pre-modulated preamble.
61  */
62
63 class gr_ofdm_insert_preamble : public gr_block
64 {
65   friend gr_ofdm_insert_preamble_sptr
66   gr_make_ofdm_insert_preamble(int fft_length,
67                                const std::vector<std::vector<gr_complex> > &preamble);
68
69 protected:
70   gr_ofdm_insert_preamble(int fft_length,
71                           const std::vector<std::vector<gr_complex> > &preamble);
72
73 private:
74   enum state_t {
75     ST_IDLE,
76     ST_PREAMBLE,
77     ST_FIRST_PAYLOAD,
78     ST_PAYLOAD
79   };
80
81   int                                           d_fft_length;
82   const std::vector<std::vector<gr_complex> >   d_preamble;
83   state_t                                       d_state;
84   int                                           d_nsymbols_output;
85   int                                           d_pending_flag;
86
87   void enter_idle();
88   void enter_preamble();
89   void enter_first_payload();
90   void enter_payload();
91   
92
93 public:
94   ~gr_ofdm_insert_preamble();
95
96   int general_work (int noutput_items,
97                     gr_vector_int &ninput_items,
98                     gr_vector_const_void_star &input_items,
99                     gr_vector_void_star &output_items);
100 };
101
102 #endif /* INCLUDED_GR_OFDM_INSERT_PREAMBLE_H */