Roman Khassraf | dbc3a50 | 2015-08-03 23:20:20 +0200 | [diff] [blame] | 1 | /* -*- c++ -*- */ |
| 2 | /* @file |
Piotr Krysik | a6268a5 | 2017-08-23 16:02:19 +0200 | [diff] [blame] | 3 | * @author (C) 2015 by Roman Khassraf <rkhassraf@gmail.com> |
Roman Khassraf | dbc3a50 | 2015-08-03 23:20:20 +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> |
| 28 | #include "burst_timeslot_splitter_impl.h" |
| 29 | #include <stdio.h> |
| 30 | #include <grgsm/endian.h> |
| 31 | #include <grgsm/gsmtap.h> |
| 32 | |
| 33 | |
| 34 | namespace gr { |
| 35 | namespace gsm { |
| 36 | |
| 37 | burst_timeslot_splitter::sptr |
| 38 | burst_timeslot_splitter::make() |
| 39 | { |
| 40 | return gnuradio::get_initial_sptr |
| 41 | (new burst_timeslot_splitter_impl()); |
| 42 | } |
| 43 | |
| 44 | /* |
| 45 | * The private constructor |
| 46 | */ |
| 47 | burst_timeslot_splitter_impl::burst_timeslot_splitter_impl() |
| 48 | : gr::block("burst_timeslot_splitter", |
| 49 | gr::io_signature::make(0, 0, 0), |
| 50 | gr::io_signature::make(0, 0, 0)) |
| 51 | { |
| 52 | message_port_register_in(pmt::mp("in")); |
| 53 | |
| 54 | message_port_register_out(pmt::mp("out0")); |
| 55 | message_port_register_out(pmt::mp("out1")); |
| 56 | message_port_register_out(pmt::mp("out2")); |
| 57 | message_port_register_out(pmt::mp("out3")); |
| 58 | message_port_register_out(pmt::mp("out4")); |
| 59 | message_port_register_out(pmt::mp("out5")); |
| 60 | message_port_register_out(pmt::mp("out6")); |
| 61 | message_port_register_out(pmt::mp("out7")); |
| 62 | |
| 63 | set_msg_handler(pmt::mp("in"), boost::bind(&burst_timeslot_splitter_impl::process_burst, this, _1)); |
| 64 | } |
| 65 | |
| 66 | /* |
| 67 | * Our virtual destructor. |
| 68 | */ |
| 69 | burst_timeslot_splitter_impl::~burst_timeslot_splitter_impl() {} |
| 70 | |
| 71 | void burst_timeslot_splitter_impl::process_burst(pmt::pmt_t msg) |
| 72 | { |
| 73 | pmt::pmt_t header_plus_burst = pmt::cdr(msg); |
| 74 | gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_plus_burst); |
| 75 | |
| 76 | unsigned int timeslot = header->timeslot; |
| 77 | |
| 78 | std::string port("out"); |
| 79 | |
| 80 | switch (timeslot) |
| 81 | { |
| 82 | case 0: |
| 83 | port.append("0"); |
| 84 | break; |
| 85 | case 1: |
| 86 | port.append("1"); |
| 87 | break; |
| 88 | case 2: |
| 89 | port.append("2"); |
| 90 | break; |
| 91 | case 3: |
| 92 | port.append("3"); |
| 93 | break; |
| 94 | case 4: |
| 95 | port.append("4"); |
| 96 | break; |
| 97 | case 5: |
| 98 | port.append("5"); |
| 99 | break; |
| 100 | case 6: |
| 101 | port.append("6"); |
| 102 | break; |
| 103 | case 7: |
| 104 | port.append("7"); |
| 105 | break; |
| 106 | default: |
| 107 | port.append("0"); |
| 108 | break; |
| 109 | } |
| 110 | |
| 111 | message_port_pub(pmt::mp(port), msg); |
| 112 | } |
| 113 | } /* namespace gsm */ |
| 114 | } /* namespace gr */ |