blob: ba4ff4cbe75a13d4b7f740b0150ca74273dd1414 [file] [log] [blame]
piotr6c692872014-02-08 14:16:26 +01001/* -*- c++ -*- */
2/*
3 * Copyright 2014 <+YOU OR YOUR COMPANY+>.
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifdef HAVE_CONFIG_H
22#include "config.h"
23#endif
24
25#include <gnuradio/io_signature.h>
26#include "bursts_printer_impl.h"
piotr6d152d92014-02-21 00:02:44 +010027#include <gsmtap.h>
28#include <iterator>
29#include <algorithm>
piotr6c692872014-02-08 14:16:26 +010030
31namespace gr {
32 namespace gsm {
piotr6d152d92014-02-21 00:02:44 +010033 void bursts_printer_impl::bursts_print(pmt::pmt_t msg)
piotr6c692872014-02-08 14:16:26 +010034 {
piotr6d152d92014-02-21 00:02:44 +010035 pmt::pmt_t burst = pmt::cdr(msg);
36 int8_t * burst_elements = (int8_t *)pmt::blob_data(burst);
37 size_t burst_len=pmt::blob_length(burst);
piotr6c692872014-02-08 14:16:26 +010038
piotr6d152d92014-02-21 00:02:44 +010039 pmt::pmt_t header_blob = pmt::car(msg);
40 gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob);
41 d_c0_channels.insert(header->arfcn);
42
43// d_channels_dbm.insert(header->signal_dbm);
44// std::copy(
45// d_c0_channels.begin(),
46// d_c0_channels.end(),
47// std::ostream_iterator<uint16_t>(std::cout, " ")
48// );
49// std::cout << std::endl;
50// std::copy(
51// d_channels_dbm.begin(),
52// d_channels_dbm.end(),
53// std::ostream_iterator<int>(std::cout, " ")
54// );
55
56 for(int ii=0; ii<burst_len; ii++)
piotr6c692872014-02-08 14:16:26 +010057 {
piotr6d152d92014-02-21 00:02:44 +010058 std::cout << std::setprecision(1) << static_cast<int>(burst_elements[ii]) << " ";
piotr6c692872014-02-08 14:16:26 +010059 }
60 std::cout << std::endl;
61 }
62
63 bursts_printer::sptr
64 bursts_printer::make()
65 {
66 return gnuradio::get_initial_sptr
67 (new bursts_printer_impl());
68 }
69
70 /*
71 * The private constructor
72 */
73 bursts_printer_impl::bursts_printer_impl()
74 : gr::block("bursts_printer",
75 gr::io_signature::make(0, 0, 0),
76 gr::io_signature::make(0, 0, 0))
77 {
78 message_port_register_in(pmt::mp("bursts"));
79 set_msg_handler(pmt::mp("bursts"), boost::bind(&bursts_printer_impl::bursts_print, this, _1));
80 }
81
82 /*
83 * Our virtual destructor.
84 */
85 bursts_printer_impl::~bursts_printer_impl()
86 {
87 }
88
89
90 } /* namespace gsm */
91} /* namespace gr */
92