blob: 20306d126f2a76ec573e5ab5eb13204367e0409d [file] [log] [blame]
Roman Khassrafd7e3eec2015-08-06 11:54:22 +02001/* -*- c++ -*- */
2/* @file
3 * @author Roman Khassraf <rkhassraf@gmail.com>
4 * @section LICENSE
5 *
6 * Gr-gsm is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3, or (at your option)
9 * any later version.
10 *
11 * Gr-gsm is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with gr-gsm; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <gnuradio/io_signature.h>
28#include "burst_timeslot_filter_impl.h"
29#include <stdio.h>
30#include <grgsm/endian.h>
31#include <grgsm/gsmtap.h>
32
33
34namespace gr {
35 namespace gsm {
36
37 burst_timeslot_filter::sptr
38 burst_timeslot_filter::make(unsigned int timeslot)
39 {
40 return gnuradio::get_initial_sptr
41 (new burst_timeslot_filter_impl(timeslot));
42 }
43
44 /*
45 * The private constructor
46 */
47 burst_timeslot_filter_impl::burst_timeslot_filter_impl(unsigned int timeslot)
48 : gr::block("burst_timeslot_filter",
49 gr::io_signature::make(0, 0, 0),
50 gr::io_signature::make(0, 0, 0)),
51 d_timeslot(timeslot)
52 {
53 message_port_register_in(pmt::mp("in"));
54 message_port_register_out(pmt::mp("out"));
55
56 set_msg_handler(pmt::mp("in"), boost::bind(&burst_timeslot_filter_impl::process_burst, this, _1));
57 }
58
59 /*
60 * Our virtual destructor.
61 */
62 burst_timeslot_filter_impl::~burst_timeslot_filter_impl() {}
63
64 void burst_timeslot_filter_impl::process_burst(pmt::pmt_t msg)
65 {
66 pmt::pmt_t header_plus_burst = pmt::cdr(msg);
67 gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_plus_burst);
68
69 unsigned int timeslot = header->timeslot;
70
71 if (header->timeslot == d_timeslot)
72 {
73 message_port_pub(pmt::mp("out"), msg);
74 }
75 }
Vadim Yanitskiy91195eb2017-07-21 06:39:40 +070076
77 /*
78 * External API
79 */
80 unsigned int
81 burst_timeslot_filter_impl::get_tn(void)
82 {
83 return d_timeslot;
84 }
85
86 unsigned int
87 burst_timeslot_filter_impl::set_tn(unsigned int tn)
88 {
89 if (tn < 8)
90 d_timeslot = tn;
91
92 return d_timeslot;
93 }
94
Roman Khassrafd7e3eec2015-08-06 11:54:22 +020095 } /* namespace gsm */
96} /* namespace gr */