diff --git a/lib/decode_mac.cc b/lib/decode_mac.cc index f82332c..5dff67e 100644 --- a/lib/decode_mac.cc +++ b/lib/decode_mac.cc @@ -24,6 +24,8 @@ using namespace gr::ieee802_11; +#define LINKTYPE_IEEE802_11 105 /* http://www.tcpdump.org/linktypes.html */ + class decode_mac_impl : public decode_mac { public: @@ -34,6 +36,8 @@ decode_mac_impl(bool log, bool debug) : d_log(log), d_debug(debug), d_snr(0), + d_nom_freq(0.0), + d_freq_offset(0.0), d_ofdm(BPSK_1_2), d_frame(d_ofdm, 0), d_frame_complete(true) { @@ -70,6 +74,8 @@ int general_work (int noutput_items, gr_vector_int& ninput_items, int len_data = pmt::to_uint64(pmt::tuple_ref(tuple, 0)); int encoding = pmt::to_uint64(pmt::tuple_ref(tuple, 1)); d_snr = pmt::to_double(pmt::tuple_ref(tuple, 2)); + d_nom_freq = pmt::to_double(pmt::tuple_ref(tuple, 3)); + d_freq_offset = pmt::to_double(pmt::tuple_ref(tuple, 4)); ofdm_param ofdm = ofdm_param((Encoding)encoding); frame_param frame = frame_param(ofdm, len_data); @@ -141,6 +147,9 @@ void decode() { pmt::pmt_t dict = pmt::make_dict(); dict = pmt::dict_add(dict, pmt::mp("encoding"), enc); dict = pmt::dict_add(dict, pmt::mp("snr"), pmt::from_double(d_snr)); + dict = pmt::dict_add(dict, pmt::mp("nomfreq"), pmt::from_double(d_nom_freq)); + dict = pmt::dict_add(dict, pmt::mp("freqofs"), pmt::from_double(d_freq_offset)); + dict = pmt::dict_add(dict, pmt::mp("dlt"), pmt::from_long(LINKTYPE_IEEE802_11)); message_port_pub(pmt::mp("out"), pmt::cons(dict, blob)); } @@ -218,7 +227,9 @@ private: frame_param d_frame; ofdm_param d_ofdm; - double d_snr; + double d_snr; // dB + double d_nom_freq; // nominal frequency, Hz + double d_freq_offset; // frequency offset, Hz viterbi_decoder d_decoder; uint8_t d_rx_symbols[48 * MAX_SYM]; diff --git a/lib/frame_equalizer_impl.cc b/lib/frame_equalizer_impl.cc index 1bc8355..6b85e66 100644 --- a/lib/frame_equalizer_impl.cc +++ b/lib/frame_equalizer_impl.cc @@ -39,7 +39,8 @@ frame_equalizer_impl::frame_equalizer_impl(Equalizer algo, double freq, double b gr::io_signature::make(1, 1, 64 * sizeof(gr_complex)), gr::io_signature::make(1, 1, 48)), d_current_symbol(0), d_log(log), d_debug(debug), d_equalizer(NULL), - d_freq(freq), d_bw(bw), d_frame_bytes(0), d_frame_symbols(0) { + d_freq(freq), d_bw(bw), d_frame_bytes(0), d_frame_symbols(0), + d_freq_offset_from_synclong(0.0) { message_port_register_out(pmt::mp("symbols")); @@ -131,6 +132,7 @@ frame_equalizer_impl::general_work (int noutput_items, d_frame_symbols = 0; d_frame_mod = d_bpsk; + d_freq_offset_from_synclong = pmt::to_double(tags.front().value) * d_bw; d_epsilon0 = pmt::to_double(tags.front().value) * d_bw / (2 * M_PI * d_freq); d_er = 0; @@ -207,11 +209,14 @@ frame_equalizer_impl::general_work (int noutput_items, if(decode_signal_field(out + o * 48)) { + // TODO: it would better to use pmt::dict instead of raw list of numbers add_item_tag(0, nitems_written(0) + o, pmt::string_to_symbol("wifi_start"), pmt::make_tuple(pmt::from_uint64(d_frame_bytes), pmt::from_uint64(d_frame_encoding), - pmt::from_double(d_equalizer->get_snr())), + pmt::from_double(d_equalizer->get_snr()), + pmt::from_double(d_freq), // nominal frequency + pmt::from_double(d_freq_offset_from_synclong)), pmt::string_to_symbol(name())); } } diff --git a/lib/frame_equalizer_impl.h b/lib/frame_equalizer_impl.h index d7ed540..86ea4dc 100644 --- a/lib/frame_equalizer_impl.h +++ b/lib/frame_equalizer_impl.h @@ -59,8 +59,9 @@ private: viterbi_decoder d_decoder; // freq offset - double d_freq; - double d_bw; + double d_freq; // Hz + double d_freq_offset_from_synclong; // Hz, estimation from "sync_long" block + double d_bw; // Hz double d_er; double d_epsilon0; gr_complex d_prev_pilots[4];