blob: 5dd41f2ad156ce70f7e93009e6151017a78be103 [file] [log] [blame]
Piotr Krysik2bb54c82016-08-16 16:05:23 +02001/* -*- c++ -*- */
2/* @file
3 * @author Piotr Krysik <ptrkrysik@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 "uplink_downlink_filter_impl.h"
29#include <grgsm/gsmtap.h>
30#define BURST_SIZE 148
31namespace gr {
32 namespace grgsm {
33
34 uplink_downlink_filter::sptr
35 uplink_downlink_filter::make()
36 {
37 return gnuradio::get_initial_sptr
38 (new uplink_downlink_filter_impl());
39 }
40
41 /*
42 * The private constructor
43 */
44 uplink_downlink_filter_impl::uplink_downlink_filter_impl()
45 : gr::block("uplink_downlink_filter",
46 gr::io_signature::make(0,0,0),
47 gr::io_signature::make(0,0,0))
48 {
49 message_port_register_in(pmt::mp("in"));
50 message_port_register_out(pmt::mp("uplink"));
51 message_port_register_out(pmt::mp("downlink"));
Piotr Krysik2bb54c82016-08-16 16:05:23 +020052 set_msg_handler(pmt::mp("in"), boost::bind(&uplink_downlink_filter_impl::process_msg, this, _1));
53 }
54
55 void uplink_downlink_filter_impl::process_msg(pmt::pmt_t msg)
56 {
57 gsmtap_hdr * header = (gsmtap_hdr *)(pmt::blob_data(pmt::cdr(msg)));
58 bool uplink_burst = (be16toh(header->arfcn) & 0x4000) ? true : false;
59 if(uplink_burst)
60 {
61 message_port_pub(pmt::mp("uplink"), msg);
62 } else {
63 message_port_pub(pmt::mp("downlink"), msg);
64 }
Piotr Krysik2bb54c82016-08-16 16:05:23 +020065 }
66
67 /*
68 * Our virtual destructor.
69 */
70 uplink_downlink_filter_impl::~uplink_downlink_filter_impl()
71 {
72 }
73 } /* namespace grgsm */
74} /* namespace gr */
75