Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 1 | /* -*- c++ -*- */ |
| 2 | /* @file |
Piotr Krysik | a6268a5 | 2017-08-23 16:02:19 +0200 | [diff] [blame] | 3 | * @author (C) 2016 by Piotr Krysik <ptrkrysik@gmail.com> |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 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> |
Piotr Krysik | a3405b2 | 2016-08-30 21:31:24 +0200 | [diff] [blame] | 28 | #include "uplink_downlink_splitter_impl.h" |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 29 | #include <grgsm/gsmtap.h> |
aurelienduarte | b52c15f | 2016-10-10 20:27:11 +0200 | [diff] [blame] | 30 | #include <grgsm/endian.h> |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 31 | #define BURST_SIZE 148 |
| 32 | namespace gr { |
Piotr Krysik | 264fbf6 | 2017-11-05 12:25:51 +0100 | [diff] [blame] | 33 | namespace gsm { |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 34 | |
Piotr Krysik | a3405b2 | 2016-08-30 21:31:24 +0200 | [diff] [blame] | 35 | uplink_downlink_splitter::sptr |
| 36 | uplink_downlink_splitter::make() |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 37 | { |
| 38 | return gnuradio::get_initial_sptr |
Piotr Krysik | a3405b2 | 2016-08-30 21:31:24 +0200 | [diff] [blame] | 39 | (new uplink_downlink_splitter_impl()); |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | /* |
| 43 | * The private constructor |
| 44 | */ |
Piotr Krysik | a3405b2 | 2016-08-30 21:31:24 +0200 | [diff] [blame] | 45 | uplink_downlink_splitter_impl::uplink_downlink_splitter_impl() |
| 46 | : gr::block("uplink_downlink_splitter", |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 47 | 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")); |
Piotr Krysik | a3405b2 | 2016-08-30 21:31:24 +0200 | [diff] [blame] | 53 | set_msg_handler(pmt::mp("in"), boost::bind(&uplink_downlink_splitter_impl::process_msg, this, _1)); |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 54 | } |
| 55 | |
Piotr Krysik | a3405b2 | 2016-08-30 21:31:24 +0200 | [diff] [blame] | 56 | void uplink_downlink_splitter_impl::process_msg(pmt::pmt_t msg) |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 57 | { |
| 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 Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | /* |
| 69 | * Our virtual destructor. |
| 70 | */ |
Piotr Krysik | a3405b2 | 2016-08-30 21:31:24 +0200 | [diff] [blame] | 71 | uplink_downlink_splitter_impl::~uplink_downlink_splitter_impl() |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 72 | { |
| 73 | } |
Piotr Krysik | 264fbf6 | 2017-11-05 12:25:51 +0100 | [diff] [blame] | 74 | } /* namespace gsm */ |
Piotr Krysik | 2bb54c8 | 2016-08-16 16:05:23 +0200 | [diff] [blame] | 75 | } /* namespace gr */ |
| 76 | |