/* * Copyright (C) 2013 Bastian Bloessl * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "utils.h" #include using namespace gr::ieee802_11; class ofdm_mapper_impl : public ofdm_mapper { public: static const int DATA_CARRIERS = 48; ofdm_mapper_impl(Encoding e, bool debug) : block ("ofdm_mapper", gr::io_signature::make(0, 0, 0), gr::io_signature::make(1, 1, sizeof(char))), d_symbols_offset(0), d_symbols(NULL), d_debug(debug), d_ofdm(e) { message_port_register_in(pmt::mp("in")); set_encoding(e); } ~ofdm_mapper_impl() { free(d_symbols); } void print_message(const char *msg, size_t len) { dout << std::hex << "OFDM MAPPER input symbols" << std::endl << "===========================" << std::endl; for(int i = 0; i < len; i++) { dout << std::hex << (int)msg[i] << " "; } dout << std::dec << std::endl; } int general_work(int noutput, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items ) { unsigned char *out = (unsigned char*)output_items[0]; dout << "OFDM MAPPER called offset: " << d_symbols_offset << " length: " << d_symbols_len << std::endl; while(!d_symbols_offset) { pmt::pmt_t msg(delete_head_blocking(pmt::intern("in"))); if(pmt::is_eof_object(msg)) { dout << "MAPPER: exiting" << std::endl; return -1; } if(pmt::is_pair(msg)) { dout << "OFDM MAPPER: received new message" << std::endl; gr::thread::scoped_lock lock(d_mutex); int psdu_length = pmt::blob_length(pmt::cdr(msg)); const char *psdu = static_cast(pmt::blob_data(pmt::cdr(msg))); // ############ INSERT MAC STUFF tx_param tx(d_ofdm, psdu_length); if(tx.n_sym > 120) { std::cout << "packet too large" <