Added C++ version of burst type filter
This commit is contained in:
parent
01c6afd495
commit
acc365f2f1
|
@ -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
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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 */
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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 */
|
|
@ -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 */
|
||||
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue