diff options
author | piotr <Piotr Krysik pkrysik@elka.pw.edu.pl> | 2014-04-17 11:09:30 +0200 |
---|---|---|
committer | piotr <Piotr Krysik pkrysik@elka.pw.edu.pl> | 2014-04-17 11:09:30 +0200 |
commit | d77c9cf983530d12ca535da4231269c0967553e4 (patch) | |
tree | dabddddd873731461d8451f3eae29098fab3d229 | |
parent | bf2d9a477bbd1362e23d7c17a42984466c54fc60 (diff) |
Added block filtering bursts containing full CCH messages
-rw-r--r-- | grc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | grc/gsm_get_ccch_bursts.xml | 16 | ||||
-rw-r--r-- | include/gsm/CMakeLists.txt | 1 | ||||
-rw-r--r-- | include/gsm/get_ccch_bursts.h | 56 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/get_ccch_bursts_impl.cc | 101 | ||||
-rw-r--r-- | lib/get_ccch_bursts_impl.h | 42 |
7 files changed, 218 insertions, 0 deletions
diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index f2f4b75..5c0ee65 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -19,5 +19,6 @@ install(FILES gsm_receiver_hier.xml + gsm_get_ccch_bursts.xml gsm_bursts_printer.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/gsm_get_ccch_bursts.xml b/grc/gsm_get_ccch_bursts.xml new file mode 100644 index 0000000..4c917b2 --- /dev/null +++ b/grc/gsm_get_ccch_bursts.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<block> + <name>get_ccch_bursts</name> + <key>gsm_get_ccch_bursts</key> + <category>gsm</category> + <import>import gsm</import> + <make>gsm.get_ccch_bursts()</make> + <sink> + <name>bursts_in</name> + <type>message</type> + </sink> + <source> + <name>bursts_out</name> + <type>message</type> + </source> +</block> diff --git a/include/gsm/CMakeLists.txt b/include/gsm/CMakeLists.txt index c7f4fb3..746f718 100644 --- a/include/gsm/CMakeLists.txt +++ b/include/gsm/CMakeLists.txt @@ -23,5 +23,6 @@ install(FILES api.h receiver.h + get_ccch_bursts.h bursts_printer.h DESTINATION include/gsm ) diff --git a/include/gsm/get_ccch_bursts.h b/include/gsm/get_ccch_bursts.h new file mode 100644 index 0000000..e0bbb1d --- /dev/null +++ b/include/gsm/get_ccch_bursts.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + + +#ifndef INCLUDED_GSM_GET_CCCH_BURSTS_H +#define INCLUDED_GSM_GET_CCCH_BURSTS_H + +#include <gsm/api.h> +#include <gnuradio/block.h> + +namespace gr { + namespace gsm { + + /*! + * \brief <+description of block+> + * \ingroup gsm + * + */ + class GSM_API get_ccch_bursts : virtual public gr::block + { + public: + typedef boost::shared_ptr<get_ccch_bursts> sptr; + + /*! + * \brief Return a shared_ptr to a new instance of gsm::get_ccch_bursts. + * + * To avoid accidental use of raw pointers, gsm::get_ccch_bursts's + * constructor is in a private implementation + * class. gsm::get_ccch_bursts::make is the public interface for + * creating new instances. + */ + static sptr make(); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_GET_CCCH_BURSTS_H */ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8899310..38539da 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -31,6 +31,7 @@ list(APPEND gsm_sources viterbi_detector.cc sch.c bursts_printer_impl.cc + get_ccch_bursts_impl.cc ) add_library(gnuradio-gsm SHARED ${gsm_sources}) diff --git a/lib/get_ccch_bursts_impl.cc b/lib/get_ccch_bursts_impl.cc new file mode 100644 index 0000000..249c271 --- /dev/null +++ b/lib/get_ccch_bursts_impl.cc @@ -0,0 +1,101 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 <perper@o2.pl>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gnuradio/io_signature.h> +#include "get_ccch_bursts_impl.h" +#include <gsmtap.h> + +namespace gr { + namespace gsm { + + void get_ccch_bursts_impl::filter_ccch(pmt::pmt_t msg) + { + pmt::pmt_t header_blob = pmt::car(msg); + pmt::pmt_t content = pmt::cdr(msg); + gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_blob); + uint32_t frame_nr = header->frame_number; + pmt::pmt_t msgs[4]; + uint32_t frame_numbers[4]; + + if(header->timeslot==0){ + std::cout << (header->frame_number % 51) << std::endl; + if((header->frame_number % 51)>=2 & (header->frame_number % 51)<=5){ + uint32_t ii = header->frame_number-2; + frame_numbers[ii]=header->frame_number; + msgs[ii] = msg; +// std::cout << "Hura, pierwszy if" << std::endl; + } + + if((header->frame_number % 51)==5){ + //check for a situation where some BCCH bursts were lost + //in this situation frame numbers won't be consecutive + bool frames_are_consecutive = true; + for(int jj=1;jj<4;jj++){ + if((frame_numbers[jj]-frame_numbers[jj-1])!=1){ + frames_are_consecutive = false; + } + } + std::cout << "Hura, durgi if" << std::endl; + if(frames_are_consecutive){ + //send bursts to the output + std::cout << "Hura, trzeci if" << std::endl; + + for(int jj=1;jj<4;jj++){ +// message_port_pub(pmt::mp("bursts_out"), msgs[jj]); + } + } + } + } + } + + get_ccch_bursts::sptr + get_ccch_bursts::make() + { + return gnuradio::get_initial_sptr + (new get_ccch_bursts_impl()); + } + + /* + * The private constructor + */ + get_ccch_bursts_impl::get_ccch_bursts_impl() + : gr::block("get_ccch_bursts", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)) + { + message_port_register_in(pmt::mp("bursts_in")); + set_msg_handler(pmt::mp("bursts_in"), boost::bind(&get_ccch_bursts_impl::filter_ccch, this, _1)); + message_port_register_out(pmt::mp("bursts_out")); + } + + /* + * Our virtual destructor. + */ + get_ccch_bursts_impl::~get_ccch_bursts_impl() + { + } + + } /* namespace gsm */ +} /* namespace gr */ + diff --git a/lib/get_ccch_bursts_impl.h b/lib/get_ccch_bursts_impl.h new file mode 100644 index 0000000..992b181 --- /dev/null +++ b/lib/get_ccch_bursts_impl.h @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GSM_GET_CCCH_BURSTS_IMPL_H +#define INCLUDED_GSM_GET_CCCH_BURSTS_IMPL_H + +#include <gsm/get_ccch_bursts.h> +#include <receiver_config.h> + +namespace gr { + namespace gsm { + + class get_ccch_bursts_impl : public get_ccch_bursts + { + public: + get_ccch_bursts_impl(); + ~get_ccch_bursts_impl(); + void filter_ccch(pmt::pmt_t msg); + }; + + } // namespace gsm +} // namespace gr + +#endif /* INCLUDED_GSM_GET_CCCH_BURSTS_IMPL_H */ + |