aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2017-11-07 19:31:42 +0100
committerPiotr Krysik <ptrkrysik@gmail.com>2017-11-07 19:31:42 +0100
commitacc365f2f19e2fc6fcc6a76cd4ea69bfd14120ab (patch)
treed001121a7241a6c4808447ae5a2bf618f39fc4b7
parent01c6afd49501e53fd5b01f6ee9818811db69f82b (diff)
Added C++ version of burst type filter
-rw-r--r--grc/flow_control/CMakeLists.txt1
-rw-r--r--grc/flow_control/gsm_burst_type_filter.xml32
-rw-r--r--grc/gsm_block_tree.xml1
-rw-r--r--include/grgsm/flow_control/CMakeLists.txt1
-rw-r--r--include/grgsm/flow_control/burst_type_filter.h63
-rw-r--r--lib/flow_control/CMakeLists.txt1
-rw-r--r--lib/flow_control/burst_type_filter_impl.cc104
-rw-r--r--lib/flow_control/burst_type_filter_impl.h55
-rw-r--r--swig/grgsm_swig.i3
9 files changed, 261 insertions, 0 deletions
diff --git a/grc/flow_control/CMakeLists.txt b/grc/flow_control/CMakeLists.txt
index a6a7319..1f98d8f 100644
--- a/grc/flow_control/CMakeLists.txt
+++ b/grc/flow_control/CMakeLists.txt
@@ -21,6 +21,7 @@ install(FILES
gsm_burst_timeslot_splitter.xml
gsm_burst_fnr_filter.xml
gsm_burst_timeslot_filter.xml
+ gsm_burst_type_filter.xml
gsm_dummy_burst_filter.xml
gsm_burst_sdcch_subslot_splitter.xml
gsm_burst_sdcch_subslot_filter.xml
diff --git a/grc/flow_control/gsm_burst_type_filter.xml b/grc/flow_control/gsm_burst_type_filter.xml
new file mode 100644
index 0000000..a615961
--- /dev/null
+++ b/grc/flow_control/gsm_burst_type_filter.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<block>
+ <name>Burst Type Filter</name>
+ <key>gsm_burst_type_filter</key>
+ <import>import grgsm</import>
+ <make>grgsm.burst_type_filter($selected_burst_types)</make>
+
+ <param>
+ <name>Selected burst types</name>
+ <key>selected_burst_types</key>
+ <value>[0,1,2,3,4,5,6,7]</value>
+ <type>int_vector</type>
+ </param>
+
+ <sink>
+ <name>in</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+
+ <source>
+ <name>out</name>
+ <type>message</type>
+ <optional>1</optional>
+ </source>
+
+ <doc>
+This block filters bursts based on their type.
+
+For more information on burst types, see GSM 05.02.
+ </doc>
+</block>
diff --git a/grc/gsm_block_tree.xml b/grc/gsm_block_tree.xml
index 479bdb4..225c28f 100644
--- a/grc/gsm_block_tree.xml
+++ b/grc/gsm_block_tree.xml
@@ -51,6 +51,7 @@
<block>gsm_burst_timeslot_filter</block>
<block>gsm_burst_sdcch_subslot_filter</block>
<block>gsm_burst_fnr_filter</block>
+ <block>gsm_burst_type_filter</block>
<block>gsm_dummy_burst_filter</block>
<block>gsm_uplink_downlink_splitter</block>
</cat>
diff --git a/include/grgsm/flow_control/CMakeLists.txt b/include/grgsm/flow_control/CMakeLists.txt
index 322c8c8..d86f1c7 100644
--- a/include/grgsm/flow_control/CMakeLists.txt
+++ b/include/grgsm/flow_control/CMakeLists.txt
@@ -27,6 +27,7 @@ install(FILES
burst_timeslot_filter.h
burst_sdcch_subslot_filter.h
burst_fnr_filter.h
+ burst_type_filter.h
dummy_burst_filter.h
uplink_downlink_splitter.h DESTINATION include/grgsm/flow_control
)
diff --git a/include/grgsm/flow_control/burst_type_filter.h b/include/grgsm/flow_control/burst_type_filter.h
new file mode 100644
index 0000000..6430039
--- /dev/null
+++ b/include/grgsm/flow_control/burst_type_filter.h
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/* @file
+ * @author (C) 2017 by Piotr Krysik <ptrkrysik@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm 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.
+ *
+ * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef INCLUDED_GSM_BURST_TYPE_FILTER_H
+#define INCLUDED_GSM_BURST_TYPE_FILTER_H
+
+#include <grgsm/api.h>
+#include <gnuradio/block.h>
+#include <grgsm/flow_control/common.h>
+
+namespace gr {
+ namespace gsm {
+
+ /*!
+ * \brief <+description of block+>
+ * \ingroup gsm
+ *
+ */
+ class GRGSM_API burst_type_filter : virtual public gr::block
+ {
+ public:
+ typedef boost::shared_ptr<burst_type_filter> sptr;
+
+ /*!
+ * \brief Return a shared_ptr to a new instance of grgsm::burst_type_filter.
+ *
+ * To avoid accidental use of raw pointers, grgsm::burst_type_filter's
+ * constructor is in a private implementation
+ * class. grgsm::burst_type_filter::make is the public interface for
+ * creating new instances.
+ */
+
+ static sptr make(const std::vector<uint8_t> & selected_burst_types);
+
+ /* External API */
+ /* Filtering policy */
+ virtual filter_policy get_policy(void) = 0;
+ virtual filter_policy set_policy(filter_policy policy) = 0;
+ virtual void set_selected_burst_types(const std::vector<uint8_t> & selected_burst_types) = 0;
+ };
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_BURST_TYPE_FILTER_H */
diff --git a/lib/flow_control/CMakeLists.txt b/lib/flow_control/CMakeLists.txt
index 30a5f50..b8f63f7 100644
--- a/lib/flow_control/CMakeLists.txt
+++ b/lib/flow_control/CMakeLists.txt
@@ -23,6 +23,7 @@ add_sources(
burst_sdcch_subslot_splitter_impl.cc
burst_timeslot_filter_impl.cc
burst_timeslot_splitter_impl.cc
+ burst_type_filter_impl.cc
dummy_burst_filter_impl.cc
uplink_downlink_splitter_impl.cc
)
diff --git a/lib/flow_control/burst_type_filter_impl.cc b/lib/flow_control/burst_type_filter_impl.cc
new file mode 100644
index 0000000..542a004
--- /dev/null
+++ b/lib/flow_control/burst_type_filter_impl.cc
@@ -0,0 +1,104 @@
+/* -*- c++ -*- */
+/* @file
+ * @author (C) 2017 by Piotr Krysik <ptrkrysik@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm 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.
+ *
+ * Gr-gsm 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 gr-gsm; 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 "burst_type_filter_impl.h"
+#include <stdio.h>
+#include <grgsm/endian.h>
+#include <grgsm/gsmtap.h>
+
+
+namespace gr {
+ namespace gsm {
+
+ burst_type_filter::sptr
+ burst_type_filter::make(const std::vector<uint8_t> & selected_burst_types)
+ {
+ return gnuradio::get_initial_sptr
+ (new burst_type_filter_impl(selected_burst_types));
+ }
+
+ /*
+ * The private constructor
+ */
+ burst_type_filter_impl::burst_type_filter_impl(const std::vector<uint8_t> & selected_burst_types)
+ : gr::block("burst_type_filter",
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(0, 0, 0)),
+ d_filter_policy(FILTER_POLICY_DEFAULT)
+ {
+ set_selected_burst_types(selected_burst_types);
+
+ message_port_register_in(pmt::mp("in"));
+ message_port_register_out(pmt::mp("out"));
+
+ set_msg_handler(pmt::mp("in"), boost::bind(&burst_type_filter_impl::process_burst, this, _1));
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ burst_type_filter_impl::~burst_type_filter_impl() {}
+
+ void burst_type_filter_impl::process_burst(pmt::pmt_t msg)
+ {
+ if (d_filter_policy == FILTER_POLICY_DROP_ALL)
+ return;
+
+ if (d_filter_policy == FILTER_POLICY_PASS_ALL) {
+ message_port_pub(pmt::mp("out"), msg);
+ return;
+ }
+
+ gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(pmt::cdr(msg));
+// std::cout << "header->type: " << (int)(header->sub_type) << std::endl;
+ if (std::find(d_selected_burst_types.begin(), d_selected_burst_types.end(), header->sub_type) != d_selected_burst_types.end()) //check if burst type is listed in burst types to pass
+ {
+ message_port_pub(pmt::mp("out"), msg);
+ }
+ }
+
+ /* Filtering policy */
+ filter_policy
+ burst_type_filter_impl::get_policy(void)
+ {
+ return d_filter_policy;
+ }
+
+ filter_policy
+ burst_type_filter_impl::set_policy(filter_policy policy)
+ {
+ d_filter_policy = policy;
+ return d_filter_policy;
+ }
+
+ void
+ burst_type_filter_impl::set_selected_burst_types(const std::vector<uint8_t> & selected_burst_types)
+ {
+ d_selected_burst_types.assign(selected_burst_types.begin(), selected_burst_types.end());
+ }
+ } /* namespace gsm */
+} /* namespace gr */
diff --git a/lib/flow_control/burst_type_filter_impl.h b/lib/flow_control/burst_type_filter_impl.h
new file mode 100644
index 0000000..5c6ad14
--- /dev/null
+++ b/lib/flow_control/burst_type_filter_impl.h
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/* @file
+ * @author (C) 2017 by Piotr Krysik <ptrkrysik@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm 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.
+ *
+ * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef INCLUDED_GSM_BURST_TYPE_FILTER_IMPL_H
+#define INCLUDED_GSM_BURST_TYPE_FILTER_IMPL_H
+
+#define BURST_TYPE_LEN 148
+
+#include <grgsm/flow_control/burst_type_filter.h>
+
+namespace gr {
+ namespace gsm {
+
+ class burst_type_filter_impl : public burst_type_filter
+ {
+ private:
+ filter_policy d_filter_policy;
+ std::vector<uint8_t> d_selected_burst_types;
+ public:
+ burst_type_filter_impl(const std::vector<uint8_t> & selected_burst_types);
+ ~burst_type_filter_impl();
+ void process_burst(pmt::pmt_t msg);
+
+ /* External API */
+ /* Filtering policy */
+ filter_policy get_policy(void);
+ filter_policy set_policy(filter_policy policy);
+
+ void set_selected_burst_types(const std::vector<uint8_t> & selected_burst_types);
+ };
+
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_BURST_TYPE_FILTER_IMPL_H */
+
diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i
index 4901b44..26b6a6d 100644
--- a/swig/grgsm_swig.i
+++ b/swig/grgsm_swig.i
@@ -47,6 +47,7 @@
#include "grgsm/flow_control/burst_timeslot_filter.h"
#include "grgsm/flow_control/burst_sdcch_subslot_filter.h"
#include "grgsm/flow_control/burst_fnr_filter.h"
+#include "grgsm/flow_control/burst_type_filter.h"
#include "grgsm/flow_control/dummy_burst_filter.h"
#include "grgsm/flow_control/uplink_downlink_splitter.h"
#include "grgsm/misc_utils/bursts_printer.h"
@@ -106,6 +107,8 @@ GR_SWIG_BLOCK_MAGIC2(gsm, burst_timeslot_filter);
GR_SWIG_BLOCK_MAGIC2(gsm, burst_sdcch_subslot_filter);
%include "grgsm/flow_control/burst_fnr_filter.h"
GR_SWIG_BLOCK_MAGIC2(gsm, burst_fnr_filter);
+%include "grgsm/flow_control/burst_type_filter.h"
+GR_SWIG_BLOCK_MAGIC2(gsm, burst_type_filter);
%include "grgsm/flow_control/dummy_burst_filter.h"
GR_SWIG_BLOCK_MAGIC2(gsm, dummy_burst_filter);
%include "grgsm/flow_control/uplink_downlink_splitter.h"