3 * Copyright 2007 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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 3, or (at your option)
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.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 #ifndef INCLUDED_GR_OFDM_FRAME_SINK_H
24 #define INCLUDED_GR_OFDM_FRAME_SINK_H
26 #include <gr_sync_block.h>
27 #include <gr_msg_queue.h>
29 class gr_ofdm_frame_sink;
30 typedef boost::shared_ptr<gr_ofdm_frame_sink> gr_ofdm_frame_sink_sptr;
32 gr_ofdm_frame_sink_sptr
33 gr_make_ofdm_frame_sink (gr_msg_queue_sptr target_queue, unsigned int occupied_tones,
34 const std::string &mod);
37 * \brief Takes an OFDM symbol in, demaps it into bits of 0's and 1's, packs
38 * them into packets, and sends to to a message queue sink.
40 * NOTE: The mod input parameter simply chooses a pre-defined demapper/slicer. Eventually,
41 * we want to be able to pass in a reference to an object to do the demapping and slicing
42 * for a given modulation type.
44 class gr_ofdm_frame_sink : public gr_sync_block
46 friend gr_ofdm_frame_sink_sptr
47 gr_make_ofdm_frame_sink (gr_msg_queue_sptr target_queue, unsigned int occupied_tones,
48 const std::string &mod);
51 enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER};
53 static const int MAX_PKT_LEN = 4096;
54 static const int HEADERBYTELEN = 4;
56 gr_msg_queue_sptr d_target_queue; // where to send the packet when received
58 unsigned int d_header; // header bits
59 int d_headerbytelen_cnt; // how many so far
61 unsigned char *d_bytes_out; // hold the current bytes produced by the demapper
63 unsigned int d_occupied_carriers;
64 unsigned int d_byte_offset;
65 unsigned int d_partial_byte;
67 unsigned char d_packet[MAX_PKT_LEN]; // assembled payload
68 int d_packetlen; // length of packet
69 int d_packet_whitener_offset; // offset into whitener string to use
70 int d_packetlen_cnt; // how many so far
73 gr_ofdm_frame_sink(gr_msg_queue_sptr target_queue, unsigned int occupied_tones,
74 const std::string &mod);
77 void enter_have_sync();
78 void enter_have_header();
82 // confirm that two copies of header info are identical
83 return ((d_header >> 16) ^ (d_header & 0xffff)) == 0;
86 unsigned char bpsk_slicer(gr_complex x);
87 unsigned int bpsk_demapper(const gr_complex *in,
90 unsigned char qpsk_slicer(gr_complex x);
91 unsigned int qpsk_demapper(const gr_complex *in,
94 // pointer to mod-specific demapper
95 unsigned int (gr_ofdm_frame_sink::*d_demapper)(const gr_complex *in, unsigned char *out);
98 ~gr_ofdm_frame_sink();
100 int work(int noutput_items,
101 gr_vector_const_void_star &input_items,
102 gr_vector_void_star &output_items);
105 #endif /* INCLUDED_GR_OFDM_FRAME_SINK_H */