00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef INCLUDED_GR_OFDM_FRAME_SINK_H
00024 #define INCLUDED_GR_OFDM_FRAME_SINK_H
00025
00026 #include <gr_sync_block.h>
00027 #include <gr_msg_queue.h>
00028
00029 class gr_ofdm_frame_sink;
00030 typedef boost::shared_ptr<gr_ofdm_frame_sink> gr_ofdm_frame_sink_sptr;
00031
00032 gr_ofdm_frame_sink_sptr
00033 gr_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position,
00034 const std::vector<unsigned char> &sym_value_out,
00035 gr_msg_queue_sptr target_queue, unsigned int occupied_tones,
00036 float phase_gain=0.25, float freq_gain=0.25*0.25/4.0);
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 class gr_ofdm_frame_sink : public gr_sync_block
00049 {
00050 friend gr_ofdm_frame_sink_sptr
00051 gr_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position,
00052 const std::vector<unsigned char> &sym_value_out,
00053 gr_msg_queue_sptr target_queue, unsigned int occupied_tones,
00054 float phase_gain, float freq_gain);
00055
00056 private:
00057 enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER};
00058
00059 static const int MAX_PKT_LEN = 4096;
00060 static const int HEADERBYTELEN = 4;
00061
00062 gr_msg_queue_sptr d_target_queue;
00063 state_t d_state;
00064 unsigned int d_header;
00065 int d_headerbytelen_cnt;
00066
00067 unsigned char *d_bytes_out;
00068
00069 unsigned int d_occupied_carriers;
00070 unsigned int d_byte_offset;
00071 unsigned int d_partial_byte;
00072
00073 unsigned char d_packet[MAX_PKT_LEN];
00074 int d_packetlen;
00075 int d_packet_whitener_offset;
00076 int d_packetlen_cnt;
00077
00078 gr_complex * d_derotated_output;
00079
00080 std::vector<gr_complex> d_sym_position;
00081 std::vector<unsigned char> d_sym_value_out;
00082 std::vector<gr_complex> d_dfe;
00083 unsigned int d_nbits;
00084
00085 unsigned char d_resid;
00086 unsigned int d_nresid;
00087 float d_phase;
00088 float d_freq;
00089 float d_phase_gain;
00090 float d_freq_gain;
00091 float d_eq_gain;
00092
00093 std::vector<int> d_subcarrier_map;
00094
00095 protected:
00096 gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_position,
00097 const std::vector<unsigned char> &sym_value_out,
00098 gr_msg_queue_sptr target_queue, unsigned int occupied_tones,
00099 float phase_gain, float freq_gain);
00100
00101 void enter_search();
00102 void enter_have_sync();
00103 void enter_have_header();
00104
00105 bool header_ok()
00106 {
00107
00108 return ((d_header >> 16) ^ (d_header & 0xffff)) == 0;
00109 }
00110
00111 unsigned char slicer(const gr_complex x);
00112 unsigned int demapper(const gr_complex *in,
00113 unsigned char *out);
00114
00115 bool set_sym_value_out(const std::vector<gr_complex> &sym_position,
00116 const std::vector<unsigned char> &sym_value_out);
00117
00118 public:
00119 ~gr_ofdm_frame_sink();
00120
00121 int work(int noutput_items,
00122 gr_vector_const_void_star &input_items,
00123 gr_vector_void_star &output_items);
00124 };
00125
00126 #endif