blob: 249c271e4b9b23922e8b37daf3f91387bca9b9f2 [file] [log] [blame]
piotrd77c9cf2014-04-17 11:09:30 +02001/* -*- c++ -*- */
2/*
3 * Copyright 2014 <perper@o2.pl>.
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifdef HAVE_CONFIG_H
22#include "config.h"
23#endif
24
25#include <gnuradio/io_signature.h>
26#include "get_ccch_bursts_impl.h"
27#include <gsmtap.h>
28
29namespace gr {
30 namespace gsm {
31
32 void get_ccch_bursts_impl::filter_ccch(pmt::pmt_t msg)
33 {
34 pmt::pmt_t header_blob = pmt::car(msg);
35 pmt::pmt_t content = pmt::cdr(msg);
36 gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob);
37 uint32_t frame_nr = header->frame_number;
38 pmt::pmt_t msgs[4];
39 uint32_t frame_numbers[4];
40
41 if(header->timeslot==0){
42 std::cout << (header->frame_number % 51) << std::endl;
43 if((header->frame_number % 51)>=2 & (header->frame_number % 51)<=5){
44 uint32_t ii = header->frame_number-2;
45 frame_numbers[ii]=header->frame_number;
46 msgs[ii] = msg;
47// std::cout << "Hura, pierwszy if" << std::endl;
48 }
49
50 if((header->frame_number % 51)==5){
51 //check for a situation where some BCCH bursts were lost
52 //in this situation frame numbers won't be consecutive
53 bool frames_are_consecutive = true;
54 for(int jj=1;jj<4;jj++){
55 if((frame_numbers[jj]-frame_numbers[jj-1])!=1){
56 frames_are_consecutive = false;
57 }
58 }
59 std::cout << "Hura, durgi if" << std::endl;
60 if(frames_are_consecutive){
61 //send bursts to the output
62 std::cout << "Hura, trzeci if" << std::endl;
63
64 for(int jj=1;jj<4;jj++){
65// message_port_pub(pmt::mp("bursts_out"), msgs[jj]);
66 }
67 }
68 }
69 }
70 }
71
72 get_ccch_bursts::sptr
73 get_ccch_bursts::make()
74 {
75 return gnuradio::get_initial_sptr
76 (new get_ccch_bursts_impl());
77 }
78
79 /*
80 * The private constructor
81 */
82 get_ccch_bursts_impl::get_ccch_bursts_impl()
83 : gr::block("get_ccch_bursts",
84 gr::io_signature::make(0, 0, 0),
85 gr::io_signature::make(0, 0, 0))
86 {
87 message_port_register_in(pmt::mp("bursts_in"));
88 set_msg_handler(pmt::mp("bursts_in"), boost::bind(&get_ccch_bursts_impl::filter_ccch, this, _1));
89 message_port_register_out(pmt::mp("bursts_out"));
90 }
91
92 /*
93 * Our virtual destructor.
94 */
95 get_ccch_bursts_impl::~get_ccch_bursts_impl()
96 {
97 }
98
99 } /* namespace gsm */
100} /* namespace gr */
101