aboutsummaryrefslogtreecommitdiffstats
path: root/lib/demapping
diff options
context:
space:
mode:
authorpiotr <Piotr Krysik pkrysik@elka.pw.edu.pl>2014-07-20 23:48:32 +0200
committerpiotr <Piotr Krysik pkrysik@elka.pw.edu.pl>2014-07-20 23:48:32 +0200
commitfaacc72413cb64544b8e46beded071ff91826d82 (patch)
treea364be32dfff1433d9d1b7a9ec3480bb54fb0a2a /lib/demapping
parent9d5d86362eed527236366023ab0fa4e1b03ac6e7 (diff)
Added typical signalization channels (CCCH, BCCH, SDCCH) decoder and demapper for BCCH.
The implementation is quite dirty at this moment.
Diffstat (limited to 'lib/demapping')
-rw-r--r--lib/demapping/get_bcch_or_ccch_bursts_impl.cc100
-rw-r--r--lib/demapping/get_bcch_or_ccch_bursts_impl.h44
2 files changed, 144 insertions, 0 deletions
diff --git a/lib/demapping/get_bcch_or_ccch_bursts_impl.cc b/lib/demapping/get_bcch_or_ccch_bursts_impl.cc
new file mode 100644
index 0000000..4e8d369
--- /dev/null
+++ b/lib/demapping/get_bcch_or_ccch_bursts_impl.cc
@@ -0,0 +1,100 @@
+/* -*- 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gnuradio/io_signature.h>
+#include <gsm/gsmtap.h>
+#include "get_bcch_or_ccch_bursts_impl.h"
+
+namespace gr {
+ namespace gsm {
+
+ get_bcch_or_ccch_bursts::sptr
+ get_bcch_or_ccch_bursts::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new get_bcch_or_ccch_bursts_impl());
+ }
+
+ /*
+ * The private constructor
+ */
+ get_bcch_or_ccch_bursts_impl::get_bcch_or_ccch_bursts_impl()
+ : gr::block("get_bcch_or_ccch_bursts",
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(0, 0, 0))
+ {
+ message_port_register_in(pmt::mp("bursts"));
+ set_msg_handler(pmt::mp("bursts"), boost::bind(&get_bcch_or_ccch_bursts_impl::filter_ccch, this, _1));
+ message_port_register_out(pmt::mp("bursts"));
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ get_bcch_or_ccch_bursts_impl::~get_bcch_or_ccch_bursts_impl()
+ {
+ }
+
+ void get_bcch_or_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;
+
+ uint32_t fn_mod51 = header->frame_number % 51;
+ const int fn51_start = 6;
+ const int fn51_stop = 9;
+
+ if(header->timeslot==0){
+ if(fn_mod51>=fn51_start && fn_mod51<=fn51_stop){
+ uint32_t ii = fn_mod51-fn51_start;
+ d_frame_numbers[ii]=header->frame_number;
+ d_bursts[ii] = msg;
+ }
+
+ if(fn_mod51==fn51_stop){
+ //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((d_frame_numbers[jj]-d_frame_numbers[jj-1])!=1){
+ frames_are_consecutive = false;
+ }
+ }
+ if(frames_are_consecutive)
+ {
+ //send bursts to the output
+ for(int jj=0; jj<4; jj++)
+ {
+ message_port_pub(pmt::mp("bursts"), d_bursts[jj]);
+ }
+ }
+ }
+ }
+ }
+ } /* namespace gsm */
+} /* namespace gr */
+
diff --git a/lib/demapping/get_bcch_or_ccch_bursts_impl.h b/lib/demapping/get_bcch_or_ccch_bursts_impl.h
new file mode 100644
index 0000000..c3c4c59
--- /dev/null
+++ b/lib/demapping/get_bcch_or_ccch_bursts_impl.h
@@ -0,0 +1,44 @@
+/* -*- 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_BCCH_OR_CCCH_BURSTS_IMPL_H
+#define INCLUDED_GSM_GET_BCCH_OR_CCCH_BURSTS_IMPL_H
+
+#include <gsm/get_bcch_or_ccch_bursts.h>
+
+namespace gr {
+ namespace gsm {
+
+ class get_bcch_or_ccch_bursts_impl : public get_bcch_or_ccch_bursts
+ {
+ private:
+ uint32_t d_frame_numbers[4];
+ pmt::pmt_t d_bursts[4];
+ public:
+ get_bcch_or_ccch_bursts_impl();
+ ~get_bcch_or_ccch_bursts_impl();
+ void filter_ccch(pmt::pmt_t msg);
+ };
+
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_GET_BCCH_OR_CCCH_BURSTS_IMPL_H */
+