blob: 424d025e731c45a0048fbf21eed6b9c37713aa5f [file] [log] [blame]
Piotr Krysik2bb54c82016-08-16 16:05:23 +02001/* -*- c++ -*- */
2/* @file
Piotr Krysika6268a52017-08-23 16:02:19 +02003 * @author (C) 2016 by Piotr Krysik <ptrkrysik@gmail.com>
Piotr Krysik2bb54c82016-08-16 16:05:23 +02004 * @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>
Piotr Krysika3405b22016-08-30 21:31:24 +020028#include "uplink_downlink_splitter_impl.h"
Piotr Krysik2bb54c82016-08-16 16:05:23 +020029#include <grgsm/gsmtap.h>
aurelienduarteb52c15f2016-10-10 20:27:11 +020030#include <grgsm/endian.h>
Piotr Krysik2bb54c82016-08-16 16:05:23 +020031#define BURST_SIZE 148
32namespace gr {
Piotr Krysik264fbf62017-11-05 12:25:51 +010033 namespace gsm {
Piotr Krysik2bb54c82016-08-16 16:05:23 +020034
Piotr Krysika3405b22016-08-30 21:31:24 +020035 uplink_downlink_splitter::sptr
36 uplink_downlink_splitter::make()
Piotr Krysik2bb54c82016-08-16 16:05:23 +020037 {
38 return gnuradio::get_initial_sptr
Piotr Krysika3405b22016-08-30 21:31:24 +020039 (new uplink_downlink_splitter_impl());
Piotr Krysik2bb54c82016-08-16 16:05:23 +020040 }
41
42 /*
43 * The private constructor
44 */
Piotr Krysika3405b22016-08-30 21:31:24 +020045 uplink_downlink_splitter_impl::uplink_downlink_splitter_impl()
46 : gr::block("uplink_downlink_splitter",
Piotr Krysik2bb54c82016-08-16 16:05:23 +020047 gr::io_signature::make(0,0,0),
48 gr::io_signature::make(0,0,0))
49 {
50 message_port_register_in(pmt::mp("in"));
51 message_port_register_out(pmt::mp("uplink"));
52 message_port_register_out(pmt::mp("downlink"));
Vadim Yanitskiya1169202021-05-03 19:00:43 +020053 set_msg_handler(pmt::mp("in"), boost::bind(&uplink_downlink_splitter_impl::process_msg, this, boost::placeholders::_1));
Piotr Krysik2bb54c82016-08-16 16:05:23 +020054 }
55
Piotr Krysika3405b22016-08-30 21:31:24 +020056 void uplink_downlink_splitter_impl::process_msg(pmt::pmt_t msg)
Piotr Krysik2bb54c82016-08-16 16:05:23 +020057 {
58 gsmtap_hdr * header = (gsmtap_hdr *)(pmt::blob_data(pmt::cdr(msg)));
59 bool uplink_burst = (be16toh(header->arfcn) & 0x4000) ? true : false;
60 if(uplink_burst)
61 {
62 message_port_pub(pmt::mp("uplink"), msg);
63 } else {
64 message_port_pub(pmt::mp("downlink"), msg);
65 }
Piotr Krysik2bb54c82016-08-16 16:05:23 +020066 }
67
68 /*
69 * Our virtual destructor.
70 */
Piotr Krysika3405b22016-08-30 21:31:24 +020071 uplink_downlink_splitter_impl::~uplink_downlink_splitter_impl()
Piotr Krysik2bb54c82016-08-16 16:05:23 +020072 {
73 }
Piotr Krysik264fbf62017-11-05 12:25:51 +010074 } /* namespace gsm */
Piotr Krysik2bb54c82016-08-16 16:05:23 +020075} /* namespace gr */
76