Roman Khassraf | 8b64d87 | 2015-08-06 17:30:04 +0200 | [diff] [blame] | 1 | /* -*- 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_sdcch_subslot_filter_impl.h" |
| 29 | #include <stdio.h> |
| 30 | #include <grgsm/endian.h> |
| 31 | #include <grgsm/gsmtap.h> |
| 32 | |
Roman Khassraf | 8b64d87 | 2015-08-06 17:30:04 +0200 | [diff] [blame] | 33 | namespace gr { |
| 34 | namespace gsm { |
| 35 | |
| 36 | burst_sdcch_subslot_filter::sptr |
| 37 | burst_sdcch_subslot_filter::make(subslot_filter_mode mode, unsigned int subslot) |
| 38 | { |
| 39 | return gnuradio::get_initial_sptr |
| 40 | (new burst_sdcch_subslot_filter_impl(mode, subslot)); |
| 41 | } |
| 42 | |
| 43 | /* |
| 44 | * The private constructor |
| 45 | */ |
| 46 | burst_sdcch_subslot_filter_impl::burst_sdcch_subslot_filter_impl(subslot_filter_mode mode, unsigned int subslot) |
| 47 | : gr::block("burst_sdcch_subslot_filter", |
| 48 | gr::io_signature::make(0, 0, 0), |
| 49 | gr::io_signature::make(0, 0, 0)), |
Piotr Krysik | 4ea1b92 | 2016-02-28 11:25:52 +0100 | [diff] [blame] | 50 | d_mode(mode), |
| 51 | d_subslot(subslot) |
Roman Khassraf | 8b64d87 | 2015-08-06 17:30:04 +0200 | [diff] [blame] | 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_sdcch_subslot_filter_impl::process_burst, this, _1)); |
| 57 | } |
| 58 | |
| 59 | /* |
| 60 | * Our virtual destructor. |
| 61 | */ |
| 62 | burst_sdcch_subslot_filter_impl::~burst_sdcch_subslot_filter_impl() {} |
| 63 | |
| 64 | void burst_sdcch_subslot_filter_impl::process_burst(pmt::pmt_t msg) |
Piotr Krysik | 4ea1b92 | 2016-02-28 11:25:52 +0100 | [diff] [blame] | 65 | { |
Steve Glass | c8edec5 | 2015-09-27 16:14:33 +1000 | [diff] [blame] | 66 | // hardcoded subslots of the channels, both SDCCH and the associated SACCH |
| 67 | // -1 means that the particular position in the frame is not SDCCH |
| 68 | static const int8_t subslots_sdcch4[102] = { |
Piotr Krysik | 4ea1b92 | 2016-02-28 11:25:52 +0100 | [diff] [blame] | 69 | -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 1, 1, 1, 1,-1,-1, 2, 2, 2, 2, 3, 3, 3, 3,-1,-1, 0, 0, 0, 0, 1, 1, 1, 1,-1, |
| 70 | -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 1, 1, 1, 1,-1,-1, 2, 2, 2, 2, 3, 3, 3, 3,-1,-1, 2, 2, 2, 2, 3, 3, 3, 3,-1 |
Steve Glass | c8edec5 | 2015-09-27 16:14:33 +1000 | [diff] [blame] | 71 | }; |
| 72 | static const int8_t subslots_sdcch8[102] = { |
Piotr Krysik | 4ea1b92 | 2016-02-28 11:25:52 +0100 | [diff] [blame] | 73 | 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,-1,-1,-1, |
| 74 | 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,-1,-1,-1 |
Steve Glass | c8edec5 | 2015-09-27 16:14:33 +1000 | [diff] [blame] | 75 | }; |
Piotr Krysik | 4ea1b92 | 2016-02-28 11:25:52 +0100 | [diff] [blame] | 76 | |
Roman Khassraf | 8b64d87 | 2015-08-06 17:30:04 +0200 | [diff] [blame] | 77 | pmt::pmt_t header_plus_burst = pmt::cdr(msg); |
| 78 | gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_plus_burst); |
| 79 | |
| 80 | uint32_t frame_nr = be32toh(header->frame_number); |
| 81 | uint32_t fn_mod102 = frame_nr % 102; |
| 82 | |
| 83 | int8_t subslot; |
| 84 | |
| 85 | if (d_mode == SS_FILTER_SDCCH8) |
| 86 | { |
Steve Glass | c8edec5 | 2015-09-27 16:14:33 +1000 | [diff] [blame] | 87 | subslot = subslots_sdcch8[fn_mod102]; |
Roman Khassraf | 8b64d87 | 2015-08-06 17:30:04 +0200 | [diff] [blame] | 88 | } |
| 89 | else if (d_mode == SS_FILTER_SDCCH4) |
| 90 | { |
Steve Glass | c8edec5 | 2015-09-27 16:14:33 +1000 | [diff] [blame] | 91 | subslot = subslots_sdcch4[fn_mod102]; |
Roman Khassraf | 8b64d87 | 2015-08-06 17:30:04 +0200 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | if ((subslot == -1) || (d_mode == SS_FILTER_SDCCH4 && subslot > 3)) |
| 95 | { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | if (subslot == d_subslot) |
| 100 | { |
| 101 | message_port_pub(pmt::mp("out"), msg); |
| 102 | } |
| 103 | } |
| 104 | } /* namespace gsm */ |
| 105 | } /* namespace gr */ |