aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2019-07-16 15:39:11 +0200
committerPiotr Krysik <ptrkrysik@gmail.com>2019-07-18 10:33:19 +0200
commitdc4cb983444ccb765f739b9b07e54bcff4ca48e5 (patch)
tree6f806839fd54ceb22b4ad264679ecf1823af4e1e
parentcd69577a405160b8de5d15add39121121897bf21 (diff)
trx: renaming of old freq hopping block and creation of a new one
The old freq_hopper -controlling USRP frequency with use of tags - was renamed to freq_hopper_tag. The new one - freq_hopper_msg - that uses uhd_source or uhd_sink control message input was created. Change-Id: Ic867446314ef2ee6903cef85d48c280981132dae
-rw-r--r--grc/gsm_block_tree.xml3
-rw-r--r--grc/trx/CMakeLists.txt3
-rw-r--r--grc/trx/gsm_freq_hopper_msg.xml81
-rw-r--r--grc/trx/gsm_freq_hopper_tag.xml (renamed from grc/trx/gsm_freq_hopping.xml)6
-rw-r--r--include/grgsm/trx/CMakeLists.txt3
-rw-r--r--include/grgsm/trx/freq_hopper_msg.h74
-rw-r--r--include/grgsm/trx/freq_hopper_tag.h (renamed from include/grgsm/trx/freq_hopping.h)11
-rw-r--r--lib/trx/CMakeLists.txt3
-rw-r--r--lib/trx/freq_hopper_msg_impl.cc273
-rw-r--r--lib/trx/freq_hopper_msg_impl.h84
-rw-r--r--lib/trx/freq_hopper_tag_impl.cc (renamed from lib/trx/freq_hopping_impl.cc)25
-rw-r--r--lib/trx/freq_hopper_tag_impl.h (renamed from lib/trx/freq_hopping_impl.h)16
-rw-r--r--swig/grgsm_swig.i9
13 files changed, 554 insertions, 37 deletions
diff --git a/grc/gsm_block_tree.xml b/grc/gsm_block_tree.xml
index 1773df3..026d00b 100644
--- a/grc/gsm_block_tree.xml
+++ b/grc/gsm_block_tree.xml
@@ -32,7 +32,8 @@
<cat>
<name>Transceiver</name>
<block>gsm_trx_burst_if</block>
- <block>gsm_freq_hopping</block>
+ <block>gsm_freq_hopper_tag</block>
+ <block>gsm_freq_hopper_msg</block>
</cat>
<cat>
<name>Logical channels demapping</name>
diff --git a/grc/trx/CMakeLists.txt b/grc/trx/CMakeLists.txt
index 0c7a636..81ef6ed 100644
--- a/grc/trx/CMakeLists.txt
+++ b/grc/trx/CMakeLists.txt
@@ -19,6 +19,7 @@
install(FILES
gsm_trx_burst_if.xml
- gsm_freq_hopping.xml
+ gsm_freq_hopper_tag.xml
+ gsm_freq_hopper_msg.xml
DESTINATION share/gnuradio/grc/blocks
)
diff --git a/grc/trx/gsm_freq_hopper_msg.xml b/grc/trx/gsm_freq_hopper_msg.xml
new file mode 100644
index 0000000..0175816
--- /dev/null
+++ b/grc/trx/gsm_freq_hopper_msg.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<block>
+ <name>freq_hopper_msg</name>
+ <key>gsm_freq_hopper_msg</key>
+ <import>import grgsm</import>
+ <make>grgsm.freq_hopper_msg($samp_rate, $start_fc_rx, $start_fc_tx, $rx_hopping, $tx_hopping, $freq_change_period)</make>
+<!-- $hopping_cmd-->
+<!-- <callback>set_fn_time_reference($init_fn, $init_time_secs, $init_time_fracs)</callback>-->
+<!-- <param>-->
+<!-- <name>Initial hopping command</name>-->
+<!-- <key>hopping_cmd</key>-->
+<!-- <value>pmt.to_pmt({'cmd': 'start', 'hopping_params': {'hsn': 1, 'maio': 0, 'ma': [1,2,3,4]} })</value>-->
+<!-- <type>raw</type>-->
+<!-- <hide>part</hide>-->
+<!-- </param>-->
+
+ <param>
+ <name>Sample rate</name>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
+ <type>float</type>
+ <hide>part</hide>
+ </param>
+
+ <param>
+ <name>start_fc_rx</name>
+ <key>start_fc_rx</key>
+ <value>fc</value>
+ <type>float</type>
+ <hide>part</hide>
+ </param>
+
+ <param>
+ <name>start_fc_tx</name>
+ <key>start_fc_tx</key>
+ <value>fc</value>
+ <type>float</type>
+ <hide>part</hide>
+ </param>
+
+ <param>
+ <name>rx_hopping</name>
+ <key>rx_hopping</key>
+ <value>True</value>
+ <type>float</type>
+ <hide>part</hide>
+ </param>
+
+ <param>
+ <name>tx_hopping</name>
+ <key>tx_hopping</key>
+ <value>True</value>
+ <type>float</type>
+ <hide>part</hide>
+ </param>
+
+ <param>
+ <name>freq_change_period</name>
+ <key>freq_change_period</key>
+ <value>0.0046</value>
+ <type>float</type>
+ <hide>part</hide>
+ </param>
+
+ <sink>
+ <name>in</name>
+ <type>complex</type>
+ </sink>
+
+<!-- <sink>-->
+<!-- <name>hopping_cmd</name>-->
+<!-- <type>message</type>-->
+<!-- <optional>1</optional>-->
+<!-- </sink>-->
+
+ <source>
+ <name>control</name>
+ <type>message</type>
+ <optional>1</optional>
+ </source>
+</block>
diff --git a/grc/trx/gsm_freq_hopping.xml b/grc/trx/gsm_freq_hopper_tag.xml
index 9e71e53..b9d1372 100644
--- a/grc/trx/gsm_freq_hopping.xml
+++ b/grc/trx/gsm_freq_hopper_tag.xml
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<block>
- <name>freq_hopping</name>
- <key>gsm_freq_hopping</key>
+ <name>freq_hopper_tag</name>
+ <key>gsm_freq_hopper_tag</key>
<import>import grgsm</import>
- <make>grgsm.freq_hopping($hopping_cmd)</make>
+ <make>grgsm.freq_hopper_tag($hopping_cmd)</make>
<!-- <callback>set_fn_time_reference($init_fn, $init_time_secs, $init_time_fracs)</callback>-->
<param>
<name>Initial hopping command</name>
diff --git a/include/grgsm/trx/CMakeLists.txt b/include/grgsm/trx/CMakeLists.txt
index 0addc79..346a807 100644
--- a/include/grgsm/trx/CMakeLists.txt
+++ b/include/grgsm/trx/CMakeLists.txt
@@ -21,7 +21,8 @@
# Install public header files
########################################################################
install(FILES
- freq_hopping.h
+ freq_hopper_tag.h
+ freq_hopper_msg.h
trx_burst_if.h
DESTINATION include/grgsm/trx
)
diff --git a/include/grgsm/trx/freq_hopper_msg.h b/include/grgsm/trx/freq_hopper_msg.h
new file mode 100644
index 0000000..12a9fe0
--- /dev/null
+++ b/include/grgsm/trx/freq_hopper_msg.h
@@ -0,0 +1,74 @@
+/* -*- c++ -*- */
+/* @file
+ * @author 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_FREQ_HOPPER_MSG_H
+#define INCLUDED_GSM_FREQ_HOPPER_MSG_H
+
+#include <grgsm/api.h>
+#include <gnuradio/sync_block.h>
+
+namespace gr {
+ namespace gsm {
+
+ /*!
+ * \brief <+description of block+>
+ * \ingroup gsm
+ *
+ */
+ class GRGSM_API freq_hopper_msg : virtual public sync_block
+ {
+ public:
+ typedef boost::shared_ptr<freq_hopper_msg> sptr;
+
+ static sptr make(
+ double samp_rate = 1e6,
+ double start_fc_rx = 1e9,
+ double start_fc_tx = 1e9,
+ bool rx_hopping=true,
+ bool tx_hopping=true,
+ double freq_change_period=0.0046);
+
+ /*!
+ * hopping_cmd is a pmt dictionary with following fields:
+ * "cmd": string with type of command, possible values:
+ * -"start" - immediately start hopping or if there is "fn"
+ * field defined start from frame number defined
+ * by that field
+ * -"stop" - immediately stop hopping or if there is "fn"
+ * field defined start from frame number defined
+ * by that field
+ * -"discard" - discard all queued "start_fn" and "stop_fn"
+ * (this command doesn't require hopping parameters or frame number)
+ * "hopping_params": dictionary with hopping parameters in following form:
+ * {"hsn": hopping_sequence_number(uint64),
+ * "ma": mobile_allocation(list of arfcns),
+ * "maio": mobile_allocation_index_offset(uint64),
+ * "n_arfcn": number_of_arfcns_in_ma}
+ * "fn": frame number when to start or stop hopping
+ */
+// virtual void add_hopping_cmd(pmt::pmt_t hopping_cmd=pmt::PMT_NIL) = 0;
+ };
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_FREQ_HOPPER_MSG_H */
diff --git a/include/grgsm/trx/freq_hopping.h b/include/grgsm/trx/freq_hopper_tag.h
index eeb3a53..fc4f8c3 100644
--- a/include/grgsm/trx/freq_hopping.h
+++ b/include/grgsm/trx/freq_hopper_tag.h
@@ -21,8 +21,8 @@
*/
-#ifndef INCLUDED_GSM_FREQ_HOPPING_H
-#define INCLUDED_GSM_FREQ_HOPPING_H
+#ifndef INCLUDED_GSM_FREQ_HOPPER_TAG_H
+#define INCLUDED_GSM_FREQ_HOPPER_TAG_H
#include <grgsm/api.h>
#include <gnuradio/block.h>
@@ -35,10 +35,10 @@ namespace gr {
* \ingroup gsm
*
*/
- class GRGSM_API freq_hopping : virtual public gr::block
+ class GRGSM_API freq_hopper_tag : virtual public gr::block
{
public:
- typedef boost::shared_ptr<freq_hopping> sptr;
+ typedef boost::shared_ptr<freq_hopper_tag> sptr;
/*!
* hopping_cmd is a pmt dictionary with following fields:
@@ -64,5 +64,4 @@ namespace gr {
} // namespace gsm
} // namespace gr
-#endif /* INCLUDED_GSM_FREQ_HOPPING_H */
-
+#endif /* INCLUDED_GSM_FREQ_HOPPER_TAG_H */
diff --git a/lib/trx/CMakeLists.txt b/lib/trx/CMakeLists.txt
index 0bfbe34..cd8f556 100644
--- a/lib/trx/CMakeLists.txt
+++ b/lib/trx/CMakeLists.txt
@@ -19,6 +19,7 @@
add_sources(
trx_burst_if_impl.cc
- freq_hopping_impl.cc
+ freq_hopper_tag_impl.cc
+ freq_hopper_msg_impl.cc
)
diff --git a/lib/trx/freq_hopper_msg_impl.cc b/lib/trx/freq_hopper_msg_impl.cc
new file mode 100644
index 0000000..678b577
--- /dev/null
+++ b/lib/trx/freq_hopper_msg_impl.cc
@@ -0,0 +1,273 @@
+/* -*- c++ -*- */
+/* @file
+ * @author 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 <grgsm/gsmtap.h>
+
+#include "freq_hopper_msg_impl.h"
+#include "../misc_utils/freq_hopping_utils.h"
+extern "C" {
+#include <osmocom/gsm/gsm_utils.h>
+}
+
+namespace gr {
+ namespace gsm {
+ using namespace pmt;
+
+ freq_hopper_msg::sptr
+ freq_hopper_msg::make(
+ double samp_rate,
+ double start_fc_rx,
+ double start_fc_tx,
+ bool rx_hopping,
+ bool tx_hopping,
+ double freq_change_period)
+ {
+ return gnuradio::get_initial_sptr
+ (new freq_hopper_msg_impl(samp_rate, start_fc_rx, start_fc_tx,
+ rx_hopping, tx_hopping, freq_change_period));
+ }
+
+ /*
+ * The private constructor
+ */
+ freq_hopper_msg_impl::freq_hopper_msg_impl(
+ double samp_rate,
+ double start_fc_rx,
+ double start_fc_tx,
+ bool rx_hopping,
+ bool tx_hopping,
+ double freq_change_period) :
+ sync_block("freq_hopper_msg",
+ gr::io_signature::make(1, 1, sizeof(gr_complex)),
+ gr::io_signature::make(0, 0, 0)),
+ d_samp_rate(samp_rate),
+ d_fc_rx(start_fc_rx),
+ d_fc_tx(start_fc_tx),
+ d_rx_hopping(rx_hopping),
+ d_tx_hopping(tx_hopping),
+ d_freq_change_period(freq_change_period),
+ d_rx_time_received(false),
+ d_last_rx_time(0.0),
+ d_current_time(0.0),
+ d_current_start_offset(0.0),
+ d_i(0),
+ d_start_time(1.0),
+ d_next_change_time(time_spec_t(2.0)),
+ d_change_advance(0.15),
+ d_rx_time_key(string_to_symbol("rx_time"))
+// d_hopping_cmd(PMT_NIL),
+// d_hopping_enable(false),
+// d_base_freq(890e6)
+ {
+ // Register I/O ports
+// message_port_register_in(mp("hopping_cmd"));
+ message_port_register_out(mp("control"));
+// d_f.push_back(-0.3e6);
+// d_f.push_back(-0.2e6);
+// d_f.push_back(-0.1e6);
+// d_f.push_back(0);
+// d_f.push_back(0.1e6);
+// d_f.push_back(0.2e6);
+// d_f.push_back(0.3e6);
+
+ d_ma.push_back(51);
+ d_ma.push_back(2);
+ d_ma.push_back(37);
+ d_ma.push_back(45);
+ d_hsn = 0;
+ d_maio = 0;
+ d_current_fn = 0;
+// // Bind message handlers
+// set_msg_handler(mp("hopping_cmd"),
+// boost::bind(&freq_hopper_msg_impl::add_hopping_cmd,
+// this, _1));
+
+// add_hopping_cmd(hopping_cmd);
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ freq_hopper_msg_impl::~freq_hopper_msg_impl()
+ {
+ }
+
+ int freq_hopper_msg_impl::work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ std::vector<tag_t> rx_time_tags;
+ get_tags_in_window(rx_time_tags, 0, 0, noutput_items, d_rx_time_key);
+ if(rx_time_tags.size() > 0){
+ tag_t rx_time_tag = rx_time_tags[0];
+ uint64_t rx_time_full_part = to_uint64(tuple_ref(rx_time_tag.value,0));
+ double rx_time_frac_part = to_double(tuple_ref(rx_time_tag.value,1));
+ d_last_rx_time = time_spec_t(rx_time_full_part, rx_time_frac_part);
+ d_current_start_offset = rx_time_tag.offset;
+ d_rx_time_received = true;
+ }
+ if(d_rx_time_received){
+ uint64_t buffer_end_offset = nitems_read(0) + noutput_items;
+ d_current_time = time_spec_t::from_ticks(buffer_end_offset - d_current_start_offset, d_samp_rate) + d_last_rx_time;
+ }
+
+// Freq. control messages generation
+ if ((d_current_time.get_real_secs() > d_start_time) &&
+ ((d_next_change_time-d_current_time).get_real_secs() < d_change_advance)){
+ pmt_t freq_change_time_pmt = cons(
+ from_uint64(d_next_change_time.get_full_secs()),
+ from_double(d_next_change_time.get_frac_secs())
+ );
+ d_next_change_time = d_next_change_time + d_freq_change_period;
+ double dsp_freq = get_dsp_freq(d_current_fn);
+ if(d_tx_hopping){
+ pmt_t tx_tune_msg = dict_add(make_dict(), mp("lo_freq"), from_double(d_fc_tx));
+// tx_tune_msg = dict_add(tx_tune_msg, mp("dsp_freq"), from_double(d_f[d_i % d_f.size()]));
+ tx_tune_msg = dict_add(tx_tune_msg, mp("dsp_freq"), from_double(dsp_freq));
+ tx_tune_msg = dict_add(tx_tune_msg, mp("time"), freq_change_time_pmt);
+ tx_tune_msg = dict_add(tx_tune_msg, mp("direction"), mp("TX"));
+ message_port_pub(mp("control"), tx_tune_msg);
+// std::cout << "tx: " << tx_tune_msg << std::endl;
+ }
+ if(d_rx_hopping){
+ pmt_t rx_tune_msg = dict_add(make_dict(), mp("lo_freq"), from_double(d_fc_rx));
+// rx_tune_msg = dict_add(rx_tune_msg, mp("dsp_freq"), from_double(-d_f[d_i % d_f.size()]));
+ rx_tune_msg = dict_add(rx_tune_msg, mp("dsp_freq"), from_double(-dsp_freq));
+ rx_tune_msg = dict_add(rx_tune_msg, mp("time"), freq_change_time_pmt);
+ rx_tune_msg = dict_add(rx_tune_msg, mp("direction"), mp("RX"));
+ message_port_pub(mp("control"), rx_tune_msg);
+// std::cout << "rx: " << rx_tune_msg << std::endl;
+ }
+ d_i++;
+ d_current_fn++;
+ }
+ return noutput_items;
+ }
+
+ double freq_hopper_msg_impl::get_dsp_freq(uint64_t fn){ //TODO: jak otrzymac fn
+ int mai = calculate_ma_sfh(d_maio, d_hsn, d_ma.size(), fn);
+ uint16_t arfcn = d_ma[mai];
+ double dsp_freq = static_cast<double>(gsm_arfcn2freq10(arfcn, 0)) * 1.0e5 - d_fc_rx;
+ }
+/*
+ void freq_hopper_msg_impl::add_hopping_cmd(pmt_t cmd) //TODO: fn and discard not supported at the moment
+ {
+ if(dict_ref(cmd,intern("cmd"), PMT_NIL) == intern("start")) {
+ if(dict_ref(cmd,intern("fn"), PMT_NIL) != PMT_NIL){
+ //TODO add the command to the map<int,pmt_t>
+ } else {
+ pmt_t hopping_params = dict_ref(cmd, intern("hopping_params"), PMT_NIL);
+ d_hopping_enable = set_hopping_params(hopping_params);
+ }
+ } else if(dict_ref(cmd,intern("cmd"), PMT_NIL) == intern("stop")) {
+ if(dict_ref(cmd,intern("fn"),PMT_NIL) != PMT_NIL){
+ //TODO add the command to the map<int,pmt_t>
+
+ } else {
+ d_hopping_enable = false;
+ }
+ }
+ }
+
+ void freq_hopper_msg_impl::set_freq_metadata(pmt_t burst)
+ {
+
+ if(d_hopping_enable) {
+ pmt_t pdu_header = car(burst);
+ pmt_t tx_time = dict_ref(pdu_header, intern("tx_time"),PMT_NIL);
+ if(tx_time != PMT_NIL){
+ pmt_t tx_command_time = cons(tuple_ref(tx_time,0),tuple_ref(tx_time,1));
+ pmt_t header_plus_burst = cdr(burst);
+ uint32_t frame_nr = 0;
+
+ pmt_t fn = dict_ref(pdu_header,intern("fn"),PMT_NIL);
+ if(fn == PMT_NIL){
+ gsmtap_hdr *header = (gsmtap_hdr *)blob_data(header_plus_burst);
+ uint32_t frame_nr = be32toh(header->frame_number);
+ } else {
+ frame_nr = to_uint64(fn);
+ }
+
+ int mai = calculate_ma_sfh(d_maio, d_hsn, d_ma.size(), frame_nr);
+ uint16_t arfcn = d_ma[mai];
+
+ // if(fn == PMT_NIL){
+ // header->arfcn = htobe16(arfcn);
+ // header->arfcn = header->arfcn | 0x8000; // set uplink flag
+ // }
+
+ //compute the frequences to be set in the burst header
+ double freq_uplink = static_cast<double>(gsm_arfcn2freq10(arfcn, 1)) * 1.0e5;
+ double freq_downlink = static_cast<double>(gsm_arfcn2freq10(arfcn, 0)) * 1.0e5;
+
+ pmt_t tx_command = dict_add(make_dict(),intern("lo_freq"),from_double(d_base_freq));
+ tx_command = dict_add(tx_command,intern("dsp_freq"),from_double(freq_uplink-d_base_freq));
+ tx_command = dict_add(tx_command,intern("time"),tx_command_time);
+
+ pmt_t rx_command = dict_add(make_dict(),intern("lo_freq"),from_double(d_base_freq));
+ rx_command = dict_add(rx_command,intern("dsp_freq"),from_double(freq_uplink-d_base_freq));
+ rx_command = dict_add(rx_command,intern("time"),tx_command_time);
+ rx_command = dict_add(rx_command,intern("direction"),intern("RX"));
+
+ pdu_header = dict_add(pdu_header, intern("tx_command"),tx_command);
+// pdu_header = dict_add(pdu_header, intern("tx_command"),rx_command);
+// std::cout << "arfcn " << arfcn << " mai " << mai << " d_ma.size() " << d_ma.size() << " d_hsn " << d_hsn << std::endl;
+ std::cout << "arfcn_uplink " << arfcn << std::endl;
+// std::cout << "freq_downlink " << freq_downlink << std::endl;
+// std::cout << "pdu_header " << pdu_header << std::endl;
+// std::cout << "size_header_plus_burst " << length(header_plus_burst) << std::endl;
+ message_port_pub(mp("bursts_out"), cons(pdu_header,header_plus_burst));
+ }
+ } else {
+ message_port_pub(mp("bursts_out"), burst);
+ }
+ }
+
+ bool freq_hopper_msg_impl::set_hopping_params(pmt_t hopping_params){
+ bool retval = false;
+ if(hopping_params != PMT_NIL){
+ //set hopping parameters immediately
+ pmt_t hsn = dict_ref(hopping_params, intern("hsn"), PMT_NIL);
+ pmt_t maio = dict_ref(hopping_params, intern("maio"), PMT_NIL);;
+ pmt_t ma = dict_ref(hopping_params, intern("ma"), PMT_NIL);
+
+ if(is_vector(ma) && is_integer(hsn) && is_integer(maio)){ //TODO: checking the values
+ d_hsn = to_uint64(hsn);
+ d_maio = to_uint64(maio);
+ d_ma.resize(length(ma));
+ for(int i=0; i<length(ma); i++){
+ d_ma[i] = to_uint64(vector_ref(ma,i));
+ }
+ retval = true;
+ }
+ }
+ return retval;
+ }*/
+
+ } /* namespace gsm */
+} /* namespace gr */
diff --git a/lib/trx/freq_hopper_msg_impl.h b/lib/trx/freq_hopper_msg_impl.h
new file mode 100644
index 0000000..2286012
--- /dev/null
+++ b/lib/trx/freq_hopper_msg_impl.h
@@ -0,0 +1,84 @@
+/* -*- c++ -*- */
+/* @file
+ * @author 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_FREQ_HOPPER_MSG_IMPL_H
+#define INCLUDED_GSM_FREQ_HOPPER_MSG_IMPL_H
+
+#include <grgsm/trx/freq_hopper_msg.h>
+#include <grgsm/misc_utils/time_spec.h>
+#include <grgsm/misc_utils/fn_time.h>
+#include <pmt/pmt.h>
+
+
+namespace gr {
+ namespace gsm {
+
+ class freq_hopper_msg_impl : public freq_hopper_msg
+ {
+ private:
+ double d_samp_rate;
+ double d_fc_rx;
+ double d_fc_tx;
+ bool d_rx_hopping;
+ bool d_tx_hopping;
+ double d_freq_change_period;
+ bool d_rx_time_received;
+ time_spec_t d_last_rx_time;
+ time_spec_t d_current_time;
+ uint64_t d_current_start_offset; //!!zmienic nazwe - ta zmienna okresla pozycje ostatniego rx_time
+ uint64_t d_i;
+ std::vector<double> d_f;
+ double d_start_time;
+ time_spec_t d_next_change_time;
+ double d_change_advance;
+ pmt::pmt_t d_rx_time_key;
+
+// bool d_hopping_enable; //if true block do the hopping, if not block just passes the bursts
+ uint64_t d_hsn; //hopping sequence number
+ uint64_t d_maio; //mobile allocation index offset
+ std::vector<uint64_t> d_ma; //mobile allocation
+
+ uint64_t d_current_fn;//!!
+
+// pmt::pmt_t d_hopping_cmd; //TODO: change this a std::map
+// void set_freq_metadata(pmt::pmt_t cmd);
+// bool set_hopping_params(pmt::pmt_t hopping_params);
+ double get_dsp_freq(uint64_t fn);
+ public:
+ freq_hopper_msg_impl(
+ double samp_rate,
+ double start_fc_rx,
+ double start_fc_tx,
+ bool rx_hopping,
+ bool tx_hopping,
+ double freq_change_period);
+ ~freq_hopper_msg_impl();
+
+ int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
+
+// void add_hopping_cmd(pmt::pmt_t hopping_cmd);
+ };
+
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_FREQ_HOPPER_MSG_IMPL_H */
diff --git a/lib/trx/freq_hopping_impl.cc b/lib/trx/freq_hopper_tag_impl.cc
index d6a2fb5..aeed88a 100644
--- a/lib/trx/freq_hopping_impl.cc
+++ b/lib/trx/freq_hopper_tag_impl.cc
@@ -1,4 +1,3 @@
-
/* -*- c++ -*- */
/* @file
* @author Piotr Krysik <ptrkrysik@gmail.com>
@@ -28,7 +27,7 @@
#include <gnuradio/io_signature.h>
#include <grgsm/gsmtap.h>
-#include "freq_hopping_impl.h"
+#include "freq_hopper_tag_impl.h"
#include "../misc_utils/freq_hopping_utils.h"
extern "C" {
#include <osmocom/gsm/gsm_utils.h>
@@ -38,20 +37,20 @@ namespace gr {
namespace gsm {
using namespace pmt;
- freq_hopping::sptr
- freq_hopping::make(
+ freq_hopper_tag::sptr
+ freq_hopper_tag::make(
pmt_t hopping_cmd)
{
return gnuradio::get_initial_sptr
- (new freq_hopping_impl(hopping_cmd));
+ (new freq_hopper_tag_impl(hopping_cmd));
}
/*
* The private constructor
*/
- freq_hopping_impl::freq_hopping_impl(
+ freq_hopper_tag_impl::freq_hopper_tag_impl(
pmt_t hopping_cmd
- ) : gr::block("freq_hopping",
+ ) : gr::block("freq_hopper_tag",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0)),
d_hopping_cmd(PMT_NIL),
@@ -65,11 +64,11 @@ namespace gr {
// Bind message handlers
set_msg_handler(mp("hopping_cmd"),
- boost::bind(&freq_hopping_impl::add_hopping_cmd,
+ boost::bind(&freq_hopper_tag_impl::add_hopping_cmd,
this, _1));
set_msg_handler(mp("bursts_in"),
- boost::bind(&freq_hopping_impl::set_freq_metadata,
+ boost::bind(&freq_hopper_tag_impl::set_freq_metadata,
this, _1));
add_hopping_cmd(hopping_cmd);
@@ -78,11 +77,11 @@ namespace gr {
/*
* Our virtual destructor.
*/
- freq_hopping_impl::~freq_hopping_impl()
+ freq_hopper_tag_impl::~freq_hopper_tag_impl()
{
}
- void freq_hopping_impl::add_hopping_cmd(pmt_t cmd) //TODO: fn and discard not supported at the moment
+ void freq_hopper_tag_impl::add_hopping_cmd(pmt_t cmd) //TODO: fn and discard not supported at the moment
{
if(dict_ref(cmd,intern("cmd"), PMT_NIL) == intern("start")) {
if(dict_ref(cmd,intern("fn"), PMT_NIL) != PMT_NIL){
@@ -101,7 +100,7 @@ namespace gr {
}
}
- void freq_hopping_impl::set_freq_metadata(pmt_t burst)
+ void freq_hopper_tag_impl::set_freq_metadata(pmt_t burst)
{
if(d_hopping_enable) {
@@ -155,7 +154,7 @@ namespace gr {
}
}
- bool freq_hopping_impl::set_hopping_params(pmt_t hopping_params){
+ bool freq_hopper_tag_impl::set_hopping_params(pmt_t hopping_params){
bool retval = false;
if(hopping_params != PMT_NIL){
//set hopping parameters immediately
diff --git a/lib/trx/freq_hopping_impl.h b/lib/trx/freq_hopper_tag_impl.h
index b6c6366..d9da2e0 100644
--- a/lib/trx/freq_hopping_impl.h
+++ b/lib/trx/freq_hopper_tag_impl.h
@@ -20,17 +20,17 @@
*
*/
-#ifndef INCLUDED_GSM_FREQ_HOPPING_IMPL_H
-#define INCLUDED_GSM_FREQ_HOPPING_IMPL_H
+#ifndef INCLUDED_GSM_FREQ_HOPPER_TAG_IMPL_H
+#define INCLUDED_GSM_FREQ_HOPPER_TAG_IMPL_H
-#include <grgsm/trx/freq_hopping.h>
+#include <grgsm/trx/freq_hopper_tag.h>
#include <grgsm/misc_utils/time_spec.h>
#include <grgsm/misc_utils/fn_time.h>
namespace gr {
namespace gsm {
- class freq_hopping_impl : public freq_hopping
+ class freq_hopper_tag_impl : public freq_hopper_tag
{
private:
bool d_hopping_enable; //if true block do the hopping, if not block just passes the bursts
@@ -38,13 +38,13 @@ namespace gr {
uint64_t d_maio; //mobile allocation index offset
double d_base_freq; //local oscillator frequency
std::vector<uint64_t> d_ma; //mobile allocation
-
+
pmt::pmt_t d_hopping_cmd; //TODO: change this uint64_to a std::map
void set_freq_metadata(pmt::pmt_t cmd);
bool set_hopping_params(pmt::pmt_t hopping_params);
public:
- freq_hopping_impl(pmt::pmt_t hopping_cmd);
- ~freq_hopping_impl();
+ freq_hopper_tag_impl(pmt::pmt_t hopping_cmd);
+ ~freq_hopper_tag_impl();
void add_hopping_cmd(pmt::pmt_t hopping_cmd);
};
@@ -52,4 +52,4 @@ namespace gr {
} // namespace gsm
} // namespace gr
-#endif /* INCLUDED_GSM_FREQ_HOPPING_IMPL_H */
+#endif /* INCLUDED_GSM_FREQ_HOPPER_TAG_IMPL_H */
diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i
index 8035dc5..d48e8ba 100644
--- a/swig/grgsm_swig.i
+++ b/swig/grgsm_swig.i
@@ -76,7 +76,8 @@
#include "grgsm/transmitter/txtime_setter.h"
#include "grgsm/transmitter/preprocess_tx_burst.h"
#include "grgsm/transmitter/gen_test_ab.h"
-#include "grgsm/trx/freq_hopping.h"
+#include "grgsm/trx/freq_hopper_tag.h"
+#include "grgsm/trx/freq_hopper_msg.h"
#include "grgsm/trx/trx_burst_if.h"
%}
@@ -155,8 +156,10 @@ GR_SWIG_BLOCK_MAGIC2(gsm, controlled_fractional_resampler_cc);
GR_SWIG_BLOCK_MAGIC2(gsm, extract_cmc);
%include "grgsm/misc_utils/extract_assignment_cmd.h"
GR_SWIG_BLOCK_MAGIC2(gsm, extract_assignment_cmd);
-%include "grgsm/trx/freq_hopping.h"
-GR_SWIG_BLOCK_MAGIC2(gsm, freq_hopping);
+%include "grgsm/trx/freq_hopper_tag.h"
+GR_SWIG_BLOCK_MAGIC2(gsm, freq_hopper_tag);
+%include "grgsm/trx/freq_hopper_msg.h"
+GR_SWIG_BLOCK_MAGIC2(gsm, freq_hopper_msg);
%include "grgsm/trx/trx_burst_if.h"
GR_SWIG_BLOCK_MAGIC2(gsm, trx_burst_if);
%include "grgsm/misc_utils/burst_to_fn_time.h"