aboutsummaryrefslogtreecommitdiffstats
path: root/lib/transmitter
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2018-04-16 22:21:29 +0200
committerPiotr Krysik <ptrkrysik@gmail.com>2018-04-16 22:21:29 +0200
commit8a8d41a58320d5f30713a6e6362c86d5db6de1de (patch)
treed95b1badab52b83126d57d410dd8e92e7a255c8e /lib/transmitter
parent8b9b88d788cc5064c0f6d7aa60a14954aee59eab (diff)
parentfe4db93e6d03e92a958664bfffcd0e2923f20e34 (diff)
Merge branch 'ptrkrysik/trx' into development
Diffstat (limited to 'lib/transmitter')
-rw-r--r--lib/transmitter/CMakeLists.txt24
-rw-r--r--lib/transmitter/gen_test_ab_impl.cc107
-rw-r--r--lib/transmitter/gen_test_ab_impl.h47
-rw-r--r--lib/transmitter/preprocess_tx_burst_impl.cc96
-rw-r--r--lib/transmitter/preprocess_tx_burst_impl.h47
-rw-r--r--lib/transmitter/txtime_setter_impl.cc196
-rw-r--r--lib/transmitter/txtime_setter_impl.h64
7 files changed, 581 insertions, 0 deletions
diff --git a/lib/transmitter/CMakeLists.txt b/lib/transmitter/CMakeLists.txt
new file mode 100644
index 0000000..eb53162
--- /dev/null
+++ b/lib/transmitter/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+add_sources(
+ txtime_setter_impl.cc
+ preprocess_tx_burst_impl.cc
+ gen_test_ab_impl
+)
diff --git a/lib/transmitter/gen_test_ab_impl.cc b/lib/transmitter/gen_test_ab_impl.cc
new file mode 100644
index 0000000..bb9c9f6
--- /dev/null
+++ b/lib/transmitter/gen_test_ab_impl.cc
@@ -0,0 +1,107 @@
+/* -*- 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 <grgsm/gsm_constants.h>
+#include "gen_test_ab_impl.h"
+
+namespace gr {
+ namespace gsm {
+
+ static uint8_t rach_synch_seq[] = {
+ 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0 ,
+ 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0,
+ };
+
+ static uint8_t AB[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+// static uint8_t AB[] = {0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1};
+// static uint8_t AB[] = { 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1};
+// static uint8_t AB[] = {1,1,1,1,1,1,1,1,1,0,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,0,1,0,1,0,1,1,1,0,0,0,0,1,1,1,0,0,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
+// ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+ gen_test_ab::sptr
+ gen_test_ab::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new gen_test_ab_impl());
+ }
+
+ /*
+ * The private constructor
+ */
+ gen_test_ab_impl::gen_test_ab_impl()
+ : gr::block("gen_test_ab",
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(0, 0, 0))
+ {
+ message_port_register_in(pmt::intern("bursts_in"));
+ message_port_register_out(pmt::intern("bursts_out"));
+
+ set_msg_handler(pmt::intern("bursts_in"), boost::bind(&gen_test_ab_impl::generate_ab, this, _1));
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ gen_test_ab_impl::~gen_test_ab_impl()
+ {
+ }
+
+ void gen_test_ab_impl::generate_ab(pmt::pmt_t burst)
+ {
+ uint8_t buf[sizeof(gsmtap_hdr) + 148];
+ struct gsmtap_hdr *tap_header = (struct gsmtap_hdr *) buf;
+ uint8_t *access_burst = buf + sizeof(gsmtap_hdr);
+
+// memset(access_burst, 0, 8); /* TB */
+// memcpy(access_burst + 8, rach_synch_seq, 41); /* sync seq */
+// memcpy(access_burst + 49, AB, 36); /* payload */
+// memset(access_burst + 85, 0, 63); /* TB + GP */
+
+ memcpy(access_burst, AB, 148);
+
+ gsmtap_hdr * header = (gsmtap_hdr *)(pmt::blob_data(pmt::cdr(burst)));
+ uint32_t frame_nr = be32toh(header->frame_number);
+ frame_nr = (frame_nr+51)% (26*51*2048);
+
+ tap_header->version = GSMTAP_VERSION;
+ tap_header->hdr_len = sizeof(gsmtap_hdr) / 4;
+ tap_header->type = GSMTAP_TYPE_UM_BURST;
+ tap_header->sub_type = GSMTAP_BURST_ACCESS;
+ tap_header->frame_number = htobe32(frame_nr);
+ tap_header->timeslot = header->timeslot;
+ tap_header->arfcn = 0;
+
+ pmt::pmt_t blob = pmt::make_blob(buf, sizeof(gsmtap_hdr) + BURST_SIZE);
+ pmt::pmt_t pdu_header = pmt::make_dict();
+
+ pmt::pmt_t new_msg = pmt::cons(pdu_header, blob);
+ message_port_pub(pmt::intern("bursts_out"), new_msg);
+ }
+ } /* namespace gsm */
+} /* namespace gr */
+
diff --git a/lib/transmitter/gen_test_ab_impl.h b/lib/transmitter/gen_test_ab_impl.h
new file mode 100644
index 0000000..366481e
--- /dev/null
+++ b/lib/transmitter/gen_test_ab_impl.h
@@ -0,0 +1,47 @@
+/* -*- 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_GEN_TEST_AB_IMPL_H
+#define INCLUDED_GSM_GEN_TEST_AB_IMPL_H
+
+#include <grgsm/transmitter/gen_test_ab.h>
+#include <grgsm/misc_utils/time_spec.h>
+#include <grgsm/misc_utils/fn_time.h>
+
+namespace gr {
+ namespace gsm {
+
+ class gen_test_ab_impl : public gen_test_ab
+ {
+ private:
+ void generate_ab(pmt::pmt_t burst);
+
+ public:
+ gen_test_ab_impl();
+ ~gen_test_ab_impl();
+ };
+
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_GEN_TEST_AB_IMPL_H */
+
diff --git a/lib/transmitter/preprocess_tx_burst_impl.cc b/lib/transmitter/preprocess_tx_burst_impl.cc
new file mode 100644
index 0000000..5fbac98
--- /dev/null
+++ b/lib/transmitter/preprocess_tx_burst_impl.cc
@@ -0,0 +1,96 @@
+/* -*- c++ -*- */
+/* @file
+ * @author Piotr Krysik <ptrkrysik@gmail.com>
+ * @author Vadim Yanitskiy <axilirator@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 <assert.h>
+
+#include <gnuradio/io_signature.h>
+#include <grgsm/gsm_constants.h>
+#include <grgsm/gsmtap.h>
+
+#include "preprocess_tx_burst_impl.h"
+
+namespace gr {
+ namespace gsm {
+
+ preprocess_tx_burst::sptr
+ preprocess_tx_burst::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new preprocess_tx_burst_impl());
+ }
+
+ /*
+ * The private constructor
+ */
+ preprocess_tx_burst_impl::preprocess_tx_burst_impl()
+ : gr::block("preprocess_tx_burst",
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(0, 0, 0))
+ {
+ message_port_register_in(pmt::mp("bursts_in"));
+ message_port_register_out(pmt::mp("bursts_out"));
+
+ set_msg_handler(pmt::mp("bursts_in"),
+ boost::bind(&preprocess_tx_burst_impl::process_burst, this, _1));
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ preprocess_tx_burst_impl::~preprocess_tx_burst_impl()
+ {
+ }
+
+ void preprocess_tx_burst_impl::process_burst(pmt::pmt_t msg_in)
+ {
+ pmt::pmt_t blob_in = pmt::cdr(msg_in);
+
+ // Extract GSMTAP header from message
+ gsmtap_hdr *burst_hdr = (gsmtap_hdr *) pmt::blob_data(blob_in);
+
+ // Extract burst bits from message
+ uint8_t *burst_bits = (uint8_t *)
+ (pmt::blob_data(blob_in)) + sizeof(gsmtap_hdr);
+
+ // Determine and check burst length
+ size_t burst_len = pmt::blob_length(blob_in) - sizeof(gsmtap_hdr);
+ assert(burst_len == BURST_SIZE);
+
+ // The Access Burst last has reduced length
+ if (burst_hdr->sub_type == GSMTAP_BURST_ACCESS)
+ burst_len = ACCESS_BURST_SIZE;
+
+ // Prepare an output message
+ pmt::pmt_t blob_out = pmt::make_blob(burst_bits, burst_len);
+ pmt::pmt_t msg_out = pmt::cons(pmt::car(msg_in), blob_out);
+
+ /* Send a message to the output */
+ message_port_pub(pmt::mp("bursts_out"), msg_out);
+ }
+
+ } /* namespace gsm */
+} /* namespace gr */
diff --git a/lib/transmitter/preprocess_tx_burst_impl.h b/lib/transmitter/preprocess_tx_burst_impl.h
new file mode 100644
index 0000000..27fc508
--- /dev/null
+++ b/lib/transmitter/preprocess_tx_burst_impl.h
@@ -0,0 +1,47 @@
+/* -*- 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_PREPROCESS_TX_BURST_IMPL_H
+#define INCLUDED_GSM_PREPROCESS_TX_BURST_IMPL_H
+
+#include <grgsm/transmitter/preprocess_tx_burst.h>
+#include <grgsm/misc_utils/time_spec.h>
+#include <grgsm/misc_utils/fn_time.h>
+
+namespace gr {
+ namespace gsm {
+
+ class preprocess_tx_burst_impl : public preprocess_tx_burst
+ {
+ private:
+ void process_burst(pmt::pmt_t burst);
+
+ public:
+ preprocess_tx_burst_impl();
+ ~preprocess_tx_burst_impl();
+ };
+
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_PREPROCESS_TX_BURST_IMPL_H */
+
diff --git a/lib/transmitter/txtime_setter_impl.cc b/lib/transmitter/txtime_setter_impl.cc
new file mode 100644
index 0000000..33bc994
--- /dev/null
+++ b/lib/transmitter/txtime_setter_impl.cc
@@ -0,0 +1,196 @@
+/* -*- c++ -*- */
+/* @file
+ * @author Piotr Krysik <ptrkrysik@gmail.com>
+ * @author Vadim Yanitskiy <axilirator@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 "txtime_setter_impl.h"
+
+#define UNKNOWN_FN 0xffffffff
+#define MAX_EARLY_TIME_DIFF 10.0
+
+namespace gr {
+ namespace gsm {
+
+ txtime_setter::sptr
+ txtime_setter::make(
+ uint32_t init_fn, uint64_t init_time_secs,
+ double init_time_fracs, uint64_t time_hint_secs,
+ double time_hint_fracs, double timing_advance,
+ double delay_correction)
+ {
+ return gnuradio::get_initial_sptr
+ (new txtime_setter_impl(init_fn, init_time_secs,
+ init_time_fracs, time_hint_secs, time_hint_fracs,
+ timing_advance, delay_correction));
+ }
+
+ /*
+ * The private constructor
+ */
+ txtime_setter_impl::txtime_setter_impl(
+ uint32_t init_fn, uint64_t init_time_secs,
+ double init_time_fracs, uint64_t time_hint_secs,
+ double time_hint_fracs, double timing_advance,
+ double delay_correction
+ ) : gr::block("txtime_setter",
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(0, 0, 0)),
+ d_time_hint(time_hint_secs,time_hint_fracs),
+ d_time_ref(init_time_secs,init_time_fracs),
+ d_delay_correction(delay_correction),
+ d_timing_advance(timing_advance),
+ d_fn_ref(init_fn),
+ d_ts_ref(0)
+ {
+ // Register I/O ports
+ message_port_register_in(pmt::mp("fn_time"));
+ message_port_register_in(pmt::mp("bursts_in"));
+ message_port_register_out(pmt::mp("bursts_out"));
+
+ // Bind message handlers
+ set_msg_handler(pmt::mp("fn_time"),
+ boost::bind(&txtime_setter_impl::process_fn_time_reference,
+ this, _1));
+ set_msg_handler(pmt::mp("bursts_in"),
+ boost::bind(&txtime_setter_impl::process_txtime_of_burst,
+ this, _1));
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ txtime_setter_impl::~txtime_setter_impl()
+ {
+ }
+
+ void txtime_setter_impl::process_fn_time_reference(pmt::pmt_t msg)
+ {
+ pmt::pmt_t not_found = pmt::intern("not_found");
+ pmt::pmt_t fn_time, time_hint;
+
+ fn_time = pmt::dict_ref(msg,
+ pmt::intern("fn_time"), not_found);
+ time_hint = pmt::dict_ref(msg,
+ pmt::intern("fn_time"), not_found);
+
+ if (fn_time != not_found) {
+ uint32_t fn_ref = static_cast<uint32_t>
+ (pmt::to_uint64(pmt::car(pmt::car(fn_time))));
+ uint32_t ts = static_cast<uint32_t>
+ (pmt::to_uint64(pmt::cdr(pmt::car(fn_time))));
+ uint64_t time_secs = pmt::to_uint64(
+ pmt::car(pmt::cdr(fn_time)));
+ double time_fracs = pmt::to_double(
+ pmt::cdr(pmt::cdr(fn_time)));
+
+ set_fn_time_reference(fn_ref, ts, time_secs, time_fracs);
+ } else if (time_hint != not_found) {
+ set_time_hint(pmt::to_uint64(pmt::car(fn_time)),
+ pmt::to_double(pmt::cdr(fn_time)));
+ }
+ }
+
+ void txtime_setter_impl::process_txtime_of_burst(pmt::pmt_t msg_in)
+ {
+ if (d_fn_ref != UNKNOWN_FN)
+ {
+ pmt::pmt_t blob = pmt::cdr(msg_in);
+
+ // Extract GSMTAP header from message
+ gsmtap_hdr *header = (gsmtap_hdr *) pmt::blob_data(blob);
+ uint32_t frame_nr = be32toh(header->frame_number);
+ uint32_t ts_num = header->timeslot;
+
+ time_format txtime = fn_time_delta_cpp(d_fn_ref, d_time_ref,
+ frame_nr, d_time_hint, ts_num, d_ts_ref);
+
+ time_spec_t txtime_spec = time_spec_t(txtime.first, txtime.second);
+ txtime_spec -= d_delay_correction;
+ txtime_spec -= d_timing_advance;
+
+ time_spec_t current_time_estimate = time_spec_t(d_time_hint.first, d_time_hint.second);
+
+ if (txtime_spec <= current_time_estimate) { // Drop too late bursts
+ std::cout << "lB" << std::flush;
+ } else if (txtime_spec > current_time_estimate + MAX_EARLY_TIME_DIFF) { // Drop too early bursts
+ std::cout << "eB" << std::flush; //TODO: too early condition might happen when changing BTSes.
+ //Wrong fn_time is applied to new or old bursts in such situation.
+ //This solution is not perfect as MS might be blocked upto
+ //MAX_EARLY_TIME_DIFF seconds.
+ //Better solution would be to indentify fn_time and burst coming
+ //from given BTS (i.e. based on ARFCN) and dropping bursts for which
+ //the bts_id doesn't match with bts_id of fn_time.
+ } else { //process bursts that are in the right time-frame
+ pmt::pmt_t tags_dict = pmt::dict_add(
+ pmt::make_dict(),
+ pmt::intern("tx_time"),
+ pmt::make_tuple(
+ pmt::from_uint64(txtime_spec.get_full_secs()),
+ pmt::from_double(txtime_spec.get_frac_secs()))
+ );
+
+ tags_dict = pmt::dict_add(tags_dict,
+ pmt::intern("fn"), pmt::from_uint64(frame_nr));
+ tags_dict = pmt::dict_add(tags_dict,
+ pmt::intern("ts"), pmt::from_uint64(ts_num));
+
+ // Send a message to the output
+ pmt::pmt_t msg_out = pmt::cons(tags_dict, pmt::cdr(msg_in));
+ message_port_pub(pmt::mp("bursts_out"), msg_out);
+ }
+ }
+ }
+
+ void txtime_setter_impl::set_fn_time_reference(
+ uint32_t fn, uint32_t ts, uint64_t time_secs,
+ double time_fracs)
+ {
+ d_fn_ref = fn;
+ d_ts_ref = ts;
+ d_time_ref = std::make_pair(time_secs, time_fracs);
+ set_time_hint(time_secs, time_fracs);
+ }
+
+ void txtime_setter_impl::set_time_hint(
+ uint64_t time_hint_secs, double time_hint_fracs)
+ {
+ d_time_hint = std::make_pair(time_hint_secs, time_hint_fracs);
+ }
+
+ void txtime_setter_impl::set_delay_correction(double delay_correction)
+ {
+ d_delay_correction = delay_correction;
+ }
+
+ void txtime_setter_impl::set_timing_advance(double timing_advance)
+ {
+ d_timing_advance = timing_advance;
+ }
+
+ } /* namespace gsm */
+} /* namespace gr */
diff --git a/lib/transmitter/txtime_setter_impl.h b/lib/transmitter/txtime_setter_impl.h
new file mode 100644
index 0000000..62f500a
--- /dev/null
+++ b/lib/transmitter/txtime_setter_impl.h
@@ -0,0 +1,64 @@
+/* -*- 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_TXTIME_SETTER_IMPL_H
+#define INCLUDED_GSM_TXTIME_SETTER_IMPL_H
+
+#include <grgsm/transmitter/txtime_setter.h>
+#include <grgsm/misc_utils/time_spec.h>
+#include <grgsm/misc_utils/fn_time.h>
+
+namespace gr {
+ namespace gsm {
+
+ class txtime_setter_impl : public txtime_setter
+ {
+ private:
+ uint32_t d_fn_ref;
+ uint32_t d_ts_ref;
+ time_format d_time_ref;
+ time_format d_time_hint;
+ double d_timing_advance;
+ double d_delay_correction;
+
+ void process_fn_time_reference(pmt::pmt_t msg);
+ void process_txtime_of_burst(pmt::pmt_t msg);
+
+ public:
+ txtime_setter_impl(uint32_t init_fn, uint64_t init_time_secs,
+ double init_time_fracs, uint64_t time_hint_secs,
+ double time_hint_fracs, double timing_advance,
+ double delay_correction);
+ ~txtime_setter_impl();
+
+ // Where all the action really happens
+ void set_fn_time_reference(uint32_t fn, uint32_t ts,
+ uint64_t time_secs, double time_fracs);
+ void set_time_hint(uint64_t time_hint_secs, double time_hint_fracs);
+ void set_delay_correction(double delay_correction);
+ void set_timing_advance(double timing_advance);
+ };
+
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_TXTIME_SETTER_IMPL_H */