diff --git a/lib/chunks_to_symbols_impl.cc b/lib/chunks_to_symbols_impl.cc index 3f74637..56a5b51 100644 --- a/lib/chunks_to_symbols_impl.cc +++ b/lib/chunks_to_symbols_impl.cc @@ -28,10 +28,17 @@ chunks_to_symbols::make() return gnuradio::get_initial_sptr(new chunks_to_symbols_impl()); } -chunks_to_symbols_impl::chunks_to_symbols_impl() - : tagged_stream_block("chunks_to_symbols", - io_signature::make(1, 1, sizeof(char)), - io_signature::make(1, 1, sizeof(gr_complex)), "packet_len") { +chunks_to_symbols_impl::chunks_to_symbols_impl() : + tagged_stream_block("chunks_to_symbols", + io_signature::make(1, 1, sizeof(char)), + io_signature::make(1, 1, sizeof(gr_complex)), "packet_len") { + + d_bpsk = constellation_bpsk::make(); + d_qpsk = constellation_qpsk::make(); + d_16qam = constellation_16qam::make(); + d_64qam = constellation_64qam::make(); + + d_mapping = d_bpsk; } chunks_to_symbols_impl::~chunks_to_symbols_impl() { } @@ -56,27 +63,25 @@ chunks_to_symbols_impl::work(int noutput_items, Encoding encoding = (Encoding)pmt::to_long(tags[0].value); - const gr_complex *mapping; - switch (encoding) { case BPSK_1_2: case BPSK_3_4: - mapping = BPSK; + d_mapping = d_bpsk; break; case QPSK_1_2: case QPSK_3_4: - mapping = QPSK; + d_mapping = d_qpsk; break; case QAM16_1_2: case QAM16_3_4: - mapping = QAM16; + d_mapping = d_16qam; break; case QAM64_2_3: case QAM64_3_4: - mapping = QAM64; + d_mapping = d_64qam; break; default: @@ -85,60 +90,8 @@ chunks_to_symbols_impl::work(int noutput_items, } for(int i = 0; i < ninput_items[0]; i++) { - out[i] = mapping[in[i]]; + d_mapping->map_to_points(in[i], out + i); } return ninput_items[0]; } - -const gr_complex chunks_to_symbols_impl::BPSK[2] = { - gr_complex(-1.0, 0.0), gr_complex(1.0, 0.0)}; - -const gr_complex chunks_to_symbols_impl::QPSK[4] = { - gr_complex(-0.7071, -0.7071), gr_complex(-0.7071, 0.7071), - gr_complex(+0.7071, -0.7071), gr_complex(+0.7071, 0.7071)}; - -const gr_complex chunks_to_symbols_impl::QAM16[16] = { - gr_complex(-0.9487, -0.9487), gr_complex(-0.9487, -0.3162), - gr_complex(-0.9487, 0.9487), gr_complex(-0.9487, 0.3162), - gr_complex(-0.3162, -0.9487), gr_complex(-0.3162, -0.3162), - gr_complex(-0.3162, 0.9487), gr_complex(-0.3162, 0.3162), - gr_complex(0.9487, -0.9487), gr_complex(0.9487, -0.3162), - gr_complex(0.9487, 0.9487), gr_complex(0.9487, 0.3162), - gr_complex(0.3162, -0.9487), gr_complex(0.3162, -0.3162), - gr_complex(0.3162, 0.9487), gr_complex(0.3162, 0.3162)}; - -const gr_complex chunks_to_symbols_impl::QAM64[64] = { - gr_complex(-1.0801, -1.0801), gr_complex(-1.0801, -0.7715), - gr_complex(-1.0801, -0.1543), gr_complex(-1.0801, -0.4629), - gr_complex(-1.0801, 1.0801), gr_complex(-1.0801, 0.7715), - gr_complex(-1.0801, 0.1543), gr_complex(-1.0801, 0.4629), - gr_complex(-0.7715, -1.0801), gr_complex(-0.7715, -0.7715), - gr_complex(-0.7715, -0.1543), gr_complex(-0.7715, -0.4629), - gr_complex(-0.7715, 1.0801), gr_complex(-0.7715, 0.7715), - gr_complex(-0.7715, 0.1543), gr_complex(-0.7715, 0.4629), - gr_complex(-0.1543, -1.0801), gr_complex(-0.1543, -0.7715), - gr_complex(-0.1543, -0.1543), gr_complex(-0.1543, -0.4629), - gr_complex(-0.1543, 1.0801), gr_complex(-0.1543, 0.7715), - gr_complex(-0.1543, 0.1543), gr_complex(-0.1543, 0.4629), - gr_complex(-0.4629, -1.0801), gr_complex(-0.4629, -0.7715), - gr_complex(-0.4629, -0.1543), gr_complex(-0.4629, -0.4629), - gr_complex(-0.4629, 1.0801), gr_complex(-0.4629, 0.7715), - gr_complex(-0.4629, 0.1543), gr_complex(-0.4629, 0.4629), - gr_complex(1.0801, -1.0801), gr_complex(1.0801, -0.7715), - gr_complex(1.0801, -0.1543), gr_complex(1.0801, -0.4629), - gr_complex(1.0801, 1.0801), gr_complex(1.0801, 0.7715), - gr_complex(1.0801, 0.1543), gr_complex(1.0801, 0.4629), - gr_complex(0.7715, -1.0801), gr_complex(0.7715, -0.7715), - gr_complex(0.7715, -0.1543), gr_complex(0.7715, -0.4629), - gr_complex(0.7715, 1.0801), gr_complex(0.7715, 0.7715), - gr_complex(0.7715, 0.1543), gr_complex(0.7715, 0.4629), - gr_complex(0.1543, -1.0801), gr_complex(0.1543, -0.7715), - gr_complex(0.1543, -0.1543), gr_complex(0.1543, -0.4629), - gr_complex(0.1543, 1.0801), gr_complex(0.1543, 0.7715), - gr_complex(0.1543, 0.1543), gr_complex(0.1543, 0.4629), - gr_complex(0.4629, -1.0801), gr_complex(0.4629, -0.7715), - gr_complex(0.4629, -0.1543), gr_complex(0.4629, -0.4629), - gr_complex(0.4629, 1.0801), gr_complex(0.4629, 0.7715), - gr_complex(0.4629, 0.1543), gr_complex(0.4629, 0.4629)}; - diff --git a/lib/chunks_to_symbols_impl.h b/lib/chunks_to_symbols_impl.h index 040df2f..ef689de 100644 --- a/lib/chunks_to_symbols_impl.h +++ b/lib/chunks_to_symbols_impl.h @@ -18,6 +18,7 @@ #define INCLUDED_IEEE802_11_CHUNKS_TO_SYMBOLS_IMPL_H #include +#include namespace gr { namespace ieee802_11 { @@ -33,11 +34,12 @@ public: gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); -protected: - static const gr_complex BPSK[2]; - static const gr_complex QPSK[4]; - static const gr_complex QAM16[16]; - static const gr_complex QAM64[64]; +private: + boost::shared_ptr d_mapping; + constellation_bpsk::sptr d_bpsk; + constellation_qpsk::sptr d_qpsk; + constellation_16qam::sptr d_16qam; + constellation_64qam::sptr d_64qam; }; } /* namespace ieee802_11 */